diff options
author | Mathias Kinzler | 2010-10-21 22:21:30 +0000 |
---|---|---|
committer | Matthias Sohn | 2010-10-21 22:21:30 +0000 |
commit | 4347a5c95b24934c2ef7efd1b1e9e53eea7c06df (patch) | |
tree | c4e4a033c07314bfe80332761637479f33be77e7 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java | |
parent | d2d3e078d3f18e35ecf4bcf077e039fc207af488 (diff) | |
download | egit-4347a5c95b24934c2ef7efd1b1e9e53eea7c06df.tar.gz egit-4347a5c95b24934c2ef7efd1b1e9e53eea7c06df.tar.xz egit-4347a5c95b24934c2ef7efd1b1e9e53eea7c06df.zip |
[historyView] Refactoring fourth part
Replace "Show all Branches" and "Compare mode" actions with
BooleanPrefActions and add the corresponding preferences so that
the toggle state of these buttons survives a restart.
Decouple the different sub-components (file list, diff viewer)
of the history page by using the Preferences directly instead
of setting the preference values in the components programmatically.
Change-Id: I220bf134494463f9269d69d22c310d5e5a0a1251
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java')
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/GitHistoryPage.java | 56 |
1 files changed, 24 insertions, 32 deletions
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 eb3dc75e60..07108ecfde 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 @@ -139,14 +139,10 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { private IAction fillCommentAction; /** Compare mode toggle */ - private IAction compareModeAction; - - private boolean compareMode = false; + private BooleanPrefAction compareModeAction; /** Show all branches toggle */ - private IAction showAllBranchesAction; - - private boolean showAllBranches = false; + private BooleanPrefAction showAllBranchesAction; /** An error text to be shown instead of the control */ private StyledText errorText; @@ -367,32 +363,31 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { showAllResourceVersionsAction .setChecked(showAllFilter == showAllResourceVersionsAction.filter); - compareModeAction = new Action(UIText.GitHistoryPage_compareMode, - IAction.AS_CHECK_BOX) { - public void run() { - compareMode = !compareMode; - setChecked(compareMode); - fileViewer.setCompareMode(compareMode); + compareModeAction = new BooleanPrefAction( + UIPreferences.RESOURCEHISTORY_COMPARE_MODE, + UIText.GitHistoryPage_CompareModeMenuLabel) { + @Override + void apply(boolean value) { + // nothing, just switch the preference } }; + actionsToDispose.add(compareModeAction); + compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW); - compareModeAction.setChecked(compareMode); - compareModeAction.setText(UIText.GitHistoryPage_CompareModeMenuLabel); compareModeAction.setToolTipText(UIText.GitHistoryPage_compareMode); - fileViewer.setCompareMode(compareMode); - showAllBranchesAction = new Action( - UIText.GitHistoryPage_showAllBranches, IAction.AS_CHECK_BOX) { - public void run() { - showAllBranches = !showAllBranches; - setChecked(showAllBranches); + showAllBranchesAction = new BooleanPrefAction( + UIPreferences.RESOURCEHISTORY_SHOW_ALL_BRANCHES, + UIText.GitHistoryPage_ShowAllBranchesMenuLabel) { + + @Override + void apply(boolean value) { refresh(); } }; + actionsToDispose.add(showAllBranchesAction); + showAllBranchesAction.setImageDescriptor(UIIcons.BRANCH); - showAllBranchesAction.setChecked(showAllBranches); - showAllBranchesAction - .setText(UIText.GitHistoryPage_ShowAllBranchesMenuLabel); showAllBranchesAction .setToolTipText(UIText.GitHistoryPage_showAllBranches); @@ -426,10 +421,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { * switch compare mode button of the view on / off */ public void setCompareMode(boolean compareMode) { - if (compareModeAction != null) { - this.compareMode = compareMode; - compareModeAction.setChecked(compareMode); - } + store.setValue(UIPreferences.RESOURCEHISTORY_COMPARE_MODE, compareMode); } @Override @@ -465,7 +457,8 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { IHandlerService.class); Command cmd = srv.getCommand(HistoryViewCommands.SHOWVERSIONS); Parameterization[] parms; - if (compareMode) { + if (store + .getBoolean(UIPreferences.RESOURCEHISTORY_COMPARE_MODE)) { try { IParameter parm = cmd .getParameter(HistoryViewCommands.COMPARE_MODE_PARAM); @@ -849,7 +842,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP, UIText.ResourceHistory_toggleCommentWrap) { void apply(boolean wrap) { - commentViewer.setWrap(wrap); + // nothing, just set the Preference } }; a.apply(a.isChecked()); @@ -862,7 +855,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL, UIText.ResourceHistory_toggleCommentFill) { void apply(boolean fill) { - commentViewer.setFill(fill); + // nothing, just set the Preference } }; a.apply(a.isChecked()); @@ -1185,8 +1178,7 @@ public class GitHistoryPage extends HistoryPage implements RefsChangedListener { } try { - - if (showAllBranches) { + if (store.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_ALL_BRANCHES)) { markStartAllRefs(Constants.R_HEADS); markStartAllRefs(Constants.R_REMOTES); } else |