aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-04-23 04:58:32 (EDT)
committerJens Baumgart2010-04-23 04:58:32 (EDT)
commite9e5ba4bcbb8180098f0ff8f3258ed29e019ef84 (patch)
treee6762b811a59ee533e0ff5d8f50e5b3a54578410
parent74396f6f925731980015a2b7003872f7178b9218 (diff)
downloadegit-e9e5ba4bcbb8180098f0ff8f3258ed29e019ef84.zip
egit-e9e5ba4bcbb8180098f0ff8f3258ed29e019ef84.tar.gz
egit-e9e5ba4bcbb8180098f0ff8f3258ed29e019ef84.tar.bz2
Implement compare mode toggle in history viewrefs/changes/92/592/2
The compare mode toggle defines the action to be executed on double click. With compare mode enabled the compare editor is launched. With compare mode disabled an editor is opened to view the selected revision. Executing Compare->With history... launches the history view with enabled compare mode (similar to CVS). Bug: 306779 Change-Id: Ie276191847b1e070dcd361606d6fc3f36468b318 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
-rw-r--r--org.eclipse.egit.ui/icons/elcl16/compare_view.gifbin0 -> 224 bytes
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIIcons.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithRevisionAction.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java58
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties1
6 files changed, 66 insertions, 12 deletions
diff --git a/org.eclipse.egit.ui/icons/elcl16/compare_view.gif b/org.eclipse.egit.ui/icons/elcl16/compare_view.gif
new file mode 100644
index 0000000..dc549bc
--- /dev/null
+++ b/org.eclipse.egit.ui/icons/elcl16/compare_view.gif
Binary files differ
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 0a83187..b3595b1 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
@@ -40,6 +40,8 @@ public class UIIcons {
/** Find icon */
public static final ImageDescriptor ELCL16_FIND;
+ /** Compare / View icon */
+ public static final ImageDescriptor ELCL16_COMPARE_VIEW;
/** Next arrow icon */
public static final ImageDescriptor ELCL16_NEXT;
/** Previous arrow icon */
@@ -118,6 +120,7 @@ public class UIIcons {
OVR_CONFLICT = map("ovr/conflict.gif"); //$NON-NLS-1$
OVR_ASSUMEVALID = map("ovr/assume_valid.gif"); //$NON-NLS-1$
ELCL16_FIND = map("elcl16/find.gif"); //$NON-NLS-1$
+ ELCL16_COMPARE_VIEW = map("elcl16/compare_view.gif"); //$NON-NLS-1$
ELCL16_NEXT = map("elcl16/next.gif"); //$NON-NLS-1$
ELCL16_PREVIOUS = map("elcl16/previous.gif"); //$NON-NLS-1$
WIZBAN_IMPORT_REPO = map("wizban/import_wiz.png"); //$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 cac5ca9..39354f1 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
@@ -184,6 +184,9 @@ public class UIText extends NLS {
public static String GitDocument_errorResolveQuickdiff;
/** */
+ public static String GitHistoryPage_compareMode;
+
+ /** */
public static String GitHistoryPage_CompareVersions;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithRevisionAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithRevisionAction.java
index a132a8e..3e97ba4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithRevisionAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareWithRevisionAction.java
@@ -10,9 +10,13 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.actions;
+import org.eclipse.egit.ui.internal.history.GitHistoryPage;
import org.eclipse.jface.action.IAction;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.team.ui.TeamUI;
+import org.eclipse.team.ui.history.IHistoryPage;
+import org.eclipse.team.ui.history.IHistoryView;
/**
* Compare the resources filtered in the history view with the current
@@ -22,7 +26,14 @@ public class CompareWithRevisionAction extends TeamAction {
@Override
public void execute(IAction action) {
- TeamUI.getHistoryView().showHistoryFor(getSelectedResources()[0]);
+ IHistoryView view = TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), getSelectedResources()[0], null);
+ if (view == null)
+ return;
+ IHistoryPage page = view.getHistoryPage();
+ if (page instanceof GitHistoryPage){
+ GitHistoryPage gitHistoryPage = (GitHistoryPage) page;
+ gitHistoryPage.setCompareMode(true);
+ }
}
public boolean isEnabled() {
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 93d77b9..1b02dc8 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
@@ -131,6 +131,10 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
private IAction viewVersionsAction = new ViewVersionsAction();
+ private IAction compareModeAction;
+
+ private boolean compareMode = false;
+
/**
* Determine if the input can be shown in this viewer.
*
@@ -324,6 +328,33 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
showAllFolderVersionsAction);
}
+ private void createCompareModeAction() {
+ final IToolBarManager barManager = getSite().getActionBars()
+ .getToolBarManager();
+ compareModeAction = new Action(UIText.GitHistoryPage_compareMode,
+ IAction.AS_CHECK_BOX) {
+ public void run() {
+ compareMode = !compareMode;
+ setChecked(compareMode);
+ }
+ };
+ compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW);
+ compareModeAction.setChecked(compareMode);
+ compareModeAction.setToolTipText(UIText.GitHistoryPage_compareMode);
+ barManager.add(compareModeAction);
+ }
+
+ /**
+ * @param compareMode
+ * switch compare mode button of the view on / off
+ */
+ public void setCompareMode(boolean compareMode) {
+ if (compareModeAction!=null) {
+ this.compareMode = compareMode;
+ compareModeAction.setChecked(compareMode);
+ }
+ }
+
@Override
public void createControl(final Composite parent) {
GridData gd;
@@ -353,17 +384,21 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
if (!(input instanceof IFile)) {
return;
}
- 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 = getFileRevisionTypedElement(resource, gitPath, commit);
- final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
- SaveableCompareEditorInput.createFileElement(resource),
- right,
- null);
- openInCompare(in);
+ 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 = getFileRevisionTypedElement(resource, gitPath, commit);
+ final GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(
+ SaveableCompareEditorInput.createFileElement(resource),
+ right,
+ null);
+ openInCompare(in);
+ } else {
+ new ViewVersionsAction().run();
+ }
}
});
@@ -380,6 +415,7 @@ public class GitHistoryPage extends HistoryPage implements RepositoryListener {
attachCommitSelectionChanged();
createLocalToolbarActions();
createResourceFilterActions();
+ createCompareModeAction();
createStandardActions();
createViewMenu();
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 1f48441..8e2c1fd 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
@@ -66,6 +66,7 @@ GitDocument_errorLoadCommit=Could not load commit {0} for {1} corresponding to {
GitDocument_errorLoadTree=Could not load tree {0} for {1} corresponding to {2} in {3}
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}.