From 1f81a14eeff9170980e167b4926896e779fa8467 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 2 Oct 2013 13:56:28 +0200 Subject: [PATCH 1/3] Overrides, cleanup javadoc --- .../vcs/impl/CheckinHandlersManager.java | 7 ++-- .../changes/ui/CommitChangeListDialog.java | 37 +++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java index 909a650d0247..1ef04e2f059c 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java @@ -37,8 +37,7 @@ public abstract class CheckinHandlersManager { * Returns the list of all registered factories which provide callbacks to run before and after * VCS checkin operations. * - * @return the list of registered factories. - * @param allActiveVcss + * @return the list of registered factories */ public abstract List getRegisteredCheckinHandlerFactories(AbstractVcs[] allActiveVcss); @@ -50,9 +49,9 @@ public abstract class CheckinHandlersManager { */ public abstract void registerCheckinHandlerFactory(BaseCheckinHandlerFactory factory); /** - * Unregisters a factory which provides callbacks to run before and after VCS checkin operations. + * Unregister a factory which provides callbacks to run before and after VCS checkin operations. * * @param factory the factory to unregister. */ - public abstract void unregisterCheckinHandlerFactory(BaseCheckinHandlerFactory handler); + public abstract void unregisterCheckinHandlerFactory(BaseCheckinHandlerFactory factory); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 6afe2ec900ca..8e385eadcd1e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -126,6 +126,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj myDialog = null; } + @Override public void run() { if (myDialog != null) { myDialog.updateButtons(); @@ -276,11 +277,13 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } else { MultipleChangeListBrowser browser = new MultipleChangeListBrowser(project, changeLists, changes, getDisposable(), initialSelection, true, true, new Runnable() { + @Override public void run() { updateWarning(); } }, new Runnable() { + @Override public void run() { for (CheckinHandler handler : myHandlers) { handler.includedChangesChanged(); @@ -333,15 +336,18 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj myBrowserExtender.addToolbarActions(this); myBrowserExtender.addSelectedListChangeListener(new SelectedListChangeListener() { + @Override public void selectedListChanged() { updateOnListSelection(); } }); myBrowser.setDiffExtendUIFactory(new DiffExtendUIFactory() { + @Override public List createActions(final Change change) { return myBrowser.createDiffActions(change); } + @Override @Nullable public JComponent createBottomComponent() { return new DiffCommitMessageEditor(CommitChangeListDialog.this); @@ -583,15 +589,18 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } } + @Override protected void doOKAction() { if (!saveDialogState()) return; saveComments(true); final DefaultListCleaner defaultListCleaner = new DefaultListCleaner(); final Runnable callCommit = new Runnable() { + @Override public void run() { try { runBeforeCommitHandlers(new Runnable() { + @Override public void run() { CommitChangeListDialog.super.doOKAction(); doCommit(myResultHandler); @@ -618,6 +627,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return new CommitAction(); } + @Override @NotNull protected Action[] createActions() { final List actions = new ArrayList(); @@ -673,11 +683,13 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj if (isOK) { final DefaultListCleaner defaultListCleaner = new DefaultListCleaner(); runBeforeCommitHandlers(new Runnable() { + @Override public void run() { boolean success = false; try { final boolean completed = ProgressManager.getInstance().runProcessWithProgressSynchronously( new Runnable() { + @Override public void run() { session.execute(getIncludedChanges(), getCommitMessage()); } @@ -729,6 +741,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj final List list = getIncludedChanges(); final Ref result = new Ref(); ChangesUtil.processChangesByVcs(myProject, list, new ChangesUtil.PerVcsProcessor() { + @Override public void process(final AbstractVcs vcs, final List items) { if (result.isNull()) { CheckinEnvironment checkinEnvironment = vcs.getCheckinEnvironment(); @@ -803,6 +816,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj PropertiesComponent.getInstance().setValue(DETAILS_SHOW_OPTION, String.valueOf(myDetailsSplitter.isOn())); } + @Override public String getCommitActionName() { String name = null; for (AbstractVcs vcs : getAffectedVcses()) { @@ -856,6 +870,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj private void runBeforeCommitHandlers(final Runnable okAction, final CommitExecutor executor) { Runnable proceedRunnable = new Runnable() { + @Override public void run() { FileDocumentManager.getInstance().saveAllDocuments(); @@ -980,6 +995,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } } + @Override @Nullable protected JComponent createCenterPanel() { JPanel rootPane = new JPanel(new BorderLayout()); @@ -1099,6 +1115,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return new ArrayList(result); } + @Override public Collection getRoots() { Set result = new HashSet(); for (Change change : myBrowser.getCurrentDisplayedChanges()) { @@ -1111,14 +1128,17 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return result; } + @Override public JComponent getComponent() { return mySplitter; } + @Override public boolean hasDiffs() { return !getIncludedChanges().isEmpty(); } + @Override public Collection getVirtualFiles() { List result = new ArrayList(); for (Change change: getIncludedChanges()) { @@ -1132,10 +1152,12 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return result; } + @Override public Collection getSelectedChanges() { return new ArrayList(getIncludedChanges()); } + @Override public Collection getFiles() { List result = new ArrayList(); for (Change change: getIncludedChanges()) { @@ -1147,6 +1169,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return result; } + @Override public Project getProject() { return myProject; } @@ -1162,6 +1185,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return false; } + @Override public void setCommitMessage(final String currentDescription) { setCommitMessageText(currentDescription); myCommitMessageArea.requestFocusInMessage(); @@ -1172,6 +1196,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return null; } + @Override public void setWarning(String s) { // todo } @@ -1181,12 +1206,15 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj myCommitMessageArea.setText(currentDescription); } + @Override public String getCommitMessage() { return myCommitMessageArea.getComment(); } + @Override public void refresh() { ChangeListManager.getInstance(myProject).invokeAfterUpdate(new Runnable() { + @Override public void run() { myBrowser.rebuildList(); for (RefreshableOnComponent component : myAdditionalComponents) { @@ -1196,12 +1224,14 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj }, InvokeAfterUpdateMode.SILENT, "commit dialog", ModalityState.current()); // title not shown for silently } + @Override public void saveState() { for (RefreshableOnComponent component : myAdditionalComponents) { component.saveState(); } } + @Override public void restoreState() { for (RefreshableOnComponent component : myAdditionalComponents) { component.restoreState(); @@ -1235,15 +1265,18 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return myBrowserExtender.getCurrentIncludedChanges(); } + @Override @NonNls protected String getDimensionServiceKey() { return "CommitChangelistDialog" + LAYOUT_VERSION; } + @Override public JComponent getPreferredFocusedComponent() { return myCommitMessageArea.getEditorField(); } + @Override public void calcData(DataKey key, DataSink sink) { if (key == Refreshable.PANEL_KEY) { sink.put(Refreshable.PANEL_KEY, this); @@ -1278,8 +1311,10 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } } + @Override public void actionPerformed(ActionEvent e) { final Runnable callExecutor = new Runnable() { + @Override public void run() { execute(myCommitExecutor); } @@ -1307,6 +1342,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj }); } + @Override public void dispose() { if (myCommitDialog != null) { myCommitDialog.setMessageConsumer(null); @@ -1318,6 +1354,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } } + @Override public Dimension getPreferredSize() { // we don't want to be squeezed to one line return new Dimension(400, 120); From 6126ecb98715ea2510198944be0155b10502f800 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 2 Oct 2013 16:44:16 +0200 Subject: [PATCH 2/3] CR-IC-2522 BeforeCommitDialogHandler --- .../src/META-INF/VcsExtensionPoints.xml | 2 - .../src/META-INF/VcsExtensions.xml | 2 - .../checkin/BeforeCheckinDialogHandler.java | 18 +++++- .../checkin/BeforeCommitDialogHandler.java | 36 ----------- .../vcs/impl/CheckinHandlersManager.java | 22 ++++--- .../changes/ui/CommitChangeListDialog.java | 59 +++++++------------ .../vcs/impl/CheckinHandlersManagerImpl.java | 15 ++--- 7 files changed, 58 insertions(+), 96 deletions(-) delete mode 100644 platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCommitDialogHandler.java diff --git a/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml b/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml index 25fdbe42e1a3..2cc7f4b4022c 100644 --- a/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/VcsExtensionPoints.xml @@ -59,7 +59,5 @@ - - diff --git a/platform/platform-resources/src/META-INF/VcsExtensions.xml b/platform/platform-resources/src/META-INF/VcsExtensions.xml index 534a18a357a9..5b77969e431d 100644 --- a/platform/platform-resources/src/META-INF/VcsExtensions.xml +++ b/platform/platform-resources/src/META-INF/VcsExtensions.xml @@ -38,8 +38,6 @@ - - diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCheckinDialogHandler.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCheckinDialogHandler.java index fc1dedfa6a5f..4d6356a06ad1 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCheckinDialogHandler.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCheckinDialogHandler.java @@ -15,12 +15,28 @@ */ package com.intellij.openapi.vcs.checkin; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.CommitExecutor; +import org.jetbrains.annotations.NotNull; + +import java.util.List; public abstract class BeforeCheckinDialogHandler { + @Deprecated + /** + * @deprecated see {@link #beforeCommitDialogShown(com.intellij.openapi.project.Project, java.util.List, Iterable, boolean)} + * @return false to cancel commit + */ + public boolean beforeCommitDialogShownCallback(Iterable executors, boolean showVcsCommit) { + throw new AbstractMethodError(); + } /** * @return false to cancel commit */ - public abstract boolean beforeCommitDialogShownCallback(Iterable executors, boolean showVcsCommit); + public boolean beforeCommitDialogShown(@NotNull Project project, @NotNull List changes, @NotNull Iterable executors, boolean showVcsCommit) { + //noinspection deprecation + return beforeCommitDialogShownCallback(executors, showVcsCommit); + } } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCommitDialogHandler.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCommitDialogHandler.java deleted file mode 100644 index 289ab010af30..000000000000 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BeforeCommitDialogHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2013 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.vcs.checkin; - -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vcs.changes.CommitExecutor; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public abstract class BeforeCommitDialogHandler { - public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.beforeCommitDialog"); - - /** - * @return false to cancel commit - */ - public abstract boolean beforeCommitDialogShownCallback(@NotNull Project project, - @NotNull List changes, - @NotNull Iterable executors, - boolean showVcsCommit); -} diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java index 1ef04e2f059c..7e0374fe8b82 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/impl/CheckinHandlersManager.java @@ -23,11 +23,6 @@ import org.jetbrains.annotations.NotNull; import java.util.List; -/** - * @author irengrig - * Date: 1/28/11 - * Time: 6:00 PM - */ public abstract class CheckinHandlersManager { public static CheckinHandlersManager getInstance() { return ServiceManager.getService(CheckinHandlersManager.class); @@ -39,16 +34,29 @@ public abstract class CheckinHandlersManager { * * @return the list of registered factories */ - public abstract List getRegisteredCheckinHandlerFactories(AbstractVcs[] allActiveVcss); + public abstract List getRegisteredCheckinHandlerFactories(AbstractVcs[] allActiveVcss); - public abstract List getMatchingVcsFactories(@NotNull final List keys); + @SuppressWarnings("UnusedDeclaration") + @Deprecated /** + * @deprecated to remove in IDEA 13 + */ + public abstract List getMatchingVcsFactories(@NotNull final List keys); + + @SuppressWarnings("UnusedDeclaration") + @Deprecated + /** + * @deprecated to remove in IDEA 13, use EP {@link com.intellij.openapi.vcs.checkin.CheckinHandlerFactory#EP_NAME} * Registers a factory which provides callbacks to run before and after VCS checkin operations. * * @param factory the factory to register. */ public abstract void registerCheckinHandlerFactory(BaseCheckinHandlerFactory factory); + + @SuppressWarnings("UnusedDeclaration") + @Deprecated /** + * @deprecated to remove in IDEA 13, use EP {@link com.intellij.openapi.vcs.checkin.CheckinHandlerFactory#EP_NAME} * Unregister a factory which provides callbacks to run before and after VCS checkin operations. * * @param factory the factory to unregister. diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 8e385eadcd1e..66c92b1f13e1 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -48,6 +48,8 @@ import com.intellij.ui.SplitterWithSecondHideable; import com.intellij.util.Alarm; import com.intellij.util.Consumer; import com.intellij.util.OnOffListener; +import com.intellij.util.containers.ContainerUtilRt; +import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -142,39 +144,19 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj private final MyUpdateButtonsRunnable myUpdateButtonsRunnable = new MyUpdateButtonsRunnable(this); - static final class MyBeforeCommitDialogHandler extends BeforeCommitDialogHandler { - @Override - public boolean beforeCommitDialogShownCallback(@NotNull Project project, - @NotNull List changes, - @NotNull Iterable executors, - boolean showVcsCommit) { - List factoryList = CheckinHandlersManager.getInstance().getMatchingVcsFactories( - Arrays.asList(ProjectLevelVcsManager.getInstance(project).getAllActiveVcss())); - for (BaseCheckinHandlerFactory factory : factoryList) { - BeforeCheckinDialogHandler handler = factory.createSystemReadyHandler(project); - if (handler != null && !handler.beforeCommitDialogShownCallback(executors, showVcsCommit)) { - return false; - } - } - return true; - } - } - private static boolean commit(final Project project, final List changes, final LocalChangeList initialSelection, final List executors, final boolean showVcsCommit, final String comment, @Nullable CommitResultHandler customResultHandler) { - for (BeforeCommitDialogHandler handler : BeforeCommitDialogHandler.EP_NAME.getExtensions()) { - if (!handler.beforeCommitDialogShownCallback(project, changes, executors, showVcsCommit)) { + for (BaseCheckinHandlerFactory factory : getCheckInFactories(project)) { + BeforeCheckinDialogHandler handler = factory.createSystemReadyHandler(project); + if (handler != null && !handler.beforeCommitDialogShown(project, changes, executors, showVcsCommit)) { return false; } } final ChangeListManager manager = ChangeListManager.getInstance(project); - final LocalChangeList defaultList = manager.getDefaultChangeList(); - final ArrayList changeLists = new ArrayList(manager.getChangeListsCopy()); - CommitChangeListDialog dialog = - new CommitChangeListDialog(project, changes, initialSelection, executors, showVcsCommit, defaultList, changeLists, null, false, - comment, customResultHandler); + CommitChangeListDialog dialog = new CommitChangeListDialog(project, changes, initialSelection, executors, showVcsCommit, manager.getDefaultChangeList(), manager.getChangeListsCopy(), null, + false, comment, customResultHandler); if (!ApplicationManager.getApplication().isUnitTestMode()) { dialog.show(); } @@ -184,6 +166,11 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return dialog.isOK(); } + private static List getCheckInFactories(Project project) { + return CheckinHandlersManager.getInstance().getRegisteredCheckinHandlerFactories( + ProjectLevelVcsManager.getInstance(project).getAllActiveVcss()); + } + public static void commitPaths(final Project project, Collection paths, final LocalChangeList initialSelection, @Nullable final CommitExecutor executor, final String comment) { final ChangeListManager manager = ChangeListManager.getInstance(project); @@ -207,7 +194,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj public static List collectExecutors(Project project, Collection changes) { List result = new ArrayList(); - for (AbstractVcs vcs : getAffectedVcses(project, changes)) { + for (AbstractVcs vcs : getAffectedVcses(project, changes)) { result.addAll(vcs.getCommitExecutors()); } result.addAll(ChangeListManager.getInstance(project).getRegisteredExecutors()); @@ -405,9 +392,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj boolean afterVisible = false; Box beforeBox = Box.createVerticalBox(); Box afterBox = Box.createVerticalBox(); - final List handlerFactories = CheckinHandlersManager.getInstance().getRegisteredCheckinHandlerFactories( - ProjectLevelVcsManager.getInstance(project).getAllActiveVcss()); - for (BaseCheckinHandlerFactory factory : handlerFactories) { + for (BaseCheckinHandlerFactory factory : getCheckInFactories(project)) { final CheckinHandler handler = factory.createHandler(this, myCommitContext); if (CheckinHandler.DUMMY.equals(handler)) continue; @@ -540,6 +525,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj // check for null since can be called from constructor before field initialization if (myWarningLabel != null) { myWarningLabel.setVisible(false); + @SuppressWarnings("ThrowableResultOfMethodCallIgnored") final VcsException updateException = ((ChangeListManagerImpl)ChangeListManager.getInstance(myProject)).getUpdateException(); if (updateException != null) { final String[] messages = updateException.getMessages(); @@ -553,8 +539,8 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } private void updateVcsOptionsVisibility() { - final List affectedVcses = getAffectedVcses(myProject, myBrowser.getSelectedChangeList().getChanges()); - for(Map.Entry entry: myPerVcsOptionsPanels.entrySet()) { + Collection> affectedVcses = getAffectedVcses(myProject, myBrowser.getSelectedChangeList().getChanges()); + for (Map.Entry entry : myPerVcsOptionsPanels.entrySet()) { entry.getValue().setVisible(affectedVcses.contains(entry.getKey())); } } @@ -1104,15 +1090,12 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj return myBrowserExtender.getAffectedVcses(); } - private static List getAffectedVcses(Project project, final Collection changes) { - Set result = new HashSet(); + private static Collection> getAffectedVcses(Project project, final Collection changes) { + Set> result = new THashSet>(); for (Change change : changes) { - final AbstractVcs vcs = ChangesUtil.getVcsForChange(change, project); - if (vcs != null) { - result.add(vcs); - } + ContainerUtilRt.addIfNotNull(result, ChangesUtil.getVcsForChange(change, project)); } - return new ArrayList(result); + return result; } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java index b31b11d301aa..a49fcea06511 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/CheckinHandlersManagerImpl.java @@ -29,11 +29,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -/** - * @author irengrig - * Date: 1/28/11 - * Time: 5:21 PM - */ public class CheckinHandlersManagerImpl extends CheckinHandlersManager { private final List myRegisteredBeforeCheckinHandlers; private final MultiMap myVcsMap; @@ -48,13 +43,13 @@ public class CheckinHandlersManagerImpl extends CheckinHandlersManager { } @Override - public List getRegisteredCheckinHandlerFactories(AbstractVcs[] allActiveVcss) { - final ArrayList list = + public List getRegisteredCheckinHandlerFactories(AbstractVcs[] allActiveVcss) { + final List list = new ArrayList(myRegisteredBeforeCheckinHandlers.size() + allActiveVcss.length); list.addAll(myRegisteredBeforeCheckinHandlers); for (AbstractVcs vcs : allActiveVcss) { final Collection factories = myVcsMap.get(vcs.getKeyInstanceMethod()); - if (! factories.isEmpty()) { + if (!factories.isEmpty()) { list.addAll(factories); } } @@ -63,10 +58,10 @@ public class CheckinHandlersManagerImpl extends CheckinHandlersManager { @Override public List getMatchingVcsFactories(@NotNull List vcsList) { - final SmartList result = new SmartList(); + final List result = new SmartList(); for (AbstractVcs vcs : vcsList) { final Collection factories = myVcsMap.get(vcs.getKeyInstanceMethod()); - if (! factories.isEmpty()) { + if (!factories.isEmpty()) { result.addAll(factories); } } From 420e6f7a2f75dd1bd35502ccff0a1855f9a6202f Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 2 Oct 2013 16:58:49 +0200 Subject: [PATCH 3/3] cleanup --- .../src/com/intellij/openapi/vcs/AbstractVcs.java | 2 -- .../intellij/openapi/vcs/changes/ChangesUtil.java | 14 ++++++++++---- .../vcs/checkin/BaseCheckinHandlerFactory.java | 9 --------- .../openapi/vcs/checkin/CheckinHandlerFactory.java | 2 +- .../vcs/checkin/VcsCheckinHandlerFactory.java | 5 ----- 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java index efc5a62500ad..7b054fc4c85e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java @@ -16,7 +16,6 @@ package com.intellij.openapi.vcs; import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.diff.impl.patch.formove.FilePathComparator; import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.UnnamedConfigurable; @@ -59,7 +58,6 @@ import java.util.List; public abstract class AbstractVcs extends StartedActivated { // true is default private static final String USE_ANNOTATION_CACHE = "vcs.use.annotation.cache"; - private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.AbstractVcs"); @NonNls protected static final String ourIntegerPattern = "\\d+"; diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java index 81374013ff26..6a97c41245ac 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangesUtil.java @@ -27,7 +27,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.Navigatable; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ import java.util.*; * @author max */ public class ChangesUtil { - private static final Key INTERNAL_OPERATION_KEY = Key.create("internal vcs operation"); + private static final Key INTERNAL_OPERATION_KEY = Key.create("internal vcs operation"); private ChangesUtil() {} @@ -148,7 +148,7 @@ public class ChangesUtil { } } } - return VfsUtil.toVirtualFileArray(files); + return VfsUtilCore.toVirtualFileArray(files); } public static Navigatable[] getNavigatableArray(final Project project, final VirtualFile[] selectedFiles) { @@ -207,6 +207,7 @@ public class ChangesUtil { public static FilePath getLocalPath(final Project project, final FilePath filePath) { // check if the file has just been renamed (IDEADEV-15494) Change change = ApplicationManager.getApplication().runReadAction(new Computable() { + @Override @Nullable public Change compute() { if (project.isDisposed()) throw new ProcessCanceledException(); @@ -255,6 +256,7 @@ public class ChangesUtil { private static VirtualFile getValidParentUnderReadAction(final FilePath filePath) { return ApplicationManager.getApplication().runReadAction(new Computable() { + @Override public VirtualFile compute() { return findValidParent(filePath); } @@ -326,6 +328,7 @@ public class ChangesUtil { final Map> changesByVcs = new HashMap>(); ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override public void run() { for (T item : items) { final AbstractVcs vcs = separator.getVcsFor(item); @@ -348,6 +351,7 @@ public class ChangesUtil { public static void processChangesByVcs(final Project project, Collection changes, PerVcsProcessor processor) { processItemsByVcs(changes, new VcsSeparator() { + @Override public AbstractVcs getVcsFor(final Change item) { return getVcsForChange(item, project); } @@ -356,6 +360,7 @@ public class ChangesUtil { public static void processVirtualFilesByVcs(final Project project, Collection files, PerVcsProcessor processor) { processItemsByVcs(files, new VcsSeparator() { + @Override public AbstractVcs getVcsFor(final VirtualFile item) { return getVcsForFile(item, project); } @@ -364,6 +369,7 @@ public class ChangesUtil { public static void processFilePathsByVcs(final Project project, Collection files, PerVcsProcessor processor) { processItemsByVcs(files, new VcsSeparator() { + @Override public AbstractVcs getVcsFor(final FilePath item) { return getVcsForFile(item.getIOFile(), project); } @@ -380,7 +386,7 @@ public class ChangesUtil { public static boolean hasFileChanges(final Collection changes) { for(Change change: changes) { - FilePath path = ChangesUtil.getFilePath(change); + FilePath path = getFilePath(change); if (!path.isDirectory()) { return true; } diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java index c20465318fb2..69773607fb7b 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/BaseCheckinHandlerFactory.java @@ -21,21 +21,12 @@ import com.intellij.openapi.vcs.changes.CommitContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -/** - * @author irengrig - * Date: 1/28/11 - * Time: 3:09 PM - * - * just interface for checkin handlers creation - */ public interface BaseCheckinHandlerFactory { /** * Creates a handler for a single Checkin Project or Checkin File operation. * - * * @param panel the class which can be used to retrieve information about the files to be committed, * and to get or set the commit message. - * @param commitContext * @return the handler instance. */ @NotNull diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java index 1b40af7ff9f6..9fce242a683f 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/CheckinHandlerFactory.java @@ -31,7 +31,6 @@ import org.jetbrains.annotations.NotNull; * and unregistered in {@link com.intellij.openapi.vcs.AbstractVcs#deactivate()} * * @author lesya - * @see com.intellij.openapi.vcs.ProjectLevelVcsManager#registerCheckinHandlerFactory(BaseCheckinHandlerFactory) * @since 5.1 */ public abstract class CheckinHandlerFactory implements BaseCheckinHandlerFactory { @@ -44,6 +43,7 @@ public abstract class CheckinHandlerFactory implements BaseCheckinHandlerFactory * and to get or set the commit message. * @return the handler instance. */ + @Override @NotNull public abstract CheckinHandler createHandler(final CheckinProjectPanel panel, CommitContext commitContext); diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java index c58a08893b8d..7a46fd9bbe8e 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/checkin/VcsCheckinHandlerFactory.java @@ -22,11 +22,6 @@ import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.changes.CommitContext; import org.jetbrains.annotations.NotNull; -/** - * @author irengrig - * Date: 1/28/11 - * Time: 3:49 PM - */ public abstract class VcsCheckinHandlerFactory implements BaseCheckinHandlerFactory { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.vcsCheckinHandlerFactory");