Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-03-01 11:40:39 -0500
committerAndre Weinand2002-03-01 11:40:39 -0500
commitf14781faacdb10aed4dda16b0f1bf6bc32292ccf (patch)
tree48671754c57b834daefb58c38508de50dba9ec38
parentd73e997665d8b3d6b685fdd6cbefdcd64dd93583 (diff)
downloadeclipse.platform.team-f14781faacdb10aed4dda16b0f1bf6bc32292ccf.tar.gz
eclipse.platform.team-f14781faacdb10aed4dda16b0f1bf6bc32292ccf.tar.xz
eclipse.platform.team-f14781faacdb10aed4dda16b0f1bf6bc32292ccf.zip
work on #9869 & improving compare pref page
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java28
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java42
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java63
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java11
-rw-r--r--bundles/org.eclipse.compare/plugin.properties15
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java28
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java42
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java63
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java11
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties15
10 files changed, 192 insertions, 126 deletions
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 169fa34d4..2ba364cf1 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
@@ -758,21 +758,21 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
if (fCopyLeftToRightAction != null) {
boolean enable= content.isRightEditable(input);
- if (enable && input instanceof ICompareInput) {
- ITypedElement e= ((ICompareInput) input).getLeft();
- if (e == null)
- enable= false;
- }
+// if (enable && input instanceof ICompareInput) {
+// ITypedElement e= ((ICompareInput) input).getLeft();
+// if (e == null)
+// enable= false;
+// }
fCopyLeftToRightAction.setEnabled(enable);
}
if (fCopyRightToLeftAction != null) {
boolean enable= content.isLeftEditable(input);
- if (enable && input instanceof ICompareInput) {
- ITypedElement e= ((ICompareInput) input).getRight();
- if (e == null)
- enable= false;
- }
+// if (enable && input instanceof ICompareInput) {
+// ITypedElement e= ((ICompareInput) input).getRight();
+// if (e == null)
+// enable= false;
+// }
fCopyRightToLeftAction.setEnabled(enable);
}
}
@@ -898,17 +898,23 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
// write back modified contents
IMergeViewerContentProvider content= (IMergeViewerContentProvider) getContentProvider();
+ boolean leftEmpty= content.getLeftContent(oldInput) != null;
+ boolean rightEmpty= content.getRightContent(oldInput) != null;
+
if (fCompareConfiguration.isLeftEditable() && fLeftSaveAction.isEnabled()) {
byte[] bytes= getContents(true);
+ if (leftEmpty && bytes != null && bytes.length == 0)
+ bytes= null;
setLeftDirty(false);
content.saveLeftContent(oldInput, bytes);
}
if (fCompareConfiguration.isRightEditable() && fRightSaveAction.isEnabled()) {
byte[] bytes= getContents(false);
+ if (rightEmpty && bytes != null && bytes.length == 0)
+ bytes= null;
setRightDirty(false);
content.saveRightContent(oldInput, bytes);
}
}
}
-
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 4a03643ab..13f45c50c 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
@@ -121,6 +121,7 @@ public class TextMergeViewer extends ContentMergeViewer {
IWorkbenchActionConstants.PASTE,
IWorkbenchActionConstants.DELETE,
IWorkbenchActionConstants.SELECT_ALL,
+ IWorkbenchActionConstants.SAVE
};
private static final String[] TEXT_ACTIONS= {
MergeSourceViewer.UNDO_ID,
@@ -130,14 +131,13 @@ public class TextMergeViewer extends ContentMergeViewer {
MergeSourceViewer.PASTE_ID,
MergeSourceViewer.DELETE_ID,
MergeSourceViewer.SELECT_ALL_ID,
+ MergeSourceViewer.SAVE_ID
};
private static final String MY_UPDATER= "my_updater"; //$NON-NLS-1$
private static final String SYNC_SCROLLING= "SYNC_SCROLLING"; //$NON-NLS-1$
-
- private static final String TEXT_FONT= ComparePreferencePage.TEXT_FONT;
-
+
private static final String BUNDLE_NAME= "org.eclipse.compare.contentmergeviewer.TextMergeViewerResources"; //$NON-NLS-1$
// constants
@@ -486,10 +486,11 @@ public class TextMergeViewer extends ContentMergeViewer {
Font oldFont= fFont;
FontData fontData= null;
- if (ps.contains(TEXT_FONT) && !ps.isDefault(TEXT_FONT))
- fontData= PreferenceConverter.getFontData(ps, TEXT_FONT);
+ if (ps.contains(ComparePreferencePage.TEXT_FONT)
+ && !ps.isDefault(ComparePreferencePage.TEXT_FONT))
+ fontData= PreferenceConverter.getFontData(ps, ComparePreferencePage.TEXT_FONT);
else
- fontData= PreferenceConverter.getDefaultFontData(ps, TEXT_FONT);
+ fontData= PreferenceConverter.getDefaultFontData(ps, ComparePreferencePage.TEXT_FONT);
if (fontData != null) {
fFont= new Font(c.getDisplay(), fontData);
@@ -764,9 +765,11 @@ public class TextMergeViewer extends ContentMergeViewer {
IActionBars actionBars= Utilities.findActionBars(fComposite);
if (actionBars != null) {
for (int i= 0; i < GLOBAL_ACTIONS.length; i++) {
- IAction action= null;
+ IAction action= null;
if (part != null)
action= part.getAction(TEXT_ACTIONS[i]);
+ if (i == 7)
+ i= 7;
actionBars.setGlobalActionHandler(GLOBAL_ACTIONS[i], action);
}
actionBars.updateActionBars();
@@ -987,18 +990,19 @@ public class TextMergeViewer extends ContentMergeViewer {
* Returns the contents of the underlying document as an array of bytes.
*
* @param left if <code>true</code> the contents of the left side is returned; otherwise the right side
- * @return the contents of the left or right document
+ * @return the contents of the left or right document or null
*/
protected byte[] getContents(boolean left) {
-
- if (left) {
- //if (fLeftContentsChanged) // TRY
- return fLeft.getDocument().get().getBytes();
- } else {
- //if (fRightContentsChanged) // TRY
- return fRight.getDocument().get().getBytes();
- }
- //return null;
+ MergeSourceViewer v= left ? fLeft : fRight;
+ if (v != null) {
+ IDocument d= v.getDocument();
+ if (d != null) {
+ String contents= d.get();
+ if (contents != null)
+ return contents.getBytes();
+ }
+ }
+ return null;
}
private IRegion normalizeDocumentRegion(IDocument doc, IRegion region) {
@@ -1796,12 +1800,12 @@ public class TextMergeViewer extends ContentMergeViewer {
selectFirstDiff();
- } else if (key.equals(TEXT_FONT)) {
+ } else if (key.equals(ComparePreferencePage.TEXT_FONT)) {
if (fPreferenceStore != null) {
updateFont(fPreferenceStore, fComposite);
invalidateLines();
}
-
+
} else if (key.equals(ComparePreferencePage.SYNCHRONIZE_SCROLLING)) {
boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
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 ed70e23d6..057ddb329 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
@@ -37,16 +37,15 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
return null;
}
public String getName() {
- return "Name"; //$NON-NLS-1$
+ return "no name"; //$NON-NLS-1$
}
public String getType() {
- return "Type"; //$NON-NLS-1$
+ return "no 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$
@@ -62,7 +61,8 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
private CompareConfiguration fCompareConfiguration;
private OverlayPreferenceStore fOverlayStore;
private Map fCheckBoxes= new HashMap();
-
+ private SelectionListener fCheckBoxListener;
+
public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING),
@@ -103,6 +103,9 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener);
}
+ /*
+ * @see IWorkbenchPreferencePage#init()
+ */
public void init(IWorkbench workbench) {
}
@@ -173,21 +176,21 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
layout.numColumns= 1;
composite.setLayout(layout);
- addCheckBox(composite, "ComparePreferences.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferences.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferences.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferences.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
- fFontEditor= addTextFontEditor(composite, "ComparePreferences.textFont.label", TEXT_FONT); //$NON-NLS-1$
+ fFontEditor= addTextFontEditor(composite, "ComparePreferencePage.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:");
+ previewLabel.setText(Utilities.getString("ComparePreferencePage.preview.label")); //$NON-NLS-1$
Control previewer= createPreviewer(composite);
GridData gd= new GridData(GridData.FILL_BOTH);
@@ -203,12 +206,12 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
private Control createPreviewer(Composite parent) {
fCompareConfiguration= new CompareConfiguration(fOverlayStore);
- fCompareConfiguration.setAncestorLabel("Common Ancestor");
+ fCompareConfiguration.setAncestorLabel(Utilities.getString("ComparePreferencePage.ancestor.label")); //$NON-NLS-1$
- fCompareConfiguration.setLeftLabel("Local");
+ fCompareConfiguration.setLeftLabel(Utilities.getString("ComparePreferencePage.left.label")); //$NON-NLS-1$
fCompareConfiguration.setLeftEditable(false);
- fCompareConfiguration.setRightLabel("Remote");
+ fCompareConfiguration.setRightLabel(Utilities.getString("ComparePreferencePage.right.label")); //$NON-NLS-1$
fCompareConfiguration.setRightEditable(false);
fTextMergeViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration);
@@ -236,27 +239,21 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
// 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) {
String label= Utilities.getString(labelKey);
- Composite editorComposite= new Composite(parent, SWT.NULL);
+ Group group= new Group(parent, SWT.NULL);
+ group.setText(label);
GridLayout layout= new GridLayout();
layout.numColumns= 3;
- editorComposite.setLayout(layout);
- WorkbenchChainedTextFontFieldEditor fe= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
- //fFontEditor.setChangeButtonText("C&hange...");
+ layout.marginWidth+= 3;
+ group.setLayout(layout);
+ WorkbenchChainedTextFontFieldEditor fe= new WorkbenchChainedTextFontFieldEditor(key, "", group); //$NON-NLS-1$
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan= 2;
- editorComposite.setLayoutData(gd);
+ group.setLayoutData(gd);
return fe;
}
@@ -272,6 +269,15 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
gd.horizontalIndent= indentation;
gd.horizontalSpan= 2;
checkBox.setLayoutData(gd);
+
+ if (fCheckBoxListener == null) {
+ fCheckBoxListener= new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Button button= (Button) e.widget;
+ fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
+ }
+ };
+ }
checkBox.addSelectionListener(fCheckBoxListener);
fCheckBoxes.put(checkBox, key);
@@ -280,12 +286,12 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
}
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)));
+ String line;
while ((line= reader.readLine()) != null) {
buffer.append(line);
buffer.append(separator);
@@ -294,7 +300,10 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
CompareUIPlugin.log(io);
} finally {
if (reader != null) {
- try { reader.close(); } catch (IOException e) {}
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
}
}
return buffer.toString();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
index 07a8c74f6..5ddbc17f1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
@@ -28,6 +28,7 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
}
public void inputChanged(Viewer v, Object o1, Object o2) {
+ // we are not interested since we have no state
}
//---- ancestor
@@ -87,6 +88,11 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
ICompareInput node= (ICompareInput) element;
if (bytes != null) {
ITypedElement left= node.getLeft();
+ // #9869: problem if left is null (because no resource exists yet) nothing is done!
+ if (left == null) {
+ node.copy(false);
+ left= node.getLeft();
+ }
if (left instanceof IEditableContent)
((IEditableContent)left).setContent(bytes);
} else {
@@ -130,6 +136,11 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
ICompareInput node= (ICompareInput) element;
if (bytes != null) {
ITypedElement right= node.getRight();
+ // #9869: problem if right is null (because no resource exists yet) nothing is done!
+ if (right == null) {
+ node.copy(true);
+ right= node.getRight();
+ }
if (right instanceof IEditableContent)
((IEditableContent)right).setContent(bytes);
} else {
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index 09e7ea489..a2eb74b8a 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -58,12 +58,15 @@ ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with
# Preference Page
#
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
+ComparePreferencePage.initiallyShowAncestorPane.label= Initially show a&ncestor pane
+ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts
+ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
+ComparePreferencePage.textFont.label= Text Font
+ComparePreferencePage.showMoreInfo.label= Show additional compare &information in status line
+ComparePreferencePage.preview.label= Preview:
+ComparePreferencePage.ancestor.label= Common Ancestor
+ComparePreferencePage.left.label= Local
+ComparePreferencePage.right.label= Remote
#
# Toolbar actions
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 169fa34d4..2ba364cf1 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
@@ -758,21 +758,21 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
if (fCopyLeftToRightAction != null) {
boolean enable= content.isRightEditable(input);
- if (enable && input instanceof ICompareInput) {
- ITypedElement e= ((ICompareInput) input).getLeft();
- if (e == null)
- enable= false;
- }
+// if (enable && input instanceof ICompareInput) {
+// ITypedElement e= ((ICompareInput) input).getLeft();
+// if (e == null)
+// enable= false;
+// }
fCopyLeftToRightAction.setEnabled(enable);
}
if (fCopyRightToLeftAction != null) {
boolean enable= content.isLeftEditable(input);
- if (enable && input instanceof ICompareInput) {
- ITypedElement e= ((ICompareInput) input).getRight();
- if (e == null)
- enable= false;
- }
+// if (enable && input instanceof ICompareInput) {
+// ITypedElement e= ((ICompareInput) input).getRight();
+// if (e == null)
+// enable= false;
+// }
fCopyRightToLeftAction.setEnabled(enable);
}
}
@@ -898,17 +898,23 @@ public abstract class ContentMergeViewer extends ContentViewer implements IPrope
// write back modified contents
IMergeViewerContentProvider content= (IMergeViewerContentProvider) getContentProvider();
+ boolean leftEmpty= content.getLeftContent(oldInput) != null;
+ boolean rightEmpty= content.getRightContent(oldInput) != null;
+
if (fCompareConfiguration.isLeftEditable() && fLeftSaveAction.isEnabled()) {
byte[] bytes= getContents(true);
+ if (leftEmpty && bytes != null && bytes.length == 0)
+ bytes= null;
setLeftDirty(false);
content.saveLeftContent(oldInput, bytes);
}
if (fCompareConfiguration.isRightEditable() && fRightSaveAction.isEnabled()) {
byte[] bytes= getContents(false);
+ if (rightEmpty && bytes != null && bytes.length == 0)
+ bytes= null;
setRightDirty(false);
content.saveRightContent(oldInput, bytes);
}
}
}
-
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 4a03643ab..13f45c50c 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
@@ -121,6 +121,7 @@ public class TextMergeViewer extends ContentMergeViewer {
IWorkbenchActionConstants.PASTE,
IWorkbenchActionConstants.DELETE,
IWorkbenchActionConstants.SELECT_ALL,
+ IWorkbenchActionConstants.SAVE
};
private static final String[] TEXT_ACTIONS= {
MergeSourceViewer.UNDO_ID,
@@ -130,14 +131,13 @@ public class TextMergeViewer extends ContentMergeViewer {
MergeSourceViewer.PASTE_ID,
MergeSourceViewer.DELETE_ID,
MergeSourceViewer.SELECT_ALL_ID,
+ MergeSourceViewer.SAVE_ID
};
private static final String MY_UPDATER= "my_updater"; //$NON-NLS-1$
private static final String SYNC_SCROLLING= "SYNC_SCROLLING"; //$NON-NLS-1$
-
- private static final String TEXT_FONT= ComparePreferencePage.TEXT_FONT;
-
+
private static final String BUNDLE_NAME= "org.eclipse.compare.contentmergeviewer.TextMergeViewerResources"; //$NON-NLS-1$
// constants
@@ -486,10 +486,11 @@ public class TextMergeViewer extends ContentMergeViewer {
Font oldFont= fFont;
FontData fontData= null;
- if (ps.contains(TEXT_FONT) && !ps.isDefault(TEXT_FONT))
- fontData= PreferenceConverter.getFontData(ps, TEXT_FONT);
+ if (ps.contains(ComparePreferencePage.TEXT_FONT)
+ && !ps.isDefault(ComparePreferencePage.TEXT_FONT))
+ fontData= PreferenceConverter.getFontData(ps, ComparePreferencePage.TEXT_FONT);
else
- fontData= PreferenceConverter.getDefaultFontData(ps, TEXT_FONT);
+ fontData= PreferenceConverter.getDefaultFontData(ps, ComparePreferencePage.TEXT_FONT);
if (fontData != null) {
fFont= new Font(c.getDisplay(), fontData);
@@ -764,9 +765,11 @@ public class TextMergeViewer extends ContentMergeViewer {
IActionBars actionBars= Utilities.findActionBars(fComposite);
if (actionBars != null) {
for (int i= 0; i < GLOBAL_ACTIONS.length; i++) {
- IAction action= null;
+ IAction action= null;
if (part != null)
action= part.getAction(TEXT_ACTIONS[i]);
+ if (i == 7)
+ i= 7;
actionBars.setGlobalActionHandler(GLOBAL_ACTIONS[i], action);
}
actionBars.updateActionBars();
@@ -987,18 +990,19 @@ public class TextMergeViewer extends ContentMergeViewer {
* Returns the contents of the underlying document as an array of bytes.
*
* @param left if <code>true</code> the contents of the left side is returned; otherwise the right side
- * @return the contents of the left or right document
+ * @return the contents of the left or right document or null
*/
protected byte[] getContents(boolean left) {
-
- if (left) {
- //if (fLeftContentsChanged) // TRY
- return fLeft.getDocument().get().getBytes();
- } else {
- //if (fRightContentsChanged) // TRY
- return fRight.getDocument().get().getBytes();
- }
- //return null;
+ MergeSourceViewer v= left ? fLeft : fRight;
+ if (v != null) {
+ IDocument d= v.getDocument();
+ if (d != null) {
+ String contents= d.get();
+ if (contents != null)
+ return contents.getBytes();
+ }
+ }
+ return null;
}
private IRegion normalizeDocumentRegion(IDocument doc, IRegion region) {
@@ -1796,12 +1800,12 @@ public class TextMergeViewer extends ContentMergeViewer {
selectFirstDiff();
- } else if (key.equals(TEXT_FONT)) {
+ } else if (key.equals(ComparePreferencePage.TEXT_FONT)) {
if (fPreferenceStore != null) {
updateFont(fPreferenceStore, fComposite);
invalidateLines();
}
-
+
} else if (key.equals(ComparePreferencePage.SYNCHRONIZE_SCROLLING)) {
boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
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 ed70e23d6..057ddb329 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
@@ -37,16 +37,15 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
return null;
}
public String getName() {
- return "Name"; //$NON-NLS-1$
+ return "no name"; //$NON-NLS-1$
}
public String getType() {
- return "Type"; //$NON-NLS-1$
+ return "no 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$
@@ -62,7 +61,8 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
private CompareConfiguration fCompareConfiguration;
private OverlayPreferenceStore fOverlayStore;
private Map fCheckBoxes= new HashMap();
-
+ private SelectionListener fCheckBoxListener;
+
public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] {
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SYNCHRONIZE_SCROLLING),
@@ -103,6 +103,9 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.addPropertyChangeListener(fPreferenceChangeListener);
}
+ /*
+ * @see IWorkbenchPreferencePage#init()
+ */
public void init(IWorkbench workbench) {
}
@@ -173,21 +176,21 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
layout.numColumns= 1;
composite.setLayout(layout);
- addCheckBox(composite, "ComparePreferences.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.synchronizeScrolling.label", SYNCHRONIZE_SCROLLING, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferences.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.initiallyShowAncestorPane.label", INITIALLY_SHOW_ANCESTOR_PANE, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferences.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.showPseudoConflicts.label", SHOW_PSEUDO_CONFLICTS, 0); //$NON-NLS-1$
- addCheckBox(composite, "ComparePreferences.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
- fFontEditor= addTextFontEditor(composite, "ComparePreferences.textFont.label", TEXT_FONT); //$NON-NLS-1$
+ fFontEditor= addTextFontEditor(composite, "ComparePreferencePage.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:");
+ previewLabel.setText(Utilities.getString("ComparePreferencePage.preview.label")); //$NON-NLS-1$
Control previewer= createPreviewer(composite);
GridData gd= new GridData(GridData.FILL_BOTH);
@@ -203,12 +206,12 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
private Control createPreviewer(Composite parent) {
fCompareConfiguration= new CompareConfiguration(fOverlayStore);
- fCompareConfiguration.setAncestorLabel("Common Ancestor");
+ fCompareConfiguration.setAncestorLabel(Utilities.getString("ComparePreferencePage.ancestor.label")); //$NON-NLS-1$
- fCompareConfiguration.setLeftLabel("Local");
+ fCompareConfiguration.setLeftLabel(Utilities.getString("ComparePreferencePage.left.label")); //$NON-NLS-1$
fCompareConfiguration.setLeftEditable(false);
- fCompareConfiguration.setRightLabel("Remote");
+ fCompareConfiguration.setRightLabel(Utilities.getString("ComparePreferencePage.right.label")); //$NON-NLS-1$
fCompareConfiguration.setRightEditable(false);
fTextMergeViewer= new TextMergeViewer(parent, SWT.BORDER, fCompareConfiguration);
@@ -236,27 +239,21 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
// 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) {
String label= Utilities.getString(labelKey);
- Composite editorComposite= new Composite(parent, SWT.NULL);
+ Group group= new Group(parent, SWT.NULL);
+ group.setText(label);
GridLayout layout= new GridLayout();
layout.numColumns= 3;
- editorComposite.setLayout(layout);
- WorkbenchChainedTextFontFieldEditor fe= new WorkbenchChainedTextFontFieldEditor(key, label, editorComposite);
- //fFontEditor.setChangeButtonText("C&hange...");
+ layout.marginWidth+= 3;
+ group.setLayout(layout);
+ WorkbenchChainedTextFontFieldEditor fe= new WorkbenchChainedTextFontFieldEditor(key, "", group); //$NON-NLS-1$
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan= 2;
- editorComposite.setLayoutData(gd);
+ group.setLayoutData(gd);
return fe;
}
@@ -272,6 +269,15 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
gd.horizontalIndent= indentation;
gd.horizontalSpan= 2;
checkBox.setLayoutData(gd);
+
+ if (fCheckBoxListener == null) {
+ fCheckBoxListener= new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Button button= (Button) e.widget;
+ fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
+ }
+ };
+ }
checkBox.addSelectionListener(fCheckBoxListener);
fCheckBoxes.put(checkBox, key);
@@ -280,12 +286,12 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
}
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)));
+ String line;
while ((line= reader.readLine()) != null) {
buffer.append(line);
buffer.append(separator);
@@ -294,7 +300,10 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
CompareUIPlugin.log(io);
} finally {
if (reader != null) {
- try { reader.close(); } catch (IOException e) {}
+ 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/MergeViewerContentProvider.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
index 07a8c74f6..5ddbc17f1 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeViewerContentProvider.java
@@ -28,6 +28,7 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
}
public void inputChanged(Viewer v, Object o1, Object o2) {
+ // we are not interested since we have no state
}
//---- ancestor
@@ -87,6 +88,11 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
ICompareInput node= (ICompareInput) element;
if (bytes != null) {
ITypedElement left= node.getLeft();
+ // #9869: problem if left is null (because no resource exists yet) nothing is done!
+ if (left == null) {
+ node.copy(false);
+ left= node.getLeft();
+ }
if (left instanceof IEditableContent)
((IEditableContent)left).setContent(bytes);
} else {
@@ -130,6 +136,11 @@ public class MergeViewerContentProvider implements IMergeViewerContentProvider {
ICompareInput node= (ICompareInput) element;
if (bytes != null) {
ITypedElement right= node.getRight();
+ // #9869: problem if right is null (because no resource exists yet) nothing is done!
+ if (right == null) {
+ node.copy(true);
+ right= node.getRight();
+ }
if (right instanceof IEditableContent)
((IEditableContent)right).setContent(bytes);
} else {
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 09e7ea489..a2eb74b8a 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -58,12 +58,15 @@ ReplaceWithPreviousFromHistoryAction.tooltip= Replace the Selected Resource with
# Preference Page
#
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
+ComparePreferencePage.initiallyShowAncestorPane.label= Initially show a&ncestor pane
+ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts
+ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
+ComparePreferencePage.textFont.label= Text Font
+ComparePreferencePage.showMoreInfo.label= Show additional compare &information in status line
+ComparePreferencePage.preview.label= Preview:
+ComparePreferencePage.ancestor.label= Common Ancestor
+ComparePreferencePage.left.label= Local
+ComparePreferencePage.right.label= Remote
#
# Toolbar actions

Back to the top