summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRuth Alkema2010-11-24 04:18:00 (EST)
committer Mathias Kinzler2010-11-24 07:26:18 (EST)
commitf6c3cb141afca80cfd74119ccfd12f42474ed527 (patch)
tree94368bd5fe02e1c6d5adb419cce65e1a040529b4
parent599a5f2b10464907ad79de8843c7ff83196acad6 (diff)
downloadegit-f6c3cb141afca80cfd74119ccfd12f42474ed527.zip
egit-f6c3cb141afca80cfd74119ccfd12f42474ed527.tar.gz
egit-f6c3cb141afca80cfd74119ccfd12f42474ed527.tar.bz2
[historyView] Added menu option to toggle 'reuse compare editor'refs/changes/28/1928/4
The option already existed in the team preferences, but this is not known to everybody. Therefore it is now also added to the menu of the GitHistoryPage. Change-Id: Ib9df76630aa6f59bd5c095f2c5c2fdfc0ddcf283 Signed-off-by: Ruth Alkema <ruth@diasoft.nl>
-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/CompareUtils.java41
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties1
4 files changed, 59 insertions, 8 deletions
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 5c0f953..13412fa 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
@@ -277,6 +277,9 @@ public class UIText extends NLS {
public static String GitHistoryPage_CompareModeMenuLabel;
/** */
+ public static String GitHistoryPage_ReuseCompareEditorMenuLabel;
+
+ /** */
public static String GitHistoryPage_CompareWithCurrentHeadMenu;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
index a1053e8..30f316f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/CompareUtils.java
@@ -27,10 +27,14 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.egit.core.internal.storage.GitFileRevision;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -45,6 +49,7 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
/**
* A collection of helper methods useful for comparing content
@@ -297,10 +302,46 @@ public class CompareUtils {
return null;
}
+ /**
+ * Action to toggle the team 'reuse compare editor' preference
+ */
+ public static class ReuseCompareEditorAction extends Action implements
+ IPreferenceChangeListener, IWorkbenchAction {
+ IEclipsePreferences node = new InstanceScope().getNode(TEAM_UI_PLUGIN);
+
+ /**
+ * Default constructor
+ */
+ public ReuseCompareEditorAction() {
+ node.addPreferenceChangeListener(this);
+ setText(UIText.GitHistoryPage_ReuseCompareEditorMenuLabel);
+ setChecked(CompareUtils.isReuseOpenEditor());
+ }
+
+ public void run() {
+ CompareUtils.setReuseOpenEditor(isChecked());
+ }
+
+ public void dispose() {
+ // stop listening
+ node.removePreferenceChangeListener(this);
+ }
+
+ public void preferenceChange(PreferenceChangeEvent event) {
+ setChecked(isReuseOpenEditor());
+
+ }
+ }
+
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 static void setReuseOpenEditor(boolean value) {
+ new InstanceScope().getNode(TEAM_UI_PLUGIN).putBoolean(
+ REUSE_COMPARE_EDITOR_PREFID, value);
+ }
}
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 dc1d2ff..31d0258 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
@@ -31,6 +31,7 @@ import org.eclipse.egit.ui.UIIcons;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.UIUtils;
+import org.eclipse.egit.ui.internal.CompareUtils;
import org.eclipse.egit.ui.internal.repository.tree.FileNode;
import org.eclipse.egit.ui.internal.repository.tree.FolderNode;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
@@ -88,7 +89,7 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.team.ui.history.HistoryPage;
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.progress.IWorkbenchSiteProgressService;
/** Graphical commit history viewer. */
@@ -111,7 +112,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
// 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 List<IWorkbenchAction> actionsToDispose = new ArrayList<IWorkbenchAction>();
private final IPersistentPreferenceStore store = (IPersistentPreferenceStore) Activator
.getDefault().getPreferenceStore();
@@ -346,6 +347,9 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
};
actionsToDispose.add(compareModeAction);
+ CompareUtils.ReuseCompareEditorAction reuseCompareEditorAction = new CompareUtils.ReuseCompareEditorAction();
+ actionsToDispose.add(reuseCompareEditorAction);
+
compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW);
compareModeAction.setToolTipText(UIText.GitHistoryPage_compareMode);
@@ -386,6 +390,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
viewMenuMgr.add(showAllResourceVersionsAction);
viewMenuMgr.add(new Separator());
viewMenuMgr.add(compareModeAction);
+ viewMenuMgr.add(reuseCompareEditorAction);
viewMenuMgr.add(showAllBranchesAction);
final IAction showCommentAction = createShowComment();
@@ -793,19 +798,19 @@ 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 (IWorkbenchAction action : actionsToDispose)
action.dispose();
actionsToDispose.clear();
cancelRefreshJob();
if (popupMgr != null) {
for (final IContributionItem i : popupMgr.getItems()) {
- if (i instanceof ActionFactory.IWorkbenchAction)
- ((ActionFactory.IWorkbenchAction) i).dispose();
+ if (i instanceof IWorkbenchAction)
+ ((IWorkbenchAction) i).dispose();
}
for (final IContributionItem i : getSite().getActionBars()
.getMenuManager().getItems()) {
- if (i instanceof ActionFactory.IWorkbenchAction)
- ((ActionFactory.IWorkbenchAction) i).dispose();
+ if (i instanceof IWorkbenchAction)
+ ((IWorkbenchAction) i).dispose();
}
}
super.dispose();
@@ -1267,7 +1272,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
}
private abstract class BooleanPrefAction extends Action implements
- IPropertyChangeListener, ActionFactory.IWorkbenchAction {
+ IPropertyChangeListener, IWorkbenchAction {
private final String prefName;
BooleanPrefAction(final String pn, final String text) {
@@ -1302,4 +1307,5 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener {
store.removePropertyChangeListener(this);
}
}
+
}
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 81f9203..9ee419a 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
@@ -94,6 +94,7 @@ GitHistoryPage_AllOfResourceMenuLabel=All &Changes of Resource
GitHistoryPage_AllOfResourceTooltip=Show all changes of selected Resource and its children
GitHistoryPage_CheckoutMenuLabel=&Checkout
GitHistoryPage_CompareModeMenuLabel=Compare &Mode
+GitHistoryPage_ReuseCompareEditorMenuLabel=Reuse Compare &Editor
GitHistoryPage_CompareWithCurrentHeadMenu=Compare with current &HEAD
GitHistoryPage_CompareWithEachOtherMenuLabel=Compare with &each other
GitHistoryPage_CompareWithWorkingTreeMenuMenuLabel=Compare with &working tree