diff options
16 files changed, 342 insertions, 198 deletions
diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html index a3c7fb797..7bd7f7f25 100644 --- a/bundles/org.eclipse.compare/buildnotes_compare.html +++ b/bundles/org.eclipse.compare/buildnotes_compare.html @@ -33,6 +33,8 @@ Problem reports fixed</h2> <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14371">#14371</a>: TextMergeViewer.sameDoc() is broken<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14378">#14378</a>: CompareEditorInput never resets dirtyness flag (detailed)<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14680">#14680</a>: Compare unreadable in high contrast black<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14952">#14952</a>: Diff Browser Opens Too Small / Not Easily Resizable<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14742">#14742</a>: Ignore whitespace preference<br>
<h2>
Problem reports closed</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 666f99e26..c2c62dbac 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java @@ -111,8 +111,11 @@ public class CompareConfiguration { if (fPreferenceStore != null) {
boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
setProperty(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b));
+
+ b= fPreferenceStore.getBoolean(ComparePreferencePage.IGNORE_WHITESPACE);
+ setProperty(CompareConfiguration.IGNORE_WHITESPACE, new Boolean(b));
}
- }
+ }
/**
* Creates a new configuration with editable left and right sides,
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java index b6d9d9616..17ca4e5cb 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java @@ -32,11 +32,10 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFileState;
@@ -77,7 +76,7 @@ import org.eclipse.compare.*; * @see IModificationDate
* @see ITypedElement
*/
-public class EditionSelectionDialog extends Dialog {
+public class EditionSelectionDialog extends ResizableDialog {
/**
* An item in an underlying edition.
@@ -167,7 +166,6 @@ public class EditionSelectionDialog extends Dialog { /** The editions of the current selected member */
private List fCurrentEditions;
private Thread fThread;
- private ResourceBundle fBundle;
private Pair fTargetPair;
/** The selected edition in the edition viewer */
private ITypedElement fSelectedItem;
@@ -209,11 +207,8 @@ public class EditionSelectionDialog extends Dialog { * @param bundle <code>ResourceBundle</code> to configure the dialog
*/
public EditionSelectionDialog(Shell parent, ResourceBundle bundle) {
- super(parent);
- setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE);
+ super(parent, bundle);
- fBundle= bundle;
-
fCompareConfiguration= new CompareConfiguration();
fCompareConfiguration.setLeftEditable(false);
fCompareConfiguration.setRightEditable(false);
@@ -607,28 +602,6 @@ public class EditionSelectionDialog extends Dialog { return null;
}
- /* (non Javadoc)
- * Returns the size initialized with the constructor.
- */
- protected Point getInitialSize() {
- Point size= new Point(Utilities.getInteger(fBundle, "width", 0), //$NON-NLS-1$
- Utilities.getInteger(fBundle, "height", 0)); //$NON-NLS-1$
-
- Shell shell= getParentShell();
- if (shell != null) {
- Point parentSize= shell.getSize();
- if (size.x <= 0)
- size.x= parentSize.x-300;
- if (size.y <= 0)
- size.y= parentSize.y-200;
- }
- if (size.x < 700)
- size.x= 700;
- if (size.y < 500)
- size.y= 500;
- return size;
- }
-
/* (non Javadoc)
* Creates SWT control tree.
*/
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java index 8239b27ab..bac04923c 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java @@ -20,7 +20,7 @@ import org.eclipse.core.runtime.*; import org.eclipse.compare.*; -public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { +public class AddFromHistoryDialog extends ResizableDialog { static class HistoryInput implements ITypedElement, IStreamContentAccessor, IModificationDate { IFile fFile; @@ -48,7 +48,6 @@ public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { } private CompareConfiguration fCompareConfiguration; - private ResourceBundle fBundle; private HistoryInput fSelectedItem; // SWT controls @@ -64,10 +63,7 @@ public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { public AddFromHistoryDialog(Shell parent, ResourceBundle bundle) { - super(parent); - setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE); - - fBundle= bundle; + super(parent, bundle); String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$ ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); @@ -297,29 +293,7 @@ public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { return MessageFormat.format(format, new Object[] { date }); } - - /* (non Javadoc) - * Returns the size initialized with the constructor. - */ - protected Point getInitialSize() { - Point size= new Point(Utilities.getInteger(fBundle, "width", 0), //$NON-NLS-1$ - Utilities.getInteger(fBundle, "height", 0)); //$NON-NLS-1$ - - Shell shell= getParentShell(); - if (shell != null) { - Point parentSize= shell.getSize(); - if (size.x <= 0) - size.x= parentSize.x-300; - if (size.y <= 0) - size.y= parentSize.y-200; - } - if (size.x < 700) - size.x= 700; - if (size.y < 500) - size.y= 500; - return size; - } - + /* (non-Javadoc) * Method declared on Dialog. */ diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java index 84e19c68a..6b6c3c49f 100644 --- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java @@ -6,36 +6,32 @@ package org.eclipse.compare.internal; import java.lang.reflect.InvocationTargetException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.layout.*;
-
-import org.eclipse.jface.dialogs.*;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.compare.CompareEditorInput;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-
-import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
-public class CompareDialog extends Dialog implements IPropertyChangeListener {
+public class CompareDialog extends ResizableDialog implements IPropertyChangeListener {
private CompareEditorInput fCompareEditorInput;
private Button fCommitButton;
CompareDialog(Shell shell, CompareEditorInput input) {
- super(shell);
- setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE);
+ super(shell, null);
Assert.isNotNull(input);
fCompareEditorInput= input;
@@ -79,25 +75,7 @@ public class CompareDialog extends Dialog implements IPropertyChangeListener { return c;
}
-
- /* (non-Javadoc)
- * Method declared on Window.
- */
- protected Point getInitialSize() {
- Point size= new Point(0, 0);
- Shell shell= getParentShell();
- if (shell != null) {
- Point parentSize= shell.getSize();
- size.x= parentSize.x-100;
- size.y= parentSize.y-100;
- }
- if (size.x < 800)
- size.x= 800;
- if (size.y < 600)
- size.y= 600;
- return size;
- }
-
+
/* (non-Javadoc)
* Method declared on Window.
*/
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 69fe23dc4..e57afdf8f 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 @@ -58,6 +58,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP 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$
+ public static final String IGNORE_WHITESPACE= PREFIX + "IgnoreWhitespace"; //$NON-NLS-1$
private WorkbenchChainedTextFontFieldEditor fFontEditor;
private TextMergeViewer fPreviewViewer;
@@ -79,6 +80,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_MORE_INFO),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TEXT_FONT),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IGNORE_WHITESPACE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
@@ -91,6 +93,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP store.setDefault(SHOW_PSEUDO_CONFLICTS, false);
store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false);
store.setDefault(SHOW_MORE_INFO, false);
+ store.setDefault(IGNORE_WHITESPACE, false);
Display display= Display.getDefault();
Color color= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
@@ -218,6 +221,8 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.ignoreWhitespace.label", IGNORE_WHITESPACE, 0); //$NON-NLS-1$
+
return composite;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java new file mode 100644 index 000000000..3f21c5ace --- /dev/null +++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java @@ -0,0 +1,137 @@ +package org.eclipse.compare.internal; + +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.Shell; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.dialogs.DialogSettings; + + +/** + * Base class for resizable Dialogs with persistent window bounds. + */ +public abstract class ResizableDialog extends Dialog { + + // dialog store id constants + private final static String DIALOG_BOUNDS_KEY= "ResizableDialogBounds"; //$NON-NLS-1$ + private static final String X= "x"; //$NON-NLS-1$ + private static final String Y= "y"; //$NON-NLS-1$ + private static final String WIDTH= "width"; //$NON-NLS-1$ + private static final String HEIGHT= "height"; //$NON-NLS-1$ + + protected ResourceBundle fBundle; + private Rectangle fNewBounds; + private IDialogSettings fSettings; + + + public ResizableDialog(Shell parent, ResourceBundle bundle) { + super(parent); + setShellStyle(getShellStyle() | SWT.RESIZE); + + fBundle= bundle; + + fSettings= CompareUIPlugin.getDefault().getDialogSettings(); + } + + protected Point getInitialSize() { + + int width= 0; + int height= 0; + + final Shell s= getShell(); + if (s != null) { + s.addShellListener( + new ShellAdapter() { + public void shellClosed(ShellEvent arg0) { + if (fNewBounds != null) + saveBounds(fNewBounds); + } + } + ); + s.addControlListener( + new ControlListener() { + public void controlMoved(ControlEvent arg0) { + fNewBounds= s.getBounds(); + } + public void controlResized(ControlEvent arg0) { + fNewBounds= s.getBounds(); + } + } + ); + } + + IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); //$NON-NLS-1$ + if (bounds == null) { + if (fBundle != null) { + width= Utilities.getInteger(fBundle, WIDTH, 0); + height= Utilities.getInteger(fBundle, HEIGHT, 0); + Shell shell= getParentShell(); + if (shell != null) { + Point parentSize= shell.getSize(); + if (width <= 0) + width= parentSize.x-300; + if (height <= 0) + height= parentSize.y-200; + } + } else { + Shell shell= getParentShell(); + if (shell != null) { + Point parentSize= shell.getSize(); + width= parentSize.x-100; + height= parentSize.y-100; + } + } + if (width < 700) + width= 700; + if (height < 500) + height= 500; + } else { + try { + width= bounds.getInt(WIDTH); + } catch (NumberFormatException e) { + width= 700; + } + try { + height= bounds.getInt(HEIGHT); + } catch (NumberFormatException e) { + height= 500; + } + } + + return new Point(width, height); + } + + protected Point getInitialLocation(Point initialSize) { + Point loc= super.getInitialLocation(initialSize); + + IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); + if (bounds != null) { + try { + loc.x= bounds.getInt(X); + } catch (NumberFormatException e) { + } + try { + loc.y= bounds.getInt(Y); + } catch (NumberFormatException e) { + } + } + return loc; + } + + private void saveBounds(Rectangle bounds) { + IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY); + if (dialogBounds == null) { + dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY); + fSettings.addSection(dialogBounds); + } + dialogBounds.put(X, bounds.x); + dialogBounds.put(Y, bounds.y); + dialogBounds.put(WIDTH, bounds.width); + dialogBounds.put(HEIGHT, bounds.height); + } +} diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties index 37c73533a..fb649b510 100644 --- a/bundles/org.eclipse.compare/plugin.properties +++ b/bundles/org.eclipse.compare/plugin.properties @@ -76,7 +76,7 @@ ComparePreferencePage.textCompareTab.label= &Text Compare ComparePreferencePage.backgroundColor1.label= Bac&kground Color:
ComparePreferencePage.backgroundColor2.label= S&ystem Default
ComparePreferencePage.backgroundColor3.label= C&ustom
-
+ComparePreferencePage.ignoreWhitespace.label= Ignore &Whitespace
#
# 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 a3c7fb797..7bd7f7f25 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 @@ -33,6 +33,8 @@ Problem reports fixed</h2> <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14371">#14371</a>: TextMergeViewer.sameDoc() is broken<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14378">#14378</a>: CompareEditorInput never resets dirtyness flag (detailed)<br>
<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14680">#14680</a>: Compare unreadable in high contrast black<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14952">#14952</a>: Diff Browser Opens Too Small / Not Easily Resizable<br>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=14742">#14742</a>: Ignore whitespace preference<br>
<h2>
Problem reports closed</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 666f99e26..c2c62dbac 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 @@ -111,8 +111,11 @@ public class CompareConfiguration { if (fPreferenceStore != null) {
boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
setProperty(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE, new Boolean(b));
+
+ b= fPreferenceStore.getBoolean(ComparePreferencePage.IGNORE_WHITESPACE);
+ setProperty(CompareConfiguration.IGNORE_WHITESPACE, new Boolean(b));
}
- }
+ }
/**
* Creates a new configuration with editable left and right sides,
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java index b6d9d9616..17ca4e5cb 100644 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java +++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java @@ -32,11 +32,10 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.*;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFileState;
@@ -77,7 +76,7 @@ import org.eclipse.compare.*; * @see IModificationDate
* @see ITypedElement
*/
-public class EditionSelectionDialog extends Dialog {
+public class EditionSelectionDialog extends ResizableDialog {
/**
* An item in an underlying edition.
@@ -167,7 +166,6 @@ public class EditionSelectionDialog extends Dialog { /** The editions of the current selected member */
private List fCurrentEditions;
private Thread fThread;
- private ResourceBundle fBundle;
private Pair fTargetPair;
/** The selected edition in the edition viewer */
private ITypedElement fSelectedItem;
@@ -209,11 +207,8 @@ public class EditionSelectionDialog extends Dialog { * @param bundle <code>ResourceBundle</code> to configure the dialog
*/
public EditionSelectionDialog(Shell parent, ResourceBundle bundle) {
- super(parent);
- setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE);
+ super(parent, bundle);
- fBundle= bundle;
-
fCompareConfiguration= new CompareConfiguration();
fCompareConfiguration.setLeftEditable(false);
fCompareConfiguration.setRightEditable(false);
@@ -607,28 +602,6 @@ public class EditionSelectionDialog extends Dialog { return null;
}
- /* (non Javadoc)
- * Returns the size initialized with the constructor.
- */
- protected Point getInitialSize() {
- Point size= new Point(Utilities.getInteger(fBundle, "width", 0), //$NON-NLS-1$
- Utilities.getInteger(fBundle, "height", 0)); //$NON-NLS-1$
-
- Shell shell= getParentShell();
- if (shell != null) {
- Point parentSize= shell.getSize();
- if (size.x <= 0)
- size.x= parentSize.x-300;
- if (size.y <= 0)
- size.y= parentSize.y-200;
- }
- if (size.x < 700)
- size.x= 700;
- if (size.y < 500)
- size.y= 500;
- return size;
- }
-
/* (non Javadoc)
* Creates SWT control tree.
*/
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java index 8239b27ab..bac04923c 100644 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java +++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java @@ -20,7 +20,7 @@ import org.eclipse.core.runtime.*; import org.eclipse.compare.*; -public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { +public class AddFromHistoryDialog extends ResizableDialog { static class HistoryInput implements ITypedElement, IStreamContentAccessor, IModificationDate { IFile fFile; @@ -48,7 +48,6 @@ public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { } private CompareConfiguration fCompareConfiguration; - private ResourceBundle fBundle; private HistoryInput fSelectedItem; // SWT controls @@ -64,10 +63,7 @@ public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { public AddFromHistoryDialog(Shell parent, ResourceBundle bundle) { - super(parent); - setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE); - - fBundle= bundle; + super(parent, bundle); String iconName= Utilities.getString(fBundle, "dateIcon", "obj16/day_obj.gif"); //$NON-NLS-2$ //$NON-NLS-1$ ImageDescriptor id= CompareUIPlugin.getImageDescriptor(iconName); @@ -297,29 +293,7 @@ public class AddFromHistoryDialog extends org.eclipse.jface.dialogs.Dialog { return MessageFormat.format(format, new Object[] { date }); } - - /* (non Javadoc) - * Returns the size initialized with the constructor. - */ - protected Point getInitialSize() { - Point size= new Point(Utilities.getInteger(fBundle, "width", 0), //$NON-NLS-1$ - Utilities.getInteger(fBundle, "height", 0)); //$NON-NLS-1$ - - Shell shell= getParentShell(); - if (shell != null) { - Point parentSize= shell.getSize(); - if (size.x <= 0) - size.x= parentSize.x-300; - if (size.y <= 0) - size.y= parentSize.y-200; - } - if (size.x < 700) - size.x= 700; - if (size.y < 500) - size.y= 500; - return size; - } - + /* (non-Javadoc) * Method declared on Dialog. */ diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java index 84e19c68a..6b6c3c49f 100644 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java +++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareDialog.java @@ -6,36 +6,32 @@ package org.eclipse.compare.internal; import java.lang.reflect.InvocationTargetException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.layout.*;
-
-import org.eclipse.jface.dialogs.*;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.compare.CompareEditorInput;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
-
-import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
-public class CompareDialog extends Dialog implements IPropertyChangeListener {
+public class CompareDialog extends ResizableDialog implements IPropertyChangeListener {
private CompareEditorInput fCompareEditorInput;
private Button fCommitButton;
CompareDialog(Shell shell, CompareEditorInput input) {
- super(shell);
- setShellStyle(SWT.CLOSE | SWT.APPLICATION_MODAL | SWT.RESIZE);
+ super(shell, null);
Assert.isNotNull(input);
fCompareEditorInput= input;
@@ -79,25 +75,7 @@ public class CompareDialog extends Dialog implements IPropertyChangeListener { return c;
}
-
- /* (non-Javadoc)
- * Method declared on Window.
- */
- protected Point getInitialSize() {
- Point size= new Point(0, 0);
- Shell shell= getParentShell();
- if (shell != null) {
- Point parentSize= shell.getSize();
- size.x= parentSize.x-100;
- size.y= parentSize.y-100;
- }
- if (size.x < 800)
- size.x= 800;
- if (size.y < 600)
- size.y= 600;
- return size;
- }
-
+
/* (non-Javadoc)
* Method declared on Window.
*/
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 69fe23dc4..e57afdf8f 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 @@ -58,6 +58,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP 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$
+ public static final String IGNORE_WHITESPACE= PREFIX + "IgnoreWhitespace"; //$NON-NLS-1$
private WorkbenchChainedTextFontFieldEditor fFontEditor;
private TextMergeViewer fPreviewViewer;
@@ -79,6 +80,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, INITIALLY_SHOW_ANCESTOR_PANE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, SHOW_MORE_INFO),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TEXT_FONT),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IGNORE_WHITESPACE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
@@ -91,6 +93,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP store.setDefault(SHOW_PSEUDO_CONFLICTS, false);
store.setDefault(INITIALLY_SHOW_ANCESTOR_PANE, false);
store.setDefault(SHOW_MORE_INFO, false);
+ store.setDefault(IGNORE_WHITESPACE, false);
Display display= Display.getDefault();
Color color= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
@@ -218,6 +221,8 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP addCheckBox(composite, "ComparePreferencePage.showMoreInfo.label", SHOW_MORE_INFO, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.ignoreWhitespace.label", IGNORE_WHITESPACE, 0); //$NON-NLS-1$
+
return composite;
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java new file mode 100644 index 000000000..3f21c5ace --- /dev/null +++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResizableDialog.java @@ -0,0 +1,137 @@ +package org.eclipse.compare.internal; + +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.Shell; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.dialogs.DialogSettings; + + +/** + * Base class for resizable Dialogs with persistent window bounds. + */ +public abstract class ResizableDialog extends Dialog { + + // dialog store id constants + private final static String DIALOG_BOUNDS_KEY= "ResizableDialogBounds"; //$NON-NLS-1$ + private static final String X= "x"; //$NON-NLS-1$ + private static final String Y= "y"; //$NON-NLS-1$ + private static final String WIDTH= "width"; //$NON-NLS-1$ + private static final String HEIGHT= "height"; //$NON-NLS-1$ + + protected ResourceBundle fBundle; + private Rectangle fNewBounds; + private IDialogSettings fSettings; + + + public ResizableDialog(Shell parent, ResourceBundle bundle) { + super(parent); + setShellStyle(getShellStyle() | SWT.RESIZE); + + fBundle= bundle; + + fSettings= CompareUIPlugin.getDefault().getDialogSettings(); + } + + protected Point getInitialSize() { + + int width= 0; + int height= 0; + + final Shell s= getShell(); + if (s != null) { + s.addShellListener( + new ShellAdapter() { + public void shellClosed(ShellEvent arg0) { + if (fNewBounds != null) + saveBounds(fNewBounds); + } + } + ); + s.addControlListener( + new ControlListener() { + public void controlMoved(ControlEvent arg0) { + fNewBounds= s.getBounds(); + } + public void controlResized(ControlEvent arg0) { + fNewBounds= s.getBounds(); + } + } + ); + } + + IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); //$NON-NLS-1$ + if (bounds == null) { + if (fBundle != null) { + width= Utilities.getInteger(fBundle, WIDTH, 0); + height= Utilities.getInteger(fBundle, HEIGHT, 0); + Shell shell= getParentShell(); + if (shell != null) { + Point parentSize= shell.getSize(); + if (width <= 0) + width= parentSize.x-300; + if (height <= 0) + height= parentSize.y-200; + } + } else { + Shell shell= getParentShell(); + if (shell != null) { + Point parentSize= shell.getSize(); + width= parentSize.x-100; + height= parentSize.y-100; + } + } + if (width < 700) + width= 700; + if (height < 500) + height= 500; + } else { + try { + width= bounds.getInt(WIDTH); + } catch (NumberFormatException e) { + width= 700; + } + try { + height= bounds.getInt(HEIGHT); + } catch (NumberFormatException e) { + height= 500; + } + } + + return new Point(width, height); + } + + protected Point getInitialLocation(Point initialSize) { + Point loc= super.getInitialLocation(initialSize); + + IDialogSettings bounds= fSettings.getSection(DIALOG_BOUNDS_KEY); + if (bounds != null) { + try { + loc.x= bounds.getInt(X); + } catch (NumberFormatException e) { + } + try { + loc.y= bounds.getInt(Y); + } catch (NumberFormatException e) { + } + } + return loc; + } + + private void saveBounds(Rectangle bounds) { + IDialogSettings dialogBounds= fSettings.getSection(DIALOG_BOUNDS_KEY); + if (dialogBounds == null) { + dialogBounds= new DialogSettings(DIALOG_BOUNDS_KEY); + fSettings.addSection(dialogBounds); + } + dialogBounds.put(X, bounds.x); + dialogBounds.put(Y, bounds.y); + dialogBounds.put(WIDTH, bounds.width); + dialogBounds.put(HEIGHT, bounds.height); + } +} 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 37c73533a..fb649b510 100644 --- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties +++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties @@ -76,7 +76,7 @@ ComparePreferencePage.textCompareTab.label= &Text Compare ComparePreferencePage.backgroundColor1.label= Bac&kground Color:
ComparePreferencePage.backgroundColor2.label= S&ystem Default
ComparePreferencePage.backgroundColor3.label= C&ustom
-
+ComparePreferencePage.ignoreWhitespace.label= Ignore &Whitespace
#
# Toolbar actions
#
|