Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Roth2015-05-02 23:33:06 +0000
committerSarika Sinha2015-09-03 10:02:31 +0000
commitf7129e87f52a65e8ccb7deb24208369cb65bdf60 (patch)
treef317582b480cf0bed7f54825424ef3840aff9168
parent741eb3a8d1f2a2cb82467197655c956a851aa741 (diff)
downloadeclipse.platform-f7129e87f52a65e8ccb7deb24208369cb65bdf60.tar.gz
eclipse.platform-f7129e87f52a65e8ccb7deb24208369cb65bdf60.tar.xz
eclipse.platform-f7129e87f52a65e8ccb7deb24208369cb65bdf60.zip
Bug 184656 - The color selection button of Syntax tab of the ant editorI20150908-0800
is larger. Use JFace ColorSelector instead of custom ColorEditor. Change-Id: I1c222a64b01c12c12fe584cc54e0881094bdc7f0 Signed-off-by: Robert Roth <robert.roth.off@gmail.com>
-rw-r--r--ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java14
-rw-r--r--ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java14
-rw-r--r--ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ColorEditor.java124
3 files changed, 16 insertions, 136 deletions
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java
index 04e92db10..810cf3fa8 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntEditorPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Robert Roth <robert.roth.off@gmail.com> - bug 184656
*******************************************************************************/
package org.eclipse.ant.internal.ui.preferences;
@@ -21,6 +22,7 @@ import org.eclipse.ant.internal.ui.AntUIPlugin;
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
import org.eclipse.ant.internal.ui.editor.text.AntDocumentSetupParticipant;
import org.eclipse.ant.internal.ui.editor.text.IAntEditorColorConstants;
+import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
@@ -245,7 +247,7 @@ public class AntEditorPreferencePage extends AbstractAntEditorPreferencePage {
AntEditorPreferenceConstants.PROBLEM_PROPERTIES, AntEditorPreferenceConstants.PROBLEM_IMPORTS,
AntEditorPreferenceConstants.PROBLEM_TASKS, AntEditorPreferenceConstants.PROBLEM_SECURITY };
- private ColorEditor fSyntaxForegroundColorEditor;
+ private ColorSelector fSyntaxForegroundColorSelector;
private Button fBoldCheckBox;
private Button fItalicCheckBox;
@@ -462,8 +464,8 @@ public class AntEditorPreferencePage extends AbstractAntEditorPreferencePage {
gd.horizontalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
- fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite);
- Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton();
+ fSyntaxForegroundColorSelector = new ColorSelector(stylesComposite);
+ Button foregroundColorButton = fSyntaxForegroundColorSelector.getButton();
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
@@ -508,7 +510,7 @@ public class AntEditorPreferencePage extends AbstractAntEditorPreferencePage {
@Override
public void widgetSelected(SelectionEvent e) {
HighlightingColorListItem item = getHighlightingColorListItem();
- PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
+ PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), fSyntaxForegroundColorSelector.getColorValue());
}
});
@@ -565,7 +567,7 @@ public class AntEditorPreferencePage extends AbstractAntEditorPreferencePage {
private void handleSyntaxColorListSelection() {
HighlightingColorListItem item = getHighlightingColorListItem();
RGB rgb = PreferenceConverter.getColor(getOverlayStore(), item.getColorKey());
- fSyntaxForegroundColorEditor.setColorValue(rgb);
+ fSyntaxForegroundColorSelector.setColorValue(rgb);
fBoldCheckBox.setSelection(getOverlayStore().getBoolean(item.getBoldKey()));
fItalicCheckBox.setSelection(getOverlayStore().getBoolean(item.getItalicKey()));
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java
index 27ea72c14..3a470cc85 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Robert Roth <robert.roth.off@gmail.com> - bug 184656
*******************************************************************************/
package org.eclipse.ant.internal.ui.preferences;
@@ -19,6 +20,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
@@ -108,7 +110,7 @@ public class AntPreferencePage extends FieldEditorPreferencePage implements IWor
}
private List fConsoleColorList;
- private ColorEditor fConsoleColorEditor;
+ private ColorSelector fConsoleColorSelector;
private IntegerFieldEditor timeout;
private BooleanFieldEditor workspacejre = null;
@@ -264,8 +266,8 @@ public class AntPreferencePage extends FieldEditorPreferencePage implements IWor
gd.horizontalAlignment = GridData.BEGINNING;
label.setLayoutData(gd);
- fConsoleColorEditor = new ColorEditor(stylesComposite);
- Button foregroundColorButton = fConsoleColorEditor.getButton();
+ fConsoleColorSelector = new ColorSelector(stylesComposite);
+ Button foregroundColorButton = fConsoleColorSelector.getButton();
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
foregroundColorButton.setLayoutData(gd);
@@ -285,7 +287,7 @@ public class AntPreferencePage extends FieldEditorPreferencePage implements IWor
return;
}
String key = fAppearanceColorListModel[i][1];
- PreferenceConverter.setValue(getPreferenceStore(), key, fConsoleColorEditor.getColorValue());
+ PreferenceConverter.setValue(getPreferenceStore(), key, fConsoleColorSelector.getColorValue());
}
});
}
@@ -318,7 +320,7 @@ public class AntPreferencePage extends FieldEditorPreferencePage implements IWor
}
String key = fAppearanceColorListModel[i][1];
RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
- fConsoleColorEditor.setColorValue(rgb);
+ fConsoleColorSelector.setColorValue(rgb);
}
/**
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ColorEditor.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ColorEditor.java
deleted file mode 100644
index 06b29d975..000000000
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/ColorEditor.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.ant.internal.ui.preferences;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-/**
- * A "button" of a certain color determined by the color picker
- */
-public class ColorEditor {
-
- private Point fExtent;
- private Image fImage;
- private RGB fColorValue;
- private Color fColor;
- private Button fButton;
-
- public ColorEditor(Composite parent) {
-
- fButton = new Button(parent, SWT.PUSH);
- fExtent = computeImageSize(parent);
- fImage = new Image(parent.getDisplay(), fExtent.x, fExtent.y);
-
- GC gc = new GC(fImage);
- gc.setBackground(fButton.getBackground());
- gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
- gc.dispose();
-
- fButton.setImage(fImage);
- fButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- ColorDialog colorDialog = new ColorDialog(fButton.getShell());
- colorDialog.setRGB(fColorValue);
- RGB newColor = colorDialog.open();
- if (newColor != null) {
- fColorValue = newColor;
- updateColorImage();
- }
- }
- });
-
- fButton.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent event) {
- if (fImage != null) {
- fImage.dispose();
- fImage = null;
- }
- if (fColor != null) {
- fColor.dispose();
- fColor = null;
- }
- }
- });
- }
-
- public RGB getColorValue() {
- return fColorValue;
- }
-
- public void setColorValue(RGB rgb) {
- fColorValue = rgb;
- updateColorImage();
- }
-
- public Button getButton() {
- return fButton;
- }
-
- protected void updateColorImage() {
-
- Display display = fButton.getDisplay();
-
- GC gc = new GC(fImage);
- gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
- gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4);
-
- if (fColor != null)
- fColor.dispose();
-
- fColor = new Color(display, fColorValue);
- gc.setBackground(fColor);
- gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5);
- gc.dispose();
-
- fButton.setImage(fImage);
- }
-
- protected Point computeImageSize(Control window) {
- GC gc = new GC(window);
- Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
- gc.setFont(f);
- int height = gc.getFontMetrics().getHeight();
- gc.dispose();
- Point p = new Point(height * 3 - 6, height);
- return p;
- }
-}

Back to the top