mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[file-history] use extension providers for show diff and create patch actions
CreatePatch action redirects to the default action for files, so provider is made active only for folders now.
This commit is contained in:
@@ -44,9 +44,11 @@
|
||||
|
||||
<diff.actions.ShowDiffAction.ExtensionProvider implementation="com.intellij.openapi.vcs.changes.shelf.DiffShelvedChangesActionProvider"/>
|
||||
<diff.actions.ShowDiffAction.ExtensionProvider implementation="com.intellij.openapi.vcs.update.ShowUpdatedDiffActionProvider"/>
|
||||
<diff.actions.ShowDiffAction.ExtensionProvider implementation="com.intellij.openapi.vcs.history.actions.CompareRevisionsAction"/>
|
||||
<diff.actions.ShowDiffAction.ExtensionProvider implementation="com.intellij.openapi.vcs.changes.actions.diff.ShowDiffAction" order="last"/>
|
||||
|
||||
<openapi.vcs.history.actions.ShowDiffAfterWithLocalAction.ExtensionProvider implementation="com.intellij.openapi.vcs.changes.shelf.DiffShelvedChangesWithLocalActionProvider"/>
|
||||
<openapi.vcs.changes.actions.CreatePatchFromChangesAction.Dialog.ExtensionProvider implementation="com.intellij.openapi.vcs.history.actions.CreatePatchFromDirectoryAction"/>
|
||||
|
||||
<selectInTarget implementation="com.intellij.openapi.vcs.changes.SelectInChangesViewTarget"/>
|
||||
|
||||
|
||||
@@ -181,23 +181,20 @@
|
||||
<group id="VcsHistoryActionsGroup"/>
|
||||
|
||||
<action id="FileHistory.AnnotateRevision" class="com.intellij.openapi.vcs.history.actions.AnnotateRevisionAction"/>
|
||||
<action id="FileHistory.CreatePatch" class="com.intellij.openapi.vcs.history.actions.CreatePatchAction"/>
|
||||
<action id="FileHistory.CompareRevisions" class="com.intellij.openapi.vcs.history.actions.CompareRevisionsAction"
|
||||
use-shortcut-of="Diff.ShowDiff"/>
|
||||
|
||||
<group id="VcsHistoryInternalGroup.Popup">
|
||||
<reference ref="FileHistory.CompareRevisions"/>
|
||||
<reference ref="Diff.ShowDiff"/>
|
||||
<reference ref="Vcs.ShowDiffWithLocal"/>
|
||||
<reference ref="VcsHistoryActionsGroup"/>
|
||||
<reference ref="FileHistory.CreatePatch"/>
|
||||
<reference ref="ChangesView.CreatePatchFromChanges"/>
|
||||
<reference ref="Vcs.GetVersion"/>
|
||||
<reference ref="FileHistory.AnnotateRevision"/>
|
||||
</group>
|
||||
|
||||
<group id="VcsHistoryInternalGroup.Toolbar">
|
||||
<reference ref="FileHistory.CompareRevisions"/>
|
||||
<reference ref="Diff.ShowDiff"/>
|
||||
<reference ref="VcsHistoryActionsGroup"/>
|
||||
<reference ref="FileHistory.CreatePatch"/>
|
||||
<reference ref="ChangesView.CreatePatchFromChanges"/>
|
||||
<reference ref="Vcs.GetVersion"/>
|
||||
<reference ref="FileHistory.AnnotateRevision"/>
|
||||
</group>
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.CurrentContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.issueLinks.IssueLinkRenderer;
|
||||
import com.intellij.openapi.vcs.changes.issueLinks.TableLinkMouseListener;
|
||||
import com.intellij.openapi.vcs.history.actions.CompareRevisionsAction;
|
||||
import com.intellij.openapi.vcs.vfs.VcsFileSystem;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFolder;
|
||||
@@ -343,7 +342,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
||||
myDualView.setTreeCellRenderer(new MyTreeCellRenderer(myDualView.getTree().getCellRenderer(), () -> myHistorySession));
|
||||
myDualView.setCellWrapper(new MyCellWrapper(() -> myHistorySession));
|
||||
|
||||
myDualView.installDoubleClickHandler(new CompareRevisionsAction());
|
||||
myDualView.installDoubleClickHandler(EmptyAction.wrap(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_DIFF_COMMON)));
|
||||
|
||||
myDualView.getFlatView().getTableViewModel().setSortable(true);
|
||||
RowSorter<? extends TableModel> rowSorter = myDualView.getFlatView().getRowSorter();
|
||||
|
||||
+10
-6
@@ -15,20 +15,16 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.history.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.AnActionExtensionProvider;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.openapi.vcs.VcsDataKeys;
|
||||
import com.intellij.openapi.vcs.history.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CompareRevisionsAction extends DumbAwareAction {
|
||||
public CompareRevisionsAction() {
|
||||
super(VcsBundle.message("action.name.compare"), VcsBundle.message("action.description.compare"), AllIcons.Actions.Diff);
|
||||
}
|
||||
public class CompareRevisionsAction implements AnActionExtensionProvider {
|
||||
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
VcsFileRevision[] revisions = e.getRequiredData(VcsDataKeys.VCS_FILE_REVISIONS);
|
||||
@@ -49,7 +45,15 @@ public class CompareRevisionsAction extends DumbAwareAction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(@NotNull AnActionEvent e) {
|
||||
return e.getData(VcsDataKeys.HISTORY_SESSION) != null;
|
||||
}
|
||||
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
e.getPresentation().setText(VcsBundle.message("action.name.compare"));
|
||||
e.getPresentation().setDescription(VcsBundle.message("action.description.compare"));
|
||||
|
||||
VcsFileRevision[] revisions = e.getData(VcsDataKeys.VCS_FILE_REVISIONS);
|
||||
VcsHistorySession historySession = e.getData(VcsDataKeys.HISTORY_SESSION);
|
||||
FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
|
||||
|
||||
+13
-15
@@ -15,19 +15,18 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.history.actions;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
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.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.actions.CreatePatchFromChangesAction;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.history.VcsHistorySession;
|
||||
import com.intellij.openapi.vcs.impl.AbstractVcsHelperImpl;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vcs.vfs.VcsFileSystem;
|
||||
@@ -37,14 +36,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreatePatchAction extends DumbAwareAction {
|
||||
private final AnAction myUsualDelegate;
|
||||
|
||||
public CreatePatchAction() {
|
||||
super(VcsBundle.message("action.name.create.patch.for.selected.revisions"),
|
||||
VcsBundle.message("action.description.create.patch.for.selected.revisions"), AllIcons.Vcs.Patch);
|
||||
myUsualDelegate = new CreatePatchFromChangesAction.Dialog();
|
||||
}
|
||||
public class CreatePatchFromDirectoryAction implements AnActionExtensionProvider {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
@@ -59,14 +51,20 @@ public class CreatePatchAction extends DumbAwareAction {
|
||||
|
||||
ProgressManager.getInstance().run(new FolderPatchCreationTask(vcs, revisions[0]));
|
||||
}
|
||||
else {
|
||||
myUsualDelegate.actionPerformed(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(@NotNull AnActionEvent e) {
|
||||
VcsHistorySession session = e.getData(VcsDataKeys.HISTORY_SESSION);
|
||||
FilePath path = e.getData(VcsDataKeys.FILE_PATH);
|
||||
return session != null && path != null && path.isDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setVisible(true);
|
||||
e.getPresentation().setText(VcsBundle.message("action.name.create.patch.for.selected.revisions"));
|
||||
e.getPresentation().setDescription(VcsBundle.message("action.description.create.patch.for.selected.revisions"));
|
||||
|
||||
VcsFileRevision[] revisions = e.getData(VcsDataKeys.VCS_FILE_REVISIONS);
|
||||
FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
|
||||
@@ -88,7 +86,7 @@ public class CreatePatchAction extends DumbAwareAction {
|
||||
}
|
||||
}
|
||||
else {
|
||||
e.getPresentation().setEnabled((revisions.length > 0) && (revisions.length < 3));
|
||||
e.getPresentation().setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user