Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.compare')
-rw-r--r--bundles/org.eclipse.compare/buildnotes_compare.html5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java27
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java18
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java85
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java283
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java446
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt10
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt10
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt10
-rw-r--r--bundles/org.eclipse.compare/plugin.properties12
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html5
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java27
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java18
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java85
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java283
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java446
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt10
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt10
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt10
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties12
20 files changed, 1664 insertions, 148 deletions
diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html
index 5de800fc0..48bf1e839 100644
--- a/bundles/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/buildnotes_compare.html
@@ -15,7 +15,9 @@ Eclipse Build Input February 26th 2002
<h2>
What's new in this drop</h2>
-Patch: for every rejected file a task marker is added
+Patch: for every rejected file a task marker is added<br>
+Compare preference page shows options in a preview<br>
+New preference option for additional compare status line information
<h3>
API changes</h3>
@@ -34,6 +36,7 @@ Problem reports fixed</h2>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9540">#9540</a>: Compare with patch: it should not be possible to check items that could not be applied<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9532">#9532</a>: Compare with patch: next disabled although clipboard specified<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7681">#7681</a>: Structured results expands import statements<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9572">#9572</a>: Debugging trace left in status bar<br>
<h2>
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
index 35d4147b8..666f99e26 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
@@ -86,6 +86,7 @@ public class CompareConfiguration {
// fgImages[Differencer.DELETION]= tmp;
}
+ private IPreferenceStore fPreferenceStore;
private ListenerList fListeners= new ListenerList();
private HashMap fProperties= new HashMap();
private boolean fLeftEditable= true;
@@ -102,17 +103,33 @@ public class CompareConfiguration {
* Creates a new configuration with editable left and right sides,
* suitable default labels, and no images.
*/
- public CompareConfiguration() {
+ public CompareConfiguration(IPreferenceStore prefStore) {
setProperty("LEFT_IS_LOCAL", new Boolean(fLeftIsLocal)); //$NON-NLS-1$
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null) {
- boolean b= ps.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
+ fPreferenceStore= prefStore;
+ if (fPreferenceStore != null) {
+ boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
setProperty(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b));
}
}
-
+
+ /**
+ * Creates a new configuration with editable left and right sides,
+ * suitable default labels, and no images.
+ */
+ public CompareConfiguration() {
+ this(CompareUIPlugin.getDefault().getPreferenceStore());
+ }
+
+ /**
+ * Returns the preference store of this configuration.
+ * @return the preference store of this configuration.
+ */
+ public IPreferenceStore getPreferenceStore() {
+ return fPreferenceStore;
+ }
+
/**
* Returns an image showing the specified change kind.
* The different kind of changes are defined in the <code>Differencer</code>.
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 987d42cd7..169fa34d4 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
@@ -284,15 +284,15 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
}
};
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- ContentMergeViewer.this.propertyChange(event);
- }
- };
-
fCompareConfiguration= cc;
- if (fCompareConfiguration != null)
+ if (fCompareConfiguration != null) {
+ fPropertyChangeListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ ContentMergeViewer.this.propertyChange(event);
+ }
+ };
fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener);
+ }
fLeftSaveAction= new SaveAction(true);
fLeftSaveAction.setEnabled(false);
@@ -716,8 +716,10 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
if (input instanceof ICompareInput)
((ICompareInput)input).removeCompareInputChangeListener(fCompareInputChangeListener);
- if (fCompareConfiguration != null)
+ if (fCompareConfiguration != null && fPropertyChangeListener != null) {
fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener);
+ fPropertyChangeListener= null;
+ }
fAncestorLabel= null;
fLeftLabel= null;
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 9d894a9ae..4a03643ab 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
@@ -197,6 +197,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private IDocumentListener fDocumentListener;
+ private IPreferenceStore fPreferenceStore;
private IPropertyChangeListener fPreferenceChangeListener;
/** All diffs for calculating scrolling position (includes line ranges without changes) */
@@ -220,10 +221,10 @@ public class TextMergeViewer extends ContentMergeViewer {
private int fPts[]= new int[8]; // scratch area for polygon drawing
- //PR1GI3HDZ
private boolean fIgnoreAncestor= false;
private ActionContributionItem fIgnoreAncestorItem;
- //end PR1GI3HDZ
+
+ private boolean fShowPseudoConflicts= false;
private ActionContributionItem fNextItem; // goto next difference
private ActionContributionItem fPreviousItem; // goto previous difference
@@ -231,6 +232,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private ActionContributionItem fCopyDiffRightToLeftItem;
private boolean fSynchronizedScrolling= true;
+ private boolean fShowMoreInfo= false;
private MergeSourceViewer fFocusPart;
@@ -442,19 +444,21 @@ public class TextMergeViewer extends ContentMergeViewer {
if (fIsMotif)
fMarginWidth= 0;
-
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null) {
+
+ fPreferenceStore= configuration.getPreferenceStore();
+ if (fPreferenceStore != null) {
fPreferenceChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
TextMergeViewer.this.propertyChange(event);
}
};
- ps.addPropertyChangeListener(fPreferenceChangeListener);
+ fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
- updateFont(ps, parent);
+ updateFont(fPreferenceStore, parent);
fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
- fSynchronizedScrolling= ps.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
+ fSynchronizedScrolling= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
+ fShowMoreInfo= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO);
+ fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS);
}
fDocumentListener= new IDocumentListener() {
@@ -550,9 +554,8 @@ public class TextMergeViewer extends ContentMergeViewer {
protected void handleDispose(DisposeEvent event) {
if (fPreferenceChangeListener != null) {
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null)
- ps.removePropertyChangeListener(fPreferenceChangeListener);
+ if (fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
fPreferenceChangeListener= null;
}
@@ -1273,7 +1276,7 @@ public class TextMergeViewer extends ContentMergeViewer {
continue;
}
- if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
+ if (useChange(kind)) {
fChangeDiffs.add(diff); // here we remember only the real diffs
updateDiffBackground(diff);
@@ -1311,6 +1314,17 @@ public class TextMergeViewer extends ContentMergeViewer {
}
}
+ /**
+ * Returns true if kind of change should be shown.
+ */
+ private boolean useChange(int kind) {
+ if (kind == RangeDifference.NOCHANGE)
+ return false;
+ if (kind == RangeDifference.ANCESTOR)
+ return fShowPseudoConflicts;
+ return true;
+ }
+
private int getTokenEnd(ITokenComparator tc, int start, int count) {
if (count <= 0)
return tc.getTokenStart(start);
@@ -1463,8 +1477,7 @@ public class TextMergeViewer extends ContentMergeViewer {
RangeDifference first= null;
for (int ii= start; ii < end; ii++) {
es= r[ii];
- int kind= es.kind();
- if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
+ if (useChange(es.kind())) {
first= es;
break;
}
@@ -1474,8 +1487,7 @@ public class TextMergeViewer extends ContentMergeViewer {
RangeDifference last= null;
for (int ii= end-1; ii >= start; ii--) {
es= r[ii];
- int kind= es.kind();
- if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
+ if (useChange(es.kind())) {
last= es;
break;
}
@@ -1557,6 +1569,9 @@ public class TextMergeViewer extends ContentMergeViewer {
private void updateStatus(Diff diff) {
+ if (! fShowMoreInfo)
+ return;
+
IActionBars bars= Utilities.findActionBars(fComposite);
if (bars == null)
return;
@@ -1596,6 +1611,18 @@ public class TextMergeViewer extends ContentMergeViewer {
slm.setMessage(s);
}
+ private void clearStatus() {
+
+ IActionBars bars= Utilities.findActionBars(fComposite);
+ if (bars == null)
+ return;
+ IStatusLineManager slm= bars.getStatusLineManager();
+ if (slm == null)
+ return;
+
+ slm.setMessage(null);
+ }
+
private String getDiffType(Diff diff) {
String s= "";
switch(diff.fDirection) {
@@ -1751,7 +1778,11 @@ public class TextMergeViewer extends ContentMergeViewer {
String key= event.getProperty();
- if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)) {
+ if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)
+ || key.equals(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS)) {
+
+ fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS);
+
// clear stuff
fCurrentDiff= null;
fChangeDiffs= null;
@@ -1766,20 +1797,28 @@ public class TextMergeViewer extends ContentMergeViewer {
selectFirstDiff();
} else if (key.equals(TEXT_FONT)) {
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null) {
- updateFont(ps, fComposite);
+ if (fPreferenceStore != null) {
+ updateFont(fPreferenceStore, fComposite);
invalidateLines();
}
} else if (key.equals(ComparePreferencePage.SYNCHRONIZE_SCROLLING)) {
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
-
- boolean b= ps.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
+ boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
if (b != fSynchronizedScrolling)
toggleSynchMode();
+ } else if (key.equals(ComparePreferencePage.SHOW_MORE_INFO)) {
+
+ boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO);
+ if (b != fShowMoreInfo) {
+ fShowMoreInfo= b;
+ if (fShowMoreInfo)
+ updateStatus(fCurrentDiff);
+ else
+ clearStatus();
+ }
+
} else
super.propertyChange(event);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index f8a64840f..ed70e23d6 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -4,36 +4,152 @@
*/
package org.eclipse.compare.internal;
-import org.eclipse.swt.widgets.Composite;
+import java.util.*;
+import java.io.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.preference.*;
+import org.eclipse.jface.util.*;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
+import org.eclipse.compare.*;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.structuremergeviewer.*;
+
-public class ComparePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+public class ComparePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ class FakeInput implements ITypedElement, IStreamContentAccessor {
+ String fContent;
+
+ FakeInput(String name) {
+ fContent= loadPreviewContentFromFile(name);
+ }
+ public Image getImage() {
+ return null;
+ }
+ public String getName() {
+ return "Name"; //$NON-NLS-1$
+ }
+ public String getType() {
+ return "Type"; //$NON-NLS-1$
+ }
+ public InputStream getContents() {
+ return new ByteArrayInputStream(fContent.getBytes());
+ }
+ };
+
private static final String PREFIX= CompareUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
public static final String SYNCHRONIZE_SCROLLING= PREFIX + "SynchronizeScrolling"; //$NON-NLS-1$
public static final String SHOW_PSEUDO_CONFLICTS= PREFIX + "ShowPseudoConflicts"; //$NON-NLS-1$
public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$
public static final String PREF_SAVE_ALL_EDITORS= PREFIX + "SaveAllEditors"; //$NON-NLS-1$
+ public static final String SHOW_MORE_INFO= PREFIX + "ShowMoreInfo"; //$NON-NLS-1$
public static final String TEXT_FONT= PREFIX + "TextFont"; //$NON-NLS-1$
+
+ private WorkbenchChainedTextFontFieldEditor fFontEditor;
+ private TextMergeViewer fTextMergeViewer;
+ private IPropertyChangeListener fPreferenceChangeListener;
+ private CompareConfiguration fCompareConfiguration;
+ private OverlayPreferenceStore fOverlayStore;
+ private Map fCheckBoxes= new HashMap();
+
- public ComparePreferencePage() {
- super(GRID);
- }
+ public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_PSEUDO_CONFLICTS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_MORE_INFO),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TEXT_FONT)
+ };
+
public static void initDefaults(IPreferenceStore store) {
store.setDefault(SYNCHRONIZE_SCROLLING, true);
store.setDefault(SHOW_PSEUDO_CONFLICTS, false);
store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false);
+ store.setDefault(SHOW_MORE_INFO, false);
WorkbenchChainedTextFontFieldEditor.startPropagate(store, TEXT_FONT);
}
+ public ComparePreferencePage() {
+
+ //setDescription(Utilities.getString("ComparePreferencePage.description")); //$NON-NLS-1$
+
+ setPreferenceStore(CompareUIPlugin.getDefault().getPreferenceStore());
+
+ fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
+ fPreferenceChangeListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ String key= event.getProperty();
+ if (key.equals(INITIALLY_SHOW_ANCESTOR_PANE)) {
+ boolean b= fOverlayStore.getBoolean(INITIALLY_SHOW_ANCESTOR_PANE);
+ if (fCompareConfiguration != null) {
+ fCompareConfiguration.setProperty(INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b));
+ }
+ }
+ }
+ };
+ fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener);
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+ /*
+ * @see PreferencePage#performOk()
+ */
+ public boolean performOk() {
+ fFontEditor.store();
+ fOverlayStore.propagate();
+ return true;
+ }
+
+ /*
+ * @see PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+
+ fFontEditor.loadDefault();
+
+ fOverlayStore.loadDefaults();
+ initializeFields();
+
+ super.performDefaults();
+
+ //fPreviewViewer.invalidateTextPresentation();
+ }
+
+ /*
+ * @see DialogPage#dispose()
+ */
+ public void dispose() {
+
+ fFontEditor.setPreferencePage(null);
+ fFontEditor.setPreferenceStore(null);
+
+ if (fOverlayStore != null) {
+ if (fPreferenceChangeListener != null) {
+ fOverlayStore.removePropertyChangeListener(fPreferenceChangeListener);
+ fPreferenceChangeListener= null;
+ }
+ fOverlayStore.stop();
+ fOverlayStore= null;
+ }
+
+ super.dispose();
+ }
+
static public boolean getSaveAllEditors() {
IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(PREF_SAVE_ALL_EDITORS);
@@ -44,40 +160,143 @@ public class ComparePreferencePage extends FieldEditorPreferencePage implements
store.setValue(PREF_SAVE_ALL_EDITORS, value);
}
- public void init(IWorkbench workbench) {
- }
+ /*
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+
+ fOverlayStore.load();
+ fOverlayStore.start();
+
+ Composite composite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 1;
+ composite.setLayout(layout);
+
+ addCheckBox(composite, "ComparePreferences.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferences.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferences.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferences.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+
+ fFontEditor= addTextFontEditor(composite, "ComparePreferences.textFont.label", TEXT_FONT); //$NON-NLS-1$
+ fFontEditor.setPreferenceStore(getPreferenceStore());
+ fFontEditor.setPreferencePage(this);
+ fFontEditor.load();
+
+ Label previewLabel= new Label(composite, SWT.NULL);
+ previewLabel.setText("Preview:");
+
+ Control previewer= createPreviewer(composite);
+ GridData gd= new GridData(GridData.FILL_BOTH);
+ gd.widthHint= convertWidthInCharsToPixels(80);
+ gd.heightHint= convertHeightInCharsToPixels(15);
+ previewer.setLayoutData(gd);
+
+ initializeFields();
+
+ return composite;
+ }
+
+ private Control createPreviewer(Composite parent) {
+
+ fCompareConfiguration= new CompareConfiguration(fOverlayStore);
+ fCompareConfiguration.setAncestorLabel("Common Ancestor");
+
+ fCompareConfiguration.setLeftLabel("Local");
+ fCompareConfiguration.setLeftEditable(false);
+
+ fCompareConfiguration.setRightLabel("Remote");
+ fCompareConfiguration.setRightEditable(false);
+
+ fTextMergeViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration);
+
+ fTextMergeViewer.setInput(
+ new DiffNode(Differencer.CONFLICTING,
+ new FakeInput("previewAncestor.txt"), //$NON-NLS-1$
+ new FakeInput("previewLeft.txt"), //$NON-NLS-1$
+ new FakeInput("previewRight.txt") //$NON-NLS-1$
+ )
+ );
- protected IPreferenceStore doGetPreferenceStore() {
- return CompareUIPlugin.getDefault().getPreferenceStore();
+ return fTextMergeViewer.getControl();
+ }
+
+ private void initializeFields() {
+
+ Iterator e= fCheckBoxes.keySet().iterator();
+ while (e.hasNext()) {
+ Button b= (Button) e.next();
+ String key= (String) fCheckBoxes.get(b);
+ b.setSelection(fOverlayStore.getBoolean(key));
+ }
}
- public void createFieldEditors() {
-
- Composite parent= getFieldEditorParent();
-
- {
- BooleanFieldEditor editor= new BooleanFieldEditor(SYNCHRONIZE_SCROLLING,
- Utilities.getString("ComparePreferences.synchronizeScrolling.label"), BooleanFieldEditor.DEFAULT, parent); //$NON-NLS-1$
- addField(editor);
+ // overlay stuff
+
+ private SelectionListener fCheckBoxListener= new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Button button= (Button) e.widget;
+ fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
}
+ };
+
+ private WorkbenchChainedTextFontFieldEditor addTextFontEditor(Composite parent, String labelKey, String key) {
- // three way merging
- {
- BooleanFieldEditor editor= new BooleanFieldEditor(SHOW_PSEUDO_CONFLICTS,
- Utilities.getString("ComparePreferences.showPseudoConflicts.label"), BooleanFieldEditor.DEFAULT, parent); //$NON-NLS-1$
- addField(editor);
- }
+ String label= Utilities.getString(labelKey);
+
+ Composite editorComposite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 3;
+ editorComposite.setLayout(layout);
+ WorkbenchChainedTextFontFieldEditor fe= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
+ //fFontEditor.setChangeButtonText("C&hange...");
+
+ GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan= 2;
+ editorComposite.setLayoutData(gd);
- {
- BooleanFieldEditor editor= new BooleanFieldEditor(INITIALLY_SHOW_ANCESTOR_PANE,
- Utilities.getString("ComparePreferences.initiallyShowAncestorPane.label"), BooleanFieldEditor.DEFAULT, parent); //$NON-NLS-1$
- addField(editor);
- }
+ return fe;
+ }
+
+ private Button addCheckBox(Composite parent, String labelKey, String key, int indentation) {
+
+ String label= Utilities.getString(labelKey);
+
+ Button checkBox= new Button(parent, SWT.CHECK);
+ checkBox.setText(label);
- {
- WorkbenchChainedTextFontFieldEditor editor= new WorkbenchChainedTextFontFieldEditor(TEXT_FONT,
- Utilities.getString("ComparePreferences.textFont.label"), parent); //$NON-NLS-1$
- addField(editor);
+ GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalIndent= indentation;
+ gd.horizontalSpan= 2;
+ checkBox.setLayoutData(gd);
+ checkBox.addSelectionListener(fCheckBoxListener);
+
+ fCheckBoxes.put(checkBox, key);
+
+ return checkBox;
+ }
+
+ private String loadPreviewContentFromFile(String filename) {
+ String line;
+ String separator= System.getProperty("line.separator"); //$NON-NLS-1$
+ StringBuffer buffer= new StringBuffer(512);
+ BufferedReader reader= null;
+ try {
+ reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
+ while ((line= reader.readLine()) != null) {
+ buffer.append(line);
+ buffer.append(separator);
+ }
+ } catch (IOException io) {
+ CompareUIPlugin.log(io);
+ } finally {
+ if (reader != null) {
+ try { reader.close(); } catch (IOException e) {}
+ }
}
+ return buffer.toString();
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
new file mode 100644
index 000000000..7c0a7f475
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
@@ -0,0 +1,446 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+package org.eclipse.compare.internal;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * An overlaying preference store.
+ */
+public class OverlayPreferenceStore implements IPreferenceStore {
+
+
+ public static final class TypeDescriptor {
+ private TypeDescriptor() {
+ }
+ };
+
+ public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
+ public static final TypeDescriptor DOUBLE= new TypeDescriptor();
+ public static final TypeDescriptor FLOAT= new TypeDescriptor();
+ public static final TypeDescriptor INT= new TypeDescriptor();
+ public static final TypeDescriptor LONG= new TypeDescriptor();
+ public static final TypeDescriptor STRING= new TypeDescriptor();
+
+ public static class OverlayKey {
+
+ TypeDescriptor fDescriptor;
+ String fKey;
+
+ public OverlayKey(TypeDescriptor descriptor, String key) {
+ fDescriptor= descriptor;
+ fKey= key;
+ }
+ };
+
+ private class PropertyListener implements IPropertyChangeListener {
+
+ /*
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ OverlayKey key= findOverlayKey(event.getProperty());
+ if (key != null)
+ propagateProperty(fParent, key, fStore);
+ }
+ };
+
+
+ private IPreferenceStore fParent;
+ private IPreferenceStore fStore;
+ private OverlayKey[] fOverlayKeys;
+
+ private PropertyListener fPropertyListener;
+
+
+ public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
+ fParent= parent;
+ fOverlayKeys= overlayKeys;
+ fStore= new PreferenceStore();
+ }
+
+ private OverlayKey findOverlayKey(String key) {
+ for (int i= 0; i < fOverlayKeys.length; i++) {
+ if (fOverlayKeys[i].fKey.equals(key))
+ return fOverlayKeys[i];
+ }
+ return null;
+ }
+
+ private boolean covers(String key) {
+ return (findOverlayKey(key) != null);
+ }
+
+ private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
+
+ if (orgin.isDefault(key.fKey)) {
+ if (!target.isDefault(key.fKey))
+ target.setToDefault(key.fKey);
+ return;
+ }
+
+ TypeDescriptor d= key.fDescriptor;
+ if (BOOLEAN == d) {
+
+ boolean originValue= orgin.getBoolean(key.fKey);
+ boolean targetValue= target.getBoolean(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (DOUBLE == d) {
+
+ double originValue= orgin.getDouble(key.fKey);
+ double targetValue= target.getDouble(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (FLOAT == d) {
+
+ float originValue= orgin.getFloat(key.fKey);
+ float targetValue= target.getFloat(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (INT == d) {
+
+ int originValue= orgin.getInt(key.fKey);
+ int targetValue= target.getInt(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (LONG == d) {
+
+ long originValue= orgin.getLong(key.fKey);
+ long targetValue= target.getLong(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (STRING == d) {
+
+ String originValue= orgin.getString(key.fKey);
+ String targetValue= target.getString(key.fKey);
+ if (targetValue != null && originValue != null && !targetValue.equals(originValue))
+ target.setValue(key.fKey, originValue);
+
+ }
+ }
+
+ public void propagate() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ propagateProperty(fStore, fOverlayKeys[i], fParent);
+ }
+
+ private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
+ TypeDescriptor d= key.fDescriptor;
+ if (BOOLEAN == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, true);
+ target.setValue(key.fKey, orgin.getBoolean(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
+
+ } else if (DOUBLE == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1.0D);
+ target.setValue(key.fKey, orgin.getDouble(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
+
+ } else if (FLOAT == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1.0F);
+ target.setValue(key.fKey, orgin.getFloat(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
+
+ } else if (INT == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1);
+ target.setValue(key.fKey, orgin.getInt(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
+
+ } else if (LONG == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1L);
+ target.setValue(key.fKey, orgin.getLong(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
+
+ } else if (STRING == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, "1");
+ target.setValue(key.fKey, orgin.getString(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
+
+ }
+ }
+
+ public void load() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ loadProperty(fParent, fOverlayKeys[i], fStore, true);
+ }
+
+ public void loadDefaults() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ setToDefault(fOverlayKeys[i].fKey);
+ }
+
+ public void start() {
+ if (fPropertyListener == null) {
+ fPropertyListener= new PropertyListener();
+ fParent.addPropertyChangeListener(fPropertyListener);
+ }
+ }
+
+ public void stop() {
+ if (fPropertyListener != null) {
+ fParent.removePropertyChangeListener(fPropertyListener);
+ fPropertyListener= null;
+ }
+ }
+
+ /*
+ * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ fStore.addPropertyChangeListener(listener);
+ }
+
+ /*
+ * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ fStore.removePropertyChangeListener(listener);
+ }
+
+ /*
+ * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+ fStore.firePropertyChangeEvent(name, oldValue, newValue);
+ }
+
+ /*
+ * @see IPreferenceStore#contains(String)
+ */
+ public boolean contains(String name) {
+ return fStore.contains(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getBoolean(String)
+ */
+ public boolean getBoolean(String name) {
+ return fStore.getBoolean(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultBoolean(String)
+ */
+ public boolean getDefaultBoolean(String name) {
+ return fStore.getDefaultBoolean(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultDouble(String)
+ */
+ public double getDefaultDouble(String name) {
+ return fStore.getDefaultDouble(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultFloat(String)
+ */
+ public float getDefaultFloat(String name) {
+ return fStore.getDefaultFloat(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultInt(String)
+ */
+ public int getDefaultInt(String name) {
+ return fStore.getDefaultInt(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultLong(String)
+ */
+ public long getDefaultLong(String name) {
+ return fStore.getDefaultLong(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultString(String)
+ */
+ public String getDefaultString(String name) {
+ return fStore.getDefaultString(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDouble(String)
+ */
+ public double getDouble(String name) {
+ return fStore.getDouble(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getFloat(String)
+ */
+ public float getFloat(String name) {
+ return fStore.getFloat(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getInt(String)
+ */
+ public int getInt(String name) {
+ return fStore.getInt(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getLong(String)
+ */
+ public long getLong(String name) {
+ return fStore.getLong(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getString(String)
+ */
+ public String getString(String name) {
+ return fStore.getString(name);
+ }
+
+ /*
+ * @see IPreferenceStore#isDefault(String)
+ */
+ public boolean isDefault(String name) {
+ return fStore.isDefault(name);
+ }
+
+ /*
+ * @see IPreferenceStore#needsSaving()
+ */
+ public boolean needsSaving() {
+ return fStore.needsSaving();
+ }
+
+ /*
+ * @see IPreferenceStore#putValue(String, String)
+ */
+ public void putValue(String name, String value) {
+ if (covers(name))
+ fStore.putValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, double)
+ */
+ public void setDefault(String name, double value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, float)
+ */
+ public void setDefault(String name, float value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, int)
+ */
+ public void setDefault(String name, int value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, long)
+ */
+ public void setDefault(String name, long value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, String)
+ */
+ public void setDefault(String name, String value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, boolean)
+ */
+ public void setDefault(String name, boolean value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setToDefault(String)
+ */
+ public void setToDefault(String name) {
+ fStore.setToDefault(name);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, double)
+ */
+ public void setValue(String name, double value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, float)
+ */
+ public void setValue(String name, float value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, int)
+ */
+ public void setValue(String name, int value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, long)
+ */
+ public void setValue(String name, long value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, String)
+ */
+ public void setValue(String name, String value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, boolean)
+ */
+ public void setValue(String name, boolean value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt
new file mode 100644
index 000000000..8f848397c
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt
@@ -0,0 +1,10 @@
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt
new file mode 100644
index 000000000..e24e0aaf1
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt
@@ -0,0 +1,10 @@
+a
+x
+c
+z
+e
+f
+g
+h
+i
+j \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt
new file mode 100644
index 000000000..b45f220e6
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt
@@ -0,0 +1,10 @@
+a
+y
+c
+z
+e
+f
+g
+h
+i
+j \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index cdfca2919..09e7ea489 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -57,11 +57,13 @@ ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with
#
# Preference Page
#
-ComparePreferencePage.name= Compare Viewers
-ComparePreferences.initiallyShowAncestorPane.label= Show A&ncestor Pane Initially
-ComparePreferences.showPseudoConflicts.label= Show &Pseudo Conflicts
-ComparePreferences.synchronizeScrolling.label= Synchronize &Scrolling Between Panes in Compare/Merge Viewers
-ComparePreferences.textFont.label= Text Font:
+ComparePreferencePage.name= Compare
+ComparePreferencePage.description= General Settings for Compare/Merge Functionality.
+ComparePreferences.initiallyShowAncestorPane.label= Initially show a&ncestor pane
+ComparePreferences.showPseudoConflicts.label= Show &pseudo conflicts
+ComparePreferences.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
+ComparePreferences.textFont.label= Text font:
+ComparePreferences.showMoreInfo.label= Show additional compare &information in status line
#
# Toolbar actions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
index 5de800fc0..48bf1e839 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
@@ -15,7 +15,9 @@ Eclipse Build Input February 26th 2002
<h2>
What's new in this drop</h2>
-Patch: for every rejected file a task marker is added
+Patch: for every rejected file a task marker is added<br>
+Compare preference page shows options in a preview<br>
+New preference option for additional compare status line information
<h3>
API changes</h3>
@@ -34,6 +36,7 @@ Problem reports fixed</h2>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9540">#9540</a>: Compare with patch: it should not be possible to check items that could not be applied<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9532">#9532</a>: Compare with patch: next disabled although clipboard specified<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7681">#7681</a>: Structured results expands import statements<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=9572">#9572</a>: Debugging trace left in status bar<br>
<h2>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
index 35d4147b8..666f99e26 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
@@ -86,6 +86,7 @@ public class CompareConfiguration {
// fgImages[Differencer.DELETION]= tmp;
}
+ private IPreferenceStore fPreferenceStore;
private ListenerList fListeners= new ListenerList();
private HashMap fProperties= new HashMap();
private boolean fLeftEditable= true;
@@ -102,17 +103,33 @@ public class CompareConfiguration {
* Creates a new configuration with editable left and right sides,
* suitable default labels, and no images.
*/
- public CompareConfiguration() {
+ public CompareConfiguration(IPreferenceStore prefStore) {
setProperty("LEFT_IS_LOCAL", new Boolean(fLeftIsLocal)); //$NON-NLS-1$
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null) {
- boolean b= ps.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
+ fPreferenceStore= prefStore;
+ if (fPreferenceStore != null) {
+ boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
setProperty(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b));
}
}
-
+
+ /**
+ * Creates a new configuration with editable left and right sides,
+ * suitable default labels, and no images.
+ */
+ public CompareConfiguration() {
+ this(CompareUIPlugin.getDefault().getPreferenceStore());
+ }
+
+ /**
+ * Returns the preference store of this configuration.
+ * @return the preference store of this configuration.
+ */
+ public IPreferenceStore getPreferenceStore() {
+ return fPreferenceStore;
+ }
+
/**
* Returns an image showing the specified change kind.
* The different kind of changes are defined in the <code>Differencer</code>.
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 987d42cd7..169fa34d4 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
@@ -284,15 +284,15 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
}
};
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- ContentMergeViewer.this.propertyChange(event);
- }
- };
-
fCompareConfiguration= cc;
- if (fCompareConfiguration != null)
+ if (fCompareConfiguration != null) {
+ fPropertyChangeListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ ContentMergeViewer.this.propertyChange(event);
+ }
+ };
fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener);
+ }
fLeftSaveAction= new SaveAction(true);
fLeftSaveAction.setEnabled(false);
@@ -716,8 +716,10 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
if (input instanceof ICompareInput)
((ICompareInput)input).removeCompareInputChangeListener(fCompareInputChangeListener);
- if (fCompareConfiguration != null)
+ if (fCompareConfiguration != null && fPropertyChangeListener != null) {
fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener);
+ fPropertyChangeListener= null;
+ }
fAncestorLabel= null;
fLeftLabel= null;
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 9d894a9ae..4a03643ab 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
@@ -197,6 +197,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private IDocumentListener fDocumentListener;
+ private IPreferenceStore fPreferenceStore;
private IPropertyChangeListener fPreferenceChangeListener;
/** All diffs for calculating scrolling position (includes line ranges without changes) */
@@ -220,10 +221,10 @@ public class TextMergeViewer extends ContentMergeViewer {
private int fPts[]= new int[8]; // scratch area for polygon drawing
- //PR1GI3HDZ
private boolean fIgnoreAncestor= false;
private ActionContributionItem fIgnoreAncestorItem;
- //end PR1GI3HDZ
+
+ private boolean fShowPseudoConflicts= false;
private ActionContributionItem fNextItem; // goto next difference
private ActionContributionItem fPreviousItem; // goto previous difference
@@ -231,6 +232,7 @@ public class TextMergeViewer extends ContentMergeViewer {
private ActionContributionItem fCopyDiffRightToLeftItem;
private boolean fSynchronizedScrolling= true;
+ private boolean fShowMoreInfo= false;
private MergeSourceViewer fFocusPart;
@@ -442,19 +444,21 @@ public class TextMergeViewer extends ContentMergeViewer {
if (fIsMotif)
fMarginWidth= 0;
-
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null) {
+
+ fPreferenceStore= configuration.getPreferenceStore();
+ if (fPreferenceStore != null) {
fPreferenceChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
TextMergeViewer.this.propertyChange(event);
}
};
- ps.addPropertyChangeListener(fPreferenceChangeListener);
+ fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
- updateFont(ps, parent);
+ updateFont(fPreferenceStore, parent);
fLeftIsLocal= Utilities.getBoolean(configuration, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
- fSynchronizedScrolling= ps.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
+ fSynchronizedScrolling= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
+ fShowMoreInfo= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO);
+ fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS);
}
fDocumentListener= new IDocumentListener() {
@@ -550,9 +554,8 @@ public class TextMergeViewer extends ContentMergeViewer {
protected void handleDispose(DisposeEvent event) {
if (fPreferenceChangeListener != null) {
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null)
- ps.removePropertyChangeListener(fPreferenceChangeListener);
+ if (fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
fPreferenceChangeListener= null;
}
@@ -1273,7 +1276,7 @@ public class TextMergeViewer extends ContentMergeViewer {
continue;
}
- if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
+ if (useChange(kind)) {
fChangeDiffs.add(diff); // here we remember only the real diffs
updateDiffBackground(diff);
@@ -1311,6 +1314,17 @@ public class TextMergeViewer extends ContentMergeViewer {
}
}
+ /**
+ * Returns true if kind of change should be shown.
+ */
+ private boolean useChange(int kind) {
+ if (kind == RangeDifference.NOCHANGE)
+ return false;
+ if (kind == RangeDifference.ANCESTOR)
+ return fShowPseudoConflicts;
+ return true;
+ }
+
private int getTokenEnd(ITokenComparator tc, int start, int count) {
if (count <= 0)
return tc.getTokenStart(start);
@@ -1463,8 +1477,7 @@ public class TextMergeViewer extends ContentMergeViewer {
RangeDifference first= null;
for (int ii= start; ii < end; ii++) {
es= r[ii];
- int kind= es.kind();
- if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
+ if (useChange(es.kind())) {
first= es;
break;
}
@@ -1474,8 +1487,7 @@ public class TextMergeViewer extends ContentMergeViewer {
RangeDifference last= null;
for (int ii= end-1; ii >= start; ii--) {
es= r[ii];
- int kind= es.kind();
- if (kind != RangeDifference.NOCHANGE && kind != RangeDifference.ANCESTOR) {
+ if (useChange(es.kind())) {
last= es;
break;
}
@@ -1557,6 +1569,9 @@ public class TextMergeViewer extends ContentMergeViewer {
private void updateStatus(Diff diff) {
+ if (! fShowMoreInfo)
+ return;
+
IActionBars bars= Utilities.findActionBars(fComposite);
if (bars == null)
return;
@@ -1596,6 +1611,18 @@ public class TextMergeViewer extends ContentMergeViewer {
slm.setMessage(s);
}
+ private void clearStatus() {
+
+ IActionBars bars= Utilities.findActionBars(fComposite);
+ if (bars == null)
+ return;
+ IStatusLineManager slm= bars.getStatusLineManager();
+ if (slm == null)
+ return;
+
+ slm.setMessage(null);
+ }
+
private String getDiffType(Diff diff) {
String s= "";
switch(diff.fDirection) {
@@ -1751,7 +1778,11 @@ public class TextMergeViewer extends ContentMergeViewer {
String key= event.getProperty();
- if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)) {
+ if (key.equals(CompareConfiguration.IGNORE_WHITESPACE)
+ || key.equals(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS)) {
+
+ fShowPseudoConflicts= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS);
+
// clear stuff
fCurrentDiff= null;
fChangeDiffs= null;
@@ -1766,20 +1797,28 @@ public class TextMergeViewer extends ContentMergeViewer {
selectFirstDiff();
} else if (key.equals(TEXT_FONT)) {
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
- if (ps != null) {
- updateFont(ps, fComposite);
+ if (fPreferenceStore != null) {
+ updateFont(fPreferenceStore, fComposite);
invalidateLines();
}
} else if (key.equals(ComparePreferencePage.SYNCHRONIZE_SCROLLING)) {
- IPreferenceStore ps= CompareUIPlugin.getDefault().getPreferenceStore();
-
- boolean b= ps.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
+ boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
if (b != fSynchronizedScrolling)
toggleSynchMode();
+ } else if (key.equals(ComparePreferencePage.SHOW_MORE_INFO)) {
+
+ boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_MORE_INFO);
+ if (b != fShowMoreInfo) {
+ fShowMoreInfo= b;
+ if (fShowMoreInfo)
+ updateStatus(fCurrentDiff);
+ else
+ clearStatus();
+ }
+
} else
super.propertyChange(event);
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index f8a64840f..ed70e23d6 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -4,36 +4,152 @@
*/
package org.eclipse.compare.internal;
-import org.eclipse.swt.widgets.Composite;
+import java.util.*;
+import java.io.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.preference.*;
+import org.eclipse.jface.util.*;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
+import org.eclipse.compare.*;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.structuremergeviewer.*;
+
-public class ComparePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+public class ComparePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ class FakeInput implements ITypedElement, IStreamContentAccessor {
+ String fContent;
+
+ FakeInput(String name) {
+ fContent= loadPreviewContentFromFile(name);
+ }
+ public Image getImage() {
+ return null;
+ }
+ public String getName() {
+ return "Name"; //$NON-NLS-1$
+ }
+ public String getType() {
+ return "Type"; //$NON-NLS-1$
+ }
+ public InputStream getContents() {
+ return new ByteArrayInputStream(fContent.getBytes());
+ }
+ };
+
private static final String PREFIX= CompareUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
public static final String SYNCHRONIZE_SCROLLING= PREFIX + "SynchronizeScrolling"; //$NON-NLS-1$
public static final String SHOW_PSEUDO_CONFLICTS= PREFIX + "ShowPseudoConflicts"; //$NON-NLS-1$
public static final String INITIALLY_SHOW_ANCESTOR_PANE= PREFIX + "InitiallyShowAncestorPane"; //$NON-NLS-1$
public static final String PREF_SAVE_ALL_EDITORS= PREFIX + "SaveAllEditors"; //$NON-NLS-1$
+ public static final String SHOW_MORE_INFO= PREFIX + "ShowMoreInfo"; //$NON-NLS-1$
public static final String TEXT_FONT= PREFIX + "TextFont"; //$NON-NLS-1$
+
+ private WorkbenchChainedTextFontFieldEditor fFontEditor;
+ private TextMergeViewer fTextMergeViewer;
+ private IPropertyChangeListener fPreferenceChangeListener;
+ private CompareConfiguration fCompareConfiguration;
+ private OverlayPreferenceStore fOverlayStore;
+ private Map fCheckBoxes= new HashMap();
+
- public ComparePreferencePage() {
- super(GRID);
- }
+ public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_PSEUDO_CONFLICTS),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_MORE_INFO),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TEXT_FONT)
+ };
+
public static void initDefaults(IPreferenceStore store) {
store.setDefault(SYNCHRONIZE_SCROLLING, true);
store.setDefault(SHOW_PSEUDO_CONFLICTS, false);
store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false);
+ store.setDefault(SHOW_MORE_INFO, false);
WorkbenchChainedTextFontFieldEditor.startPropagate(store, TEXT_FONT);
}
+ public ComparePreferencePage() {
+
+ //setDescription(Utilities.getString("ComparePreferencePage.description")); //$NON-NLS-1$
+
+ setPreferenceStore(CompareUIPlugin.getDefault().getPreferenceStore());
+
+ fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys);
+ fPreferenceChangeListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ String key= event.getProperty();
+ if (key.equals(INITIALLY_SHOW_ANCESTOR_PANE)) {
+ boolean b= fOverlayStore.getBoolean(INITIALLY_SHOW_ANCESTOR_PANE);
+ if (fCompareConfiguration != null) {
+ fCompareConfiguration.setProperty(INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b));
+ }
+ }
+ }
+ };
+ fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener);
+ }
+
+ public void init(IWorkbench workbench) {
+ }
+
+ /*
+ * @see PreferencePage#performOk()
+ */
+ public boolean performOk() {
+ fFontEditor.store();
+ fOverlayStore.propagate();
+ return true;
+ }
+
+ /*
+ * @see PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+
+ fFontEditor.loadDefault();
+
+ fOverlayStore.loadDefaults();
+ initializeFields();
+
+ super.performDefaults();
+
+ //fPreviewViewer.invalidateTextPresentation();
+ }
+
+ /*
+ * @see DialogPage#dispose()
+ */
+ public void dispose() {
+
+ fFontEditor.setPreferencePage(null);
+ fFontEditor.setPreferenceStore(null);
+
+ if (fOverlayStore != null) {
+ if (fPreferenceChangeListener != null) {
+ fOverlayStore.removePropertyChangeListener(fPreferenceChangeListener);
+ fPreferenceChangeListener= null;
+ }
+ fOverlayStore.stop();
+ fOverlayStore= null;
+ }
+
+ super.dispose();
+ }
+
static public boolean getSaveAllEditors() {
IPreferenceStore store= CompareUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(PREF_SAVE_ALL_EDITORS);
@@ -44,40 +160,143 @@ public class ComparePreferencePage extends FieldEditorPreferencePage implements
store.setValue(PREF_SAVE_ALL_EDITORS, value);
}
- public void init(IWorkbench workbench) {
- }
+ /*
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+
+ fOverlayStore.load();
+ fOverlayStore.start();
+
+ Composite composite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 1;
+ composite.setLayout(layout);
+
+ addCheckBox(composite, "ComparePreferences.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferences.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferences.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
+
+ addCheckBox(composite, "ComparePreferences.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+
+ fFontEditor= addTextFontEditor(composite, "ComparePreferences.textFont.label", TEXT_FONT); //$NON-NLS-1$
+ fFontEditor.setPreferenceStore(getPreferenceStore());
+ fFontEditor.setPreferencePage(this);
+ fFontEditor.load();
+
+ Label previewLabel= new Label(composite, SWT.NULL);
+ previewLabel.setText("Preview:");
+
+ Control previewer= createPreviewer(composite);
+ GridData gd= new GridData(GridData.FILL_BOTH);
+ gd.widthHint= convertWidthInCharsToPixels(80);
+ gd.heightHint= convertHeightInCharsToPixels(15);
+ previewer.setLayoutData(gd);
+
+ initializeFields();
+
+ return composite;
+ }
+
+ private Control createPreviewer(Composite parent) {
+
+ fCompareConfiguration= new CompareConfiguration(fOverlayStore);
+ fCompareConfiguration.setAncestorLabel("Common Ancestor");
+
+ fCompareConfiguration.setLeftLabel("Local");
+ fCompareConfiguration.setLeftEditable(false);
+
+ fCompareConfiguration.setRightLabel("Remote");
+ fCompareConfiguration.setRightEditable(false);
+
+ fTextMergeViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration);
+
+ fTextMergeViewer.setInput(
+ new DiffNode(Differencer.CONFLICTING,
+ new FakeInput("previewAncestor.txt"), //$NON-NLS-1$
+ new FakeInput("previewLeft.txt"), //$NON-NLS-1$
+ new FakeInput("previewRight.txt") //$NON-NLS-1$
+ )
+ );
- protected IPreferenceStore doGetPreferenceStore() {
- return CompareUIPlugin.getDefault().getPreferenceStore();
+ return fTextMergeViewer.getControl();
+ }
+
+ private void initializeFields() {
+
+ Iterator e= fCheckBoxes.keySet().iterator();
+ while (e.hasNext()) {
+ Button b= (Button) e.next();
+ String key= (String) fCheckBoxes.get(b);
+ b.setSelection(fOverlayStore.getBoolean(key));
+ }
}
- public void createFieldEditors() {
-
- Composite parent= getFieldEditorParent();
-
- {
- BooleanFieldEditor editor= new BooleanFieldEditor(SYNCHRONIZE_SCROLLING,
- Utilities.getString("ComparePreferences.synchronizeScrolling.label"), BooleanFieldEditor.DEFAULT, parent); //$NON-NLS-1$
- addField(editor);
+ // overlay stuff
+
+ private SelectionListener fCheckBoxListener= new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Button button= (Button) e.widget;
+ fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
}
+ };
+
+ private WorkbenchChainedTextFontFieldEditor addTextFontEditor(Composite parent, String labelKey, String key) {
- // three way merging
- {
- BooleanFieldEditor editor= new BooleanFieldEditor(SHOW_PSEUDO_CONFLICTS,
- Utilities.getString("ComparePreferences.showPseudoConflicts.label"), BooleanFieldEditor.DEFAULT, parent); //$NON-NLS-1$
- addField(editor);
- }
+ String label= Utilities.getString(labelKey);
+
+ Composite editorComposite= new Composite(parent, SWT.NULL);
+ GridLayout layout= new GridLayout();
+ layout.numColumns= 3;
+ editorComposite.setLayout(layout);
+ WorkbenchChainedTextFontFieldEditor fe= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
+ //fFontEditor.setChangeButtonText("C&hange...");
+
+ GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan= 2;
+ editorComposite.setLayoutData(gd);
- {
- BooleanFieldEditor editor= new BooleanFieldEditor(INITIALLY_SHOW_ANCESTOR_PANE,
- Utilities.getString("ComparePreferences.initiallyShowAncestorPane.label"), BooleanFieldEditor.DEFAULT, parent); //$NON-NLS-1$
- addField(editor);
- }
+ return fe;
+ }
+
+ private Button addCheckBox(Composite parent, String labelKey, String key, int indentation) {
+
+ String label= Utilities.getString(labelKey);
+
+ Button checkBox= new Button(parent, SWT.CHECK);
+ checkBox.setText(label);
- {
- WorkbenchChainedTextFontFieldEditor editor= new WorkbenchChainedTextFontFieldEditor(TEXT_FONT,
- Utilities.getString("ComparePreferences.textFont.label"), parent); //$NON-NLS-1$
- addField(editor);
+ GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalIndent= indentation;
+ gd.horizontalSpan= 2;
+ checkBox.setLayoutData(gd);
+ checkBox.addSelectionListener(fCheckBoxListener);
+
+ fCheckBoxes.put(checkBox, key);
+
+ return checkBox;
+ }
+
+ private String loadPreviewContentFromFile(String filename) {
+ String line;
+ String separator= System.getProperty("line.separator"); //$NON-NLS-1$
+ StringBuffer buffer= new StringBuffer(512);
+ BufferedReader reader= null;
+ try {
+ reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
+ while ((line= reader.readLine()) != null) {
+ buffer.append(line);
+ buffer.append(separator);
+ }
+ } catch (IOException io) {
+ CompareUIPlugin.log(io);
+ } finally {
+ if (reader != null) {
+ try { reader.close(); } catch (IOException e) {}
+ }
}
+ return buffer.toString();
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
new file mode 100644
index 000000000..7c0a7f475
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/OverlayPreferenceStore.java
@@ -0,0 +1,446 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+package org.eclipse.compare.internal;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * An overlaying preference store.
+ */
+public class OverlayPreferenceStore implements IPreferenceStore {
+
+
+ public static final class TypeDescriptor {
+ private TypeDescriptor() {
+ }
+ };
+
+ public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
+ public static final TypeDescriptor DOUBLE= new TypeDescriptor();
+ public static final TypeDescriptor FLOAT= new TypeDescriptor();
+ public static final TypeDescriptor INT= new TypeDescriptor();
+ public static final TypeDescriptor LONG= new TypeDescriptor();
+ public static final TypeDescriptor STRING= new TypeDescriptor();
+
+ public static class OverlayKey {
+
+ TypeDescriptor fDescriptor;
+ String fKey;
+
+ public OverlayKey(TypeDescriptor descriptor, String key) {
+ fDescriptor= descriptor;
+ fKey= key;
+ }
+ };
+
+ private class PropertyListener implements IPropertyChangeListener {
+
+ /*
+ * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ OverlayKey key= findOverlayKey(event.getProperty());
+ if (key != null)
+ propagateProperty(fParent, key, fStore);
+ }
+ };
+
+
+ private IPreferenceStore fParent;
+ private IPreferenceStore fStore;
+ private OverlayKey[] fOverlayKeys;
+
+ private PropertyListener fPropertyListener;
+
+
+ public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
+ fParent= parent;
+ fOverlayKeys= overlayKeys;
+ fStore= new PreferenceStore();
+ }
+
+ private OverlayKey findOverlayKey(String key) {
+ for (int i= 0; i < fOverlayKeys.length; i++) {
+ if (fOverlayKeys[i].fKey.equals(key))
+ return fOverlayKeys[i];
+ }
+ return null;
+ }
+
+ private boolean covers(String key) {
+ return (findOverlayKey(key) != null);
+ }
+
+ private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
+
+ if (orgin.isDefault(key.fKey)) {
+ if (!target.isDefault(key.fKey))
+ target.setToDefault(key.fKey);
+ return;
+ }
+
+ TypeDescriptor d= key.fDescriptor;
+ if (BOOLEAN == d) {
+
+ boolean originValue= orgin.getBoolean(key.fKey);
+ boolean targetValue= target.getBoolean(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (DOUBLE == d) {
+
+ double originValue= orgin.getDouble(key.fKey);
+ double targetValue= target.getDouble(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (FLOAT == d) {
+
+ float originValue= orgin.getFloat(key.fKey);
+ float targetValue= target.getFloat(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (INT == d) {
+
+ int originValue= orgin.getInt(key.fKey);
+ int targetValue= target.getInt(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (LONG == d) {
+
+ long originValue= orgin.getLong(key.fKey);
+ long targetValue= target.getLong(key.fKey);
+ if (targetValue != originValue)
+ target.setValue(key.fKey, originValue);
+
+ } else if (STRING == d) {
+
+ String originValue= orgin.getString(key.fKey);
+ String targetValue= target.getString(key.fKey);
+ if (targetValue != null && originValue != null && !targetValue.equals(originValue))
+ target.setValue(key.fKey, originValue);
+
+ }
+ }
+
+ public void propagate() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ propagateProperty(fStore, fOverlayKeys[i], fParent);
+ }
+
+ private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
+ TypeDescriptor d= key.fDescriptor;
+ if (BOOLEAN == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, true);
+ target.setValue(key.fKey, orgin.getBoolean(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
+
+ } else if (DOUBLE == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1.0D);
+ target.setValue(key.fKey, orgin.getDouble(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
+
+ } else if (FLOAT == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1.0F);
+ target.setValue(key.fKey, orgin.getFloat(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
+
+ } else if (INT == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1);
+ target.setValue(key.fKey, orgin.getInt(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
+
+ } else if (LONG == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, 1L);
+ target.setValue(key.fKey, orgin.getLong(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
+
+ } else if (STRING == d) {
+
+ if (forceInitialization)
+ target.setValue(key.fKey, "1");
+ target.setValue(key.fKey, orgin.getString(key.fKey));
+ target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
+
+ }
+ }
+
+ public void load() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ loadProperty(fParent, fOverlayKeys[i], fStore, true);
+ }
+
+ public void loadDefaults() {
+ for (int i= 0; i < fOverlayKeys.length; i++)
+ setToDefault(fOverlayKeys[i].fKey);
+ }
+
+ public void start() {
+ if (fPropertyListener == null) {
+ fPropertyListener= new PropertyListener();
+ fParent.addPropertyChangeListener(fPropertyListener);
+ }
+ }
+
+ public void stop() {
+ if (fPropertyListener != null) {
+ fParent.removePropertyChangeListener(fPropertyListener);
+ fPropertyListener= null;
+ }
+ }
+
+ /*
+ * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ fStore.addPropertyChangeListener(listener);
+ }
+
+ /*
+ * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ fStore.removePropertyChangeListener(listener);
+ }
+
+ /*
+ * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+ fStore.firePropertyChangeEvent(name, oldValue, newValue);
+ }
+
+ /*
+ * @see IPreferenceStore#contains(String)
+ */
+ public boolean contains(String name) {
+ return fStore.contains(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getBoolean(String)
+ */
+ public boolean getBoolean(String name) {
+ return fStore.getBoolean(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultBoolean(String)
+ */
+ public boolean getDefaultBoolean(String name) {
+ return fStore.getDefaultBoolean(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultDouble(String)
+ */
+ public double getDefaultDouble(String name) {
+ return fStore.getDefaultDouble(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultFloat(String)
+ */
+ public float getDefaultFloat(String name) {
+ return fStore.getDefaultFloat(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultInt(String)
+ */
+ public int getDefaultInt(String name) {
+ return fStore.getDefaultInt(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultLong(String)
+ */
+ public long getDefaultLong(String name) {
+ return fStore.getDefaultLong(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDefaultString(String)
+ */
+ public String getDefaultString(String name) {
+ return fStore.getDefaultString(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getDouble(String)
+ */
+ public double getDouble(String name) {
+ return fStore.getDouble(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getFloat(String)
+ */
+ public float getFloat(String name) {
+ return fStore.getFloat(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getInt(String)
+ */
+ public int getInt(String name) {
+ return fStore.getInt(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getLong(String)
+ */
+ public long getLong(String name) {
+ return fStore.getLong(name);
+ }
+
+ /*
+ * @see IPreferenceStore#getString(String)
+ */
+ public String getString(String name) {
+ return fStore.getString(name);
+ }
+
+ /*
+ * @see IPreferenceStore#isDefault(String)
+ */
+ public boolean isDefault(String name) {
+ return fStore.isDefault(name);
+ }
+
+ /*
+ * @see IPreferenceStore#needsSaving()
+ */
+ public boolean needsSaving() {
+ return fStore.needsSaving();
+ }
+
+ /*
+ * @see IPreferenceStore#putValue(String, String)
+ */
+ public void putValue(String name, String value) {
+ if (covers(name))
+ fStore.putValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, double)
+ */
+ public void setDefault(String name, double value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, float)
+ */
+ public void setDefault(String name, float value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, int)
+ */
+ public void setDefault(String name, int value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, long)
+ */
+ public void setDefault(String name, long value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, String)
+ */
+ public void setDefault(String name, String value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setDefault(String, boolean)
+ */
+ public void setDefault(String name, boolean value) {
+ if (covers(name))
+ fStore.setDefault(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setToDefault(String)
+ */
+ public void setToDefault(String name) {
+ fStore.setToDefault(name);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, double)
+ */
+ public void setValue(String name, double value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, float)
+ */
+ public void setValue(String name, float value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, int)
+ */
+ public void setValue(String name, int value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, long)
+ */
+ public void setValue(String name, long value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, String)
+ */
+ public void setValue(String name, String value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+
+ /*
+ * @see IPreferenceStore#setValue(String, boolean)
+ */
+ public void setValue(String name, boolean value) {
+ if (covers(name))
+ fStore.setValue(name, value);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt
new file mode 100644
index 000000000..8f848397c
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewAncestor.txt
@@ -0,0 +1,10 @@
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt
new file mode 100644
index 000000000..e24e0aaf1
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewLeft.txt
@@ -0,0 +1,10 @@
+a
+x
+c
+z
+e
+f
+g
+h
+i
+j \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt
new file mode 100644
index 000000000..b45f220e6
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/previewRight.txt
@@ -0,0 +1,10 @@
+a
+y
+c
+z
+e
+f
+g
+h
+i
+j \ No newline at end of file
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 cdfca2919..09e7ea489 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -57,11 +57,13 @@ ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with
#
# Preference Page
#
-ComparePreferencePage.name= Compare Viewers
-ComparePreferences.initiallyShowAncestorPane.label= Show A&ncestor Pane Initially
-ComparePreferences.showPseudoConflicts.label= Show &Pseudo Conflicts
-ComparePreferences.synchronizeScrolling.label= Synchronize &Scrolling Between Panes in Compare/Merge Viewers
-ComparePreferences.textFont.label= Text Font:
+ComparePreferencePage.name= Compare
+ComparePreferencePage.description= General Settings for Compare/Merge Functionality.
+ComparePreferences.initiallyShowAncestorPane.label= Initially show a&ncestor pane
+ComparePreferences.showPseudoConflicts.label= Show &pseudo conflicts
+ComparePreferences.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
+ComparePreferences.textFont.label= Text font:
+ComparePreferences.showMoreInfo.label= Show additional compare &information in status line
#
# Toolbar actions

Back to the top