### Eclipse Workspace Patch 1.0
#P org.eclipse.compare
Index: compare/org/eclipse/compare/internal/CompareMessages.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java,v
retrieving revision 1.20
diff -u -r1.20 CompareMessages.java
--- compare/org/eclipse/compare/internal/CompareMessages.java 10 Oct 2008 14:55:31 -0000 1.20
+++ compare/org/eclipse/compare/internal/CompareMessages.java 7 Jan 2009 11:53:23 -0000
@@ -130,6 +130,9 @@
public static String CompareWithOtherResourceDialog_workspaceMainButton;
public static String CompareWithOtherResourceDialog_workspaceRadioButton;
+ public static String ChangeEncodingAction_message_noEncodingSupport;
+ public static String ChangeEncodingAction_button_apply_label;
+
static {
NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
}
Index: compare/org/eclipse/compare/internal/CompareMessages.properties
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties,v
retrieving revision 1.31
diff -u -r1.31 CompareMessages.properties
--- compare/org/eclipse/compare/internal/CompareMessages.properties 10 Oct 2008 14:55:31 -0000 1.31
+++ compare/org/eclipse/compare/internal/CompareMessages.properties 7 Jan 2009 11:53:23 -0000
@@ -141,3 +141,7 @@
CompareWithOtherResourceDialog_externalFolderRadioButton=External folder
CompareWithOtherResourceDialog_workspaceMainButton=Browse...
CompareWithOtherResourceDialog_workspaceRadioButton=Workspace
+
+# change encoding action
+ChangeEncodingAction_message_noEncodingSupport=No encoding support installed
+ChangeEncodingAction_button_apply_label=Apply
\ No newline at end of file
Index: compare/org/eclipse/compare/internal/MergeSourceViewer.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java,v
retrieving revision 1.47
diff -u -r1.47 MergeSourceViewer.java
--- compare/org/eclipse/compare/internal/MergeSourceViewer.java 7 Jan 2009 10:14:11 -0000 1.47
+++ compare/org/eclipse/compare/internal/MergeSourceViewer.java 7 Jan 2009 11:53:23 -0000
@@ -105,6 +105,7 @@
public static final String SAVE_ID= "save"; //$NON-NLS-1$
public static final String FIND_ID= "find"; //$NON-NLS-1$
public static final String GOTO_LINE_ID= "gotoLine"; //$NON-NLS-1$
+ public static final String CHANGE_ENCODING_ID= "changeEncoding"; //$NON-NLS-1$
class TextOperationAction extends MergeViewerAction {
@@ -799,6 +800,7 @@
addMenu(menu, SELECT_ALL_ID);
menu.add(new Separator("edit")); //$NON-NLS-1$
+ addMenu(menu, CHANGE_ENCODING_ID);
menu.add(new Separator("find")); //$NON-NLS-1$
addMenu(menu, FIND_ID);
Index: compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java,v
retrieving revision 1.239
diff -u -r1.239 TextMergeViewer.java
--- compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java 7 Jan 2009 10:14:11 -0000 1.239
+++ compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java 7 Jan 2009 11:53:22 -0000
@@ -37,6 +37,7 @@
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.SharedDocumentAdapter;
import org.eclipse.compare.internal.BufferedCanvas;
+import org.eclipse.compare.internal.ChangeEncodingAction;
import org.eclipse.compare.internal.ChangePropertyAction;
import org.eclipse.compare.internal.CompareEditorSelectionProvider;
import org.eclipse.compare.internal.CompareHandlerService;
@@ -157,6 +158,8 @@
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.IEncodingSupport;
+import org.eclipse.ui.editors.text.IStorageDocumentProvider;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
@@ -497,7 +500,7 @@
}
}
- class ContributorInfo implements IElementStateListener, VerifyListener, IDocumentListener {
+ class ContributorInfo implements IElementStateListener, VerifyListener, IDocumentListener, IEncodingSupport {
private final TextMergeViewer fViewer;
private final Object fElement;
private char fLeg;
@@ -521,11 +524,53 @@
}
}
}
-
+
+ public void setEncoding(String encoding) {
+ if (fDocumentKey == null || fDocumentProvider == null) {
+ return;
+ }
+ if (fDocumentProvider instanceof IStorageDocumentProvider) {
+ IStorageDocumentProvider provider = (IStorageDocumentProvider) fDocumentProvider;
+ String current = provider.getEncoding(fDocumentKey);
+ boolean dirty = fDocumentProvider.canSaveDocument(fDocumentKey);
+ if (!dirty) {
+ String internal = encoding == null ? "" : encoding; //$NON-NLS-1$
+ if (!internal.equals(current)) {
+ provider.setEncoding(fDocumentKey, encoding);
+ try {
+ fDocumentProvider.resetDocument(fDocumentKey);
+ } catch (CoreException e) {
+ // TODO:
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
public String getEncoding() {
- if (fEncoding == null)
- return ResourcesPlugin.getEncoding();
- return fEncoding;
+ if (fDocumentProvider != null && fDocumentKey != null
+ && fDocumentProvider instanceof IStorageDocumentProvider) {
+ IStorageDocumentProvider provider = (IStorageDocumentProvider) fDocumentProvider;
+ return provider.getEncoding(fDocumentKey);
+ }
+ return null;
+ }
+
+ public String getDefaultEncoding() {
+ if (fDocumentProvider != null && fDocumentKey != null
+ && fDocumentProvider instanceof IStorageDocumentProvider) {
+ IStorageDocumentProvider provider = (IStorageDocumentProvider) fDocumentProvider;
+ return provider.getDefaultEncoding();
+ }
+ return null;
+ }
+
+ public String getInternalEncoding() {
+ if (fEncoding != null) {
+ return fEncoding;
+ }
+ return ResourcesPlugin.getEncoding();
}
public void setEncodingIfAbsent(ContributorInfo otherContributor) {
@@ -716,7 +761,7 @@
String s= null;
try {
- String encoding = getEncoding();
+ String encoding = getInternalEncoding();
s = Utilities.readString(sca, encoding);
} catch (CoreException ex) {
this.fViewer.setError(fLeg, ex.getMessage());
@@ -836,7 +881,7 @@
*
* @return the document key used to obtain a shared document or null
*/
- private IEditorInput getDocumentKey() {
+ public IEditorInput getDocumentKey() {
if (fDocumentKey != null)
return fDocumentKey;
if (isUsingDefaultContentProvider() && fElement != null && canHaveSharedDocument()) {
@@ -979,6 +1024,7 @@
if (oldContributor != null) {
fSelection = oldContributor.fSelection;
fTopIndex = oldContributor.fTopIndex;
+ fEncoding = oldContributor.fEncoding;
}
}
@@ -1937,6 +1983,10 @@
service.activateContext("org.eclipse.ui.textEditorScope"); //$NON-NLS-1$
}
}
+
+ contributeChangeEncodingAction(fAncestor, MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR);
+ contributeChangeEncodingAction(fLeft, MergeViewerContentProvider.LEFT_CONTRIBUTOR);
+ contributeChangeEncodingAction(fRight, MergeViewerContentProvider.RIGHT_CONTRIBUTOR);
}
private void hsynchViewport(final TextViewer tv1, final TextViewer tv2, final TextViewer tv3) {
@@ -2430,6 +2480,11 @@
viewer.addAction(MergeSourceViewer.GOTO_LINE_ID, action);
}
+ private void contributeChangeEncodingAction(MergeSourceViewer viewer, char type) {
+ IAction action = new ChangeEncodingAction(this, type, fComposite.getShell());
+ viewer.addAction(MergeSourceViewer.CHANGE_ENCODING_ID, action);
+ }
+
private void connectGlobalActions(final MergeSourceViewer part) {
if (fHandlerService != null) {
if (part != null)
@@ -2938,7 +2993,7 @@
if (contents != null) {
byte[] bytes;
try {
- bytes= contents.getBytes(left ? fLeftContributor.getEncoding() : fRightContributor.getEncoding());
+ bytes= contents.getBytes(left ? fLeftContributor.getInternalEncoding() : fRightContributor.getInternalEncoding());
} catch(UnsupportedEncodingException ex) {
// use default encoding
bytes= contents.getBytes();
@@ -4898,4 +4953,31 @@
return true;
return false;
}
+
+ public IEncodingSupport getEncodingSupport(char type) {
+ switch (type) {
+ case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR:
+ return fAncestorContributor;
+ case MergeViewerContentProvider.LEFT_CONTRIBUTOR:
+ return fLeftContributor;
+ case MergeViewerContentProvider.RIGHT_CONTRIBUTOR:
+ return fRightContributor;
+ default:
+ return null;
+ }
+ }
+
+ public IEditorInput getEditorInput(char type) {
+ switch (type) {
+ case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR:
+ return fAncestorContributor.getDocumentKey();
+ case MergeViewerContentProvider.LEFT_CONTRIBUTOR:
+ return fLeftContributor.getDocumentKey();
+ case MergeViewerContentProvider.RIGHT_CONTRIBUTOR:
+ return fRightContributor.getDocumentKey();
+ default:
+ return null;
+ }
+ }
+
}
Index: compare/org/eclipse/compare/internal/ChangeEncodingAction.java
===================================================================
RCS file: compare/org/eclipse/compare/internal/ChangeEncodingAction.java
diff -N compare/org/eclipse/compare/internal/ChangeEncodingAction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ compare/org/eclipse/compare/internal/ChangeEncodingAction.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+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.editors.text.IEncodingSupport;
+import org.eclipse.ui.ide.dialogs.AbstractEncodingFieldEditor;
+import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
+import org.eclipse.ui.ide.dialogs.ResourceEncodingFieldEditor;
+import org.eclipse.ui.texteditor.ResourceAction;
+
+public class ChangeEncodingAction extends ResourceAction {
+
+ private static final int APPLY_ID= IDialogConstants.OK_ID + IDialogConstants.CANCEL_ID + 1;
+
+ private static final String BUNDLE_FOR_CONSTRUCTED_KEYS = "org.eclipse.ui.texteditor.ConstructedTextEditorMessages"; //$NON-NLS-1$
+ private static final String ENCODING_PREF_KEY= "encoding"; //$NON-NLS-1$
+ private static final String PREFIX = "Editor.ChangeEncodingAction.";
+
+ private static ResourceBundle fgBundleForConstructedKeys = ResourceBundle
+ .getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
+
+ private String fDialogTitle;
+ private TextMergeViewer viewer;
+ private char type;
+ private Shell shell;
+
+ public ChangeEncodingAction(TextMergeViewer viewer, char type, Shell shell) {
+ super(fgBundleForConstructedKeys, PREFIX); //$NON-NLS-1$
+ this.viewer = viewer;
+ this.type = type;
+ this.shell = shell;
+
+ String key = PREFIX + "dialog.title"; //$NON-NLS-1$;
+ fDialogTitle = getString(fgBundleForConstructedKeys, key, null);
+ }
+
+ /*
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ public void run() {
+ final IResource resource= getResource();
+ final IEncodingSupport encodingSupport= getEncodingSupport();
+ if (resource == null && encodingSupport == null) {
+ MessageDialog.openInformation(shell, fDialogTitle, CompareMessages.ChangeEncodingAction_message_noEncodingSupport);
+ return;
+ }
+
+ Dialog dialog= new Dialog(shell) {
+ private AbstractEncodingFieldEditor fEncodingEditor;
+ private IPreferenceStore store= null;
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(fDialogTitle);
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ Control composite= super.createDialogArea(parent);
+ if (!(composite instanceof Composite)) {
+ composite.dispose();
+ composite= new Composite(parent, SWT.NONE);
+ }
+
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ parent.setLayout(layout);
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ composite.setLayoutData(data);
+ composite.setFont(parent.getFont());
+
+ DialogPage page= new MessageDialogPage((Composite)composite) {
+ public void setErrorMessage(String newMessage) {
+ super.setErrorMessage(newMessage);
+ setButtonEnabledState(IDialogConstants.OK_ID, newMessage == null);
+ setButtonEnabledState(APPLY_ID, newMessage == null);
+ }
+
+ private void setButtonEnabledState(int id, boolean state) {
+ Button button= getButton(id);
+ if (button != null)
+ button.setEnabled(state);
+ }
+ };
+
+ if (resource != null) {
+ fEncodingEditor= new ResourceEncodingFieldEditor("", (Composite)composite, resource); //$NON-NLS-1$
+ fEncodingEditor.setPage(page);
+ fEncodingEditor.load();
+ } else {
+ fEncodingEditor= new EncodingFieldEditor(ENCODING_PREF_KEY, "", (Composite)composite); //$NON-NLS-1$
+ store= new PreferenceStore();
+ String defaultEncoding= encodingSupport.getDefaultEncoding();
+ if (defaultEncoding != null) {
+ store.setDefault(ENCODING_PREF_KEY, defaultEncoding);
+ }
+ String encoding= encodingSupport.getEncoding();
+ if (encoding != null)
+ store.setValue(ENCODING_PREF_KEY, encoding);
+ fEncodingEditor.setPreferenceStore(store);
+
+ fEncodingEditor.setPage(page);
+ fEncodingEditor.load();
+
+ if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
+ fEncodingEditor.loadDefault();
+ }
+
+ return composite;
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, APPLY_ID, CompareMessages.ChangeEncodingAction_button_apply_label, false);
+ super.createButtonsForButtonBar(parent);
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == APPLY_ID)
+ apply();
+ else
+ super.buttonPressed(buttonId);
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ apply();
+ super.okPressed();
+ }
+
+ private void apply() {
+ fEncodingEditor.store();
+
+ if (resource == null) {
+ String encoding= fEncodingEditor.getPreferenceStore().getString(fEncodingEditor.getPreferenceName());
+ encodingSupport.setEncoding(encoding);
+ }
+ }
+ };
+ dialog.open();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.IUpdate#update()
+ */
+ public void update() {
+ setEnabled((getResource() != null || getEncodingSupport() != null));
+ }
+
+ /**
+ * Gets the resource which is being edited in the editor.
+ *
+ * @return the resource being edited or null
s
+ */
+ private IResource getResource() {
+ if (viewer != null && viewer.getEditorInput(type) != null)
+ return (IResource)viewer.getEditorInput(type).getAdapter(IResource.class);
+
+ return null;
+ }
+
+ /**
+ * Gets the editor's encoding support.
+ *
+ * @return the resource being edited or null
s
+ */
+ private IEncodingSupport getEncodingSupport() {
+ if (viewer != null)
+ return viewer.getEncodingSupport(type);
+
+ return null;
+ }
+}
Index: compare/org/eclipse/compare/internal/MessageRegion.java
===================================================================
RCS file: compare/org/eclipse/compare/internal/MessageRegion.java
diff -N compare/org/eclipse/compare/internal/MessageRegion.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ compare/org/eclipse/compare/internal/MessageRegion.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.jface.resource.JFaceResources;
+
+
+/**
+ * The MessageRegion is the optional area to
+ * show messages in the page.
+ *
+ * XXX: Copied from org.eclipse.jface.preference.PreferencePage.MessageRegion + * see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=84061 + *
+ * + * @since 3.1 + */ +class MessageRegion { + + private Text messageText; + + private Label messageImageLabel; + + private Composite messageComposite; + + private String lastMessageText = "";//$NON-NLS-1$ + + private int lastMessageType; + + /** + * Create a new instance of the receiver. + */ + public MessageRegion() { + //No initial behavior + } + + /** + * Create the contents for the receiver. + * + * @param parent the Composite that the children will be created in + */ + public void createContents(Composite parent) { + messageComposite = new Composite(parent, SWT.NONE); + GridLayout messageLayout = new GridLayout(); + messageLayout.numColumns = 2; + messageLayout.marginWidth = 0; + messageLayout.marginHeight = 0; + messageLayout.makeColumnsEqualWidth = false; + messageComposite.setLayout(messageLayout); + messageImageLabel = new Label(messageComposite, SWT.NONE); + + GridData imageData = new GridData(GridData.VERTICAL_ALIGN_CENTER); + Image sizingImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); + Rectangle imageBounds; + if(sizingImage == null) + imageBounds = new Rectangle(0,0,IDialogConstants.VERTICAL_MARGIN * 2,IDialogConstants.VERTICAL_MARGIN * 2); + else + imageBounds = sizingImage.getBounds(); + imageData.heightHint = imageBounds.height + IDialogConstants.VERTICAL_SPACING; + imageData.widthHint = imageBounds.width + IDialogConstants.HORIZONTAL_SPACING; + messageImageLabel.setLayoutData(imageData); + + messageText = new Text(messageComposite, SWT.NONE); + messageText.setEditable(false); + messageText.setBackground(parent.getDisplay().getSystemColor( + SWT.COLOR_WIDGET_BACKGROUND)); + + GridData textData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL + | GridData.VERTICAL_ALIGN_CENTER); + messageText.setLayoutData(textData); + hideRegion(); + + } + + /** + * Set the layoutData for the messageArea. In most cases this will be a copy of the layoutData + * used in setTitleLayoutData. + * + * @param layoutData the layoutData for the message area composite. + */ + public void setMessageLayoutData(Object layoutData) { + messageComposite.setLayoutData(layoutData); + } + + /** + * Show the new message in the message text and update the image. Base the background color on + * whether or not there are errors. + * + * @param newMessage The new value for the message + * @param newType One of the IMessageProvider constants. If newType is IMessageProvider.NONE + * show the title. + * @see IMessageProvider + */ + public void updateText(String newMessage, int newType) { + Image newImage = null; + boolean showingError = false; + switch (newType) { + case IMessageProvider.NONE: + hideRegion(); + return; + case IMessageProvider.INFORMATION: + newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO); + break; + case IMessageProvider.WARNING: + newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); + break; + case IMessageProvider.ERROR: + newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); + showingError = true; + break; + } + + if(newMessage == null){//No message so clear the area + hideRegion(); + return; + } + showRegion(); + // Any more updates required + if (newMessage.equals(messageText.getText()) + && newImage == messageImageLabel.getImage()) + return; + messageImageLabel.setImage(newImage); + messageText.setText(newMessage); + if (showingError) + setMessageColors(JFaceColors.getErrorBackground(messageComposite.getDisplay())); + else { + lastMessageText = newMessage; + setMessageColors(JFaceColors.getBannerBackground(messageComposite.getDisplay())); + } + + } + + /** + * Show and enable the widgets in the message region + */ + private void showRegion() { + messageComposite.setVisible(true); + } + + /** + * Hide the message region and clear out the caches. + */ + private void hideRegion() { + messageComposite.setVisible(false); + lastMessageText = null; + lastMessageType = IMessageProvider.NONE; + } + + /** + * Set the colors of the message area. + * + * @param color the color to be use in the message area. + */ + private void setMessageColors(Color color) { + messageText.setBackground(color); + messageComposite.setBackground(color); + messageImageLabel.setBackground(color); + } + + /** + * Clear the error message. Restore the previously displayed message if + * there is one, if not restore the title label. + * + */ + public void clearErrorMessage() { + updateText(lastMessageText, lastMessageType); + } +} Index: compare/org/eclipse/compare/internal/MessageDialogPage.java =================================================================== RCS file: compare/org/eclipse/compare/internal/MessageDialogPage.java diff -N compare/org/eclipse/compare/internal/MessageDialogPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compare/org/eclipse/compare/internal/MessageDialogPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2000, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Hiroyuki Inaba