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); } }