Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2010-08-10 07:33:07 +0000
committerChris Aniszczyk2010-08-10 16:45:22 +0000
commit96faaecf12d7e42fb2058b583472b4b733e08594 (patch)
treefeb86553548cefcaee881c691b220ba8dd3511e7 /org.eclipse.egit.ui
parent5c9453527f157ae344e1fa15ffa7b378ab912665 (diff)
downloadegit-96faaecf12d7e42fb2058b583472b4b733e08594.tar.gz
egit-96faaecf12d7e42fb2058b583472b4b733e08594.tar.xz
egit-96faaecf12d7e42fb2058b583472b4b733e08594.zip
Git History View: cleanup and usability
This change is intended as first step to imporove the usabily of the Git History View. From the end user perspective, the following changes are noticeable: 1. there is a new toolbar button "Show all versions for the resource" which makes the "resource mode" explicit (in other words, we now have four radio buttons insted of three where selection of no button at all would represent the fourth option) 2. "Wrap comments" and "Fill paragraphs" is only available when the context menu is opened on the comment viewer 3. The file-specific menu entries (compare, open) were promoted to the top of the context menu if a file is selected Internally, all the "popupMenu" contributions were removed and replaced with command contributions and the corresponding actions were refactored out of the GitHistoryView class into handlers in order to improve maintainability. Change-Id: I318476873c0142e18e3cf8928ea693f3adaba1ab Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.ui/icons/elcl16/filterresource.gifbin0 -> 896 bytes
-rw-r--r--org.eclipse.egit.ui/plugin.properties25
-rw-r--r--org.eclipse.egit.ui/plugin.xml363
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIIcons.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java31
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevCommitOperationAction.java120
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevObjectOperation.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java6
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitAction.java23
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitAction.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitAction.java21
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/HardResetToRevisionAction.java46
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MixedResetToRevisionAction.java34
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/QuickdiffBaselineOperation.java57
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java32
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineHeadParentAction.java31
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SetQuickdiffBaselineAction.java32
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SoftResetToRevisionAction.java34
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitCreatePatchWizard.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java616
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommanndHandler.java187
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java (renamed from org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitActionHandler.java)16
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareVersionsHandler.java84
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareWithWorkingTreeHandler.java63
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java (renamed from org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitActionHandler.java)13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreatePatchHandler.java55
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateTagOnCommitHandler.java (renamed from org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitActionHandler.java)18
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/HistoryViewCommands.java31
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java82
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetQuickdiffBaselineHandler.java41
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/SetQuickdiffBaselineHandler.java40
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowVersionsHandler.java121
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties13
35 files changed, 1215 insertions, 1087 deletions
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
index 04a0a1822e..f14b3a397a 100644
--- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
@@ -63,6 +63,7 @@ Export-Package: org.eclipse.egit.ui;version="0.9.0",
org.eclipse.egit.ui.internal.factories;version="0.9.0";x-internal:=true,
org.eclipse.egit.ui.internal.fetch;version="0.9.0";x-internal:=true,
org.eclipse.egit.ui.internal.history;version="0.9.0";x-internal:=true,
+ org.eclipse.egit.ui.internal.history.command;version="0.9.0";x-internal:=true,
org.eclipse.egit.ui.internal.preferences;version="0.9.0";x-internal:=true,
org.eclipse.egit.ui.internal.push;version="0.9.0";x-internal:=true,
org.eclipse.egit.ui.internal.repository;version="0.9.0";x-internal:=true,
diff --git a/org.eclipse.egit.ui/icons/elcl16/filterresource.gif b/org.eclipse.egit.ui/icons/elcl16/filterresource.gif
new file mode 100644
index 0000000000..606ff6ca57
--- /dev/null
+++ b/org.eclipse.egit.ui/icons/elcl16/filterresource.gif
Binary files differ
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index d618dab5ef..ce920a1597 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -166,8 +166,23 @@ TeamMenuCommandsLabel = The commands for the Team menu
SharedCommandsLabel = The shared commands
RepositoryCommandsLabel = The commands for the repositories view
HistoryViewCommandsLabel = History View Commands
-HistoryCreateTagCommandLabel = Create Tag...
-HistoryCreateBranchCommandLabel = Create Branch...
-CheckoutCommitActionLabel = &Checkout
-CreateBranchOnCommitActionLabel = Create &Branch...
-CreateTagOnCommitActionLabel = Create &Tag... \ No newline at end of file
+CompareWithEachOther.label = Compare with &each other
+CompareWithWorktree.label = Compare with &working tree
+Open.label = &Open
+Checkout.label = &Checkout
+CreateBranch.label = Create &Branch...
+CreateTag.label = Create &Tag...
+CreatePatch.label = Create &Patch...
+HistoryViewCommands.extension.name = The history view commands
+CompareCommand.name = Compare with each other
+CompareWithWorkTreeCommand.name = Compare with Working Tree
+OpenCommand.name = Open
+CompareModeCommandParameter.name = Compare mode
+CreatePatchCommand.name = Create Patch
+CreateBranchCommand.name = Create Branch
+CreateTagCommand.name = Create Tag
+ResetCommand.name = Reset
+ResetModeCommandParameter.name = Reset mode
+ResetQuickdiffCommand.name = Reset quickdiff baseline
+ResetTargetCommandParameter.name = Reset target (HEAD, HEAD^1)
+SetQuickdiffBaselineCommand.name = Set quickdiff baseline \ No newline at end of file
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index d329363aba..c2cf8f1698 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -182,91 +182,6 @@
menubarPath="team.main/group10">
</action>
</objectContribution>
- <objectContribution
- id="org.eclipse.egit.ui.revCommitContributions"
- objectClass="org.eclipse.jgit.revwalk.RevCommit">
- <action
- class="org.eclipse.egit.ui.internal.actions.SoftResetToRevisionAction"
- id="org.eclipse.egit.ui.softresettorevision"
- label="%Soft_Reset_label"
- menubarPath="org.eclipse.egit.ui.reset/reset"
- enablesFor="1"
- tooltip="%Soft_Reset_tooltip">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.MixedResetToRevisionAction"
- id="org.eclipse.egit.ui.mixedresettorevision"
- label="%Mixed_Reset_label"
- menubarPath="org.eclipse.egit.ui.reset/reset"
- enablesFor="1"
- tooltip="%Mixed_Reset_tooltip">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.HardResetToRevisionAction"
- id="org.eclipse.egit.ui.hardresettorevision"
- label="%Hard_Reset_label"
- menubarPath="org.eclipse.egit.ui.reset/reset"
- enablesFor="1"
- tooltip="%Hard_Reset_tooltip">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.SetQuickdiffBaselineAction"
- enablesFor="1"
- id="org.eclipse.egit.ui.setquickdiffbaseline"
- label="%Set_As_Quickdiff_Baseline_label"
- menubarPath="org.eclipse.egit.ui.quickdiffbaseline/quickdiff">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.ResetQuickdiffBaselineAction"
- enablesFor="*"
- id="org.eclipse.egit.ui.resetquickdiffbaseline"
- label="%Reset_Quickdiff_Baseline_To_HEAD_label"
- menubarPath="org.eclipse.egit.ui.quickdiffbaseline/quickdiff">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.ResetQuickdiffBaselineHeadParentAction"
- enablesFor="*"
- id="org.eclipse.egit.ui.resetquickdiffheadparentbaseline"
- label="%Reset_Quickdiff_Baseline_To_First_Parent_label"
- menubarPath="org.eclipse.egit.ui.quickdiffbaseline/quickdiff">
- </action>
- <menu
- id="org.eclipse.egit.ui.quickdiffbaseline"
- label="%QuickDiffMenuName"
- path="additions">
- <groupMarker
- name="quickdiff">
- </groupMarker>
- </menu>
- <menu
- icon="icons/obj16/reset.gif"
- id="org.eclipse.egit.ui.reset"
- label="%ResetMenuName"
- path="additions">
- <groupMarker
- name="reset">
- </groupMarker>
- </menu>
- <action
- class="org.eclipse.egit.ui.internal.actions.CheckoutCommitAction"
- enablesFor="1"
- icon="icons/obj16/checkout.gif"
- id="org.eclipse.egit.ui.CheckoutCommitAction"
- label="%CheckoutCommitActionLabel">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.CreateBranchOnCommitAction"
- icon="icons/obj16/branch_obj.gif"
- id="org.eclipse.egit.ui.command.historyCreateBranchAction"
- label="%CreateBranchOnCommitActionLabel">
- </action>
- <action
- class="org.eclipse.egit.ui.internal.actions.CreateTagOnCommitAction"
- icon="icons/obj16/version_rep.gif"
- id="org.eclipse.egit.ui.command.historyCreateTagAction"
- label="%CreateTagOnCommitActionLabel">
- </action>
- </objectContribution>
<objectContribution
adaptable="true"
id="org.eclipse.egit.ui.fileContributions"
@@ -539,20 +454,9 @@
</commandParameter>
</command>
<command
- defaultHandler="org.eclipse.egit.ui.internal.actions.CheckoutCommitActionHandler"
id="org.eclipse.egit.ui.CheckoutCommand"
name="%CheckoutCommand">
</command>
- <command
- defaultHandler="org.eclipse.egit.ui.internal.actions.CreateTagOnCommitActionHandler"
- id="org.eclipse.egit.ui.command.historyCreateTag"
- name="%HistoryCreateTagCommandLabel">
- </command>
- <command
- defaultHandler="org.eclipse.egit.ui.internal.actions.CreateBranchOnCommitActionHandler"
- id="org.eclipse.egit.ui.command.historyCreateBranch"
- name="%HistoryCreateBranchCommandLabel">
- </command>
</extension>
<extension
point="org.eclipse.ui.views">
@@ -1273,6 +1177,172 @@
style="toggle">
</command>
</menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.egit.ui.historyPageContributions">
+ <command
+ commandId="org.eclipse.egit.ui.history.CompareVersions"
+ label="%CompareWithEachOther.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.CompareWithWorkingTree"
+ label="%CompareWithWorktree.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.ShowVersions"
+ label="%Open.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <separator
+ name="org.eclipse.egit.ui.fileGroup"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.egit.ui.CheckoutCommand"
+ label="%Checkout.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.CreateBranch"
+ label="%CreateBranch.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.CreateTag"
+ label="%CreateTag.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.CreatePatch"
+ label="%CreatePatch.label"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <separator
+ name="org.eclipse.egit.ui.resetQuickdiffGroup"
+ visible="true">
+ </separator>
+ <menu
+ icon="icons/obj16/reset.gif"
+ id="reset"
+ label="%ResetMenuName">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <count
+ value="1">
+ </count>
+ </and>
+ </visibleWhen>
+ <command
+ commandId="org.eclipse.egit.ui.history.Reset"
+ label="%Soft_Reset_label"
+ style="push"
+ tooltip="%Soft_Reset_tooltip">
+ <parameter
+ name="org.eclipse.egit.ui.history.ResetMode"
+ value="Soft">
+ </parameter>
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.Reset"
+ label="%Mixed_Reset_label"
+ style="push"
+ tooltip="%Mixed_Reset_tooltip">
+ <parameter
+ name="org.eclipse.egit.ui.history.ResetMode"
+ value="Mixed">
+ </parameter>
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.Reset"
+ label="%Hard_Reset_label"
+ style="push"
+ tooltip="%Hard_Reset_tooltip">
+ <parameter
+ name="org.eclipse.egit.ui.history.ResetMode"
+ value="Hard">
+ </parameter>
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menu>
+ <menu
+ id="quickdiff"
+ label="%QuickDiffMenuName">
+ <command
+ commandId="org.eclipse.egit.ui.history.SetQuickdiffBaseline"
+ label="%Set_As_Quickdiff_Baseline_label"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <count
+ value="+">
+ </count>
+ </and>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.ResetQuickdiffBaseline"
+ label="%Reset_Quickdiff_Baseline_To_HEAD_label"
+ style="push">
+ <parameter
+ name="org.eclipse.egit.ui.history.ResetQuickdiffBaselineTarget"
+ value="HEAD">
+ </parameter>
+ <visibleWhen
+ checkEnabled="false">
+ <count
+ value="*">
+ </count>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.egit.ui.history.ResetQuickdiffBaseline"
+ label="%Reset_Quickdiff_Baseline_To_First_Parent_label"
+ style="push">
+ <parameter
+ name="org.eclipse.egit.ui.history.ResetQuickdiffBaselineTarget"
+ value="HEAD^1">
+ </parameter>
+ <visibleWhen
+ checkEnabled="false">
+ <count
+ value="*">
+ </count>
+ </visibleWhen>
+ </command>
+ </menu>
+ </menuContribution>
</extension>
<extension
name="%RepositoryCommandsLabel"
@@ -1469,14 +1539,10 @@
icon="icons/obj16/history.gif">
</image>
<image
- commandId="org.eclipse.egit.ui.command.historyCreateBranch"
+ commandId="org.eclipse.egit.ui.history.CreateBranch"
icon="icons/obj16/branch_obj.gif">
</image>
<image
- commandId="org.eclipse.egit.ui.command.historyCreateTag"
- icon="icons/obj16/version_rep.gif">
- </image>
- <image
commandId="org.eclipse.egit.ui.CheckoutCommand"
icon="icons/obj16/checkout.gif">
</image>
@@ -1488,6 +1554,10 @@
commandId="org.eclipse.egit.ui.RepositoriesViewNewRemote"
icon="icons/obj16/remotespec.gif">
</image>
+ <image
+ commandId="org.eclipse.egit.ui.history.CreateTag"
+ icon="icons/obj16/version_rep.gif">
+ </image>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
@@ -1639,6 +1709,34 @@
</and>
</activeWhen>
</handler>
+ <handler
+ commandId="org.eclipse.egit.ui.CheckoutCommand">
+ <class
+ class="org.eclipse.egit.ui.internal.history.command.CheckoutCommitHandler"></class>
+ <activeWhen>
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <instanceof
+ value="org.eclipse.jgit.revwalk.RevCommit">
+ </instanceof>
+ </iterate>
+ </and>
+ </activeWhen>
+ </handler>
+ <handler
+ commandId="org.eclipse.egit.ui.history.SetQuickdiffBaseline">
+ <class
+ class="org.eclipse.egit.ui.internal.history.command.SetQuickdiffBaselineHandler">
+ </class>
+ <enabledWhen>
+ <count
+ value="1">
+ </count>
+ </enabledWhen>
+ </handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
@@ -1659,4 +1757,67 @@
sequence="M1+M3+M">
</key>
</extension>
+ <extension
+ name="%HistoryViewCommands.extension.name"
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.CompareVersionsHandler"
+ id="org.eclipse.egit.ui.history.CompareVersions"
+ name="%CompareCommand.name">
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.CompareWithWorkingTreeHandler"
+ id="org.eclipse.egit.ui.history.CompareWithWorkingTree"
+ name="%CompareWithWorkTreeCommand.name">
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.ShowVersionsHandler"
+ id="org.eclipse.egit.ui.history.ShowVersions"
+ name="%OpenCommand.name">
+ <commandParameter
+ id="org.eclipse.egit.ui.history.CompareMode"
+ name="%CompareModeCommandParameter.name"
+ optional="true">
+ </commandParameter>
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.CreatePatchHandler"
+ id="org.eclipse.egit.ui.history.CreatePatch"
+ name="%CreatePatchCommand.name">
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.CreateBranchOnCommitHandler"
+ id="org.eclipse.egit.ui.history.CreateBranch"
+ name="%CreateBranchCommand.name">
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.CreateTagOnCommitHandler"
+ id="org.eclipse.egit.ui.history.CreateTag"
+ name="%CreateTagCommand.name">
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.ResetHandler"
+ id="org.eclipse.egit.ui.history.Reset"
+ name="%ResetCommand.name">
+ <commandParameter
+ id="org.eclipse.egit.ui.history.ResetMode"
+ name="%ResetModeCommandParameter.name"
+ optional="false">
+ </commandParameter>
+ </command>
+ <command
+ defaultHandler="org.eclipse.egit.ui.internal.history.command.ResetQuickdiffBaselineHandler"
+ id="org.eclipse.egit.ui.history.ResetQuickdiffBaseline"
+ name="%ResetQuickdiffCommand.name">
+ <commandParameter
+ id="org.eclipse.egit.ui.history.ResetQuickdiffBaselineTarget"
+ name="%ResetTargetCommandParameter.name"
+ optional="false">
+ </commandParameter>
+ </command>
+ <command
+ id="org.eclipse.egit.ui.history.SetQuickdiffBaseline"
+ name="%SetQuickdiffBaselineCommand.name.7">
+ </command>
+ </extension>
</plugin>
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIIcons.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIIcons.java
index fa66e74336..f89908e660 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIIcons.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIIcons.java
@@ -85,15 +85,18 @@ public class UIIcons {
/** Connect Wizard banner */
public static final ImageDescriptor WIZBAN_CONNECT_REPO;
- /** History filter, select all version in repo */
+ /** History view, select all version in repo */
public static ImageDescriptor FILTERREPO;
- /** History filter, select all version in same project */
+ /** History view, select all version in same project */
public static ImageDescriptor FILTERPROJECT;
- /** History filter, select all version in same folder */
+ /** History view, select all version in same folder */
public static ImageDescriptor FILTERFOLDER;
+ /** History view, select all version of resource */
+ public static ImageDescriptor FILTERRESOURCE;
+
/** Import button */
public static ImageDescriptor FETCH;
@@ -165,6 +168,7 @@ public class UIIcons {
CHECKBOX_DISABLED_CHECKED = map("checkboxes/disabled_checked.gif"); //$NON-NLS-1$
CHECKBOX_DISABLED_UNCHECKED = map("checkboxes/disabled_unchecked.gif"); //$NON-NLS-1$
FILTERREPO = map("elcl16/filterrepo.gif"); //$NON-NLS-1$
+ FILTERRESOURCE = map("elcl16/filterresource.gif"); //$NON-NLS-1$
FILTERPROJECT = map("elcl16/filterproject.gif"); //$NON-NLS-1$
FILTERFOLDER = map("elcl16/filterfolder.gif"); //$NON-NLS-1$
FETCH = map("obj16/pull.gif"); //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 513fcf541b..b776cbafba 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -22,10 +22,7 @@ public class UIText extends NLS {
public static String WizardProjectsImportPage_filterText;
/** */
- public static String AbstractHitoryViewCommandHandler_CanNotGetCommitMessage;
-
- /** */
- public static String AbstractHitoryViewCommandHandler_NoRepositoryMessage;
+ public static String AbstractHistoryCommanndHandler_NoInputMessage;
/** */
public static String Activator_refreshFailed;
@@ -154,9 +151,6 @@ public class UIText extends NLS {
public static String SelectResetTypePage_PageTitle;
/** */
- public static String SetQuickdiffBaselineAction_setQuickdiffBaseline;
-
- /** */
public static String SharingWizard_windowTitle;
/** */
@@ -238,12 +232,6 @@ public class UIText extends NLS {
public static String GitHistoryPage_compareMode;
/** */
- public static String GitHistoryPage_CompareVersions;
-
- /** */
- public static String GitHistoryPage_CompareWithWorking;
-
- /** */
public static String GitHistoryPage_errorLookingUpPath;
/** */
@@ -253,9 +241,6 @@ public class UIText extends NLS {
public static String GitHistoryPage_errorReadingHeadCommit;
/** */
- public static String GitHistoryPage_CreatePatch;
-
- /** */
public static String GitHistoryPage_Date;
/** */
@@ -271,15 +256,15 @@ public class UIText extends NLS {
public static String GitHistoryPage_notContainedInCommits;
/** */
- public static String GitHistoryPage_open;
-
- /** */
public static String GitHistoryPage_openFailed;
/** */
public static String GitHistoryPage_From;
/** */
+ public static String GitHistoryPage_ShowAllVersionsForResource;
+
+ /** */
public static String GitHistoryPage_Subject;
/** */
@@ -838,9 +823,6 @@ public class UIText extends NLS {
public static String QuickDiff_failedLoading;
/** */
- public static String QuickdiffBaselineOperation_baseline;
-
- /** */
public static String ResetAction_errorResettingHead;
/** */
@@ -856,10 +838,7 @@ public class UIText extends NLS {
public static String ResetCommand_WizardTitle;
/** */
- public static String ResetQuickdiffBaselineAction_resetQuickdiffBaseline;
-
- /** */
- public static String ResetQuickdiffBaselineHeadParentAction_0;
+ public static String ResetQuickdiffBaselineHandler_NoTargetMessage;
/** */
public static String ResetTargetSelectionDialog_ResetButton;
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevCommitOperationAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevCommitOperationAction.java
deleted file mode 100644
index 2e05cd7efc..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevCommitOperationAction.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.internal.history.RevObjectSelectionProvider;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Common functionality resource based EGit operations.
- *
- */
-public abstract class AbstractRevCommitOperationAction implements IObjectActionDelegate {
- /**
- * The active workbench part
- */
- protected IWorkbenchPart wp;
-
- private IEGitOperation op;
-
- private List selection;
-
- public void selectionChanged(final IAction act, final ISelection sel) {
- if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
- selection = ((IStructuredSelection) sel).toList();
- } else {
- selection = Collections.EMPTY_LIST;
- }
- }
-
- public void setActivePart(final IAction act, final IWorkbenchPart part) {
- wp = part;
- }
-
- /**
- * Instantiate an operation on an action on provided objects.
- * @param actSelection
- *
- * @return a {@link IEGitOperation} for invoking this operation later on
- */
- protected abstract IEGitOperation createOperation(final List<RevCommit> actSelection);
-
- /**
- * @return the name of the execution Job
- */
- protected abstract String getJobName();
-
- /**
- * A method to invoke when the operation is finished.
- * The method is called outside the UI thread.
- */
- protected void postOperation() {
- // Empty
- }
-
- public void run(final IAction act) {
- op = createOperation(getSelectedCommits());
- if(op==null)
- return;
- String jobname = getJobName();
- Job job = new Job(jobname) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- op.execute(monitor);
- postOperation();
- } catch (CoreException e) {
- return Activator.createErrorStatus(e.getStatus()
- .getMessage(), e);
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.setRule(op.getSchedulingRule());
- job.schedule();
- }
-
- private List<RevCommit> getSelectedCommits() {
- List<RevCommit> commits = new ArrayList<RevCommit>();
- for(Object object: selection) {
- if(object instanceof RevCommit)
- commits.add((RevCommit) object);
- }
- return commits;
- }
-
- /**
- * Find out which repository is involved here
- *
- * @return the Git repository associated with the selected RevObject
- */
- protected Repository getActiveRepository() {
- RevObjectSelectionProvider selectionProvider = (RevObjectSelectionProvider) wp
- .getSite().getSelectionProvider();
- return selectionProvider.getActiveRepository();
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevObjectOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevObjectOperation.java
deleted file mode 100644
index b69c8f385b..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/AbstractRevObjectOperation.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.jgit.lib.Repository;
-
-abstract class AbstractRevObjectOperation implements IEGitOperation {
-
- Repository repository;
-
- AbstractRevObjectOperation(final Repository repository) {
- this.repository = repository;
- }
-
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
index 93c46babc1..2c3af3ba73 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
@@ -32,12 +32,6 @@ public class ActionCommands {
/** "Compare with revision" action command id */
public static final String COMPARE_WITH_REVISION_ACTION = "org.eclipse.egit.ui.team.CompareWithRevision"; //$NON-NLS-1$
- /** "Create Branch" command id */
- public static final String CREATE_BRANCH = "org.eclipse.egit.ui.command.historyCreateBranch"; //$NON-NLS-1$
-
- /** "Create Tag" command id */
- public static final String CREATE_TAG = "org.eclipse.egit.ui.command.historyCreateTag"; //$NON-NLS-1$
-
/** "Discard changes" action command id */
public static final String DISCARD_CHANGES_ACTION = "org.eclipse.egit.ui.team.Discard"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitAction.java
deleted file mode 100644
index ecf7fc5796..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitAction.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import org.eclipse.egit.ui.internal.commands.SharedCommands;
-
-/**
- * Check out a commit
- */
-public class CheckoutCommitAction extends RepositoryAction {
- /**
- * Constructs this action
- */
- public CheckoutCommitAction() {
- super(SharedCommands.CHECKOUT, new CheckoutCommitActionHandler());
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitAction.java
deleted file mode 100644
index cba5ff80c2..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitAction.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-/**
- * Create a branch on a commit
- */
-public class CreateBranchOnCommitAction extends RepositoryAction {
- /**
- * Constructs this action
- */
- public CreateBranchOnCommitAction() {
- super(ActionCommands.CREATE_BRANCH,
- new CreateBranchOnCommitActionHandler());
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitAction.java
deleted file mode 100644
index 528bba8ae2..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitAction.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-/**
- * Create a tag on a commit
- */
-public class CreateTagOnCommitAction extends RepositoryAction {
- /**
- * Constructs this action
- */
- public CreateTagOnCommitAction() {
- super(ActionCommands.CREATE_TAG, new CreateTagOnCommitActionHandler());
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/HardResetToRevisionAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/HardResetToRevisionAction.java
deleted file mode 100644
index 0299a5b414..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/HardResetToRevisionAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.List;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.core.op.ResetOperation;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jgit.revwalk.RevCommit;
-
-/**
- * Hard reset to selected revision
- */
-public class HardResetToRevisionAction extends AbstractRevCommitOperationAction {
-
- @Override
- protected IEGitOperation createOperation(final List<RevCommit> commits) {
- return new ResetOperation(getActiveRepository(),
- commits.get(0).getName(),
- ResetOperation.ResetType.HARD);
- }
-
- @Override
- protected String getJobName() {
- return UIText.HardResetToRevisionAction_hardReset;
- }
-
- @Override
- public void run(IAction act) {
- if (!MessageDialog.openQuestion(wp.getSite().getShell(),
- UIText.ResetTargetSelectionDialog_ResetQuestion,
- UIText.ResetTargetSelectionDialog_ResetConfirmQuestion))
- return;
- super.run(act);
- }
-
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MixedResetToRevisionAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MixedResetToRevisionAction.java
deleted file mode 100644
index 3a8e2f1c60..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/MixedResetToRevisionAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.List;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.core.op.ResetOperation;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.jgit.revwalk.RevCommit;
-
-/**
- * Mixed reset to selected revision
- */
-public class MixedResetToRevisionAction extends AbstractRevCommitOperationAction {
-
- @Override
- protected IEGitOperation createOperation(List<RevCommit> selection) {
- return new ResetOperation(getActiveRepository(),
- selection.get(0).name(),
- ResetOperation.ResetType.MIXED);
- }
-
- @Override
- protected String getJobName() {
- return UIText.MixedResetToRevisionAction_mixedReset;
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/QuickdiffBaselineOperation.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/QuickdiffBaselineOperation.java
deleted file mode 100644
index b957074ff7..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/QuickdiffBaselineOperation.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.egit.ui.internal.decorators.GitQuickDiffProvider;
-import org.eclipse.jgit.lib.Repository;
-
-/**
- * UI operation to change the git quickdiff baseline
- */
-public class QuickdiffBaselineOperation extends AbstractRevObjectOperation {
-
- private final String baseline;
-
- /**
- * Construct a QuickdiffBaselineOperation for changing quickdiff baseline
- * @param repository
- *
- * @param baseline
- */
- QuickdiffBaselineOperation(final Repository repository, final String baseline) {
- super(repository);
- this.baseline = baseline;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CoreException {
- try {
- GitQuickDiffProvider.setBaselineReference(repository, baseline);
- } catch (IOException e) {
- Activator
- .logError(
- UIText.QuickdiffBaselineOperation_baseline,
- e);
- }
- }
-
- public ISchedulingRule getSchedulingRule() {
- return null;
- }
-
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
index 758cea2bee..27d2aa179f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java
@@ -50,7 +50,7 @@ import org.eclipse.ui.handlers.IHandlerService;
/**
* A helper class for Team Actions on Git controlled projects
*/
-public abstract class RepositoryActionHandler extends AbstractHandler {
+abstract class RepositoryActionHandler extends AbstractHandler {
/**
* @param event
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java
deleted file mode 100644
index 615bee4c00..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineAction.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.List;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.revwalk.RevCommit;
-
-/**
- * Changes the reference for the quickdiff to HEAD
- */
-public class ResetQuickdiffBaselineAction extends AbstractRevCommitOperationAction {
-
- @Override
- protected IEGitOperation createOperation(List<RevCommit> selection) {
- return new QuickdiffBaselineOperation(getActiveRepository(), Constants.HEAD);
- }
-
- @Override
- protected String getJobName() {
- return UIText.ResetQuickdiffBaselineAction_resetQuickdiffBaseline;
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineHeadParentAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineHeadParentAction.java
deleted file mode 100644
index 510241f957..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetQuickdiffBaselineHeadParentAction.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.List;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.jgit.revwalk.RevCommit;
-
-/**
- * Changes the reference for the quickdiff to the (first) parent of HEAD
- */
-public class ResetQuickdiffBaselineHeadParentAction extends AbstractRevCommitOperationAction {
-
- @Override
- protected IEGitOperation createOperation(List<RevCommit> selection) {
- return new QuickdiffBaselineOperation(getActiveRepository(), "HEAD^1"); //$NON-NLS-1$
- }
-
- @Override
- protected String getJobName() {
- return UIText.ResetQuickdiffBaselineHeadParentAction_0;
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SetQuickdiffBaselineAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SetQuickdiffBaselineAction.java
deleted file mode 100644
index 37a5f72db4..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SetQuickdiffBaselineAction.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.List;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.jgit.revwalk.RevCommit;
-
-/**
- * Changes the reference for the quickdiff
- */
-public class SetQuickdiffBaselineAction extends AbstractRevCommitOperationAction {
-
- @Override
- protected IEGitOperation createOperation(List<RevCommit> selection) {
- return new QuickdiffBaselineOperation(getActiveRepository(), selection.get(0).getId().name());
- }
-
- @Override
- protected String getJobName() {
- return UIText.SetQuickdiffBaselineAction_setQuickdiffBaseline;
- }
-
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SoftResetToRevisionAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SoftResetToRevisionAction.java
deleted file mode 100644
index 7def224d76..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/SoftResetToRevisionAction.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
-
-import java.util.List;
-
-import org.eclipse.egit.core.op.IEGitOperation;
-import org.eclipse.egit.core.op.ResetOperation;
-import org.eclipse.egit.ui.UIText;
-import org.eclipse.jgit.revwalk.RevCommit;
-
-/**
- * Soft reset to selected revision
- */
-public class SoftResetToRevisionAction extends AbstractRevCommitOperationAction {
-
- @Override
- protected IEGitOperation createOperation(List<RevCommit> selection) {
- return new ResetOperation(getActiveRepository(),
- selection.get(0).name(),
- ResetOperation.ResetType.SOFT);
- }
-
- @Override
- protected String getJobName() {
- return UIText.SoftResetToRevisionAction_softReset;
- }
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitCreatePatchWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitCreatePatchWizard.java
index 704b9eaf01..dcbdf57cc3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitCreatePatchWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitCreatePatchWizard.java
@@ -42,6 +42,7 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
@@ -66,7 +67,7 @@ import org.osgi.framework.Bundle;
*/
public class GitCreatePatchWizard extends Wizard {
- private SWTCommit commit;
+ private RevCommit commit;
private TreeWalk walker;
@@ -88,7 +89,7 @@ public class GitCreatePatchWizard extends Wizard {
* @param walker
* @param db
*/
- public static void run(IWorkbenchPart part, final SWTCommit commit,
+ public static void run(IWorkbenchPart part, final RevCommit commit,
TreeWalk walker, Repository db) {
final String title = UIText.GitCreatePatchWizard_CreatePatchTitle;
final GitCreatePatchWizard wizard = new GitCreatePatchWizard(commit,
@@ -108,7 +109,7 @@ public class GitCreatePatchWizard extends Wizard {
* @param walker
* @param db
*/
- public GitCreatePatchWizard(SWTCommit commit, TreeWalk walker, Repository db) {
+ public GitCreatePatchWizard(RevCommit commit, TreeWalk walker, Repository db) {
this.commit = commit;
this.walker = walker;
this.db = db;
@@ -464,7 +465,6 @@ public class GitCreatePatchWizard extends Wizard {
* A wizard Page used to specify options of the created patch
*/
public static class OptionsPage extends WizardPage {
-
private Button gitFormat;
/**
@@ -495,7 +495,5 @@ public class GitCreatePatchWizard extends Wizard {
Dialog.applyDialogFont(composite);
setControl(composite);
}
-
}
-
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
index 69e4986220..1551c3976e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java
@@ -13,46 +13,38 @@ package org.eclipse.egit.ui.internal.history;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.IParameter;
+import org.eclipse.core.commands.Parameterization;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.egit.core.ResourceList;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
-import org.eclipse.egit.ui.internal.CompareUtils;
-import org.eclipse.egit.ui.internal.EgitUiEditorUtils;
-import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.eclipse.egit.ui.internal.history.command.HistoryViewCommands;
import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
@@ -65,7 +57,6 @@ import org.eclipse.jgit.events.RefsChangedEvent;
import org.eclipse.jgit.events.RefsChangedListener;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -91,66 +82,54 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
-import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.ui.history.HistoryPage;
-import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
/** Graphical commit history viewer. */
public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
- private static final String PREF_COMMENT_WRAP = UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP;
-
- private static final String PREF_COMMENT_FILL = UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL;
-
- private static final String SHOW_COMMENT = UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT;
-
- private static final String SHOW_FILES = UIPreferences.RESOURCEHISTORY_SHOW_REV_DETAIL;
-
- private static final String SPLIT_GRAPH = UIPreferences.RESOURCEHISTORY_GRAPH_SPLIT;
-
- private static final String SPLIT_INFO = UIPreferences.RESOURCEHISTORY_REV_SPLIT;
-
- private static final String SHOW_FIND_TOOLBAR = UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR;
private static final String POPUP_ID = "org.eclipse.egit.ui.historyPageContributions"; //$NON-NLS-1$
- /** The team ui plugin ID which is not accessible */
- private static final String TEAM_UI_PLUGIN = "org.eclipse.team.ui"; //$NON-NLS-1$
+ /** Standard action: select all */
+ private IAction selectAllAction;
+
+ /** Standard action: copy to clip board */
+ private IAction copyAction;
- /** A copy of the non-accessible preference constant IPreferenceIds.REUSE_OPEN_COMPARE_EDITOR from the team ui plug in */
- private static final String REUSE_COMPARE_EDITOR_PREFID = "org.eclipse.team.ui.reuse_open_compare_editors"; //$NON-NLS-1$
+ /** Show Comment */
+ private IAction showCommentAction;
- private IAction compareAction = new CompareWithWorkingTreeAction();
+ /** Show File */
+ private IAction showFilesAction;
- private IAction compareVersionsAction = new CompareVersionsAction();
+ /** Wrap comment */
+ private IAction wrapCommentAction;
- private IAction viewVersionsAction = new ViewVersionsAction();
+ /** Fill comment */
+ private IAction fillCommentAction;
+ /** Compare mode toggle */
private IAction compareModeAction;
private boolean compareMode = false;
- private CreatePatchAction createPatchAction = new CreatePatchAction();
-
// we need to keep track of these actions so that we can
// dispose them when the page is disposed (the history framework
// does not do this for us)
private final List<BooleanPrefAction> actionsToDispose = new ArrayList<BooleanPrefAction>();
- private final IPersistentPreferenceStore store = (IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore();
+ private final IPersistentPreferenceStore store = (IPersistentPreferenceStore) Activator
+ .getDefault().getPreferenceStore();
private ListenerHandle myRefsChangedHandle;
@@ -238,8 +217,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
/**
* Highlight flag that can be applied to commits to make them stand out.
* <p>
- * Allocated at the same time as {@link #currentWalk}. If the walk
- * rebuilds, so must this flag.
+ * Allocated at the same time as {@link #currentWalk}. If the walk rebuilds,
+ * so must this flag.
*/
private RevFlag highlightFlag;
@@ -259,21 +238,21 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
private static final String PREF_SHOWALLFILTER = "org.eclipse.egit.ui.githistorypage.showallfilter"; //$NON-NLS-1$
enum ShowFilter {
- SHOWALLRESOURCE,
- SHOWALLFOLDER,
- SHOWALLPROJECT,
- SHOWALLREPO,
+ SHOWALLRESOURCE, SHOWALLFOLDER, SHOWALLPROJECT, SHOWALLREPO,
}
class ShowFilterAction extends Action {
private final ShowFilter filter;
- ShowFilterAction(ShowFilter filter, ImageDescriptor icon, String toolTipText) {
+ ShowFilterAction(ShowFilter filter, ImageDescriptor icon,
+ String toolTipText) {
super(null, IAction.AS_CHECK_BOX);
this.filter = filter;
setImageDescriptor(icon);
+ setText(toolTipText);
setToolTipText(toolTipText);
}
+
@Override
public void run() {
String oldName = getName();
@@ -291,12 +270,16 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
showAllProjectVersionsAction.setChecked(false);
if (this != showAllFolderVersionsAction)
showAllFolderVersionsAction.setChecked(false);
+ if (this != showAllResourceVersionsAction)
+ showAllResourceVersionsAction.setChecked(false);
refresh();
}
- GitHistoryPage.this.firePropertyChange(GitHistoryPage.this, P_NAME, oldName, getName());
+ GitHistoryPage.this.firePropertyChange(GitHistoryPage.this, P_NAME,
+ oldName, getName());
Activator.getDefault().getPreferenceStore().setValue(
PREF_SHOWALLFILTER, showAllFilter.toString());
}
+
@Override
public String toString() {
return "ShowFilter[" + filter.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
@@ -311,6 +294,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
private ShowFilterAction showAllFolderVersionsAction;
+ private ShowFilterAction showAllResourceVersionsAction;
+
private void createResourceFilterActions() {
try {
showAllFilter = ShowFilter.valueOf(Activator.getDefault()
@@ -331,23 +316,32 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
ShowFilter.SHOWALLFOLDER, UIIcons.FILTERFOLDER,
UIText.HistoryPage_ShowAllVersionsForFolder);
+ showAllResourceVersionsAction = new ShowFilterAction(
+ ShowFilter.SHOWALLRESOURCE, UIIcons.FILTERRESOURCE,
+ UIText.GitHistoryPage_ShowAllVersionsForResource);
+
showAllRepoVersionsAction
.setChecked(showAllFilter == showAllRepoVersionsAction.filter);
showAllProjectVersionsAction
.setChecked(showAllFilter == showAllProjectVersionsAction.filter);
showAllFolderVersionsAction
.setChecked(showAllFilter == showAllFolderVersionsAction.filter);
-
- getSite().getActionBars().getToolBarManager().add(new Separator());
-
- getSite().getActionBars().getToolBarManager().add(
- showAllRepoVersionsAction);
-
- getSite().getActionBars().getToolBarManager().add(
- showAllProjectVersionsAction);
-
- getSite().getActionBars().getToolBarManager().add(
- showAllFolderVersionsAction);
+ showAllResourceVersionsAction
+ .setChecked(showAllFilter == showAllResourceVersionsAction.filter);
+
+ IToolBarManager mgr = getSite().getActionBars().getToolBarManager();
+ mgr.add(new Separator());
+ mgr.add(showAllRepoVersionsAction);
+ mgr.add(showAllProjectVersionsAction);
+ mgr.add(showAllFolderVersionsAction);
+ mgr.add(showAllResourceVersionsAction);
+
+ IMenuManager viewMenuMgr = getSite().getActionBars().getMenuManager();
+ viewMenuMgr.add(new Separator());
+ viewMenuMgr.add(showAllRepoVersionsAction);
+ viewMenuMgr.add(showAllProjectVersionsAction);
+ viewMenuMgr.add(showAllFolderVersionsAction);
+ viewMenuMgr.add(showAllResourceVersionsAction);
}
private void createCompareModeAction() {
@@ -365,15 +359,16 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
compareModeAction.setChecked(compareMode);
compareModeAction.setToolTipText(UIText.GitHistoryPage_compareMode);
fileViewer.setCompareMode(compareMode);
+ barManager.add(new Separator());
barManager.add(compareModeAction);
}
/**
* @param compareMode
- * switch compare mode button of the view on / off
+ * switch compare mode button of the view on / off
*/
public void setCompareMode(boolean compareMode) {
- if (compareModeAction!=null) {
+ if (compareModeAction != null) {
this.compareMode = compareMode;
compareModeAction.setChecked(compareMode);
}
@@ -403,36 +398,47 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
graph.getTableView().addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
final Object input = getInput();
- // if multiple resources (IResourceList) or something not a file is selected we do nothing
+ // if multiple resources (IResourceList) or something not a file
+ // is selected we do nothing
if (!(input instanceof IFile)) {
return;
}
+
+ ICommandService srv = (ICommandService) getSite().getService(
+ ICommandService.class);
+ IHandlerService hsrv = (IHandlerService) getSite().getService(
+ IHandlerService.class);
+ Command cmd = srv.getCommand(HistoryViewCommands.SHOWVERSIONS);
+ Parameterization[] parms;
if (compareMode) {
- final IFile resource = (IFile) input;
- final RepositoryMapping mapping = RepositoryMapping.getMapping(resource.getProject());
- final String gitPath = mapping.getRepoRelativePath(resource);
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- SWTCommit commit = (SWTCommit) selection.getFirstElement();
- ITypedElement right = CompareUtils
- .getFileRevisionTypedElement(gitPath, commit, db);
- final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
- SaveableCompareEditorInput.createFileElement(resource),
- right,
- null);
- openInCompare(in);
- } else {
- new ViewVersionsAction().run();
+ try {
+ IParameter parm = cmd
+ .getParameter(HistoryViewCommands.COMPARE_MODE_PARAM);
+ parms = new Parameterization[] { new Parameterization(
+ parm, Boolean.TRUE.toString()) };
+ } catch (NotDefinedException e) {
+ Activator.handleError(e.getMessage(), e, true);
+ parms = null;
+ }
+ } else
+ parms = null;
+ ParameterizedCommand pcmd = new ParameterizedCommand(cmd, parms);
+ try {
+ hsrv.executeCommandInContext(pcmd, null, hsrv
+ .getCurrentState());
+ } catch (Exception e) {
+ Activator.handleError(e.getMessage(), e, true);
}
}
-
});
revInfoSplit = new SashForm(graphDetailSplit, SWT.HORIZONTAL);
commentViewer = new CommitMessageViewer(revInfoSplit);
fileViewer = new CommitFileDiffViewer(revInfoSplit);
findToolbar = new FindToolbar(ourControl);
- layoutSashForm(graphDetailSplit, SPLIT_GRAPH);
- layoutSashForm(revInfoSplit, SPLIT_INFO);
+ layoutSashForm(graphDetailSplit,
+ UIPreferences.RESOURCEHISTORY_GRAPH_SPLIT);
+ layoutSashForm(revInfoSplit, UIPreferences.RESOURCEHISTORY_REV_SPLIT);
revObjectSelectionProvider = new RevObjectSelectionProvider();
popupMgr = new MenuManager(null, POPUP_ID);
@@ -441,9 +447,12 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
createResourceFilterActions();
createCompareModeAction();
createStandardActions();
- createViewMenu();
- finishContextMenu();
+ getSite().registerContextMenu(POPUP_ID, popupMgr,
+ revObjectSelectionProvider);
+ getHistoryPageSite().getPart().getSite().setSelectionProvider(
+ revObjectSelectionProvider);
+
attachContextMenu(graph.getControl());
attachContextMenu(commentViewer.getControl());
attachContextMenu(fileViewer.getControl());
@@ -452,73 +461,6 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
if (myRefsChangedHandle == null)
myRefsChangedHandle = Repository.getGlobalListenerList()
.addRefsChangedListener(this);
-
- getSite().setSelectionProvider(revObjectSelectionProvider);
- }
-
- private void openInCompare(CompareEditorInput input) {
- IWorkbenchPage workBenchPage = getSite().getPage();
- IEditorPart editor = findReusableCompareEditor(input, workBenchPage);
- if (editor != null) {
- IEditorInput otherInput = editor.getEditorInput();
- if (otherInput.equals(input)) {
- // simply provide focus to editor
- if (OpenStrategy.activateOnOpen())
- workBenchPage.activate(editor);
- else
- workBenchPage.bringToTop(editor);
- } else {
- // if editor is currently not open on that input either re-use
- // existing
- CompareUI.reuseCompareEditor(input, (IReusableEditor) editor);
- if (OpenStrategy.activateOnOpen())
- workBenchPage.activate(editor);
- else
- workBenchPage.bringToTop(editor);
- }
- } else {
- CompareUI.openCompareEditor(input);
- }
- }
-
- /**
- * Returns an editor that can be re-used. An open compare editor that
- * has un-saved changes cannot be re-used.
- * @param input the input being opened
- * @param page
- * @return an EditorPart or <code>null</code> if none can be found
- */
- private IEditorPart findReusableCompareEditor(CompareEditorInput input, IWorkbenchPage page) {
- IEditorReference[] editorRefs = page.getEditorReferences();
- // first loop looking for an editor with the same input
- for (int i = 0; i < editorRefs.length; i++) {
- IEditorPart part = editorRefs[i].getEditor(false);
- if (part != null
- && (part.getEditorInput() instanceof GitCompareFileRevisionEditorInput)
- && part instanceof IReusableEditor
- && part.getEditorInput().equals(input)) {
- return part;
- }
- }
- // if none found and "Reuse open compare editors" preference is on use
- // a non-dirty editor
- if (isReuseOpenEditor()) {
- for (int i = 0; i < editorRefs.length; i++) {
- IEditorPart part = editorRefs[i].getEditor(false);
- if (part != null
- && (part.getEditorInput() instanceof SaveableCompareEditorInput)
- && part instanceof IReusableEditor && !part.isDirty()) {
- return part;
- }
- }
- }
- // no re-usable editor found
- return null;
- }
-
- private static boolean isReuseOpenEditor() {
- boolean defaultReuse = new DefaultScope().getNode(TEAM_UI_PLUGIN).getBoolean(REUSE_COMPARE_EDITOR_PREFID, false);
- return new InstanceScope().getNode(TEAM_UI_PLUGIN).getBoolean(REUSE_COMPARE_EDITOR_PREFID, defaultReuse);
}
private Runnable refschangedRunnable;
@@ -553,58 +495,48 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
}
- private void finishContextMenu() {
- popupMgr.add(new Separator());
- popupMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- getSite().registerContextMenu(POPUP_ID, popupMgr,
- revObjectSelectionProvider);
- getHistoryPageSite().getPart().getSite().setSelectionProvider(
- revObjectSelectionProvider);
- }
-
private void attachContextMenu(final Control c) {
- c.setMenu(popupMgr.createContextMenu(c));
-
if (c == graph.getControl()) {
-
+ // commit table
+ c.setMenu(popupMgr.createContextMenu(c));
c.addMenuDetectListener(new MenuDetectListener() {
-
public void menuDetected(MenuDetectEvent e) {
- popupMgr.remove(new ActionContributionItem(createPatchAction));
- popupMgr.remove(new ActionContributionItem(compareAction));
- popupMgr.remove(new ActionContributionItem(
- compareVersionsAction));
- popupMgr.remove(new ActionContributionItem(
- viewVersionsAction));
- int size = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection()).size();
- if (size == 1) {
+ if (popupMgr.isEmpty()) {
+ // copy and such after additions
+ popupMgr.add(new Separator(
+ IWorkbenchActionConstants.MB_ADDITIONS));
+ popupMgr.add(copyAction);
popupMgr.add(new Separator());
- popupMgr.add(createPatchAction);
- createPatchAction.setEnabled(createPatchAction.isEnabled());
+ popupMgr.add(showCommentAction);
+ popupMgr.add(showFilesAction);
}
- if (IFile.class.isAssignableFrom(getInput().getClass())) {
- popupMgr.add(new Separator());
- if (size == 1) {
- popupMgr.add(compareAction);
- } else if (size == 2) {
- popupMgr.add(compareVersionsAction);
- }
- if (size >= 1)
- popupMgr.add(viewVersionsAction);
+ }
+ });
+ } else if (c == commentViewer.getControl()) {
+ // comment viewer
+ final MenuManager mgr = new MenuManager();
+ c.setMenu(mgr.createContextMenu(c));
+ c.addMenuDetectListener(new MenuDetectListener() {
+ public void menuDetected(MenuDetectEvent e) {
+ if (mgr.isEmpty()) {
+ mgr.add(selectAllAction);
+ mgr.add(copyAction);
+ mgr.add(new Separator());
+ mgr.add(wrapCommentAction);
+ mgr.add(fillCommentAction);
}
}
});
} else {
+ // file list
+ final MenuManager mgr = new MenuManager();
+ c.setMenu(mgr.createContextMenu(c));
c.addMenuDetectListener(new MenuDetectListener() {
-
public void menuDetected(MenuDetectEvent e) {
- popupMgr.remove(new ActionContributionItem(createPatchAction));
- popupMgr.remove(new ActionContributionItem(compareAction));
- popupMgr.remove(new ActionContributionItem(
- compareVersionsAction));
- popupMgr.remove(new ActionContributionItem(
- viewVersionsAction));
+ if (mgr.isEmpty()) {
+ mgr.add(selectAllAction);
+ mgr.add(copyAction);
+ }
}
});
}
@@ -638,9 +570,12 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
private void layout() {
- final boolean showComment = store.getBoolean(SHOW_COMMENT);
- final boolean showFiles = store.getBoolean(SHOW_FILES);
- final boolean showFindToolbar = store.getBoolean(SHOW_FIND_TOOLBAR);
+ final boolean showComment = store
+ .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT);
+ final boolean showFiles = store
+ .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_REV_DETAIL);
+ final boolean showFindToolbar = store
+ .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR);
if (showComment && showFiles) {
graphDetailSplit.setMaximizedControl(null);
@@ -706,9 +641,11 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
private IAction createFindToolbarAction() {
- final IAction r = new Action(UIText.GitHistoryPage_find, UIIcons.ELCL16_FIND) {
+ final IAction r = new Action(UIText.GitHistoryPage_find,
+ UIIcons.ELCL16_FIND) {
public void run() {
- store.setValue(SHOW_FIND_TOOLBAR, isChecked());
+ store.setValue(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR,
+ isChecked());
if (store.needsSaving()) {
try {
store.save();
@@ -719,41 +656,15 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
layout();
}
};
- r.setChecked(store.getBoolean(SHOW_FIND_TOOLBAR));
+ r.setChecked(store
+ .getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_FINDTOOLBAR));
r.setToolTipText(UIText.HistoryPage_findbar_findTooltip);
return r;
}
- private void createViewMenu() {
- final IActionBars actionBars = getSite().getActionBars();
- final IMenuManager menuManager = actionBars.getMenuManager();
- IAction a;
-
- a = createCommentWrap();
- menuManager.add(a);
- popupMgr.add(a);
-
- a = createCommentFill();
- menuManager.add(a);
- popupMgr.add(a);
-
- menuManager.add(new Separator());
- popupMgr.add(new Separator());
-
- a = createShowComment();
- menuManager.add(a);
- popupMgr.add(a);
-
- a = createShowFiles();
- menuManager.add(a);
- popupMgr.add(a);
-
- menuManager.add(new Separator());
- popupMgr.add(new Separator());
- }
-
private IAction createCommentWrap() {
- final BooleanPrefAction a = new BooleanPrefAction(PREF_COMMENT_WRAP,
+ final BooleanPrefAction a = new BooleanPrefAction(
+ UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP,
UIText.ResourceHistory_toggleCommentWrap) {
void apply(boolean wrap) {
commentViewer.setWrap(wrap);
@@ -765,7 +676,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
private IAction createCommentFill() {
- final BooleanPrefAction a = new BooleanPrefAction(PREF_COMMENT_FILL,
+ final BooleanPrefAction a = new BooleanPrefAction(
+ UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL,
UIText.ResourceHistory_toggleCommentFill) {
void apply(boolean fill) {
commentViewer.setFill(fill);
@@ -777,18 +689,28 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
private IAction createShowComment() {
- BooleanPrefAction a = new BooleanPrefAction(SHOW_COMMENT,
+ BooleanPrefAction a = new BooleanPrefAction(
+ UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT,
UIText.ResourceHistory_toggleRevComment) {
void apply(final boolean value) {
layout();
}
+
+ @Override
+ public void run() {
+ super.run();
+ wrapCommentAction.setEnabled(isChecked());
+ fillCommentAction.setEnabled(isChecked());
+ }
+
};
actionsToDispose.add(a);
return a;
}
private IAction createShowFiles() {
- BooleanPrefAction a = new BooleanPrefAction(SHOW_FILES,
+ BooleanPrefAction a = new BooleanPrefAction(
+ UIPreferences.RESOURCEHISTORY_SHOW_REV_DETAIL,
UIText.ResourceHistory_toggleRevDetail) {
void apply(final boolean value) {
layout();
@@ -821,9 +743,27 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
b.setGlobalActionHandler(ActionFactory.COPY.getId(), copy);
b.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), sAll);
- popupMgr.add(createStandardAction(ActionFactory.COPY));
- popupMgr.add(createStandardAction(ActionFactory.SELECT_ALL));
- popupMgr.add(new Separator());
+ copyAction = createStandardAction(ActionFactory.COPY);
+ selectAllAction = createStandardAction(ActionFactory.SELECT_ALL);
+
+ showCommentAction = createShowComment();
+ showFilesAction = createShowFiles();
+ wrapCommentAction = createCommentWrap();
+ fillCommentAction = createCommentFill();
+
+ wrapCommentAction.setEnabled(showCommentAction.isChecked());
+ fillCommentAction.setEnabled(showCommentAction.isChecked());
+
+ final IMenuManager menuManager = getSite().getActionBars()
+ .getMenuManager();
+
+ menuManager.add(showFilesAction);
+ menuManager.add(showCommentAction);
+
+ menuManager.add(new Separator());
+
+ menuManager.add(wrapCommentAction);
+ menuManager.add(fillCommentAction);
}
private IAction createStandardAction(final ActionFactory af) {
@@ -841,7 +781,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
// dispose of the actions (the history framework doesn't do this for us)
- for (BooleanPrefAction action: actionsToDispose)
+ for (BooleanPrefAction action : actionsToDispose)
action.dispose();
actionsToDispose.clear();
cancelRefreshJob();
@@ -892,8 +832,10 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
else if (o instanceof ResourceList)
in = o;
else if (o instanceof IAdaptable) {
- IResource resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
- in = resource == null ? null : new ResourceList(new IResource[] { resource });
+ IResource resource = (IResource) ((IAdaptable) o)
+ .getAdapter(IResource.class);
+ in = resource == null ? null : new ResourceList(
+ new IResource[] { resource });
} else
in = null;
return super.setInput(in);
@@ -939,7 +881,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
paths.add(name);
} else if (showAllFilter == ShowFilter.SHOWALLREPO) {
// nothing
- } else /*if (showAllFilter == ShowFilter.SHOWALLRESOURCE)*/ {
+ } else /* if (showAllFilter == ShowFilter.SHOWALLRESOURCE) */{
final String name = map.getRepoRelativePath(r);
if (name != null && name.length() > 0)
paths.add(name);
@@ -978,8 +920,9 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
try {
currentWalk.markStart(currentWalk.parseCommit(headId));
} catch (IOException e) {
- Activator.logError(NLS.bind(UIText.GitHistoryPage_errorReadingHeadCommit,
- headId, db.getDirectory().getAbsolutePath()), e);
+ Activator.logError(NLS.bind(
+ UIText.GitHistoryPage_errorReadingHeadCommit, headId, db
+ .getDirectory().getAbsolutePath()), e);
return false;
}
@@ -1000,7 +943,6 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
fileViewer.addSelectionChangedListener(commentViewer);
commentViewer.setTreeWalk(fileWalker);
commentViewer.setDb(db);
- createPatchAction.setTreeWalk(fileWalker);
findToolbar.clear();
graph.setInput(highlightFlag, null, null);
@@ -1077,8 +1019,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
public void run() {
if (!graph.getControl().isDisposed() && job == j) {
graph.setInput(highlightFlag, list, asArray);
- findToolbar.setInput(highlightFlag, graph.getTableView().getTable(),
- asArray);
+ findToolbar.setInput(highlightFlag, graph.getTableView()
+ .getTable(), asArray);
}
}
});
@@ -1233,192 +1175,4 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
// gained it from us.
}
}
-
- private class CompareWithWorkingTreeAction extends Action {
- public CompareWithWorkingTreeAction() {
- super(UIText.GitHistoryPage_CompareWithWorking);
- }
-
- @Override
- public void run() {
- IStructuredSelection selection = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection());
- if (selection.size() == 1) {
- Iterator<?> it = selection.iterator();
- SWTCommit commit = (SWTCommit) it.next();
- if (getInput() instanceof IFile){
- IFile file = (IFile) getInput();
- final RepositoryMapping mapping = RepositoryMapping.getMapping(file.getProject());
- final String gitPath = mapping.getRepoRelativePath(file);
- ITypedElement right = CompareUtils
- .getFileRevisionTypedElement(gitPath, commit, db);
- final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
- SaveableCompareEditorInput.createFileElement(file),
- right,
- null);
- openInCompare(in);
- }
-
- }
-
- }
-
- @Override
- public boolean isEnabled() {
- int size = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection()).size();
- return IFile.class.isAssignableFrom(getInput().getClass())
- && size == 1;
- }
-
- }
-
- private class CompareVersionsAction extends Action {
- public CompareVersionsAction() {
- super(UIText.GitHistoryPage_CompareVersions);
- }
-
- @Override
- public void run() {
- IStructuredSelection selection = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection());
- if (selection.size() == 2) {
- Iterator<?> it = selection.iterator();
- SWTCommit commit1 = (SWTCommit) it.next();
- SWTCommit commit2 = (SWTCommit) it.next();
-
- if (getInput() instanceof IFile){
- IFile resource = (IFile) getInput();
- final RepositoryMapping map = RepositoryMapping
- .getMapping(resource);
- final String gitPath = map
- .getRepoRelativePath(resource);
-
- final ITypedElement base = CompareUtils
- .getFileRevisionTypedElement(gitPath, commit1, db);
- final ITypedElement next = CompareUtils
- .getFileRevisionTypedElement(gitPath, commit2, db);
- CompareEditorInput in = new GitCompareFileRevisionEditorInput(base, next, null);
- openInCompare(in);
- }
-
- }
-
- }
-
- @Override
- public boolean isEnabled() {
- int size = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection()).size();
- return IFile.class.isAssignableFrom(getInput().getClass())
- && size == 2;
- }
-
- }
-
- private class ViewVersionsAction extends Action {
- public ViewVersionsAction() {
- super(UIText.GitHistoryPage_open);
- }
-
- @Override
- public void run() {
- IStructuredSelection selection = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection());
- if (selection.size() < 1)
- return;
- if (!(getInput() instanceof IFile))
- return;
- IFile resource = (IFile) getInput();
- final RepositoryMapping map = RepositoryMapping
- .getMapping(resource);
- final String gitPath = map.getRepoRelativePath(resource);
- Iterator<?> it = selection.iterator();
- boolean errorOccured = false;
- List<ObjectId> ids = new ArrayList<ObjectId>();
- while (it.hasNext()) {
- SWTCommit commit = (SWTCommit) it.next();
- IFileRevision rev = null;
- try {
- rev = CompareUtils.getFileRevision(gitPath, commit, db, null);
- } catch (IOException e) {
- Activator.logError(NLS.bind(
- UIText.GitHistoryPage_errorLookingUpPath, gitPath,
- commit.getId()), e);
- errorOccured = true;
- }
- if (rev != null) {
- try {
- EgitUiEditorUtils.openEditor(getSite().getPage(), rev,
- new NullProgressMonitor());
- } catch (CoreException e) {
- Activator.logError(UIText.GitHistoryPage_openFailed, e);
- errorOccured = true;
- }
- } else {
- ids.add(commit.getId());
- }
- }
- if (errorOccured)
- Activator.showError(UIText.GitHistoryPage_openFailed, null);
- if (ids.size() > 0) {
- String idList = ""; //$NON-NLS-1$
- for (ObjectId objectId : ids) {
- idList += objectId.getName() + " "; //$NON-NLS-1$
- }
- MessageDialog.openError(getSite().getShell(),
- UIText.GitHistoryPage_fileNotFound, NLS.bind(
- UIText.GitHistoryPage_notContainedInCommits,
- gitPath, idList));
- }
-
- }
-
- @Override
- public boolean isEnabled() {
- int size = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection()).size();
- return IFile.class.isAssignableFrom(getInput().getClass())
- && size >= 1;
- }
-
- }
-
- private class CreatePatchAction extends Action {
-
- private TreeWalk walker;
-
- public CreatePatchAction() {
- super(UIText.GitHistoryPage_CreatePatch);
- }
-
- @Override
- public void run() {
- IStructuredSelection selection = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection());
- if (selection.size() == 1) {
-
- Iterator<?> it = selection.iterator();
- SWTCommit commit = (SWTCommit) it.next();
-
- GitCreatePatchWizard.run(getHistoryPageSite().getPart(),
- commit, walker, db);
- }
- }
-
- public void setTreeWalk(TreeWalk walker) {
- this.walker = walker;
- }
-
- @Override
- public boolean isEnabled() {
- IStructuredSelection selection = ((IStructuredSelection) revObjectSelectionProvider
- .getSelection());
- Iterator<?> it = selection.iterator();
- SWTCommit commit = (SWTCommit) it.next();
- return (commit.getParentCount() == 1);
-
- }
-
- }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommanndHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommanndHandler.java
new file mode 100644
index 0000000000..ed96eaa502
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/AbstractHistoryCommanndHandler.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.eclipse.jface.util.OpenStrategy;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.Tag;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.team.ui.history.IHistoryView;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IReusableEditor;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Common helper methods for the history command handlers
+ */
+abstract class AbstractHistoryCommanndHandler extends AbstractHandler {
+
+ /** The team ui plugin ID which is not accessible */
+ private static final String TEAM_UI_PLUGIN = "org.eclipse.team.ui"; //$NON-NLS-1$
+
+ /**
+ * A copy of the non-accessible preference constant
+ * IPreferenceIds.REUSE_OPEN_COMPARE_EDITOR from the team ui plug in
+ */
+ private static final String REUSE_COMPARE_EDITOR_PREFID = "org.eclipse.team.ui.reuse_open_compare_editors"; //$NON-NLS-1$
+
+ protected IWorkbenchPart getPart(ExecutionEvent event)
+ throws ExecutionException {
+ return HandlerUtil.getActivePartChecked(event);
+ }
+
+ protected IStructuredSelection getSelection(ExecutionEvent event)
+ throws ExecutionException {
+ ISelection selection;
+ if (event != null)
+ selection = HandlerUtil.getCurrentSelectionChecked(event);
+ else
+ selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ return new StructuredSelection();
+ }
+
+ protected Object getInput(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchPart part;
+ if (event != null)
+ part = getPart(event);
+ else
+ part = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().getActivePart();
+
+ if (!(part instanceof IHistoryView))
+ throw new ExecutionException(
+ UIText.AbstractHistoryCommanndHandler_NoInputMessage);
+ return (((IHistoryView) part).getHistoryPage().getInput());
+ }
+
+ protected void openInCompare(ExecutionEvent event, CompareEditorInput input)
+ throws ExecutionException {
+ IWorkbenchPage workBenchPage = HandlerUtil
+ .getActiveWorkbenchWindowChecked(event).getActivePage();
+ IEditorPart editor = findReusableCompareEditor(input, workBenchPage);
+ if (editor != null) {
+ IEditorInput otherInput = editor.getEditorInput();
+ if (otherInput.equals(input)) {
+ // simply provide focus to editor
+ if (OpenStrategy.activateOnOpen())
+ workBenchPage.activate(editor);
+ else
+ workBenchPage.bringToTop(editor);
+ } else {
+ // if editor is currently not open on that input either re-use
+ // existing
+ CompareUI.reuseCompareEditor(input, (IReusableEditor) editor);
+ if (OpenStrategy.activateOnOpen())
+ workBenchPage.activate(editor);
+ else
+ workBenchPage.bringToTop(editor);
+ }
+ } else {
+ CompareUI.openCompareEditor(input);
+ }
+ }
+
+ private IEditorPart findReusableCompareEditor(CompareEditorInput input,
+ IWorkbenchPage page) {
+ IEditorReference[] editorRefs = page.getEditorReferences();
+ // first loop looking for an editor with the same input
+ for (int i = 0; i < editorRefs.length; i++) {
+ IEditorPart part = editorRefs[i].getEditor(false);
+ if (part != null
+ && (part.getEditorInput() instanceof GitCompareFileRevisionEditorInput)
+ && part instanceof IReusableEditor
+ && part.getEditorInput().equals(input)) {
+ return part;
+ }
+ }
+ // if none found and "Reuse open compare editors" preference is on use
+ // a non-dirty editor
+ if (isReuseOpenEditor()) {
+ for (int i = 0; i < editorRefs.length; i++) {
+ IEditorPart part = editorRefs[i].getEditor(false);
+ if (part != null
+ && (part.getEditorInput() instanceof SaveableCompareEditorInput)
+ && part instanceof IReusableEditor && !part.isDirty()) {
+ return part;
+ }
+ }
+ }
+ // no re-usable editor found
+ return null;
+ }
+
+ /**
+ * @return the flag
+ */
+ private boolean isReuseOpenEditor() {
+ boolean defaultReuse = new DefaultScope().getNode(TEAM_UI_PLUGIN)
+ .getBoolean(REUSE_COMPARE_EDITOR_PREFID, false);
+ return new InstanceScope().getNode(TEAM_UI_PLUGIN).getBoolean(
+ REUSE_COMPARE_EDITOR_PREFID, defaultReuse);
+ }
+
+ protected Repository getRepository(ExecutionEvent event)
+ throws ExecutionException {
+ Object input = getInput(event);
+ return RepositoryMapping.getMapping((IResource) input).getRepository();
+ }
+
+ /**
+ * @param event
+ * @return the tags
+ * @throws ExecutionException
+ */
+ protected List<Tag> getRevTags(ExecutionEvent event)
+ throws ExecutionException {
+ Repository repo = getRepository(event);
+ Collection<Ref> revTags = repo.getTags().values();
+ List<Tag> tags = new ArrayList<Tag>();
+ RevWalk walk = new RevWalk(repo);
+ for (Ref ref : revTags) {
+ try {
+ Tag tag = walk.parseTag(repo.resolve(ref.getName()))
+ .asTag(walk);
+ tags.add(tag);
+ } catch (IOException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ }
+ }
+ return tags;
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java
index 3865a3d27e..757fef4970 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CheckoutCommitActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CheckoutCommitHandler.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
+package org.eclipse.egit.ui.internal.history.command;
import java.io.IOException;
import java.util.ArrayList;
@@ -51,12 +51,12 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
- * Action for checking out a commit
+ * Check out of a commit.
*/
-public class CheckoutCommitActionHandler extends RepositoryActionHandler {
-
+public class CheckoutCommitHandler extends AbstractHistoryCommanndHandler {
private final class BranchMessageDialog extends MessageDialog {
private final List<RefNode> nodes;
@@ -112,7 +112,6 @@ public class CheckoutCommitActionHandler extends RepositoryActionHandler {
public RefNode getSelectedNode() {
return selected;
}
-
}
private final class BranchLabelProvider extends LabelProvider {
@@ -129,9 +128,8 @@ public class CheckoutCommitActionHandler extends RepositoryActionHandler {
}
public Object execute(ExecutionEvent event) throws ExecutionException {
-
PlotCommit commit = (PlotCommit) getSelection(event).getFirstElement();
- Repository repo = getRepository(false, event);
+ Repository repo = getRepository(event);
List<Ref> availableBranches = new ArrayList<Ref>();
final BranchOperation op;
@@ -158,8 +156,8 @@ public class CheckoutCommitActionHandler extends RepositoryActionHandler {
for (Ref ref : availableBranches) {
nodes.add(new RefNode(repoNode, repo, ref));
}
- BranchMessageDialog dlg = new BranchMessageDialog(getShell(event),
- nodes);
+ BranchMessageDialog dlg = new BranchMessageDialog(HandlerUtil
+ .getActiveShellChecked(event), nodes);
if (dlg.open() == Window.OK) {
op = new BranchOperation(repo, dlg.getSelectedNode()
.getObject().getName());
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareVersionsHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareVersionsHandler.java
new file mode 100644
index 0000000000..beba2e32a1
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareVersionsHandler.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import java.util.Iterator;
+
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.internal.CompareUtils;
+import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.team.ui.history.IHistoryView;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Compare the file contents of two commits.
+ */
+public class CompareVersionsHandler extends AbstractHistoryCommanndHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = getSelection(event);
+ if (selection.size() == 2) {
+ Iterator<?> it = selection.iterator();
+ RevCommit commit1 = (RevCommit) it.next();
+ RevCommit commit2 = (RevCommit) it.next();
+
+ Object input = null;
+ IWorkbenchPart part = getPart(event);
+ if (part instanceof IHistoryView) {
+ input = ((IHistoryView) part).getHistoryPage().getInput();
+ }
+
+ if (input != null && input instanceof IFile) {
+ IFile resource = (IFile) input;
+ final RepositoryMapping map = RepositoryMapping
+ .getMapping(resource);
+ final String gitPath = map.getRepoRelativePath(resource);
+
+ final ITypedElement base = CompareUtils
+ .getFileRevisionTypedElement(gitPath, commit1, map
+ .getRepository());
+ final ITypedElement next = CompareUtils
+ .getFileRevisionTypedElement(gitPath, commit2, map
+ .getRepository());
+ CompareEditorInput in = new GitCompareFileRevisionEditorInput(
+ base, next, null);
+ openInCompare(event, in);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ try {
+ IWorkbenchPart part = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().getActivePart();
+ if (!(part instanceof IHistoryView))
+ return false;
+ IHistoryView view = (IHistoryView) part;
+ if (!(view.getHistoryPage().getInput() instanceof IFile))
+ return false;
+ IStructuredSelection sel = getSelection(null);
+ Object[] selected = sel.toArray();
+ return selected.length == 2 && selected[0] instanceof RevCommit
+ && selected[1] instanceof RevCommit;
+ } catch (ExecutionException e) {
+ Activator.handleError(e.getMessage(), e, false);
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareWithWorkingTreeHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareWithWorkingTreeHandler.java
new file mode 100644
index 0000000000..764b9c1617
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CompareWithWorkingTreeHandler.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import java.util.Iterator;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.internal.CompareUtils;
+import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
+
+/**
+ * Compare the file content of a commit with the working tree
+ */
+public class CompareWithWorkingTreeHandler extends
+ AbstractHistoryCommanndHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = getSelection(event);
+ if (selection.size() == 1) {
+ Iterator<?> it = selection.iterator();
+ RevCommit commit = (RevCommit) it.next();
+ Object input = getInput(event);
+ if (input instanceof IFile) {
+ IFile file = (IFile) input;
+ final RepositoryMapping mapping = RepositoryMapping
+ .getMapping(file.getProject());
+ final String gitPath = mapping.getRepoRelativePath(file);
+ ITypedElement right = CompareUtils.getFileRevisionTypedElement(
+ gitPath, commit, mapping.getRepository());
+ final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
+ SaveableCompareEditorInput.createFileElement(file),
+ right, null);
+ openInCompare(event, in);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ try {
+ int size = getSelection(null).size();
+ return IFile.class.isAssignableFrom(getInput(null).getClass())
+ && size == 1;
+ } catch (ExecutionException e) {
+ Activator.handleError(e.getMessage(), e, false);
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java
index 5bbe5d71de..8232a4e8f1 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateBranchOnCommitActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateBranchOnCommitHandler.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
+package org.eclipse.egit.ui.internal.history.command;
import java.io.IOException;
@@ -25,23 +25,24 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
- * Create a branch based on a commit
+ * Create a branch based on a commit.
*/
-public class CreateBranchOnCommitActionHandler extends RepositoryActionHandler {
-
+public class CreateBranchOnCommitHandler extends AbstractHistoryCommanndHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
PlotCommit commit = (PlotCommit) getSelection(event)
.getFirstElement();
ObjectId startAt = commit.getId();
- Repository repo = getRepository(false, event);
+ Repository repo = getRepository(event);
String prompt = NLS.bind(
UIText.CreateBranchHandler_CreatePromptMessage, startAt
.name(), Constants.R_HEADS);
- InputDialog dlg = new InputDialog(getShell(event),
+ InputDialog dlg = new InputDialog(HandlerUtil
+ .getActiveShellChecked(event),
UIText.BranchSelectionDialog_QuestionNewBranchTitle,
prompt, "", ValidationUtils //$NON-NLS-1$
.getRefNameInputValidator(repo, Constants.R_HEADS));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreatePatchHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreatePatchHandler.java
new file mode 100644
index 0000000000..58569fc243
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreatePatchHandler.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.internal.history.GitCreatePatchWizard;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.treewalk.TreeWalk;
+
+/**
+ * Create a patch based on a commit.
+ */
+public class CreatePatchHandler extends AbstractHistoryCommanndHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = getSelection(event);
+ if (selection.size() == 1) {
+ RevCommit commit = (RevCommit) selection.getFirstElement();
+ Object input = getInput(event);
+ if (!(input instanceof IResource))
+ return null;
+ RepositoryMapping mapping = RepositoryMapping
+ .getMapping((IResource) getInput(event));
+
+ GitCreatePatchWizard.run(getPart(event), commit, new TreeWalk(
+ mapping.getRepository()), mapping.getRepository());
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ try {
+ IStructuredSelection selection = getSelection(null);
+ if (selection.size() != 1)
+ return false;
+ RevCommit commit = (RevCommit) selection.getFirstElement();
+ return (commit.getParentCount() == 1);
+ } catch (ExecutionException e) {
+ Activator.handleError(e.getMessage(), e, false);
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateTagOnCommitHandler.java
index 200465914f..55084fc3ea 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CreateTagOnCommitActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/CreateTagOnCommitHandler.java
@@ -6,7 +6,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui.internal.actions;
+package org.eclipse.egit.ui.internal.history.command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -24,20 +24,20 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Tag;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
- * Create a tag based on a commit
+ * Create a tag based on a commit.
*/
-public class CreateTagOnCommitActionHandler extends RepositoryActionHandler {
-
+public class CreateTagOnCommitHandler extends AbstractHistoryCommanndHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
PlotCommit commit = (PlotCommit) getSelection(event).getFirstElement();
- final Repository repo = getRepository(false, event);
+ final Repository repo = getRepository(event);
- CreateTagDialog dialog = new CreateTagDialog(getShell(event),
- ValidationUtils
- .getRefNameInputValidator(repo, Constants.R_TAGS),
- commit.getId());
+ CreateTagDialog dialog = new CreateTagDialog(HandlerUtil
+ .getActiveShellChecked(event), ValidationUtils
+ .getRefNameInputValidator(repo, Constants.R_TAGS), commit
+ .getId());
dialog.setExistingTags(getRevTags(event));
if (dialog.open() != Window.OK)
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/HistoryViewCommands.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/HistoryViewCommands.java
new file mode 100644
index 0000000000..eb8a6789d4
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/HistoryViewCommands.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+/**
+ * Constants for the commands used in the history view.
+ * <p>
+ * Only those constants are listed that are being used in code.
+ */
+public class HistoryViewCommands {
+ /**
+ * "Compare mode" parameter for the "open" command (see
+ * {@link #SHOWVERSIONS})
+ */
+ public static final String COMPARE_MODE_PARAM = "org.eclipse.egit.ui.history.CompareMode"; //$NON-NLS-1$
+
+ /** "Reset" mode (sort, mixed, hard) */
+ public static final String RESET_MODE = "org.eclipse.egit.ui.history.ResetMode"; //$NON-NLS-1$
+
+ /** "Target" parameter for setting the quickdiff baseline (HEAD or HEAD^1) */
+ public static final String BASELINE_TARGET = "org.eclipse.egit.ui.history.ResetQuickdiffBaselineTarget"; //$NON-NLS-1$
+
+ /** "Open" or "Show Versions" (depending on the selection) */
+ public static final String SHOWVERSIONS = "org.eclipse.egit.ui.history.ShowVersions"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java
new file mode 100644
index 0000000000..63fbd331bb
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetHandler.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.egit.core.op.ResetOperation;
+import org.eclipse.egit.core.op.ResetOperation.ResetType;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * "Reset" with parameter (hard, mixed, soft).
+ */
+public class ResetHandler extends AbstractHistoryCommanndHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final Repository repo = getRepository(event);
+ final RevCommit commit = (RevCommit) getSelection(event)
+ .getFirstElement();
+
+ String type = event.getParameter(HistoryViewCommands.RESET_MODE);
+ final ResetType resetType;
+
+ if (type.equals("Hard")) { //$NON-NLS-1$
+ resetType = ResetType.HARD;
+ } else if (type.equals("Mixed")) { //$NON-NLS-1$
+ resetType = ResetType.MIXED;
+ } else if (type.equals("Soft")) { //$NON-NLS-1$
+ resetType = ResetType.SOFT;
+ } else {
+ throw new ExecutionException("Could not determine the reset type"); //$NON-NLS-1$ TODO
+ }
+
+ String jobName = "Reset"; //$NON-NLS-1$
+ switch (resetType) {
+ case HARD:
+ if (!MessageDialog.openQuestion(HandlerUtil
+ .getActiveShellChecked(event),
+ UIText.ResetTargetSelectionDialog_ResetQuestion,
+ UIText.ResetTargetSelectionDialog_ResetConfirmQuestion))
+ return null;
+
+ jobName = UIText.HardResetToRevisionAction_hardReset;
+ break;
+ case SOFT:
+ jobName = UIText.SoftResetToRevisionAction_softReset;
+ break;
+ case MIXED:
+ jobName = UIText.MixedResetToRevisionAction_mixedReset;
+ break;
+ }
+
+ Job job = new Job(jobName) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ new ResetOperation(repo, commit.getName(), resetType)
+ .execute(null);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ return null;
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetQuickdiffBaselineHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetQuickdiffBaselineHandler.java
new file mode 100644
index 0000000000..994747f9c8
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ResetQuickdiffBaselineHandler.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.decorators.GitQuickDiffProvider;
+import org.eclipse.jgit.lib.Repository;
+
+/**
+ * "Reset quickdiff baseline" with parameter (HEAD, or HEAD^1)
+ */
+public class ResetQuickdiffBaselineHandler extends
+ AbstractHistoryCommanndHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ String baseline = event
+ .getParameter(HistoryViewCommands.BASELINE_TARGET);
+ Repository repo = getRepository(event);
+ if (baseline == null)
+ throw new ExecutionException(
+ UIText.ResetQuickdiffBaselineHandler_NoTargetMessage);
+
+ try {
+ GitQuickDiffProvider.setBaselineReference(repo, baseline);
+ } catch (IOException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/SetQuickdiffBaselineHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/SetQuickdiffBaselineHandler.java
new file mode 100644
index 0000000000..3b7097a4d4
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/SetQuickdiffBaselineHandler.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.decorators.GitQuickDiffProvider;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+/**
+ * "Set quickdiff baseline" to selected commit.
+ */
+public class SetQuickdiffBaselineHandler extends AbstractHistoryCommanndHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Repository repo = getRepository(event);
+ String baseline = ((RevCommit) getSelection(event).getFirstElement())
+ .getId().name();
+ if (baseline == null)
+ throw new ExecutionException(
+ UIText.ResetQuickdiffBaselineHandler_NoTargetMessage);
+
+ try {
+ GitQuickDiffProvider.setBaselineReference(repo, baseline);
+ } catch (IOException e) {
+ throw new ExecutionException(e.getMessage(), e);
+ }
+
+ return null;
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowVersionsHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowVersionsHandler.java
new file mode 100644
index 0000000000..b00df26654
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/ShowVersionsHandler.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.history.command;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.CompareUtils;
+import org.eclipse.egit.ui.internal.EgitUiEditorUtils;
+import org.eclipse.egit.ui.internal.GitCompareFileRevisionEditorInput;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
+
+/**
+ * Show versions/open.
+ * <p>
+ * If a single version is selected, open it, otherwise open several versions of
+ * the file content.
+ */
+public class ShowVersionsHandler extends AbstractHistoryCommanndHandler {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ boolean compareMode = Boolean.TRUE.toString().equals(
+ event.getParameter(HistoryViewCommands.COMPARE_MODE_PARAM));
+ IStructuredSelection selection = getSelection(event);
+ if (selection.size() < 1)
+ return null;
+ Object input = getInput(event);
+ if (!(input instanceof IFile))
+ return null;
+ IFile resource = (IFile) input;
+ final RepositoryMapping map = RepositoryMapping.getMapping(resource);
+ final String gitPath = map.getRepoRelativePath(resource);
+ Iterator<?> it = selection.iterator();
+ boolean errorOccured = false;
+ List<ObjectId> ids = new ArrayList<ObjectId>();
+ while (it.hasNext()) {
+ RevCommit commit = (RevCommit) it.next();
+ IFileRevision rev = null;
+ try {
+ rev = CompareUtils.getFileRevision(gitPath, commit, map
+ .getRepository(), null);
+ } catch (IOException e) {
+ Activator.logError(NLS.bind(
+ UIText.GitHistoryPage_errorLookingUpPath, gitPath,
+ commit.getId()), e);
+ errorOccured = true;
+ }
+ if (rev != null) {
+ if (compareMode) {
+ ITypedElement right = CompareUtils
+ .getFileRevisionTypedElement(gitPath, commit, map
+ .getRepository());
+ final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
+ SaveableCompareEditorInput
+ .createFileElement(resource), right, null);
+ try {
+ openInCompare(event, in);
+ } catch (Exception e) {
+ errorOccured = true;
+ }
+ } else {
+ try {
+ EgitUiEditorUtils.openEditor(getPart(event).getSite()
+ .getPage(), rev, new NullProgressMonitor());
+ } catch (CoreException e) {
+ Activator.logError(UIText.GitHistoryPage_openFailed, e);
+ errorOccured = true;
+ }
+ }
+ } else {
+ ids.add(commit.getId());
+ }
+ }
+ if (errorOccured)
+ Activator.showError(UIText.GitHistoryPage_openFailed, null);
+ if (ids.size() > 0) {
+ String idList = ""; //$NON-NLS-1$
+ for (ObjectId objectId : ids) {
+ idList += objectId.getName() + " "; //$NON-NLS-1$
+ }
+ MessageDialog.openError(getPart(event).getSite().getShell(),
+ UIText.GitHistoryPage_fileNotFound, NLS.bind(
+ UIText.GitHistoryPage_notContainedInCommits,
+ gitPath, idList));
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ try {
+ int size = getSelection(null).size();
+ return size >= 1
+ && IFile.class.isAssignableFrom(getInput(null).getClass());
+ } catch (ExecutionException e) {
+ return false;
+ }
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 044e8733da..51f6b97d82 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -7,8 +7,7 @@
#
###############################################################################
-AbstractHitoryViewCommandHandler_CanNotGetCommitMessage=Can not get a single commit from the current selection
-AbstractHitoryViewCommandHandler_NoRepositoryMessage=Could not obtain RepositoryMapping
+AbstractHistoryCommanndHandler_NoInputMessage=Could not get the current input from the history view
Activator_refreshingProjects=Refreshing git managed projects
Activator_refreshJobName=Git index refresh Job
Activator_repoScanJobName=Repository Change Scanner
@@ -53,7 +52,6 @@ SelectRemoteNamePage_RemoteNameTitle=Remote Name
SelectRemoteNamePage_SelectRemoteNameMessage=Select a remote name
SelectResetTypePage_PageMessage=The content of {0} will be replaced with the content of {1}
SelectResetTypePage_PageTitle=Reset {0}
-SetQuickdiffBaselineAction_setQuickdiffBaseline=Set Quickdiff Baseline
SharingWizard_windowTitle=Configure Git Repository
SharingWizard_failed=Failed to initialize Git team provider.
@@ -84,20 +82,17 @@ GitDocument_errorLoadTree=Could not load tree {0} for {1} corresponding to {2} i
GitDocument_errorRefreshQuickdiff=Failed to refresh quickdiff
GitDocument_errorResolveQuickdiff=Could not resolve quickdiff baseline {0} corresponding to {1} in {2}
GitHistoryPage_compareMode=Compare Mode
-GitHistoryPage_CompareVersions=Compare with each other
-GitHistoryPage_CompareWithWorking=Compare with &Working Tree
GitHistoryPage_errorLookingUpPath=IO error looking up path {0} in {1}.
GitHistoryPage_errorParsingHead=Cannot parse HEAD in: {0}
GitHistoryPage_errorReadingHeadCommit=Cannot read HEAD commit {0} in: {1}
GitHistoryPage_fileNotFound=File not found
GitHistoryPage_find=Find
GitHistoryPage_notContainedInCommits=File {0} is not contained in the commits: {1}
-GitHistoryPage_open=&Open
GitHistoryPage_openFailed=Opening Editor failed
-GitHistoryPage_CreatePatch=Create &Patch...
GitHistoryPage_Date=Date
GitHistoryPage_FileNotInCommit={0} not in {1}
GitHistoryPage_From=From
+GitHistoryPage_ShowAllVersionsForResource=Show all versions for the resource
GitHistoryPage_Subject=Subject
GitProjectPropertyPage_LabelBranch=Branch:
GitProjectPropertyPage_LabelGitDir=Git directory:
@@ -293,15 +288,13 @@ RefSpecPage_annotatedTagsFetchTags=Always fetch tags, even if we do not have the
RefSpecPage_annotatedTagsNoTags=Never fetch tags, even if we have the thing it points at
QuickDiff_failedLoading=Quick diff failed to obtain file data.
-QuickdiffBaselineOperation_baseline=Cannot set quickdiff baseline
ResetAction_errorResettingHead=Cannot reset HEAD now
ResetAction_repositoryState=Repository state: {0}
ResetAction_reset=Resetting to {0}
ResetCommand_ResetFailureMessage=Reset failed
ResetCommand_WizardTitle=Reset
-ResetQuickdiffBaselineAction_resetQuickdiffBaseline=Reset Quickdiff Baseline
-ResetQuickdiffBaselineHeadParentAction_0=Reset Quickdiff Baseline
+ResetQuickdiffBaselineHandler_NoTargetMessage=No reset target provided
ResetTargetSelectionDialog_ResetButton=&Reset
ResetTargetSelectionDialog_ResetConfirmQuestion=Resetting will overwrite any changes in your working directory.\n\nDo you wish to continue?
ResetTargetSelectionDialog_ResetQuestion=Really reset?

Back to the top