[168408] JSP Highlighting is flaky
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/LineStyleProviderForJava.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/LineStyleProviderForJava.java
index 2c70ebe..60b4dd8 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/LineStyleProviderForJava.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/LineStyleProviderForJava.java
@@ -82,7 +82,14 @@
Color bgColor = ta.getBackground();
if (bgColor == null)
bgColor = attr.getBackground();
- presentation.add(new StyleRange(offset, length, attr.getForeground(), bgColor, attr.getStyle()));
+ StyleRange result = new StyleRange(offset, length, attr.getForeground(), bgColor, attr.getStyle());
+ if((attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0) {
+ result.strikeout = true;
+ }
+ if((attr.getStyle() & TextAttribute.UNDERLINE) != 0) {
+ result.underline = true;
+ }
+ presentation.add(result);
}
/**
@@ -99,7 +106,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);
}
}
}
@@ -119,25 +144,89 @@
RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR);
boolean bold = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD);
boolean italics = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC);
- ta = createTextAttribute(foreground, null, bold, italics);
+ boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_STRIKETHROUGH);
+ boolean underline = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italics) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ ta = createTextAttribute(foreground, null, style);
} else if (colorKey == IStyleConstantsJSPJava.JAVA_STRING) {
// string
RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_STRING_COLOR);
boolean bold = store.getBoolean(PreferenceConstants.EDITOR_STRING_BOLD);
boolean italics = store.getBoolean(PreferenceConstants.EDITOR_STRING_ITALIC);
- ta = createTextAttribute(foreground, null, bold, italics);
+ boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_STRING_STRIKETHROUGH);
+ boolean underline = store.getBoolean(PreferenceConstants.EDITOR_STRING_UNDERLINE);
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italics) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ ta = createTextAttribute(foreground, null, style);
} else if (colorKey == IStyleConstantsJSPJava.JAVA_SINGLE_LINE_COMMENT) {
// single line comment
RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR);
boolean bold = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD);
boolean italics = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC);
- ta = createTextAttribute(foreground, null, bold, italics);
+ boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_STRIKETHROUGH);
+ boolean underline = store.getBoolean(PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_UNDERLINE);
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italics) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ ta = createTextAttribute(foreground, null, style);
} else if (colorKey == IStyleConstantsJSPJava.JAVA_DEFAULT) {
// default
RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR);
boolean bold = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD);
boolean italics = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC);
- ta = createTextAttribute(foreground, null, bold, italics);
+ boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_STRIKETHROUGH);
+ boolean underline = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_UNDERLINE);
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italics) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ ta = createTextAttribute(foreground, null, style);
}
if (ta != null) {
getTextAttributes().put(colorKey, ta);
@@ -145,16 +234,8 @@
}
}
}
-
- private TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold) {
- return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, bold ? SWT.BOLD : SWT.NORMAL);
- }
- private TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold, boolean italics) {
- int style = bold ? SWT.BOLD : SWT.NORMAL;
- if (italics)
- style |= SWT.ITALIC;
-
+ private TextAttribute createTextAttribute(RGB foreground, RGB background, int style) {
return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, style);
}
@@ -281,7 +362,6 @@
fScanner.setRange(document, lastStart, remainingLength);
while (true) {
-
IToken token = fScanner.nextToken();
if (token.isEOF()) {
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/jspel/LineStyleProviderForJSPEL.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/jspel/LineStyleProviderForJSPEL.java
index 8f000a0..ca5844e 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/jspel/LineStyleProviderForJSPEL.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/jspel/LineStyleProviderForJSPEL.java
@@ -107,7 +107,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);
}
}
}
@@ -127,13 +145,45 @@
RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR);
boolean bold = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD);
boolean italics = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC);
- ta = createTextAttribute(foreground, null, bold, italics);
+ boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_STRIKETHROUGH);
+ boolean underline = store.getBoolean(PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italics) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ ta = createTextAttribute(foreground, null, style);
} else if (colorKey == IStyleConstantsJSPEL.EL_DEFAULT) {
// default
RGB foreground = PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR);
boolean bold = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD);
boolean italics = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC);
- ta = createTextAttribute(foreground, null, bold, italics);
+ boolean strikethrough = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_STRIKETHROUGH);
+ boolean underline = store.getBoolean(PreferenceConstants.EDITOR_JAVA_DEFAULT_UNDERLINE);
+ int style = SWT.NORMAL;
+ if (bold) {
+ style = style | SWT.BOLD;
+ }
+ if (italics) {
+ style = style | SWT.ITALIC;
+ }
+ if (strikethrough) {
+ style = style | TextAttribute.STRIKETHROUGH;
+ }
+ if (underline) {
+ style = style | TextAttribute.UNDERLINE;
+ }
+
+ ta = createTextAttribute(foreground, null, style);
}
if (ta != null) {
getTextAttributes().put(colorKey, ta);
@@ -141,16 +191,8 @@
}
}
}
-
- private TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold) {
- return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, bold ? SWT.BOLD : SWT.NORMAL);
- }
-
- private TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold, boolean italics) {
- int style = bold ? SWT.BOLD : SWT.NORMAL;
- if (italics)
- style |= SWT.ITALIC;
-
+
+ private TextAttribute createTextAttribute(RGB foreground, RGB background, int style) {
return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, style);
}
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 4e08fe2..77e67fb 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
@@ -14,11 +14,11 @@
-import com.ibm.icu.util.StringTokenizer;
-
import org.eclipse.swt.graphics.RGB;
import org.eclipse.wst.sse.ui.internal.Logger;
+import com.ibm.icu.util.StringTokenizer;
+
public class ColorHelper {
public final static String BACKGROUND = "background";//$NON-NLS-1$
@@ -26,6 +26,7 @@
public final static String FOREGROUND = "foreground";//$NON-NLS-1$
public final static String NAME = "name";//$NON-NLS-1$
private final static String STYLE_SEPARATOR = "|"; //$NON-NLS-1$
+ private final static String NULL = "null"; //$NON-NLS-1$
/**
* Return an RGB String given the int r, g, b values
@@ -64,7 +65,7 @@
styleString.append(s);
}
else {
- styleString.append(Boolean.FALSE.toString());
+ styleString.append(NULL);
}
}
else {
@@ -140,10 +141,20 @@
String[] stylePrefs = new String[6];
if (preference != null) {
StringTokenizer st = new StringTokenizer(preference, STYLE_SEPARATOR);
- String foreground = st.nextToken().trim();
- String background = st.nextToken().trim();
- stylePrefs[0] = foreground;
- stylePrefs[1] = background;
+ if (st.hasMoreTokens()) {
+ String foreground = st.nextToken().trim();
+ stylePrefs[0] = foreground;
+ }
+ else {
+ stylePrefs[0] = NULL;
+ }
+ if (st.hasMoreTokens()) {
+ String background = st.nextToken().trim();
+ stylePrefs[1] = background;
+ }
+ else {
+ stylePrefs[1] = NULL;
+ }
if (st.hasMoreTokens()) {
String bold = st.nextToken().trim();
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 006c5c0..6112076 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
@@ -45,7 +45,6 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -118,7 +117,7 @@
return;
if (e.widget == fBold) {
// get current (newly old) style
- String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
+ String prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[2];
@@ -126,13 +125,13 @@
if (!newValue.equals(oldValue)) {
stylePrefs[2] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
+ getPreferenceStore().setValue(namedStyle, newPrefString);
refresh();
}
}
} else if (showItalic && e.widget == fItalic) {
// get current (newly old) style
- String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
+ String prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[3];
@@ -140,12 +139,12 @@
if (!newValue.equals(oldValue)) {
stylePrefs[3] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
+ getPreferenceStore().setValue(namedStyle, newPrefString);
refresh();
}
}
} else if (e.widget == fClearStyle) {
- getPreferenceStore().setToDefault(getPreferenceKey(namedStyle));
+ getPreferenceStore().setToDefault(namedStyle);
refresh();
}
}
@@ -287,29 +286,6 @@
}
}
- private RGB changeColor(RGB startValue) {
- ColorDialog colorDlg = new ColorDialog(getShell());
- if (startValue != null)
- colorDlg.setRGB(startValue);
- if(colorDlg.getText() == null || colorDlg.getText().length() == 0)
- colorDlg.setText(SSEUIMessages.StyledTextColorPicker_0);
- colorDlg.open();
- RGB newRGB = colorDlg.getRGB();
- if (newRGB != null)
- return newRGB;
- return startValue;
- }
-
- private String changeColor(String rgb) {
- String changedColor = "null"; //$NON-NLS-1$
-
- RGB newColor = changeColor(ColorHelper.toRGB(rgb));
- // null check to see if using default value
- if (newColor != null)
- changedColor = ColorHelper.toRGBString(newColor);
- return changedColor;
- }
-
protected void close() {
}
@@ -438,17 +414,20 @@
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 prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[0];
- // open color dialog to get new color
- String newValue = changeColor(oldValue);
+ String newValue = "null"; //$NON-NLS-1$
+ Object newValueObject = event.getNewValue();
+ if (newValueObject instanceof RGB) {
+ newValue = ColorHelper.toRGBString((RGB)newValueObject);
+ }
if (!newValue.equals(oldValue)) {
stylePrefs[0] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
+ getPreferenceStore().setValue(namedStyle, newPrefString);
refresh();
}
}
@@ -460,17 +439,21 @@
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 prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
String oldValue = stylePrefs[1];
- // open color dialog to get new color
- String newValue = changeColor(oldValue);
-
+
+ String newValue = "null"; //$NON-NLS-1$
+ Object newValueObject = event.getNewValue();
+ if (newValueObject instanceof RGB) {
+ newValue = ColorHelper.toRGBString((RGB)newValueObject);
+ }
+
if (!newValue.equals(oldValue)) {
stylePrefs[1] = newValue;
String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getPreferenceStore().setValue(getPreferenceKey(namedStyle), newPrefString);
+ getPreferenceStore().setValue(namedStyle, newPrefString);
refresh();
}
}
@@ -511,7 +494,7 @@
TextAttribute ta = new TextAttribute(getDefaultForeground(), getDefaultBackground(), SWT.NORMAL);
if (namedStyle != null && getPreferenceStore() != null) {
- String prefString = getPreferenceStore().getString(getPreferenceKey(namedStyle));
+ String prefString = getPreferenceStore().getString(namedStyle);
String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
if (stylePrefs != null) {
RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
@@ -623,17 +606,6 @@
return fParser;
}
- /**
- * @deprecated just key key (no need for generator)
- */
- private String getPreferenceKey(String key) {
- String newKey = key;
-// if (fGeneratorKey != null) {
-// newKey = PreferenceKeyGenerator.generateKey(key, fGeneratorKey);
-// }
- return newKey;
- }
-
private IPreferenceStore getPreferenceStore() {
return fPreferenceStore;
}