[147866] StyledTextColorPicker color buttons look bad in Mac.
diff --git a/bundles/org.eclipse.wst.sse.ui/.options b/bundles/org.eclipse.wst.sse.ui/.options
index fadf5bf..c37c9dc 100644
--- a/bundles/org.eclipse.wst.sse.ui/.options
+++ b/bundles/org.eclipse.wst.sse.ui/.options
@@ -2,7 +2,7 @@
org.eclipse.wst.sse.ui/debug/tracefilter=
#org.eclipse.wst.sse.ui.edit.util.ActionContributer._showDebugStatus
-org.eclipse.wst.sse.ui/actioncontributor/debugstatusfields=false
+org.eclipse.wst.sse.ui/actioncontributor/debugstatusfields=true
#org.eclipse.wst.sse.ui.extension.TransferBuilder.debugTime
@@ -63,4 +63,4 @@
org.eclipse.wst.sse.ui/debug/reconcilerSpelling=false
-org.eclipse.wst.sse.ui/debug/reconcilerValidators=false
\ No newline at end of file
+org.eclipse.wst.sse.ui/debug/reconcilerValidators=false
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/ColorHelper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/ColorHelper.java
index 58aefdb..4e08fe2 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/ColorHelper.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/ColorHelper.java
@@ -57,15 +57,23 @@
public static String packStylePreferences(String[] stylePrefs) {
StringBuffer styleString = new StringBuffer();
- if (stylePrefs.length == 3) {
- for (int i = 0; i < 3; ++i) {
- String s = stylePrefs[i];
- styleString.append(s);
-
- // add in the separator (except on last iteration)
- if (i != 2) {
- styleString.append(" " + STYLE_SEPARATOR + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ for (int i = 0; i < stylePrefs.length; ++i) {
+ String s = stylePrefs[i];
+ if (i < 2) {
+ if (s != null) {
+ styleString.append(s);
}
+ else {
+ styleString.append(Boolean.FALSE.toString());
+ }
+ }
+ else {
+ styleString.append(Boolean.valueOf(s));
+ }
+
+ // add in the separator (except on last iteration)
+ if (i < stylePrefs.length - 1) {
+ styleString.append(" " + STYLE_SEPARATOR + " "); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -123,22 +131,47 @@
* should be in the form of Foreground RGB String | Background
* RGB String | Bold true/false
* @return String[] where String[0] = Foreground RGB String, String[1] =
- * Background RGB String, String[2] = Bold true/false OR null if
- * ran into problems extracting
+ * Background RGB String, String[2] = Bold true/false, 3 = Italic
+ * true/false, 4 = Strikethrough true/false, 5 = Underline
+ * true/false; indexes 2-4 may be null if we ran into problems
+ * extracting
*/
public static String[] unpackStylePreferences(String preference) {
- String[] stylePrefs = null;
+ String[] stylePrefs = new String[6];
if (preference != null) {
StringTokenizer st = new StringTokenizer(preference, STYLE_SEPARATOR);
- if (st.countTokens() == 3) {
- String foreground = st.nextToken().trim();
- String background = st.nextToken().trim();
- String bold = st.nextToken().trim();
+ String foreground = st.nextToken().trim();
+ String background = st.nextToken().trim();
+ stylePrefs[0] = foreground;
+ stylePrefs[1] = background;
- stylePrefs = new String[3];
- stylePrefs[0] = foreground;
- stylePrefs[1] = background;
- stylePrefs[2] = bold;
+ if (st.hasMoreTokens()) {
+ String bold = st.nextToken().trim();
+ stylePrefs[2] = Boolean.valueOf(bold).toString();
+ }
+ else {
+ stylePrefs[2] = Boolean.FALSE.toString();
+ }
+ if (st.hasMoreTokens()) {
+ String italic = st.nextToken().trim();
+ stylePrefs[3] = Boolean.valueOf(italic).toString();
+ }
+ else {
+ stylePrefs[3] = Boolean.FALSE.toString();
+ }
+ if (st.hasMoreTokens()) {
+ String strikethrough = st.nextToken().trim();
+ stylePrefs[4] = Boolean.valueOf(strikethrough).toString();
+ }
+ else {
+ stylePrefs[4] = Boolean.FALSE.toString();
+ }
+ if (st.hasMoreTokens()) {
+ String underline = st.nextToken().trim();
+ stylePrefs[5] = Boolean.valueOf(underline).toString();
+ }
+ else {
+ stylePrefs[5] = Boolean.FALSE.toString();
}
}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/StyledTextColorPicker.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/StyledTextColorPicker.java
index 6fbb099..006c5c0 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/StyledTextColorPicker.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/ui/StyledTextColorPicker.java
@@ -16,9 +16,12 @@
import java.util.Dictionary;
import java.util.List;
+import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.ACC;
import org.eclipse.swt.accessibility.AccessibleAdapter;
@@ -38,11 +41,6 @@
import org.eclipse.swt.events.TraverseListener;
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.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -104,7 +102,7 @@
*/
public void getValue(AccessibleControlEvent e) {
if (e.childID == ACC.CHILDID_SELF) {
- e.result = getColorButtonValue(fBackground);
+ e.result = fBackground.getColorValue().toString();
}
}
};
@@ -118,39 +116,7 @@
String namedStyle = getStyleName(fStyleCombo.getItem(fStyleCombo.getSelectionIndex()));
if (namedStyle == null)
return;
- if (e.widget == fForeground) {
- // get current (newly old) style
- String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[0];
- // open color dialog to get new color
- String newValue = changeColor(oldValue);
-
- if (!newValue.equals(oldValue)) {
- stylePrefs[0] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
- refresh();
- }
- }
- } else if (e.widget == fBackground) {
- // get current (newly old) style
- String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[1];
- // open color dialog to get new color
- String newValue = changeColor(oldValue);
-
- if (!newValue.equals(oldValue)) {
- stylePrefs[1] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
- refresh();
- }
- }
- } else if (e.widget == fBold) {
+ if (e.widget == fBold) {
// get current (newly old) style
String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
@@ -197,7 +163,7 @@
activate(getStyleName(description));
}
};
- protected Button fBackground;
+ protected ColorSelector fBackground;
protected Label fBackgroundLabel;
protected Button fBold;
protected Button fClearStyle;
@@ -210,7 +176,7 @@
// Dictionary mapping the ITextRegion types above to display strings, for
// use in the combo box
protected Dictionary fDescriptions = null;
- protected Button fForeground;
+ protected ColorSelector fForeground;
protected Label fForegroundLabel;
// private String fGeneratorKey;
protected String fInput = ""; //$NON-NLS-1$
@@ -224,7 +190,7 @@
*/
public void getValue(AccessibleControlEvent e) {
if (e.childID == ACC.CHILDID_SELF) {
- e.result = getColorButtonValue(fForeground);
+ e.result = fForeground.getColorValue().toString();
}
}
};
@@ -285,22 +251,14 @@
if (color == null) {
color = fDefaultForeground;
}
- if (fForeground.getSize().x > 0 && fForeground.getSize().y > 0 && (fForeground.getImage() == null || fForeground.getImage().getImageData() == null || fForeground.getImage().getImageData().getRGBs() == null || fForeground.getImage().getImageData().getRGBs().length < 1 || !fForeground.getImage().getImageData().getRGBs()[0].equals(color.getRGB()))) {
- if (fForeground.getImage() != null)
- fForeground.getImage().dispose();
- Image foreground = new Image(getDisplay(), new ImageData(fForeground.getSize().x, fForeground.getSize().y, 1, new PaletteData(new RGB[]{color.getRGB()})));
- fForeground.setImage(foreground);
- }
+ fForeground.setColorValue(color.getRGB());
+
color = attribute.getBackground();
if (color == null) {
color = fDefaultBackground;
}
- if (fBackground.getSize().x > 0 && fBackground.getSize().y > 0 && (fBackground.getImage() == null || fBackground.getImage().getImageData() == null || fBackground.getImage().getImageData().getRGBs() == null || fBackground.getImage().getImageData().getRGBs().length < 1 || !fBackground.getImage().getImageData().getRGBs()[0].equals(color.getRGB()))) {
- if (fBackground.getImage() != null)
- fBackground.getImage().dispose();
- Image background = new Image(getDisplay(), new ImageData(fBackground.getSize().x, fBackground.getSize().y, 1, new PaletteData(new RGB[]{color.getRGB()})));
- fBackground.setImage(background);
- }
+ fBackground.setColorValue(color.getRGB());
+
fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0);
if (showItalic)
fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0);
@@ -356,21 +314,6 @@
}
/**
- * Determines size of color button copied from
- * org.eclipse.jdt.internal.ui.preferences.ColorEditor 1 modification -
- * added 4 to final height
- */
- private 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 + 4);
- return p;
- }
-
- /**
* Creates an new checkbox instance and sets the default layout data.
*
* @param group
@@ -435,9 +378,10 @@
// row 2 - foreground label, button, background label, button, bold,
// italics?
fForegroundLabel = createLabel(styleRow2, SSEUIMessages.Foreground_UI_); //$NON-NLS-1$ = "Foreground"
- fForeground = createPushButton(styleRow2, ""); //$NON-NLS-1$
- setAccessible(fForeground, fForegroundLabel.getText());
- fForeground.getAccessible().addAccessibleControlListener(foregroundAccListener); // defect
+ fForeground = new ColorSelector(styleRow2);
+ fForeground.getButton().setLayoutData(new GridData());
+ setAccessible(fForeground.getButton(), fForegroundLabel.getText());
+ fForeground.getButton().getAccessible().addAccessibleControlListener(foregroundAccListener); // defect
// 200764
// -
// ACC:display
@@ -445,13 +389,12 @@
// for
// color
// buttons
- Point buttonSize = computeImageSize(parent);
- ((GridData) fForeground.getLayoutData()).widthHint = buttonSize.x;
- ((GridData) fForeground.getLayoutData()).heightHint = buttonSize.y;
+ ((GridData) fForeground.getButton().getLayoutData()).minimumWidth = 20;
fBackgroundLabel = createLabel(styleRow2, SSEUIMessages.Background_UI_); //$NON-NLS-1$ = "Background"
- fBackground = createPushButton(styleRow2, ""); //$NON-NLS-1$
- setAccessible(fBackground, fBackgroundLabel.getText());
- fBackground.getAccessible().addAccessibleControlListener(backgroundAccListener); // defect
+ fBackground = new ColorSelector(styleRow2);
+ fBackground.getButton().setLayoutData(new GridData());
+ setAccessible(fBackground.getButton(), fBackgroundLabel.getText());
+ fBackground.getButton().getAccessible().addAccessibleControlListener(backgroundAccListener); // defect
// 200764
// -
// ACC:display
@@ -459,8 +402,7 @@
// for
// color
// buttons
- ((GridData) fBackground.getLayoutData()).widthHint = buttonSize.x;
- ((GridData) fBackground.getLayoutData()).heightHint = buttonSize.y;
+ ((GridData) fBackground.getButton().getLayoutData()).minimumWidth = 20;
createLabel(styleRow2, ""); //$NON-NLS-1$
fBold = createCheckBox(styleRow2, SSEUIMessages.Bold_UI_);
if (showItalic)
@@ -491,8 +433,51 @@
// traversal for
// fText widget
setAccessible(fText, SSEUIMessages.Sample_text__UI_); //$NON-NLS-1$ = "&Sample text:"
- fForeground.addSelectionListener(buttonListener);
- fBackground.addSelectionListener(buttonListener);
+ fForeground.addListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
+ // get current (newly old) style
+ String namedStyle = getStyleName(fStyleCombo.getItem(fStyleCombo.getSelectionIndex()));
+ String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
+ String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
+ if (stylePrefs != null) {
+ String oldValue = stylePrefs[0];
+ // open color dialog to get new color
+ String newValue = changeColor(oldValue);
+
+ if (!newValue.equals(oldValue)) {
+ stylePrefs[0] = newValue;
+ String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
+ getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
+ refresh();
+ }
+ }
+ }
+ }
+ });
+ fBackground.addListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
+ // get current (newly old) style
+ String namedStyle = getStyleName(fStyleCombo.getItem(fStyleCombo.getSelectionIndex()));
+ String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
+ String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
+ if (stylePrefs != null) {
+ String oldValue = stylePrefs[1];
+ // open color dialog to get new color
+ String newValue = changeColor(oldValue);
+
+ if (!newValue.equals(oldValue)) {
+ stylePrefs[1] = newValue;
+ String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
+ getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
+ refresh();
+ }
+ }
+ }
+ }
+ });
+
fClearStyle.addSelectionListener(buttonListener);
fBold.addSelectionListener(buttonListener);
if (showItalic)
@@ -553,12 +538,12 @@
/**
* @return String - color Button b's current RBG value
*/
- private String getColorButtonValue(Button b) {
- if ((b == null) || (b.getImage() == null) || (b.getImage().getImageData() == null) || (b.getImage().getImageData().getRGBs() == null) || (b.getImage().getImageData().getRGBs()[0] == null))
- return null;
- String val = b.getImage().getImageData().getRGBs()[0].toString();
- return val;
- }
+// private String getColorButtonValue(Button b) {
+// if ((b == null) || (b.getImage() == null) || (b.getImage().getImageData() == null) || (b.getImage().getImageData().getRGBs() == null) || (b.getImage().getImageData().getRGBs()[0] == null))
+// return null;
+// String val = b.getImage().getImageData().getRGBs()[0].toString();
+// return val;
+// }
/**
* @deprecated use getPreferenceStore instead left for legacy clients,
@@ -769,10 +754,10 @@
}
public void releasePickerResources() {
- if (fForeground != null && !fForeground.isDisposed() && fForeground.getImage() != null)
- fForeground.getImage().dispose();
- if (fBackground != null && !fBackground.isDisposed() && fBackground.getImage() != null)
- fBackground.getImage().dispose();
+// if (fForeground != null && !fForeground.isDisposed() && fForeground.getImage() != null)
+// fForeground.getImage().dispose();
+// if (fBackground != null && !fBackground.isDisposed() && fBackground.getImage() != null)
+// fBackground.getImage().dispose();
}
private void selectColorAtOffset(int offset) {
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/provisional/style/AbstractLineStyleProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/provisional/style/AbstractLineStyleProvider.java
index 9194a57..586c2d5 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/provisional/style/AbstractLineStyleProvider.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/provisional/style/AbstractLineStyleProvider.java
@@ -88,7 +88,25 @@
RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
RGB background = ColorHelper.toRGB(stylePrefs[1]);
boolean bold = Boolean.valueOf(stylePrefs[2]).booleanValue();
- getTextAttributes().put(colorKey, createTextAttribute(foreground, background, bold));
+ boolean italic = Boolean.valueOf(stylePrefs[3]).booleanValue();
+ boolean strikethrough = Boolean.valueOf(stylePrefs[4]).booleanValue();
+ boolean underline = Boolean.valueOf(stylePrefs[5]).booleanValue();
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italic) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ TextAttribute createTextAttribute = createTextAttribute(foreground, background, style);
+ getTextAttributes().put(colorKey, createTextAttribute);
}
}
}
@@ -112,6 +130,12 @@
if (end > maxOffset)
end = maxOffset;
StyleRange result = new StyleRange(start, end - start, attr.getForeground(), attr.getBackground(), attr.getStyle());
+ if((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) {
+ result.strikeout = true;
+ }
+ if((attr.getStyle() & TextAttribute.UNDERLINE) != 0) {
+ result.underline = true;
+ }
return result;
}
@@ -120,6 +144,10 @@
return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, bold ? SWT.BOLD : SWT.NORMAL);
}
+ protected TextAttribute createTextAttribute(RGB foreground, RGB background, int style) {
+ return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, style);
+ }
+
abstract protected TextAttribute getAttributeFor(ITextRegion region);
abstract protected IPreferenceStore getColorPreferences();