diff --git a/platform/diff-impl/src/com/intellij/diff/actions/ShowDiffAction.java b/platform/diff-impl/src/com/intellij/diff/actions/ShowDiffAction.java new file mode 100644 index 000000000000..1d856d071d30 --- /dev/null +++ b/platform/diff-impl/src/com/intellij/diff/actions/ShowDiffAction.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 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.diff.actions; + +import com.intellij.openapi.actionSystem.AnActionExtensionProvider; +import com.intellij.openapi.actionSystem.ExtendableAction; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.project.DumbAware; + +public class ShowDiffAction extends ExtendableAction implements DumbAware { + private static final ExtensionPointName EP_NAME = + ExtensionPointName.create("com.intellij.diff.actions.ShowDiffAction.ExtensionProvider"); + + public ShowDiffAction() { + super(EP_NAME); + } +} diff --git a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java index 51d68e528299..a2b826f7b528 100644 --- a/platform/diff-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java +++ b/platform/diff-impl/src/com/intellij/openapi/vcs/ex/ShowLineStatusRangeDiffAction.java @@ -22,6 +22,7 @@ import com.intellij.diff.contents.DocumentContent; import com.intellij.diff.requests.DiffRequest; import com.intellij.diff.requests.SimpleDiffRequest; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -41,7 +42,7 @@ public class ShowLineStatusRangeDiffAction extends DumbAwareAction { public ShowLineStatusRangeDiffAction(@NotNull LineStatusTrackerBase lineStatusTracker, @NotNull Range range, @Nullable Editor editor) { myLineStatusTracker = lineStatusTracker; myRange = range; - ActionUtil.copyFrom(this, "ChangesView.Diff"); + ActionUtil.copyFrom(this, IdeActions.ACTION_SHOW_DIFF_COMMON); } public void update(final AnActionEvent e) { diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/AnActionExtensionProvider.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/AnActionExtensionProvider.java new file mode 100644 index 000000000000..0cbd7006fbe0 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/AnActionExtensionProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2017 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.actionSystem; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +/** + * Allows to override AnAction behavior in some context, + * not affecting the others. + * + * Note, that various flags cannot be overridden. Ex: + * {@link AnAction#isEnabledInModalContext()} + * {@link AnAction#isDumbAware()} + * {@link AnAction#isTransparentUpdate()} + * + * @see ExtendableAction + */ +@ApiStatus.Experimental +public interface AnActionExtensionProvider { + /** + * @return whether current provider should be used in given context + *

+ * Provider should not modify presentation in this method. + * Only the first active provider will be used. + */ + boolean isActive(@NotNull AnActionEvent e); + + void update(@NotNull AnActionEvent e); + + void actionPerformed(@NotNull AnActionEvent e); +} diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/ExtendableAction.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ExtendableAction.java new file mode 100644 index 000000000000..82fb394abbb8 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/ExtendableAction.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2017 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.actionSystem; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@ApiStatus.Experimental +public class ExtendableAction extends AnAction { + @NotNull private final ExtensionPointName myExtensionPoint; + + public ExtendableAction(@NotNull ExtensionPointName extensionPoint) { + myExtensionPoint = extensionPoint; + } + + @Override + public final void update(@NotNull AnActionEvent e) { + e.getPresentation().copyFrom(getTemplatePresentation()); + + AnActionExtensionProvider provider = getProvider(e); + if (provider != null) { + provider.update(e); + } + else { + defaultUpdate(e); + } + } + + @Override + public final void actionPerformed(@NotNull AnActionEvent e) { + AnActionExtensionProvider provider = getProvider(e); + if (provider != null) { + provider.actionPerformed(e); + } + else { + defaultActionPerformed(e); + } + } + + @Nullable + private AnActionExtensionProvider getProvider(@NotNull AnActionEvent e) { + return ContainerUtil.find(myExtensionPoint.getExtensions(), provider -> provider.isActive(e)); + } + + protected void defaultUpdate(@NotNull AnActionEvent e) { + e.getPresentation().setEnabledAndVisible(false); + } + + protected void defaultActionPerformed(@NotNull AnActionEvent e) { + } +} diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 571409922d1b..ec9925002c84 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -1253,7 +1253,7 @@ action.ChangesView.SetDefault.description=Set changelist to which new changes ar action.ChangesView.Move.text=Move to Another Changelist... action.ChangesView.Move.description=Move selected changes to another changelist action.ChangesView.Diff.text=Show Diff -action.ChangesView.Diff.description=Show diff for selected change +action.ChangesView.Diff.description=Compare files or revisions action.ChangesView.DeleteUnversioned.text=Delete action.ChangesView.DeleteUnversioned.description= action.ChangesView.AddUnversioned.text=Add to VCS @@ -1388,9 +1388,6 @@ action.SliceBackward.description=Search for values which can be assigned to sele action.SliceForward.text=Analyze Data Flow _from Here action.SliceSliceForward.description=Search for values escaped from this location -action.ShelvedChanges.Diff.text=Show Diff -action.ShelvedChanges.Diff.description=Show diff for selected change - action.ChangeTemplateDataLanguage.text=Change Template Data Language group.FileOpenGroup.text=File Open Actions @@ -1568,9 +1565,6 @@ action.Images.Thumbnails.Hide.description=Close thumbnails window action.Images.ShowThumbnails.text=Show Image Thumbnails action.Images.ShowThumbnails.description=Show thumbnails view for current directory -action.Diff.UpdatedFiles.text=Show Diff -action.Diff.UpdatedFiles.description=Show diff with version before update - action.TabList.text=Show Hidden Tabs action.TabList.description=Show dropdown with the list of tabs that don't fit on the screen in single-row tab layout diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 4419b87ce75b..8e4b64654c5b 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -257,6 +257,8 @@ + + diff --git a/platform/platform-resources/src/META-INF/VcsExtensions.xml b/platform/platform-resources/src/META-INF/VcsExtensions.xml index 157d455862e6..3e07f966628d 100644 --- a/platform/platform-resources/src/META-INF/VcsExtensions.xml +++ b/platform/platform-resources/src/META-INF/VcsExtensions.xml @@ -36,6 +36,10 @@ + + + + diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 4da0e1cdcd0b..e84937974541 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -172,7 +172,7 @@ - + diff --git a/platform/platform-resources/src/idea/VcsActions.xml b/platform/platform-resources/src/idea/VcsActions.xml index 297618180aa7..0a5248f4442a 100644 --- a/platform/platform-resources/src/idea/VcsActions.xml +++ b/platform/platform-resources/src/idea/VcsActions.xml @@ -97,8 +97,7 @@ text="Shelve Silently" description="Shelve changes to appropriate shelved changelists" icon="AllIcons.Vcs.ShelveSilent"> - + @@ -107,7 +106,7 @@ - + - + @@ -166,7 +164,7 @@ - + @@ -239,8 +237,7 @@ - + @@ -300,7 +297,7 @@ - + @@ -353,7 +350,7 @@ - + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java index 7ba34cc0fc37..1f68827b0c30 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowDiffFromAnnotation.java @@ -17,9 +17,9 @@ package com.intellij.openapi.vcs.actions; import com.intellij.diff.DiffDialogHints; import com.intellij.diff.util.DiffUserDataKeysEx; -import com.intellij.icons.AllIcons; -import com.intellij.idea.ActionsBundle; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.diff.DiffNavigationContext; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -62,9 +62,7 @@ class ShowDiffFromAnnotation extends DumbAwareAction implements UpToDateLineNumb private boolean myEnabled; ShowDiffFromAnnotation(final FileAnnotation fileAnnotation, final AbstractVcs vcs, final VirtualFile file) { - super(ActionsBundle.message("action.Diff.UpdatedFiles.text"), - ActionsBundle.message("action.Diff.UpdatedFiles.description"), - AllIcons.Actions.Diff); + ActionUtil.copyFrom(this, IdeActions.ACTION_SHOW_DIFF_COMMON); myFileAnnotation = fileAnnotation; myVcs = vcs; myFile = file; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index a130ac5a7225..a43c2189bb97 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -176,7 +176,7 @@ public class ChangesViewManager implements ChangesViewI, ProjectComponent, Persi EmptyAction.registerWithShortcutSet(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, CommonShortcuts.getMove(), panel); EmptyAction.registerWithShortcutSet("ChangesView.Rename",CommonShortcuts.getRename() , panel); EmptyAction.registerWithShortcutSet("ChangesView.SetDefault", new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_DOWN_MASK | ctrlMask())), panel); - EmptyAction.registerWithShortcutSet("ChangesView.Diff", CommonShortcuts.getDiff(), panel); + EmptyAction.registerWithShortcutSet(IdeActions.ACTION_SHOW_DIFF_COMMON, CommonShortcuts.getDiff(), panel); DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("ChangesViewToolbar"); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, group, false); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffAction.java index 767b492f8105..b36d7d7c686f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffAction.java @@ -19,13 +19,8 @@ import com.intellij.diff.DiffManager; import com.intellij.diff.chains.DiffRequestChain; import com.intellij.diff.util.DiffUserDataKeys; import com.intellij.idea.ActionsBundle; -import com.intellij.openapi.actionSystem.ActionPlaces; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Key; @@ -40,9 +35,13 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -public class ShowDiffAction extends AnAction implements DumbAware { - private static final Logger LOG = Logger.getInstance(ShowDiffAction.class); +public class ShowDiffAction implements AnActionExtensionProvider { + @Override + public boolean isActive(@NotNull AnActionEvent e) { + return true; + } + @Override public void update(@NotNull AnActionEvent e) { Change[] changes = e.getData(VcsDataKeys.CHANGES); Project project = e.getData(CommonDataKeys.PROJECT); @@ -66,6 +65,7 @@ public class ShowDiffAction extends AnAction implements DumbAware { return false; } + @Override public void actionPerformed(@NotNull final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final Change[] changes = e.getData(VcsDataKeys.CHANGES); @@ -110,7 +110,8 @@ public class ShowDiffAction extends AnAction implements DumbAware { if (needsConversion) { ChangeListManager.getInstance(project).invokeAfterUpdate(performer, InvokeAfterUpdateMode.BACKGROUND_CANCELLABLE, - ActionsBundle.actionText("ChangesView.Diff"), ModalityState.current()); + ActionsBundle.actionText(IdeActions.ACTION_SHOW_DIFF_COMMON), + ModalityState.current()); } else { performer.run(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java index 5105a52e00bf..6d44ed22c9b3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java @@ -28,10 +28,7 @@ import com.intellij.diff.requests.SimpleDiffRequest; import com.intellij.diff.requests.UnknownFileTypeDiffRequest; import com.intellij.diff.tools.util.SoftHardCacheMap; import com.intellij.diff.util.DiffUtil; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.diff.impl.patch.*; import com.intellij.openapi.diff.impl.patch.apply.ApplyFilePatchBase; import com.intellij.openapi.diff.impl.patch.apply.GenericPatchApplier; @@ -39,7 +36,6 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.UserDataHolder; import com.intellij.openapi.util.UserDataHolderBase; @@ -77,18 +73,25 @@ import static com.intellij.openapi.vcs.changes.patch.PatchDiffRequestFactory.cre import static com.intellij.util.ObjectUtils.assertNotNull; import static com.intellij.util.ObjectUtils.chooseNotNull; -public class DiffShelvedChangesAction extends AnAction implements DumbAware { - +public class DiffShelvedChangesAction implements AnActionExtensionProvider { private static final String DIFF_WITH_BASE_ERROR = "Base content not found or not applicable."; public static final String SHELVED_VERSION = "Shelved Version"; public static final String BASE_VERSION = "Base Version"; public static final String CURRENT_VERSION = "Current Version"; - public void update(final AnActionEvent e) { + @Override + public boolean isActive(@NotNull AnActionEvent e) { + return e.getData(ShelvedChangesViewManager.SHELVED_CHANGELIST_KEY) != null || + e.getData(ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY) != null; + } + + @Override + public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(isEnabled(e.getDataContext())); } - public void actionPerformed(final AnActionEvent e) { + @Override + public void actionPerformed(@NotNull AnActionEvent e) { showShelvedChangesDiff(e.getDataContext()); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesWithLocalAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesWithLocalAction.java index 663b8197a98a..0bbf95973ac9 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesWithLocalAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesWithLocalAction.java @@ -16,10 +16,16 @@ package com.intellij.openapi.vcs.changes.shelf; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.DumbAwareAction; + +public class DiffShelvedChangesWithLocalAction extends DumbAwareAction { + @Override + public void update(final AnActionEvent e) { + e.getPresentation().setEnabled(DiffShelvedChangesAction.isEnabled(e.getDataContext())); + } -public class DiffShelvedChangesWithLocalAction extends DiffShelvedChangesAction { @Override public void actionPerformed(AnActionEvent e) { - showShelvedChangesDiff(e.getDataContext(), true); + DiffShelvedChangesAction.showShelvedChangesDiff(e.getDataContext(), true); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java index 5a3fc4163612..8e0d58c0accc 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java @@ -153,7 +153,7 @@ public class ShelvedChangesViewManager implements ProjectComponent { DnDSupport.createBuilder(myTree).disableAsTarget().setImageProvider(this::createDraggedImage).setBeanProvider(this::createDragStartBean) .install(); - final AnAction showDiffAction = ActionManager.getInstance().getAction("ShelvedChanges.Diff"); + final AnAction showDiffAction = ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_DIFF_COMMON); showDiffAction.registerCustomShortcutSet(showDiffAction.getShortcutSet(), myTree); final EditSourceAction editSourceAction = new EditSourceAction(); editSourceAction.registerCustomShortcutSet(editSourceAction.getShortcutSet(), myTree); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java index 0e520695ff16..e4102ff02781 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserBase.java @@ -377,7 +377,7 @@ public abstract class ChangesBrowserBase extends JPanel implements TypeSafeDa showDiff(); } }; - ActionUtil.copyFrom(myDiffAction, "ChangesView.Diff"); + ActionUtil.copyFrom(myDiffAction, IdeActions.ACTION_SHOW_DIFF_COMMON); myDiffAction.registerCustomShortcutSet(myViewer, null); toolBarGroup.add(myDiffAction); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/ShowUpdatedDiffAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/ShowUpdatedDiffAction.java index ec6d7263233c..588611b74eac 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/ShowUpdatedDiffAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/ShowUpdatedDiffAction.java @@ -31,7 +31,6 @@ import com.intellij.history.Label; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.UserDataHolder; @@ -48,12 +47,18 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -public class ShowUpdatedDiffAction extends AnAction implements DumbAware { +public class ShowUpdatedDiffAction implements AnActionExtensionProvider { @Override - public void update(AnActionEvent e) { + public boolean isActive(@NotNull AnActionEvent e) { + return isVisible(e.getDataContext()); + } + + @Override + public void update(@NotNull AnActionEvent e) { final DataContext dc = e.getDataContext(); final Presentation presentation = e.getPresentation(); + presentation.setDescription("Show diff with version before update"); //presentation.setVisible(isVisible(dc)); presentation.setEnabled(isVisible(dc) && isEnabled(dc)); @@ -69,7 +74,8 @@ public class ShowUpdatedDiffAction extends AnAction implements DumbAware { return iterable != null; } - public void actionPerformed(AnActionEvent e) { + @Override + public void actionPerformed(@NotNull AnActionEvent e) { final DataContext dc = e.getDataContext(); if ((!isVisible(dc)) || (!isEnabled(dc))) return; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java index 0732e8ed8199..d9a376af61a4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/UpdateInfoTree.java @@ -152,7 +152,7 @@ public class UpdateInfoTree extends PanelWithActionsAndCloseButton { group.add(new FilterAction()); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPAND_ALL)); group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COLLAPSE_ALL)); - group.add(ActionManager.getInstance().getAction("Diff.UpdatedFiles")); + group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_DIFF_COMMON)); } protected JComponent createCenterPanel() { diff --git a/platform/vcs-log/impl/src/META-INF/vcs-log.xml b/platform/vcs-log/impl/src/META-INF/vcs-log.xml index 1ef23acc2ace..5d9159125ca2 100644 --- a/platform/vcs-log/impl/src/META-INF/vcs-log.xml +++ b/platform/vcs-log/impl/src/META-INF/vcs-log.xml @@ -34,8 +34,9 @@ - + + @@ -79,9 +80,6 @@ use-shortcut-of="EditSource" text="Open Repository Version" description="Open editor with selected revision of the file" icon="AllIcons.Actions.EditSource"/> - - + @@ -139,7 +137,7 @@ - + @@ -183,7 +181,7 @@ - + diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogActionPlaces.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogActionPlaces.java index 83057ed17a6a..f00b9c0adb40 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogActionPlaces.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogActionPlaces.java @@ -36,5 +36,5 @@ public class VcsLogActionPlaces { public static final String VCS_LOG_TEXT_FILTER_SETTINGS_ACTION = "Vcs.Log.QuickTextFilterSettings"; public static final String VCS_LOG_FOCUS_TEXT_FILTER = "Vcs.Log.FocusTextFilter"; public static final String VCS_LOG_SHOW_DETAILS_ACTION = "Vcs.Log.ShowDetailsAction"; - public static final String VCS_LOG_SHOW_DIFF_ACTION = "Vcs.Log.ShowDiff"; + public static final String VCS_LOG_SHOW_DIFF_ACTION = "Diff.ShowDiff"; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/VcsLogActionPromoter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/VcsLogActionPromoter.java deleted file mode 100644 index 2a30b3257a5e..000000000000 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/VcsLogActionPromoter.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000-2017 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.vcs.log.ui.actions; - -import com.intellij.openapi.actionSystem.ActionPromoter; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.vcs.log.VcsLogDataKeys; -import com.intellij.vcs.log.VcsLogUi; -import com.intellij.vcs.log.history.FileHistoryUi; -import com.intellij.vcs.log.ui.actions.history.CompareRevisionsFromHistoryAction; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class VcsLogActionPromoter implements ActionPromoter { - - @Override - public List promote(@NotNull List actions, @NotNull DataContext context) { - List promoted = ContainerUtil.newArrayList(); - - VcsLogUi ui = VcsLogDataKeys.VCS_LOG_UI.getData(context); - if (ui != null && ui instanceof FileHistoryUi) { - CompareRevisionsFromHistoryAction compareAction = ContainerUtil.findInstance(actions, CompareRevisionsFromHistoryAction.class); - if (compareAction != null) promoted.add(compareAction); - } - - return promoted; - } -} diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/CompareRevisionsFromHistoryAction.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/CompareRevisionsFromHistoryAction.java index 6f048af48a35..b2c6d7c7c7b5 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/CompareRevisionsFromHistoryAction.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/actions/history/CompareRevisionsFromHistoryAction.java @@ -15,24 +15,16 @@ */ package com.intellij.vcs.log.ui.actions.history; -import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.AnActionExtensionProvider; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.progress.Task; -import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsDataKeys; -import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.actions.diff.ShowDiffAction; import com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext; import com.intellij.openapi.vcs.history.VcsDiffUtil; -import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; import com.intellij.vcs.log.CommitId; import com.intellij.vcs.log.VcsFullCommitDetails; @@ -48,12 +40,17 @@ import java.util.List; import static com.intellij.util.ObjectUtils.notNull; -public class CompareRevisionsFromHistoryAction extends AnAction implements DumbAware { +public class CompareRevisionsFromHistoryAction implements AnActionExtensionProvider { private static final String COMPARE_TEXT = "Compare"; private static final String COMPARE_DESCRIPTION = "Compare selected versions"; private static final String DIFF_TEXT = "Show Diff"; private static final String DIFF_DESCRIPTION = "Show diff with previous version"; + @Override + public boolean isActive(@NotNull AnActionEvent e) { + return e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI) != null; + } + public void update(@NotNull AnActionEvent e) { Project project = e.getProject(); FileHistoryUi ui = e.getData(VcsLogInternalDataKeys.FILE_HISTORY_UI); diff --git a/plugins/svn4idea/src/META-INF/plugin.xml b/plugins/svn4idea/src/META-INF/plugin.xml index bf4d8125e38a..2b007daa60ab 100644 --- a/plugins/svn4idea/src/META-INF/plugin.xml +++ b/plugins/svn4idea/src/META-INF/plugin.xml @@ -87,10 +87,10 @@ - + - +