Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-04-12 15:03:16 +0000
committerMichael Valenta2007-04-12 15:03:16 +0000
commitb97f628c69dc697a5f142417eb364992597dedfa (patch)
tree597c82e3ca9abc7bbeb1964bbd1d6445676a7f7d /bundles/org.eclipse.compare
parentf35c9cb5360ff166ab514a63d4ccd501df46ff6e (diff)
downloadeclipse.platform.team-b97f628c69dc697a5f142417eb364992597dedfa.tar.gz
eclipse.platform.team-b97f628c69dc697a5f142417eb364992597dedfa.tar.xz
eclipse.platform.team-b97f628c69dc697a5f142417eb364992597dedfa.zip
Bug 181260 [Viewers] Compare viewers should bind command for Show Line Numbers
Diffstat (limited to 'bundles/org.eclipse.compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java36
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java12
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java36
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java12
12 files changed, 74 insertions, 38 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index bb46f8008..6f7551953 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -3881,7 +3881,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
});
Utilities.registerAction(fHandlerService, showWhitespaceAction, ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS, fActivations);
- toggleLineNumbersAction = new TextEditorPropertyAction(new MergeSourceViewer[] {
+ toggleLineNumbersAction = new TextEditorPropertyAction(CompareMessages.TextMergeViewer_16, new MergeSourceViewer[] {
fLeft, fRight, fAncestor
}, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
Utilities.registerAction(fHandlerService, toggleLineNumbersAction, ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE, fActivations);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
index bebbdc9ca..aafc9bb1b 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
@@ -52,6 +52,7 @@ public final class CompareMessages extends NLS {
public static String NavigationEndDialog_0;
public static String NavigationEndDialog_1;
public static String RangeComparatorLCS_0;
+ public static String ShowWhitespaceAction_0;
public static String StructureDiffViewer_0;
public static String StructureDiffViewer_1;
public static String StructureDiffViewer_2;
@@ -66,6 +67,7 @@ public final class CompareMessages extends NLS {
public static String TextMergeViewer_13;
public static String TextMergeViewer_14;
public static String TextMergeViewer_15;
+ public static String TextMergeViewer_16;
public static String TextMergeViewer_2;
public static String TextMergeViewer_3;
public static String TextMergeViewer_4;
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
index c2b0bce27..0385ae6cc 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
@@ -68,6 +68,7 @@ TextMergeViewer_12=Element is Read Only
TextMergeViewer_13=The element being edited is read-only
TextMergeViewer_14=Element is Read Only
TextMergeViewer_15=The element being edited is read-only
+TextMergeViewer_16=Show Line Numbers
TextMergeViewer_atEnd_message= End of document reached. Continue from beginning?
TextMergeViewer_atBeginning_title= Go to Previous Difference
@@ -113,3 +114,4 @@ RangeComparatorLCS_0=Finding differences
SelectAncestorDialog_title=Select Common Ancestor
SelectAncestorDialog_message=Which resource would you like to use as the common ancestor in the three-way compare?
SelectAncestorDialog_option=''{0}''
+ShowWhitespaceAction_0=Show Whitespace Characters
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
index 160c24046..34e50d99a 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
@@ -12,30 +12,25 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ResourceBundle;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.texteditor.FindReplaceAction;
+import java.util.*;
import org.eclipse.compare.ICompareContainer;
import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
import org.eclipse.jface.text.*;
import org.eclipse.jface.text.source.*;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
-import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.texteditor.FindReplaceAction;
/**
* Extends the JFace SourceViewer with some convenience methods.
*/
@@ -89,6 +84,7 @@ public class MergeSourceViewer extends SourceViewer
private IPropertyChangeListener fPreferenceChangeListener;
private boolean fShowLineNumber=false;
private LineNumberRulerColumn fLineNumberColumn;
+ private List textActions = new ArrayList();
public MergeSourceViewer(Composite parent, int style, ResourceBundle bundle, ICompareContainer container) {
super(parent, new CompositeRuler(), style | SWT.H_SCROLL | SWT.V_SCROLL);
@@ -430,6 +426,12 @@ public class MergeSourceViewer extends SourceViewer
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator("text")); //$NON-NLS-1$
+ for (Iterator iterator = textActions.iterator(); iterator.hasNext();) {
+ IAction action = (IAction) iterator.next();
+ menu.add(action);
+ }
+
menu.add(new Separator("rest")); //$NON-NLS-1$
// update all actions
@@ -533,4 +535,8 @@ public class MergeSourceViewer extends SourceViewer
updateLineNumberRuler();
}
+
+ public void addTextAction(TextEditorPropertyAction textEditorPropertyAction) {
+ textActions.add(textEditorPropertyAction);
+ }
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
index 74307d5f7..633a1ba44 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
@@ -21,7 +21,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction {
private boolean isWhitespaceShowing;
public ShowWhitespaceAction(MergeSourceViewer[] viewers) {
- super(viewers, AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS);
+ super(CompareMessages.ShowWhitespaceAction_0, viewers, AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS);
}
protected void toggleState(boolean checked) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
index 57734ab53..4526f6afc 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
@@ -23,14 +23,22 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL
private final String preferenceKey;
private IPreferenceStore store;
- public TextEditorPropertyAction(MergeSourceViewer[] viewers, String preferenceKey) {
- super(null, IAction.AS_CHECK_BOX);
+ public TextEditorPropertyAction(String label, MergeSourceViewer[] viewers, String preferenceKey) {
+ super(label, IAction.AS_CHECK_BOX);
this.viewers = viewers;
this.preferenceKey = preferenceKey;
this.store = EditorsUI.getPreferenceStore();
if (store != null)
store.addPropertyChangeListener(this);
synchronizeWithPreference();
+ addActionToViewers();
+ }
+
+ private void addActionToViewers() {
+ for (int i = 0; i < viewers.length; i++) {
+ MergeSourceViewer viewer = viewers[i];
+ viewer.addTextAction(this);
+ }
}
public MergeSourceViewer[] getViewers() {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index bb46f8008..6f7551953 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -3881,7 +3881,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
});
Utilities.registerAction(fHandlerService, showWhitespaceAction, ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS, fActivations);
- toggleLineNumbersAction = new TextEditorPropertyAction(new MergeSourceViewer[] {
+ toggleLineNumbersAction = new TextEditorPropertyAction(CompareMessages.TextMergeViewer_16, new MergeSourceViewer[] {
fLeft, fRight, fAncestor
}, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
Utilities.registerAction(fHandlerService, toggleLineNumbersAction, ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE, fActivations);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
index bebbdc9ca..aafc9bb1b 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
@@ -52,6 +52,7 @@ public final class CompareMessages extends NLS {
public static String NavigationEndDialog_0;
public static String NavigationEndDialog_1;
public static String RangeComparatorLCS_0;
+ public static String ShowWhitespaceAction_0;
public static String StructureDiffViewer_0;
public static String StructureDiffViewer_1;
public static String StructureDiffViewer_2;
@@ -66,6 +67,7 @@ public final class CompareMessages extends NLS {
public static String TextMergeViewer_13;
public static String TextMergeViewer_14;
public static String TextMergeViewer_15;
+ public static String TextMergeViewer_16;
public static String TextMergeViewer_2;
public static String TextMergeViewer_3;
public static String TextMergeViewer_4;
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
index c2b0bce27..0385ae6cc 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
@@ -68,6 +68,7 @@ TextMergeViewer_12=Element is Read Only
TextMergeViewer_13=The element being edited is read-only
TextMergeViewer_14=Element is Read Only
TextMergeViewer_15=The element being edited is read-only
+TextMergeViewer_16=Show Line Numbers
TextMergeViewer_atEnd_message= End of document reached. Continue from beginning?
TextMergeViewer_atBeginning_title= Go to Previous Difference
@@ -113,3 +114,4 @@ RangeComparatorLCS_0=Finding differences
SelectAncestorDialog_title=Select Common Ancestor
SelectAncestorDialog_message=Which resource would you like to use as the common ancestor in the three-way compare?
SelectAncestorDialog_option=''{0}''
+ShowWhitespaceAction_0=Show Whitespace Characters
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
index 160c24046..34e50d99a 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java
@@ -12,30 +12,25 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ResourceBundle;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.texteditor.FindReplaceAction;
+import java.util.*;
import org.eclipse.compare.ICompareContainer;
import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
import org.eclipse.jface.text.*;
import org.eclipse.jface.text.source.*;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
-import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.texteditor.FindReplaceAction;
/**
* Extends the JFace SourceViewer with some convenience methods.
*/
@@ -89,6 +84,7 @@ public class MergeSourceViewer extends SourceViewer
private IPropertyChangeListener fPreferenceChangeListener;
private boolean fShowLineNumber=false;
private LineNumberRulerColumn fLineNumberColumn;
+ private List textActions = new ArrayList();
public MergeSourceViewer(Composite parent, int style, ResourceBundle bundle, ICompareContainer container) {
super(parent, new CompositeRuler(), style | SWT.H_SCROLL | SWT.V_SCROLL);
@@ -430,6 +426,12 @@ public class MergeSourceViewer extends SourceViewer
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menu.add(new Separator("text")); //$NON-NLS-1$
+ for (Iterator iterator = textActions.iterator(); iterator.hasNext();) {
+ IAction action = (IAction) iterator.next();
+ menu.add(action);
+ }
+
menu.add(new Separator("rest")); //$NON-NLS-1$
// update all actions
@@ -533,4 +535,8 @@ public class MergeSourceViewer extends SourceViewer
updateLineNumberRuler();
}
+
+ public void addTextAction(TextEditorPropertyAction textEditorPropertyAction) {
+ textActions.add(textEditorPropertyAction);
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
index 74307d5f7..633a1ba44 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowWhitespaceAction.java
@@ -21,7 +21,7 @@ public class ShowWhitespaceAction extends TextEditorPropertyAction {
private boolean isWhitespaceShowing;
public ShowWhitespaceAction(MergeSourceViewer[] viewers) {
- super(viewers, AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS);
+ super(CompareMessages.ShowWhitespaceAction_0, viewers, AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS);
}
protected void toggleState(boolean checked) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
index 57734ab53..4526f6afc 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/TextEditorPropertyAction.java
@@ -23,14 +23,22 @@ public class TextEditorPropertyAction extends Action implements IPropertyChangeL
private final String preferenceKey;
private IPreferenceStore store;
- public TextEditorPropertyAction(MergeSourceViewer[] viewers, String preferenceKey) {
- super(null, IAction.AS_CHECK_BOX);
+ public TextEditorPropertyAction(String label, MergeSourceViewer[] viewers, String preferenceKey) {
+ super(label, IAction.AS_CHECK_BOX);
this.viewers = viewers;
this.preferenceKey = preferenceKey;
this.store = EditorsUI.getPreferenceStore();
if (store != null)
store.addPropertyChangeListener(this);
synchronizeWithPreference();
+ addActionToViewers();
+ }
+
+ private void addActionToViewers() {
+ for (int i = 0; i < viewers.length; i++) {
+ MergeSourceViewer viewer = viewers[i];
+ viewer.addTextAction(this);
+ }
}
public MergeSourceViewer[] getViewers() {

Back to the top