Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-04-20 18:33:08 +0000
committerMichael Valenta2007-04-20 18:33:08 +0000
commit668735c6e72c4652879bbc69f3906d534d473379 (patch)
tree770158da3b2bb4ae8e0df0360aed5d81aa3d6f8d /bundles/org.eclipse.compare
parent6c0cb53ca6ba25e50befc615bc184a591828d19b (diff)
downloadeclipse.platform.team-668735c6e72c4652879bbc69f3906d534d473379.tar.gz
eclipse.platform.team-668735c6e72c4652879bbc69f3906d534d473379.tar.xz
eclipse.platform.team-668735c6e72c4652879bbc69f3906d534d473379.zip
Bug 175254 Move "Ignore White Space Where Applicable" toolbar button to merge viewer toolbar
Diffstat (limited to 'bundles/org.eclipse.compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java17
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java3
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java14
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties3
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java31
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java9
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java26
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java26
-rw-r--r--bundles/org.eclipse.compare/plugin.properties3
-rw-r--r--bundles/org.eclipse.compare/plugin.xml6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java17
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java14
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java31
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java9
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java26
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java2
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java26
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties3
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml6
24 files changed, 148 insertions, 136 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index 78e4a876e..4934b2563 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -153,9 +153,6 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
private boolean fDirty= false;
private ArrayList fDirtyViewers= new ArrayList();
private IPropertyChangeListener fDirtyStateListener;
-
- private IgnoreWhiteSpaceAction fIgnoreWhitespace;
- private ShowPseudoConflicts fShowPseudoConflicts;
boolean fStructureCompareOnSingleClick= true;
@@ -215,10 +212,6 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
fCompareConfiguration= configuration;
Assert.isNotNull(configuration);
- ResourceBundle bundle= CompareUI.getResourceBundle();
- fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, configuration);
- fShowPseudoConflicts= new ShowPseudoConflicts(bundle, configuration);
-
fDirtyStateListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String propertyName= e.getProperty();
@@ -429,10 +422,14 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
* @param toolBarManager the <code>ToolBarManager</code> to which to contribute
*/
public void contributeToToolBar(ToolBarManager toolBarManager) {
-
+ ResourceBundle bundle= CompareUI.getResourceBundle();
+ ChangePropertyAction ignoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(bundle, getCompareConfiguration());
+ toolBarManager.getControl().addDisposeListener(ignoreWhitespace);
+ ChangePropertyAction showPseudoConflicts= ChangePropertyAction.createShowPseudoConflictsAction(bundle, getCompareConfiguration());
+ toolBarManager.getControl().addDisposeListener(showPseudoConflicts);
toolBarManager.add(new Separator());
- toolBarManager.add(fIgnoreWhitespace);
- toolBarManager.add(fShowPseudoConflicts);
+ toolBarManager.add(ignoreWhitespace);
+ toolBarManager.add(showPseudoConflicts);
}
/**
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index f82efada1..e880d9a78 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -811,11 +811,12 @@ public abstract class ContentMergeViewer extends ContentViewer
fHandlerService.registerAction(fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); //$NON-NLS-1$
}
- Action a= new ChangePropertyAction(fBundle, getCompareConfiguration(), "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); //$NON-NLS-1$
+ final ChangePropertyAction a= new ChangePropertyAction(fBundle, getCompareConfiguration(), "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); //$NON-NLS-1$
a.setChecked(fAncestorVisible);
fAncestorItem= new ActionContributionItem(a);
fAncestorItem.setVisible(false);
tbm.appendToGroup("modes", fAncestorItem); //$NON-NLS-1$
+ tbm.getControl().addDisposeListener(a);
createToolItems(tbm);
updateToolItems();
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 e7eb9507f..f6154d1c5 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
@@ -286,6 +286,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private InternalOutlineViewerCreator fOutlineViewerCreator;
private TextEditorPropertyAction toggleLineNumbersAction;
private IFindReplaceTarget fFindReplaceTarget;
+ private ChangePropertyAction fIgnoreWhitespace;
private final class InternalOutlineViewerCreator extends OutlineViewerCreator implements ISelectionChangedListener {
public Viewer findStructureViewer(Viewer oldViewer,
@@ -1792,6 +1793,9 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (toggleLineNumbersAction != null)
toggleLineNumbersAction.dispose();
+ if (fIgnoreWhitespace != null)
+ fIgnoreWhitespace.dispose();
+
super.handleDispose(event);
}
@@ -3931,6 +3935,16 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
fLeft, fRight, fAncestor
}, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
fHandlerService.registerAction(toggleLineNumbersAction, ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE);
+
+ fIgnoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(getResourceBundle(), getCompareConfiguration());
+ fIgnoreWhitespace.setActionDefinitionId(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE);
+ fLeft.addTextAction(fIgnoreWhitespace);
+ fRight.addTextAction(fIgnoreWhitespace);
+ fAncestor.addTextAction(fIgnoreWhitespace);
+ // Register for key binding if we are not in an editor
+ if (!(getCompareConfiguration().getContainer().getWorkbenchPart() instanceof IEditorPart)) {
+ fHandlerService.registerAction(fIgnoreWhitespace, fIgnoreWhitespace.getActionDefinitionId());
+ }
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
index ff58771fc..970a55431 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
@@ -111,3 +111,6 @@ Editor.FindReplace.label=&Find/Replace...
Editor.FindReplace.tooltip=Find/Replace
Editor.FindReplace.image=
Editor.FindReplace.description=Find/Replace
+
+action.IgnoreWhiteSpace.label=&Ignore White Space
+action.IgnoreWhiteSpace.tooltip=Ignore White Space Where Applicable
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java
index 5216c345a..17f7837e9 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java
@@ -13,18 +13,28 @@ package org.eclipse.compare.internal;
import java.util.ResourceBundle;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.compare.CompareConfiguration;
/**
* Toggles a boolean property of an <code>CompareConfiguration</code>.
*/
-public class ChangePropertyAction extends Action {
+public class ChangePropertyAction extends Action implements IPropertyChangeListener, DisposeListener {
private CompareConfiguration fCompareConfiguration;
private String fPropertyKey;
private ResourceBundle fBundle;
private String fPrefix;
+ public static ChangePropertyAction createIgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration compareConfiguration) {
+ return new ChangePropertyAction(bundle, compareConfiguration, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$
+ }
+ public static ChangePropertyAction createShowPseudoConflictsAction(ResourceBundle bundle, CompareConfiguration compareConfiguration) {
+ return new ChangePropertyAction(bundle, compareConfiguration, "action.ShowPseudoConflicts.", CompareConfiguration.SHOW_PSEUDO_CONFLICTS); //$NON-NLS-1$
+ }
public ChangePropertyAction(ResourceBundle bundle, CompareConfiguration cc, String rkey, String pkey) {
fPropertyKey= pkey;
@@ -47,7 +57,26 @@ public class ChangePropertyAction extends Action {
}
public void setCompareConfiguration(CompareConfiguration cc) {
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.removePropertyChangeListener(this);
fCompareConfiguration= cc;
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.addPropertyChangeListener(this);
setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false));
}
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(fPropertyKey)) {
+ setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false));
+ }
+ }
+
+ public void dispose(){
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.removePropertyChangeListener(this);
+ }
+
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ }
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
index a1d8eb14e..a1c683548 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
@@ -27,20 +27,20 @@ public class CompareEditorContributor extends EditorActionBarContributor {
private IEditorPart fActiveEditorPart= null;
- private IgnoreWhiteSpaceAction fIgnoreWhitespace;
+ private ChangePropertyAction fIgnoreWhitespace;
private NavigationAction fNext;
private NavigationAction fPrevious;
private NavigationAction fToolbarNext;
private NavigationAction fToolbarPrevious;
-
public CompareEditorContributor() {
ResourceBundle bundle= CompareUI.getResourceBundle();
IWorkbenchHelpSystem helpSystem= PlatformUI.getWorkbench().getHelpSystem();
- fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, null);
+ fIgnoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(bundle, null);
+ fIgnoreWhitespace.setActionDefinitionId(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE);
helpSystem.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION);
fNext= new NavigationAction(bundle, true);
@@ -105,6 +105,8 @@ public class CompareEditorContributor extends EditorActionBarContributor {
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNext);
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPrevious);
+ actionBars.setGlobalActionHandler(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE, fIgnoreWhitespace);
+
CompareConfiguration cc= editor.getCompareConfiguration();
fIgnoreWhitespace.setCompareConfiguration(cc);
} else {
@@ -119,5 +121,6 @@ public class CompareEditorContributor extends EditorActionBarContributor {
public void dispose() {
setActiveEditor(null);
super.dispose();
+ fIgnoreWhitespace.dispose();
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
index 3c0a72cf9..b80bb76cb 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
@@ -44,4 +44,6 @@ public interface ICompareUIConstants {
public static final String PREF_VALUE_PROMPT = "prompt"; //$NON-NLS-1$
public static final String PREF_VALUE_LOOP = "loop"; //$NON-NLS-1$
public static final String PREF_VALUE_NEXT = "next"; //$NON-NLS-1$
+
+ public static final String COMMAND_IGNORE_WHITESPACE = PREFIX + "ignoreWhiteSpace"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java
deleted file mode 100644
index 1df567343..000000000
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.internal;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.*;
-
-/**
- * Toggles the <code>ICompareConfiguration.IGNORE_WS</code> property of an
- * <code>ICompareConfiguration</code>.
- */
-public class IgnoreWhiteSpaceAction extends ChangePropertyAction {
-
- public IgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration cc) {
- super(bundle, cc, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$
- }
-}
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 c3792f230..a7094b049 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
@@ -553,7 +553,7 @@ public class MergeSourceViewer extends SourceViewer
updateLineNumberRuler();
}
- public void addTextAction(TextEditorPropertyAction textEditorPropertyAction) {
+ public void addTextAction(IAction textEditorPropertyAction) {
textActions.add(textEditorPropertyAction);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java
deleted file mode 100644
index a560a2592..000000000
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.internal;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.*;
-
-/**
- * Toggles the <code>ICompareConfiguration.SHOW_PSEUDO_CONFLICTS</code> property of an
- * <code>ICompareConfiguration</code>.
- */
-public class ShowPseudoConflicts extends ChangePropertyAction {
-
- public ShowPseudoConflicts(ResourceBundle bundle, CompareConfiguration cc) {
- super(bundle, cc, "action.ShowPseudoConflicts.", CompareConfiguration.SHOW_PSEUDO_CONFLICTS); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index 47d21eaf0..d139fb5c4 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -71,6 +71,9 @@ Command.selectNextChange.description= Select Next Change
Command.selectPreviousChange.name= Select Previous Change
Command.selectPreviousChange.description= Select Previous Change
+Command.ignoreWhiteSpace.name= Ignore White Space
+Command.ignoreWhiteSpace.description= Ignore white space where applicable
+
#
# Context menu & actions
diff --git a/bundles/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugin.xml
index 613ad9cd9..a2cc8ad49 100644
--- a/bundles/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugin.xml
@@ -158,6 +158,12 @@
categoryId="org.eclipse.compare.ui.category.compare"
id="org.eclipse.compare.selectPreviousChange">
</command>
+ <command
+ categoryId="org.eclipse.compare.ui.category.compare"
+ description="%Command.ignoreWhiteSpace.description"
+ id="org.eclipse.compare.ignoreWhiteSpace"
+ name="%Command.ignoreWhiteSpace.name">
+ </command>
</extension>
<extension
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index 78e4a876e..4934b2563 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -153,9 +153,6 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
private boolean fDirty= false;
private ArrayList fDirtyViewers= new ArrayList();
private IPropertyChangeListener fDirtyStateListener;
-
- private IgnoreWhiteSpaceAction fIgnoreWhitespace;
- private ShowPseudoConflicts fShowPseudoConflicts;
boolean fStructureCompareOnSingleClick= true;
@@ -215,10 +212,6 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
fCompareConfiguration= configuration;
Assert.isNotNull(configuration);
- ResourceBundle bundle= CompareUI.getResourceBundle();
- fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, configuration);
- fShowPseudoConflicts= new ShowPseudoConflicts(bundle, configuration);
-
fDirtyStateListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
String propertyName= e.getProperty();
@@ -429,10 +422,14 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
* @param toolBarManager the <code>ToolBarManager</code> to which to contribute
*/
public void contributeToToolBar(ToolBarManager toolBarManager) {
-
+ ResourceBundle bundle= CompareUI.getResourceBundle();
+ ChangePropertyAction ignoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(bundle, getCompareConfiguration());
+ toolBarManager.getControl().addDisposeListener(ignoreWhitespace);
+ ChangePropertyAction showPseudoConflicts= ChangePropertyAction.createShowPseudoConflictsAction(bundle, getCompareConfiguration());
+ toolBarManager.getControl().addDisposeListener(showPseudoConflicts);
toolBarManager.add(new Separator());
- toolBarManager.add(fIgnoreWhitespace);
- toolBarManager.add(fShowPseudoConflicts);
+ toolBarManager.add(ignoreWhitespace);
+ toolBarManager.add(showPseudoConflicts);
}
/**
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index f82efada1..e880d9a78 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -811,11 +811,12 @@ public abstract class ContentMergeViewer extends ContentViewer
fHandlerService.registerAction(fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); //$NON-NLS-1$
}
- Action a= new ChangePropertyAction(fBundle, getCompareConfiguration(), "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); //$NON-NLS-1$
+ final ChangePropertyAction a= new ChangePropertyAction(fBundle, getCompareConfiguration(), "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); //$NON-NLS-1$
a.setChecked(fAncestorVisible);
fAncestorItem= new ActionContributionItem(a);
fAncestorItem.setVisible(false);
tbm.appendToGroup("modes", fAncestorItem); //$NON-NLS-1$
+ tbm.getControl().addDisposeListener(a);
createToolItems(tbm);
updateToolItems();
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 e7eb9507f..f6154d1c5 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
@@ -286,6 +286,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
private InternalOutlineViewerCreator fOutlineViewerCreator;
private TextEditorPropertyAction toggleLineNumbersAction;
private IFindReplaceTarget fFindReplaceTarget;
+ private ChangePropertyAction fIgnoreWhitespace;
private final class InternalOutlineViewerCreator extends OutlineViewerCreator implements ISelectionChangedListener {
public Viewer findStructureViewer(Viewer oldViewer,
@@ -1792,6 +1793,9 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
if (toggleLineNumbersAction != null)
toggleLineNumbersAction.dispose();
+ if (fIgnoreWhitespace != null)
+ fIgnoreWhitespace.dispose();
+
super.handleDispose(event);
}
@@ -3931,6 +3935,16 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
fLeft, fRight, fAncestor
}, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);
fHandlerService.registerAction(toggleLineNumbersAction, ITextEditorActionDefinitionIds.LINENUMBER_TOGGLE);
+
+ fIgnoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(getResourceBundle(), getCompareConfiguration());
+ fIgnoreWhitespace.setActionDefinitionId(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE);
+ fLeft.addTextAction(fIgnoreWhitespace);
+ fRight.addTextAction(fIgnoreWhitespace);
+ fAncestor.addTextAction(fIgnoreWhitespace);
+ // Register for key binding if we are not in an editor
+ if (!(getCompareConfiguration().getContainer().getWorkbenchPart() instanceof IEditorPart)) {
+ fHandlerService.registerAction(fIgnoreWhitespace, fIgnoreWhitespace.getActionDefinitionId());
+ }
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
index ff58771fc..970a55431 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
@@ -111,3 +111,6 @@ Editor.FindReplace.label=&Find/Replace...
Editor.FindReplace.tooltip=Find/Replace
Editor.FindReplace.image=
Editor.FindReplace.description=Find/Replace
+
+action.IgnoreWhiteSpace.label=&Ignore White Space
+action.IgnoreWhiteSpace.tooltip=Ignore White Space Where Applicable
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java
index 5216c345a..17f7837e9 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ChangePropertyAction.java
@@ -13,18 +13,28 @@ package org.eclipse.compare.internal;
import java.util.ResourceBundle;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.compare.CompareConfiguration;
/**
* Toggles a boolean property of an <code>CompareConfiguration</code>.
*/
-public class ChangePropertyAction extends Action {
+public class ChangePropertyAction extends Action implements IPropertyChangeListener, DisposeListener {
private CompareConfiguration fCompareConfiguration;
private String fPropertyKey;
private ResourceBundle fBundle;
private String fPrefix;
+ public static ChangePropertyAction createIgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration compareConfiguration) {
+ return new ChangePropertyAction(bundle, compareConfiguration, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$
+ }
+ public static ChangePropertyAction createShowPseudoConflictsAction(ResourceBundle bundle, CompareConfiguration compareConfiguration) {
+ return new ChangePropertyAction(bundle, compareConfiguration, "action.ShowPseudoConflicts.", CompareConfiguration.SHOW_PSEUDO_CONFLICTS); //$NON-NLS-1$
+ }
public ChangePropertyAction(ResourceBundle bundle, CompareConfiguration cc, String rkey, String pkey) {
fPropertyKey= pkey;
@@ -47,7 +57,26 @@ public class ChangePropertyAction extends Action {
}
public void setCompareConfiguration(CompareConfiguration cc) {
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.removePropertyChangeListener(this);
fCompareConfiguration= cc;
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.addPropertyChangeListener(this);
setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false));
}
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(fPropertyKey)) {
+ setChecked(Utilities.getBoolean(fCompareConfiguration, fPropertyKey, false));
+ }
+ }
+
+ public void dispose(){
+ if (fCompareConfiguration != null)
+ fCompareConfiguration.removePropertyChangeListener(this);
+ }
+
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ }
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
index a1d8eb14e..a1c683548 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditorContributor.java
@@ -27,20 +27,20 @@ public class CompareEditorContributor extends EditorActionBarContributor {
private IEditorPart fActiveEditorPart= null;
- private IgnoreWhiteSpaceAction fIgnoreWhitespace;
+ private ChangePropertyAction fIgnoreWhitespace;
private NavigationAction fNext;
private NavigationAction fPrevious;
private NavigationAction fToolbarNext;
private NavigationAction fToolbarPrevious;
-
public CompareEditorContributor() {
ResourceBundle bundle= CompareUI.getResourceBundle();
IWorkbenchHelpSystem helpSystem= PlatformUI.getWorkbench().getHelpSystem();
- fIgnoreWhitespace= new IgnoreWhiteSpaceAction(bundle, null);
+ fIgnoreWhitespace= ChangePropertyAction.createIgnoreWhiteSpaceAction(bundle, null);
+ fIgnoreWhitespace.setActionDefinitionId(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE);
helpSystem.setHelp(fIgnoreWhitespace, ICompareContextIds.IGNORE_WHITESPACE_ACTION);
fNext= new NavigationAction(bundle, true);
@@ -105,6 +105,8 @@ public class CompareEditorContributor extends EditorActionBarContributor {
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNext);
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPrevious);
+ actionBars.setGlobalActionHandler(ICompareUIConstants.COMMAND_IGNORE_WHITESPACE, fIgnoreWhitespace);
+
CompareConfiguration cc= editor.getCompareConfiguration();
fIgnoreWhitespace.setCompareConfiguration(cc);
} else {
@@ -119,5 +121,6 @@ public class CompareEditorContributor extends EditorActionBarContributor {
public void dispose() {
setActiveEditor(null);
super.dispose();
+ fIgnoreWhitespace.dispose();
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
index 3c0a72cf9..b80bb76cb 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
@@ -44,4 +44,6 @@ public interface ICompareUIConstants {
public static final String PREF_VALUE_PROMPT = "prompt"; //$NON-NLS-1$
public static final String PREF_VALUE_LOOP = "loop"; //$NON-NLS-1$
public static final String PREF_VALUE_NEXT = "next"; //$NON-NLS-1$
+
+ public static final String COMMAND_IGNORE_WHITESPACE = PREFIX + "ignoreWhiteSpace"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java
deleted file mode 100644
index 1df567343..000000000
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IgnoreWhiteSpaceAction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.internal;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.*;
-
-/**
- * Toggles the <code>ICompareConfiguration.IGNORE_WS</code> property of an
- * <code>ICompareConfiguration</code>.
- */
-public class IgnoreWhiteSpaceAction extends ChangePropertyAction {
-
- public IgnoreWhiteSpaceAction(ResourceBundle bundle, CompareConfiguration cc) {
- super(bundle, cc, "action.IgnoreWhiteSpace.", CompareConfiguration.IGNORE_WHITESPACE); //$NON-NLS-1$
- }
-}
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 c3792f230..a7094b049 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
@@ -553,7 +553,7 @@ public class MergeSourceViewer extends SourceViewer
updateLineNumberRuler();
}
- public void addTextAction(TextEditorPropertyAction textEditorPropertyAction) {
+ public void addTextAction(IAction textEditorPropertyAction) {
textActions.add(textEditorPropertyAction);
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java
deleted file mode 100644
index a560a2592..000000000
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ShowPseudoConflicts.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.internal;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.compare.*;
-
-/**
- * Toggles the <code>ICompareConfiguration.SHOW_PSEUDO_CONFLICTS</code> property of an
- * <code>ICompareConfiguration</code>.
- */
-public class ShowPseudoConflicts extends ChangePropertyAction {
-
- public ShowPseudoConflicts(ResourceBundle bundle, CompareConfiguration cc) {
- super(bundle, cc, "action.ShowPseudoConflicts.", CompareConfiguration.SHOW_PSEUDO_CONFLICTS); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
index 47d21eaf0..d139fb5c4 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -71,6 +71,9 @@ Command.selectNextChange.description= Select Next Change
Command.selectPreviousChange.name= Select Previous Change
Command.selectPreviousChange.description= Select Previous Change
+Command.ignoreWhiteSpace.name= Ignore White Space
+Command.ignoreWhiteSpace.description= Ignore white space where applicable
+
#
# Context menu & actions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
index 613ad9cd9..a2cc8ad49 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
@@ -158,6 +158,12 @@
categoryId="org.eclipse.compare.ui.category.compare"
id="org.eclipse.compare.selectPreviousChange">
</command>
+ <command
+ categoryId="org.eclipse.compare.ui.category.compare"
+ description="%Command.ignoreWhiteSpace.description"
+ id="org.eclipse.compare.ignoreWhiteSpace"
+ name="%Command.ignoreWhiteSpace.name">
+ </command>
</extension>
<extension

Back to the top