[88951] for LineStyleProviderForJava (which is used for JSP scriptlet regions), bg color is now user selectable (default white)
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java
index ed663ec..ebc084e 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIMessages.java
@@ -73,6 +73,7 @@
public static String JSPSourcePreferencePage_0;
public static String JSPSourcePreferencePage_1;
public static String JSPSourcePreferencePage_2;
+ public static String JSPColorPage_jsp_content;
static {
// load message values from bundle file
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties
index 18ed4a9..c559209 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/JSPUIPluginResources.properties
@@ -67,4 +67,5 @@
#
JSPSourcePreferencePage_0=JSP Source preferences are based on the content within the JSP.
JSPSourcePreferencePage_1=See <a>''{0}''</a> for JSP with HTML content.
-JSPSourcePreferencePage_2=See <a>''{0}''</a> for JSP with XML content.
\ No newline at end of file
+JSPSourcePreferencePage_2=See <a>''{0}''</a> for JSP with XML content.
+JSPColorPage_jsp_content=JSP Content
\ No newline at end of file
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/JSPUIPreferenceInitializer.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/JSPUIPreferenceInitializer.java
index bb908c4..2f9e58e 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/JSPUIPreferenceInitializer.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/JSPUIPreferenceInitializer.java
@@ -4,6 +4,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
+import org.eclipse.jst.jsp.ui.internal.style.IStyleConstantsJSP;
import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML;
import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
@@ -51,6 +52,11 @@
styleValue = ColorHelper.getColorString(191, 95, 63) + NOBACKGROUNDBOLD;
store.setDefault(IStyleConstantsHTML.SCRIPT_AREA_BORDER, styleValue);
+ // white by default until requested otherwise
+ //styleValue = "null | " + ColorHelper.getColorString(240, 220, 200) + " | false"; //$NON-NLS-1$//$NON-NLS-2$
+ styleValue = "null | " + ColorHelper.getColorString(255,255,255) + " | false"; //$NON-NLS-1$//$NON-NLS-2$
+ store.setDefault(IStyleConstantsJSP.JSP_CONTENT, styleValue);
+
// set default new jsp file template to use in new file wizard
/*
* Need to find template name that goes with default template id (name
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPColorPage.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPColorPage.java
index e199d3c..0a320b4 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPColorPage.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/preferences/ui/JSPColorPage.java
@@ -21,6 +21,7 @@
import org.eclipse.jst.jsp.ui.internal.JSPUIMessages;
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
import org.eclipse.jst.jsp.ui.internal.editor.IHelpContextIds;
+import org.eclipse.jst.jsp.ui.internal.style.IStyleConstantsJSP;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -75,12 +76,17 @@
contextStyleMap.put(DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN, IStyleConstantsHTML.SCRIPT_AREA_BORDER);
contextStyleMap.put(DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE, IStyleConstantsHTML.SCRIPT_AREA_BORDER);
contextStyleMap.put(DOMJSPRegionContexts.JSP_CLOSE, IStyleConstantsHTML.SCRIPT_AREA_BORDER);
+
+ contextStyleMap.put(DOMJSPRegionContexts.JSP_CONTENT, IStyleConstantsJSP.JSP_CONTENT);
+
contextStyleMap.put(DOMJSPRegionContexts.JSP_DIRECTIVE_NAME, IStyleConstantsXML.TAG_NAME);
contextStyleMap.put(DOMJSPRegionContexts.JSP_ROOT_TAG_NAME, IStyleConstantsXML.TAG_NAME);
contextStyleMap.put(DOMJSPRegionContexts.JSP_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER);
contextStyleMap.put(DOMJSPRegionContexts.JSP_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT);
contextStyleMap.put(DOMJSPRegionContexts.JSP_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER);
+ contextStyleMap.put(DOMJSPRegionContexts.JSP_CONTENT, IStyleConstantsJSP.JSP_CONTENT);
+
contextStyleMap.put(DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
contextStyleMap.put(DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
}
@@ -90,6 +96,7 @@
descriptions.remove(IStyleConstantsXML.XML_CONTENT); // leave content between tags alone
descriptions.remove(IStyleConstantsXML.DECL_BORDER); // xml/html specific
descriptions.put(IStyleConstantsHTML.SCRIPT_AREA_BORDER, JSPUIMessages.JSP_Delimiters_UI_); //$NON-NLS-1$ = "JSP Delimiters"
+ descriptions.put(IStyleConstantsJSP.JSP_CONTENT, JSPUIMessages.JSPColorPage_jsp_content);
}
protected void initStyleList(ArrayList list) {
@@ -97,17 +104,18 @@
list.remove(IStyleConstantsXML.XML_CONTENT); // leave content between tags alone
list.remove(IStyleConstantsXML.DECL_BORDER); // xml/html specific
list.add(IStyleConstantsHTML.SCRIPT_AREA_BORDER);
+ list.add(IStyleConstantsJSP.JSP_CONTENT);
}
protected void setupPicker(StyledTextColorPicker picker) {
IModelManager mmanager = StructuredModelManager.getModelManager();
picker.setParser(mmanager.createStructuredDocumentFor(ContentTypeIdForJSP.ContentTypeID_JSP).getParser());
- // create descriptions for hilighting types
+ // create descriptions for highlighting types
Dictionary descriptions = new Hashtable();
initDescriptions(descriptions);
- // map region types to hilighting types
+ // map region types to highlighting types
Dictionary contextStyleMap = new Hashtable();
initContextStyleMap(contextStyleMap);
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/IStyleConstantsJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/IStyleConstantsJSP.java
new file mode 100644
index 0000000..87860e6
--- /dev/null
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/IStyleConstantsJSP.java
@@ -0,0 +1,5 @@
+package org.eclipse.jst.jsp.ui.internal.style;
+
+public interface IStyleConstantsJSP {
+ public static final String JSP_CONTENT = "jsp_content";
+}
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/JavaCodeScanner.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/JavaCodeScanner.java
index 5114372..c69436d 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/JavaCodeScanner.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/style/java/JavaCodeScanner.java
@@ -22,7 +22,6 @@
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
-import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.swt.graphics.Color;
import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
@@ -56,8 +55,8 @@
*/
public JavaCodeScanner() {
// if we use null here, system default will be used
- Color background = null; //provider.getColor(JavaColorProvider.EDITOR_BACKGROUND);
+ Color background = null; //provider.getColor(JavaColorProvider.EDITOR_BACKGROUND);
JavaColorProvider.getInstance().loadJavaColors();
IToken keyword = new Token(new TextAttribute(EditorUtility.getColor(JavaColorProvider.KEYWORD), background, JavaColorProvider.KEYWORD_BOLD));
IToken type = new Token(new TextAttribute(EditorUtility.getColor(JavaColorProvider.TYPE), background, JavaColorProvider.TYPE_BOLD));
@@ -79,7 +78,7 @@
rules.add(new SingleLineRule("'", "'", string, '\\'));//$NON-NLS-2$//$NON-NLS-1$
// Add generic whitespace rule.
- rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));
+ //rules.add(new WhitespaceRule(new JavaWhitespaceDetector()));
// Add word rule for keywords, types, and constants.
WordRule wordRule = new WordRule(new JavaWordDetector(), other);
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 cca3fe6..36110a5 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
@@ -23,10 +23,12 @@
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
+import org.eclipse.jst.jsp.ui.internal.style.IStyleConstantsJSP;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.wst.html.ui.internal.style.IStyleConstantsHTML;
+import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
import org.eclipse.wst.sse.ui.internal.provisional.style.AbstractLineStyleProvider;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
@@ -49,7 +51,6 @@
loadColors();
fScanner = new JavaCodeScanner();
fDefaultTextAttribute = new TextAttribute(EditorUtility.getColor(JavaColorProvider.DEFAULT));
-
}
/**
@@ -62,11 +63,7 @@
*/
protected void addRange(Collection presentation, int offset, int length, TextAttribute attr) {
- Point range = getHighlighter().getTextViewer().getSelectedRange();
- int caret = range.x;
- int selection = range.y;
- IDocument doc = getDocument();
- Color bg = attr.getBackground();
+// Color bg = attr.getBackground();
// all editors use same background color
// // if current line highlight on, use line highlight color for background
// if(JavaColorProvider.EDITOR_CURRENT_LINE && selection == 1) {
@@ -79,8 +76,14 @@
// Logger.logException(e);
// }
// }
-
- presentation.add(new StyleRange(offset, length, attr.getForeground(), bg, attr.getStyle()));
+ // support for user defined backgroud for JSP scriptlet regions
+ String styleString = JSPUIPlugin.getDefault().getPreferenceStore().getString(IStyleConstantsJSP.JSP_CONTENT);
+ String[] prefs = ColorHelper.unpackStylePreferences(styleString);
+ Color bgColor = (prefs != null && prefs.length == 3 && Display.getCurrent() != null)
+ ? new Color(Display.getCurrent(), ColorHelper.toRGB(prefs[1]))
+ : attr.getBackground();
+
+ presentation.add(new StyleRange(offset, length, attr.getForeground(), bgColor, attr.getStyle()));
}
protected void clearColors() {
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 d2999e3..85de62e 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
@@ -268,14 +268,33 @@
fForegroundLabel.setEnabled(false);
fBackgroundLabel.setEnabled(false);
} else {
- fForeground.setEnabled(true);
- fBackground.setEnabled(true);
- fClearStyle.setEnabled(true);
- fBold.setEnabled(true);
- if (showItalic)
- fItalic.setEnabled(true);
- fForegroundLabel.setEnabled(true);
- fBackgroundLabel.setEnabled(true);
+ // more granular enablement of StyledColorWidget
+ String colorStyleString = getPreferenceStore().getString(namedStyle);
+ String[] prefs = ColorHelper.unpackStylePreferences(colorStyleString);
+ if(prefs != null && prefs.length == 3) {
+ fForeground.setEnabled(prefs[0].startsWith("#"));
+ fForegroundLabel.setEnabled(prefs[0].startsWith("#"));
+
+ fBackground.setEnabled(prefs[1].startsWith("#"));
+ fBackgroundLabel.setEnabled(prefs[1].startsWith("#"));
+
+ fBold.setEnabled(prefs[1].equals("true"));
+
+ fClearStyle.setEnabled(true);
+ if (showItalic)
+ fItalic.setEnabled(true);
+ }
+ else {
+
+ fForeground.setEnabled(true);
+ fBackground.setEnabled(true);
+ fClearStyle.setEnabled(true);
+ fBold.setEnabled(true);
+ if (showItalic)
+ fItalic.setEnabled(true);
+ fForegroundLabel.setEnabled(true);
+ fBackgroundLabel.setEnabled(true);
+ }
}
TextAttribute attribute = getAttribute(namedStyle);
Color color = attribute.getForeground();