diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsResultEx.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsResultEx.java index b6f21c82e72b..0cae321c8cbf 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsResultEx.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/CvsResultEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,64 +22,76 @@ import com.intellij.openapi.vcs.VcsException; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Iterator; /** * author: lesya */ public class CvsResultEx implements CvsResult { private final List myErrors = new ArrayList(); - private final List myWarnings = new ArrayList(); private boolean myIsCanceled = false; + @Override public void setIsCanceled() { myIsCanceled = true; } + @Override public List getErrors() { - return myErrors; + final ArrayList errors = new ArrayList(); + for (VcsException error : myErrors) { + if (!error.isWarning()) { + errors.add(error); + } + } + return errors; } public List getWarnings() { - return myWarnings; + final ArrayList warnings = new ArrayList(); + for (VcsException error : myErrors) { + if (error.isWarning()) { + warnings.add(error); + } + } + return warnings; } + @Override public boolean isCanceled() { return myIsCanceled; } + @Override public void addAllErrors(Collection errors) { myErrors.addAll(errors); } - public void addAllWarnings(Collection warnings) { - myWarnings.addAll(warnings); - } - + @Override public boolean hasNoErrors() { - return myErrors.isEmpty(); + for (VcsException error : myErrors) { + if (!error.isWarning()) { + return false; + } + } + return true; } + @Override public VcsException composeError() { return myErrors.iterator().next(); } + @Override public void addError(VcsException error) { myErrors.add(error); } + @Override public List getErrorsAndWarnings() { - ArrayList result = new ArrayList(); - result.addAll(myErrors); - for (Iterator iterator = myWarnings.iterator(); iterator.hasNext();) { - VcsException vcsException = iterator.next(); - vcsException.setIsWarning(true); - } - result.addAll(myWarnings); - return result; + return myErrors; } - public boolean finishedUnsuccessfully(boolean shouldBeLoggedIn, CvsHandler handler) { + public boolean finishedUnsuccessfully(CvsHandler handler) { checkIsCanceled(handler); if (!hasNoErrors()) return true; if (isCanceled()) return true; diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/StickyHeadGetter.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/StickyHeadGetter.java index fdc46f30daf7..4f71c7c00957 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/StickyHeadGetter.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/StickyHeadGetter.java @@ -132,8 +132,6 @@ public abstract class StickyHeadGetter { public void addError(VcsException ex) { logSuccess.set(Boolean.FALSE); } - public void addWarning(VcsException ex) { - } public List getErrors() { return null; } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsExecution/CvsOperationExecutor.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsExecution/CvsOperationExecutor.java index 3a30df3bd791..cbbde8db9e09 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsExecution/CvsOperationExecutor.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsExecution/CvsOperationExecutor.java @@ -42,9 +42,11 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.wm.StatusBar; +import com.intellij.pom.Navigatable; import com.intellij.ui.content.ContentManager; import com.intellij.ui.errorView.ContentManagerProvider; import com.intellij.ui.errorView.ErrorViewFactory; +import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.ErrorTreeView; import com.intellij.util.ui.MessageCategory; import org.jetbrains.annotations.NotNull; @@ -91,9 +93,7 @@ public class CvsOperationExecutor { this(true, project, modalityState); } - public void performActionSync(final CvsHandler handler, - final CvsOperationExecutorCallback callback) { - + public void performActionSync(final CvsHandler handler, final CvsOperationExecutorCallback callback) { final CvsTabbedWindow tabbedWindow = myIsQuietOperation ? null : openTabbedWindow(handler); final Runnable finish = new Runnable() { @@ -101,15 +101,14 @@ public class CvsOperationExecutor { public void run() { try { myResult.addAllErrors(handler.getErrorsExceptAborted()); - myResult.addAllWarnings(handler.getWarnings()); handler.finish(); if (myProject == null || myProject != null && !myProject.isDisposed()) { - showErrors(handler.getErrorsExceptAborted(), handler.getWarnings(), tabbedWindow); + showErrors(handler, tabbedWindow); } } finally { try { - if (myResult.finishedUnsuccessfully(true, handler)) { + if (myResult.finishedUnsuccessfully(handler)) { callback.executionFinished(false); } else { @@ -136,12 +135,12 @@ public class CvsOperationExecutor { handler.beforeLogin(); - if (myResult.finishedUnsuccessfully(false, handler)) return; + if (myResult.finishedUnsuccessfully(handler)) return; setText(CvsBundle.message("progress.text.preparing.for.action", handler.getTitle())); handler.run(myProject, myExecutor); - if (myResult.finishedUnsuccessfully(true, handler)) return; + if (myResult.finishedUnsuccessfully(handler)) return; } catch (ProcessCanceledException ex) { @@ -200,72 +199,49 @@ public class CvsOperationExecutor { return ProgressManager.getInstance().getProgressIndicator() != null; } - protected void showErrors(final List errors, CvsTabbedWindow tabbedWindow) { - showErrors(errors, new ArrayList(), tabbedWindow); - } - - protected void showErrors(final List errors, - final List warnings, - final CvsTabbedWindow tabbedWindow) { + protected void showErrors(final CvsHandler handler, final CvsTabbedWindow tabbedWindow) { + final List errors = handler.getErrorsExceptAborted(); if (!myShowErrors || myIsQuietOperation) return; if (tabbedWindow == null) { - if (errors.isEmpty() && warnings.isEmpty()) return; + if (errors.isEmpty()) return; final List messages = new ArrayList(); for (VcsException error : errors) { if (! StringUtil.isEmptyOrSpaces(error.getMessage())) { messages.add(error.getMessage()); } } - for (VcsException error : warnings) { - if (! StringUtil.isEmptyOrSpaces(error.getMessage())) { - messages.add(error.getMessage()); - } - } final String errorMessage = StringUtil.join(messages, "\n"); - Messages.showErrorDialog(errorMessage, "CVS error"); + Messages.showErrorDialog(errorMessage, "CVS Error"); return; } - if (errors.isEmpty() && warnings.isEmpty()) { + if (errors.isEmpty()) { tabbedWindow.hideErrors(); } else { - ErrorTreeView errorTreeView = tabbedWindow.addErrorsTreeView(ErrorViewFactory.SERVICE.getInstance() - .createErrorTreeView(myProject, - null, - true, - new AnAction[]{ - (DefaultActionGroup)ActionManager.getInstance() - .getAction("CvsActions")}, - new AnAction[]{new AnAction( - CvsBundle.message( - "configure.global.cvs.settings.action.name"), null, - IconLoader.getIcon("/nodes/cvs_global.png")) { - public void actionPerformed(AnActionEvent e) { - new ConfigureCvsGlobalSettingsDialog().show(); - } - }, new ReconfigureCvsRootAction() - }, - new ContentManagerProvider() { - public ContentManager getParentContent() { - return tabbedWindow.getContentManager(); - } - })); - fillErrors(errors, warnings, errorTreeView); + ErrorTreeView errorTreeView = tabbedWindow.addErrorsTreeView( + ErrorViewFactory.SERVICE.getInstance().createErrorTreeView( + myProject, null, true, + new AnAction[]{(DefaultActionGroup)ActionManager.getInstance().getAction("CvsActions")}, + new AnAction[]{new GlobalCvsSettingsAction(), new ReconfigureCvsRootAction()}, + new ContentManagerProvider() { + public ContentManager getParentContent() { + return tabbedWindow.getContentManager(); + } + })); + for (final VcsException exception : errors) { + final String groupName = DateFormatUtil.formatDateTime(System.currentTimeMillis()) + ' ' + handler.getTitle(); + if (exception.isWarning()) { + errorTreeView.addMessage(MessageCategory.WARNING, exception.getMessages(), groupName, DummyNavigatable.INSTANCE, + null, null, exception); + } else { + errorTreeView.addMessage(MessageCategory.ERROR, exception.getMessages(), groupName, DummyNavigatable.INSTANCE, + null, null, exception); + } + } tabbedWindow.ensureVisible(myProject); } } - private static void fillErrors(final List errors, final List warnings, final ErrorTreeView errorTreeView) { - for (final VcsException exception : errors) { - errorTreeView.addMessage(MessageCategory.ERROR, exception.getMessages(), exception.getVirtualFile(), -1, -1, exception); - } - - for (final VcsException exception : warnings) { - errorTreeView.addMessage(MessageCategory.WARNING, exception.getMessages(), exception.getVirtualFile(), -1, -1, exception); - } - - } - @NotNull private static Editor createView(Project project) { EditorFactory editorFactory = EditorFactory.getInstance(); Document document = editorFactory.createDocument(""); @@ -288,7 +264,6 @@ public class CvsOperationExecutor { } } - @Nullable public CvsTabbedWindow openTabbedWindow(final CvsHandler output) { if (ApplicationManager.getApplication().isUnitTestMode()) return null; @@ -334,6 +309,35 @@ public class CvsOperationExecutor { return myResult; } + private static class DummyNavigatable implements Navigatable { + public static final Navigatable INSTANCE = new DummyNavigatable(); + + private DummyNavigatable() {} + + @Override + public void navigate(boolean requestFocus) {} + + @Override + public boolean canNavigate() { + return false; + } + + @Override + public boolean canNavigateToSource() { + return false; + } + } + + private static class GlobalCvsSettingsAction extends AnAction { + public GlobalCvsSettingsAction() { + super(CvsBundle.message("configure.global.cvs.settings.action.name"), null, IconLoader.getIcon("/nodes/cvs_global.png")); + } + + public void actionPerformed(AnActionEvent e) { + new ConfigureCvsGlobalSettingsDialog().show(); + } + } + private class ReconfigureCvsRootAction extends AnAction { public ReconfigureCvsRootAction() { super(CvsBundle.message("action.name.reconfigure.cvs.root"), null, IconLoader.getIcon("/nodes/cvs_roots.png")); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/CvsHandler.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/CvsHandler.java index bc9ac60e7fb4..fe594ffeef34 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/CvsHandler.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvshandlers/CvsHandler.java @@ -102,10 +102,6 @@ public abstract class CvsHandler extends CvsMessagesAdapter{ return result; } - public List getWarnings() { - return myErrorMessageProcessor.getWarnings(); - } - @Override public void addFileMessage(String message, ICvsFileSystem cvsFileSystem) { setText2(message); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorMessagesProcessor.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorMessagesProcessor.java index e687c965f71f..b14387f6cf11 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorMessagesProcessor.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorMessagesProcessor.java @@ -27,34 +27,21 @@ import java.util.List; public class ErrorMessagesProcessor extends CvsMessagesAdapter implements ErrorProcessor { private final List myErrors; - private final List myWarnings; public ErrorMessagesProcessor(List errors) { myErrors = errors; - myWarnings = new ArrayList(); } public ErrorMessagesProcessor() { this(new ArrayList()); } - public void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot) { - addErrorOnCurrentMessage(relativeFilePath, message, cvsFileSystem, myErrors, cvsRoot); - } - - public void addWarning(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot) { - addErrorOnCurrentMessage(relativeFilePath, message, cvsFileSystem, myWarnings, cvsRoot); - } - - private static void addErrorOnCurrentMessage(String relativeFileName, - String message, - ICvsFileSystem cvsFileSystem, - List collection, - String cvsRoot) { - VirtualFile vFile = getVirtualFile(cvsFileSystem, relativeFileName); + public void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot, boolean warning) { + VirtualFile vFile = getVirtualFile(cvsFileSystem, relativeFilePath); VcsException vcsException = new CvsException(message, cvsRoot); if (vFile != null) vcsException.setVirtualFile(vFile); - collection.add(vcsException); + vcsException.setIsWarning(warning); + myErrors.add(vcsException); } private static VirtualFile getVirtualFile(ICvsFileSystem cvsFileSystem, String relativeFileName) { @@ -67,20 +54,7 @@ public class ErrorMessagesProcessor extends CvsMessagesAdapter implements ErrorP return myErrors; } - public List getWarnings() { - return myWarnings; - } - - public void clear() { - myErrors.clear(); - myWarnings.clear(); - } - public void addError(VcsException ex) { myErrors.add(ex); } - - public void addWarning(VcsException ex) { - myWarnings.add(ex); - } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorProcessor.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorProcessor.java index 5c9e5ad05e6f..1038948a09d9 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorProcessor.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsErrors/ErrorProcessor.java @@ -25,6 +25,6 @@ import java.util.List; public interface ErrorProcessor { void addError(VcsException ex); - void addWarning(VcsException ex); + List getErrors(); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsCompositeListener.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsCompositeListener.java index de4daec5f618..50cd23b4ec64 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsCompositeListener.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsCompositeListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,6 @@ public class CvsCompositeListener implements CvsListenersCollection, CvsMessages for (final Object myListener : myListeners) { ((CvsMessagesListener)myListener).addFileMessage(message); } - } public void addMessage(String message) { @@ -62,25 +61,15 @@ public class CvsCompositeListener implements CvsListenersCollection, CvsMessages } } - public void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot) { + public void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot, boolean warning) { for (final Object myListener : myListeners) { - ((CvsMessagesListener)myListener).addError(message, relativeFilePath, cvsFileSystem, cvsRoot); + ((CvsMessagesListener)myListener).addError(message, relativeFilePath, cvsFileSystem, cvsRoot, warning); } - - } - - public void addWarning(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot) { - for (final Object myListener : myListeners) { - ((CvsMessagesListener)myListener).addWarning(message, relativeFilePath, cvsFileSystem, cvsRoot); - } - } public void addFileMessage(String message, ICvsFileSystem cvsFileSystem) { for (final Object myListener : myListeners) { ((CvsMessagesListener)myListener).addFileMessage(message, cvsFileSystem); } - } - } \ No newline at end of file diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesAdapter.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesAdapter.java index 4f6c9185aee8..52436873de9e 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesAdapter.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ */ package com.intellij.cvsSupport2.cvsoperations.cvsMessages; -import com.intellij.cvsSupport2.cvsoperations.cvsMessages.MessageEvent; -import com.intellij.cvsSupport2.cvsoperations.cvsMessages.MessageEvent; import org.netbeans.lib.cvsclient.file.ICvsFileSystem; /** @@ -35,10 +33,7 @@ public class CvsMessagesAdapter implements CvsMessagesListener{ public void commandStarted(String command) { } - public void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot) { - } - - public void addWarning(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot) { + public void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot, boolean warning) { } public void addFileMessage(String message, ICvsFileSystem cvsFileSystem) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesListener.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesListener.java index cfb2b54a3d39..58683dfb6802 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesListener.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsoperations/cvsMessages/CvsMessagesListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,21 +15,22 @@ */ package com.intellij.cvsSupport2.cvsoperations.cvsMessages; +import com.intellij.CvsBundle; import org.netbeans.lib.cvsclient.file.ICvsFileSystem; -import java.text.MessageFormat; - public interface CvsMessagesListener { CvsMessagesListener STANDARD_OUTPUT = new CvsMessagesAdapter() { + @Override public void addMessage(MessageEvent event) { if (event.getMessage().length() > 0) System.out.println(event.getMessage()); System.out.flush(); } + @Override public void commandStarted(String command) { - System.out.println(com.intellij.CvsBundle.message("output.command.started", command)); + System.out.println(CvsBundle.message("output.command.started", command)); System.out.flush(); } @@ -43,9 +44,7 @@ public interface CvsMessagesListener { void commandStarted(String command); - void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot); - - void addWarning(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot); + void addError(String message, String relativeFilePath, ICvsFileSystem cvsFileSystem, String cvsRoot, boolean warning); void addFileMessage(String message, ICvsFileSystem cvsFileSystem); diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/javacvsImpl/io/StoringLineSeparatorsLocalFileWriter.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/javacvsImpl/io/StoringLineSeparatorsLocalFileWriter.java index 82b9108826a0..6f14923c0d2b 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/javacvsImpl/io/StoringLineSeparatorsLocalFileWriter.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/javacvsImpl/io/StoringLineSeparatorsLocalFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -159,7 +159,8 @@ public class StoringLineSeparatorsLocalFileWriter implements ILocalFileWriter { } finally { CvsUtil.skip(inputStream, length); - myErrorProcessor.addWarning(vcsEx); + vcsEx.setIsWarning(true); + myErrorProcessor.addError(vcsEx); } } @@ -175,7 +176,7 @@ public class StoringLineSeparatorsLocalFileWriter implements ILocalFileWriter { } } - private String getLineSeparatorFor(VirtualFile virtualFile) { + private static String getLineSeparatorFor(VirtualFile virtualFile) { try { return FileDocumentManager.getInstance().getLineSeparator(virtualFile, null); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/openapi/cvsIntegration/CvsResult.java b/plugins/cvs/cvs-plugin/src/com/intellij/openapi/cvsIntegration/CvsResult.java index a20a99e0982b..37c09e69c216 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/openapi/cvsIntegration/CvsResult.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/openapi/cvsIntegration/CvsResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,6 @@ public interface CvsResult { void addAllErrors(Collection errors); - void addAllWarnings(Collection warnings); - boolean hasNoErrors(); VcsException composeError();