Bug 62237 - Ant syntax coloring options lacks a preview
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AbstractAntSourceViewerConfiguration.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AbstractAntSourceViewerConfiguration.java
index 573a291..2347e8e 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AbstractAntSourceViewerConfiguration.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AbstractAntSourceViewerConfiguration.java
@@ -17,13 +17,19 @@
import org.eclipse.ant.internal.ui.editor.text.IAntEditorColorConstants;
import org.eclipse.ant.internal.ui.editor.text.MultilineDamagerRepairer;
import org.eclipse.ant.internal.ui.model.AntUIPlugin;
-import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.ant.internal.ui.model.ColorManager;
+import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
public abstract class AbstractAntSourceViewerConfiguration extends SourceViewerConfiguration {
@@ -31,6 +37,7 @@
private AntEditorTagScanner tagScanner;
private AntEditorProcInstrScanner instructionScanner;
private MultilineDamagerRepairer damageRepairer;
+ private TextAttribute xmlCommentAttribute;
private AntEditorProcInstrScanner getDefaultScanner() {
if (instructionScanner == null) {
@@ -57,8 +64,8 @@
reconciler.setDamager(dr, AntEditorPartitionScanner.XML_TAG);
reconciler.setRepairer(dr, AntEditorPartitionScanner.XML_TAG);
- damageRepairer= new MultilineDamagerRepairer(null,
- new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.XML_COMMENT_COLOR)));
+ xmlCommentAttribute= new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.XML_COMMENT_COLOR));
+ damageRepairer= new MultilineDamagerRepairer(null, xmlCommentAttribute);
reconciler.setDamager(damageRepairer, AntEditorPartitionScanner.XML_COMMENT);
reconciler.setRepairer(damageRepairer, AntEditorPartitionScanner.XML_COMMENT);
@@ -69,15 +76,58 @@
* Preference colors have changed.
* Update the default tokens of the scanners.
*/
- public void updateScanners() {
+ public void adaptToPreferenceChange(PropertyChangeEvent event) {
if (tagScanner == null) {
return; //property change before the editor is fully created
}
- tagScanner.adaptToColorChange();
- instructionScanner.adaptToColorChange();
-
- damageRepairer.setDefaultTextAttribute(new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.XML_COMMENT_COLOR)));
+ tagScanner.adaptToPreferenceChange(event);
+ instructionScanner.adaptToPreferenceChange(event);
+ String property= event.getProperty();
+ if (property.startsWith(IAntEditorColorConstants.XML_COMMENT_COLOR)) {
+ if (property.endsWith(AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)) {
+ adaptToStyleChange(event, SWT.BOLD);
+ } else if (property.endsWith(AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)) {
+ adaptToStyleChange(event, SWT.ITALIC);
+ } else {
+ adaptToColorChange(event);
+ }
+ damageRepairer.setDefaultTextAttribute(xmlCommentAttribute);
+ }
}
+
+ private void adaptToStyleChange(PropertyChangeEvent event, int styleAttribute) {
+ boolean eventValue= false;
+ Object value= event.getNewValue();
+ if (value instanceof Boolean) {
+ eventValue= ((Boolean) value).booleanValue();
+ } else if (IPreferenceStore.TRUE.equals(value)) {
+ eventValue= true;
+ }
+
+ boolean activeValue= (xmlCommentAttribute.getStyle() & styleAttribute) == styleAttribute;
+ if (activeValue != eventValue) {
+ xmlCommentAttribute= new TextAttribute(xmlCommentAttribute.getForeground(), xmlCommentAttribute.getBackground(), eventValue ? xmlCommentAttribute.getStyle() | styleAttribute : xmlCommentAttribute.getStyle() & ~styleAttribute);
+ }
+ }
+
+ /**
+ * Update the text attributes associated with the tokens of this scanner as a color preference has been changed.
+ */
+ private void adaptToColorChange(PropertyChangeEvent event) {
+ RGB rgb= null;
+
+ Object value= event.getNewValue();
+ if (value instanceof RGB) {
+ rgb= (RGB) value;
+ } else if (value instanceof String) {
+ rgb= StringConverter.asRGB((String) value);
+ }
+
+ if (rgb != null) {
+ xmlCommentAttribute= new TextAttribute(ColorManager.getDefault().getColor(rgb), xmlCommentAttribute.getBackground(), xmlCommentAttribute.getStyle());
+ }
+ }
+
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] {
@@ -89,4 +139,13 @@
public int getTabWidth(ISourceViewer sourceViewer) {
return AntUIPlugin.getDefault().getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
+
+ public boolean affectsTextPresentation(PropertyChangeEvent event) {
+ String property= event.getProperty();
+ return property.startsWith(IAntEditorColorConstants.TEXT_COLOR) ||
+ property.startsWith(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR) ||
+ property.startsWith(IAntEditorColorConstants.STRING_COLOR) ||
+ property.startsWith(IAntEditorColorConstants.TAG_COLOR) ||
+ property.startsWith(IAntEditorColorConstants.XML_COMMENT_COLOR);
+ }
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java
index 46a0ca6..c5462a8 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditor.java
@@ -23,7 +23,6 @@
import org.eclipse.ant.internal.ui.editor.outline.XMLCore;
import org.eclipse.ant.internal.ui.editor.text.AnnotationAccess;
import org.eclipse.ant.internal.ui.editor.text.AntEditorDocumentProvider;
-import org.eclipse.ant.internal.ui.editor.text.IAntEditorColorConstants;
import org.eclipse.ant.internal.ui.editor.text.IReconcilingParticipant;
import org.eclipse.ant.internal.ui.model.AntUIPlugin;
import org.eclipse.ant.internal.ui.model.AntUtil;
@@ -451,12 +450,7 @@
* @see org.eclipse.ui.texteditor.AbstractTextEditor#affectsTextPresentation(org.eclipse.jface.util.PropertyChangeEvent)
*/
protected boolean affectsTextPresentation(PropertyChangeEvent event) {
- String property= event.getProperty();
- return property.equals(IAntEditorColorConstants.TEXT_COLOR) ||
- property.equals(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR) ||
- property.equals(IAntEditorColorConstants.STRING_COLOR) ||
- property.equals(IAntEditorColorConstants.TAG_COLOR) ||
- property.equals(IAntEditorColorConstants.XML_COMMENT_COLOR);
+ return ((AntEditorSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event);
}
/* (non-Javadoc)
@@ -487,7 +481,7 @@
AntEditorSourceViewerConfiguration sourceViewerConfiguration= (AntEditorSourceViewerConfiguration)getSourceViewerConfiguration();
if (affectsTextPresentation(event)) {
- sourceViewerConfiguration.updateScanners();
+ sourceViewerConfiguration.adaptToPreferenceChange(event);
}
sourceViewerConfiguration.changeConfiguration(event);
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AbstractAntEditorScanner.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AbstractAntEditorScanner.java
new file mode 100644
index 0000000..d063cce
--- /dev/null
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AbstractAntEditorScanner.java
@@ -0,0 +1,76 @@
+/**********************************************************************
+Copyright (c) 2000, 2004 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ IBM Corporation - Initial implementation
+**********************************************************************/
+
+package org.eclipse.ant.internal.ui.editor.text;
+
+import org.eclipse.ant.internal.ui.model.AntUIPlugin;
+import org.eclipse.ant.internal.ui.model.ColorManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+public abstract class AbstractAntEditorScanner extends RuleBasedScanner {
+
+ protected void adaptToColorChange(PropertyChangeEvent event, Token token) {
+ RGB rgb= null;
+
+ Object value= event.getNewValue();
+ if (value instanceof RGB) {
+ rgb= (RGB) value;
+ } else if (value instanceof String) {
+ rgb= StringConverter.asRGB((String) value);
+ }
+
+ if (rgb != null) {
+ TextAttribute attr= (TextAttribute) token.getData();
+ token.setData(new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle()));
+ }
+ }
+
+ protected void adaptToStyleChange(PropertyChangeEvent event, Token token, int styleAttribute) {
+ if (token == null) {
+ return;
+ }
+ boolean eventValue= false;
+ Object value= event.getNewValue();
+ if (value instanceof Boolean) {
+ eventValue= ((Boolean) value).booleanValue();
+ } else if (IPreferenceStore.TRUE.equals(value)) {
+ eventValue= true;
+ }
+
+ TextAttribute attr= (TextAttribute) token.getData();
+ boolean activeValue= (attr.getStyle() & styleAttribute) == styleAttribute;
+ if (activeValue != eventValue) {
+ token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(), eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute));
+ }
+ }
+
+ protected TextAttribute createTextAttribute(String colorID, String boldKey, String italicKey) {
+ Color color= null;
+ if (colorID != null) {
+ color= AntUIPlugin.getPreferenceColor(colorID);
+ }
+ IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore();
+ int style= store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
+ if (store.getBoolean(italicKey)) {
+ style |= SWT.ITALIC;
+ }
+
+ return new TextAttribute(color, null, style);
+ }
+}
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorProcInstrScanner.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorProcInstrScanner.java
index 246131b..0e1f8fa 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorProcInstrScanner.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorProcInstrScanner.java
@@ -14,27 +14,27 @@
package org.eclipse.ant.internal.ui.editor.text;
-import org.eclipse.ant.internal.ui.model.AntUIPlugin;
-import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
import org.eclipse.jface.text.rules.IRule;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
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.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
/**
* The scanner to tokenize for XML processing instructions and text
*/
-public class AntEditorProcInstrScanner extends RuleBasedScanner {
+public class AntEditorProcInstrScanner extends AbstractAntEditorScanner {
Token fProcInstructionToken= null;
public AntEditorProcInstrScanner() {
IRule[] rules =new IRule[2];
fProcInstructionToken =
- new Token(
- new TextAttribute(
- AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR)));
+ new Token(createTextAttribute(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR,
+ IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX,
+ IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX));
//Add rule for processing instructions
rules[0]= new SingleLineRule("<?", "?>", fProcInstructionToken); //$NON-NLS-1$ //$NON-NLS-2$
@@ -44,15 +44,28 @@
setRules(rules);
- setDefaultReturnToken(new Token(
- new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.TEXT_COLOR))));
+ setDefaultReturnToken(new Token(createTextAttribute(IAntEditorColorConstants.TEXT_COLOR,
+ IAntEditorColorConstants.TEXT_COLOR + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX,
+ IAntEditorColorConstants.TEXT_COLOR + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)));
}
- /**
- * Update the text attributes associated with the tokens of this scanner as a color preference has been changed.
- */
- public void adaptToColorChange() {
- ((Token)fDefaultReturnToken).setData(new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.TEXT_COLOR)));
- fProcInstructionToken.setData(new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR)));
- }
+ private Token getTokenAffected(PropertyChangeEvent event) {
+ if (event.getProperty().startsWith(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR)) {
+ return fProcInstructionToken;
+ }
+ return (Token)fDefaultReturnToken;
+ }
+
+ public void adaptToPreferenceChange(PropertyChangeEvent event) {
+ String property= event.getProperty();
+ if (property.startsWith(IAntEditorColorConstants.TEXT_COLOR) || property.startsWith(IAntEditorColorConstants.PROCESSING_INSTRUCTIONS_COLOR)) {
+ if (property.endsWith(AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)) {
+ adaptToStyleChange(event, getTokenAffected(event), SWT.BOLD);
+ } else if (property.endsWith(AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)) {
+ adaptToStyleChange(event, getTokenAffected(event), SWT.ITALIC);
+ } else {
+ adaptToColorChange(event, getTokenAffected(event));
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java
index 67189ee..545cfcb 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntEditorTagScanner.java
@@ -14,26 +14,27 @@
package org.eclipse.ant.internal.ui.editor.text;
-import org.eclipse.ant.internal.ui.model.AntUIPlugin;
-import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.ant.internal.ui.preferences.AntEditorPreferenceConstants;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.MultiLineRule;
-import org.eclipse.jface.text.rules.RuleBasedScanner;
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.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
/**
* The scanner to tokenize for strings and tags
*/
-public class AntEditorTagScanner extends RuleBasedScanner {
+public class AntEditorTagScanner extends AbstractAntEditorScanner {
private Token fStringToken;
public AntEditorTagScanner() {
fStringToken= new Token(
- new TextAttribute(
- AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.STRING_COLOR)));
+ createTextAttribute(IAntEditorColorConstants.STRING_COLOR,
+ IAntEditorColorConstants.STRING_COLOR + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX,
+ IAntEditorColorConstants.STRING_COLOR + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX));
IRule[] rules= new IRule[3];
@@ -47,14 +48,30 @@
setRules(rules);
setDefaultReturnToken(
- new Token(new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.TAG_COLOR))));
+ new Token(createTextAttribute(IAntEditorColorConstants.TAG_COLOR,
+ IAntEditorColorConstants.TAG_COLOR + AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX,
+ IAntEditorColorConstants.TAG_COLOR + AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)));
}
- /**
- * Update the text attributes associated with the tokens of this scanner as a color preference has been changed.
- */
- public void adaptToColorChange() {
- ((Token)fDefaultReturnToken).setData(new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.TAG_COLOR)));
- fStringToken.setData(new TextAttribute(AntUIPlugin.getPreferenceColor(IAntEditorColorConstants.STRING_COLOR)));
+ public void adaptToPreferenceChange(PropertyChangeEvent event) {
+ String property= event.getProperty();
+ if (property.startsWith(IAntEditorColorConstants.TAG_COLOR) || property.startsWith(IAntEditorColorConstants.STRING_COLOR)) {
+ if (property.endsWith(AntEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)) {
+ adaptToStyleChange(event, getTokenAffected(event), SWT.BOLD);
+ } else if (property.endsWith(AntEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)) {
+ adaptToStyleChange(event, getTokenAffected(event), SWT.ITALIC);
+ } else {
+ adaptToColorChange(event, getTokenAffected(event));
+ }
+ }
+ }
+
+ private Token getTokenAffected(PropertyChangeEvent event) {
+ String property= event.getProperty();
+ if (property.startsWith(IAntEditorColorConstants.STRING_COLOR)) {
+ return fStringToken;
+ }// else if (property.startsWith(IAntEditorColorConstants.TAG_COLOR)) {
+ return (Token)fDefaultReturnToken;
+ //}
}
}
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencesMessages.properties b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencesMessages.properties
index 13070db..41c173f 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencesMessages.properties
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencesMessages.properties
@@ -118,7 +118,7 @@
AntEditorPreferencePage.showLineNumbers=Show lin&e numbers
AntEditorPreferencePage.highlightCurrentLine=Hi&ghlight current line
AntEditorPreferencePage.showPrintMargin=Sho&w print margin
-AntEditorPreferencePage.color=C&olor:
+AntEditorPreferencePage.6=C&olor:
AntEditorPreferencePage.appearanceOptions=Appearance co&lor options:
AntEditorPreferencePage.lineNumberForegroundColor=Line number foreground
AntEditorPreferencePage.currentLineHighlighColor=Current line highlight
@@ -128,11 +128,21 @@
AntEditorPreferencePage.Ant_editor_constant_strings_3=Constant strings
AntEditorPreferencePage.Ant_editor_tags_4=Tags
AntEditorPreferencePage.Ant_editor_comments_5=Comments
-AntEditorPreferencePage.Col&or__6=Col&or:
AntEditorPreferencePage.37=Displayed &tab width:
AntEditorPreferencePage.38=No tab width specified
AntEditorPreferencePage.39=Invalid tab width specified
+AntEditorPreferencePage.3=System de&fault
AntEditorPreferencePage.40=&Insert spaces for tabs when typing
+AntEditorPreferencePage.41= Selection foreground color
+AntEditorPreferencePage.42= Selection background color
+AntEditorPreferencePage.0=System De&fault
+AntEditorPreferencePage.1=Synta&x
+AntEditorPreferencePage.2=Background color
+AntEditorPreferencePage.4=C&ustom:
+AntEditorPreferencePage.5=Fore&ground:
+AntEditorPreferencePage.7=&Bold
+AntEditorPreferencePage.8=I&talic
+AntEditorPreferencePage.9=&Preview:
ClasspathModel.2=Ant Home Entries
ClasspathModel.3=Global Entries
@@ -148,7 +158,3 @@
AntCodeFormatterPreferencePage.8=No maximum line width specified
AntCodeFormatterPreferencePage.9=Invalid maximum line width specified
AntCodeFormatterPreferencePage.10=&Wrap long element tags
-AntCodeFormatterPreferencePage.11=White Space
-AntCodeFormatterPreferencePage.12=Delete &blank lines (work in progress)
-AntCodeFormatterPreferencePage.13=Comments
-AntCodeFormatterPreferencePage.14=&Format comments (work in progress)
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreviewerUpdater.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreviewerUpdater.java
new file mode 100644
index 0000000..abed0bd
--- /dev/null
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreviewerUpdater.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ant.internal.ui.preferences;
+
+import org.eclipse.ant.internal.ui.editor.AbstractAntSourceViewerConfiguration;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+/**
+ * Handles Java editor font changes for Java source preview viewers.
+ *
+ * @since 3.0
+ */
+class AntPreviewerUpdater {
+
+ private Color fForegroundColor= null;
+ private Color fBackgroundColor= null;
+ private Color fSelectionBackgroundColor= null;
+ private Color fSelectionForegroundColor= null;
+
+
+ /**
+ * Creates a source preview updater for the given viewer, configuration and preference store.
+ *
+ * @param viewer the viewer
+ * @param configuration the configuration
+ * @param preferenceStore the preference store
+ */
+ AntPreviewerUpdater(final SourceViewer viewer, final AbstractAntSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) {
+
+ initializeViewerColors(viewer, preferenceStore);
+
+ final IPropertyChangeListener fontChangeListener= new IPropertyChangeListener() {
+ /*
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(JFaceResources.TEXT_FONT)) {
+ Font font= JFaceResources.getFont(JFaceResources.TEXT_FONT);
+ viewer.getTextWidget().setFont(font);
+ }
+ }
+ };
+ final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
+ /*
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+
+ String property= event.getProperty();
+
+ if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
+ AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) ||
+ AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
+ AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT.equals(property))
+ {
+ initializeViewerColors(viewer, preferenceStore);
+ }
+
+ if (configuration.affectsTextPresentation(event)) {
+ configuration.adaptToPreferenceChange(event);
+ viewer.invalidateTextPresentation();
+ }
+ }
+ };
+ viewer.getTextWidget().addDisposeListener(new DisposeListener() {
+ /*
+ * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+ */
+ public void widgetDisposed(DisposeEvent e) {
+ preferenceStore.removePropertyChangeListener(propertyChangeListener);
+ JFaceResources.getFontRegistry().removeListener(fontChangeListener);
+ }
+ });
+ JFaceResources.getFontRegistry().addListener(fontChangeListener);
+ preferenceStore.addPropertyChangeListener(propertyChangeListener);
+ }
+
+ /**
+ * Initializes the given viewer's colors.
+ *
+ * @param viewer the viewer to be initialized
+ * @since 2.0
+ */
+ protected void initializeViewerColors(ISourceViewer viewer, IPreferenceStore store) {
+
+ StyledText styledText= viewer.getTextWidget();
+
+ // ----------- foreground color --------------------
+ Color color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
+ styledText.setForeground(color);
+
+ if (fForegroundColor != null) {
+ fForegroundColor.dispose();
+ }
+
+ fForegroundColor= color;
+
+ // ---------- background color ----------------------
+ color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
+ styledText.setBackground(color);
+
+ if (fBackgroundColor != null) {
+ fBackgroundColor.dispose();
+ }
+
+ fBackgroundColor= color;
+
+ // ----------- selection foreground color --------------------
+ color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
+ styledText.setSelectionForeground(color);
+
+ if (fSelectionForegroundColor != null) {
+ fSelectionForegroundColor.dispose();
+ }
+
+ fSelectionForegroundColor= color;
+
+ // ---------- selection background color ----------------------
+ color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT)
+ ? null
+ : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
+ styledText.setSelectionBackground(color);
+
+ if (fSelectionBackgroundColor != null) {
+ fSelectionBackgroundColor.dispose();
+ }
+
+ fSelectionBackgroundColor= color;
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ *
+ * @param store the store to read from
+ * @param key the key used for the lookup in the preference store
+ * @param display the display used create the color
+ * @return the created color according to the specification in the preference store
+ * @since 2.0
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+
+ RGB rgb= null;
+
+ if (store.contains(key)) {
+
+ if (store.isDefault(key))
+ rgb= PreferenceConverter.getDefaultColor(store, key);
+ else
+ rgb= PreferenceConverter.getColor(store, key);
+
+ if (rgb != null)
+ return new Color(display, rgb);
+ }
+
+ return null;
+ }
+
+ public void dispose() {
+ if (fForegroundColor != null) {
+ fForegroundColor.dispose();
+ fForegroundColor= null;
+ }
+
+ if (fBackgroundColor != null) {
+ fBackgroundColor.dispose();
+ fBackgroundColor= null;
+ }
+
+ if (fSelectionForegroundColor != null) {
+ fSelectionForegroundColor.dispose();
+ fSelectionForegroundColor= null;
+ }
+
+ if (fSelectionBackgroundColor != null) {
+ fSelectionBackgroundColor.dispose();
+ fSelectionBackgroundColor= null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/SyntaxPreviewCode.txt b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/SyntaxPreviewCode.txt
new file mode 100644
index 0000000..44a3352
--- /dev/null
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/SyntaxPreviewCode.txt
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="greetings">
+ <target name="greetings">
+ <!--Saying HI
+ to the world-->
+ <echo>
+ Eclipse!
+ </echo>
+ </target>
+</project>
\ No newline at end of file