[SCM] Lisaac eclipse plugin branch, master, updated. e504707c944c462bc821f9128f418f2490c459d2

Damien Bouvarel dams.bouvarel at wanadoo.fr
Wed Apr 15 13:17:17 UTC 2009


The following commit has been merged in the master branch:
commit e504707c944c462bc821f9128f418f2490c459d2
Author: Damien Bouvarel <dams.bouvarel at wanadoo.fr>
Date:   Wed Apr 15 14:54:10 2009 +0200

    Syntax Coloring preference page

diff --git a/plugin.xml b/plugin.xml
index a11c2ac..29d8e17 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -55,7 +55,7 @@
    <extension
          point="org.eclipse.ui.preferencePages">
       <page
-            name="Lisaac Preferences"
+            name="Lisaac"
             class="org.eclipse.lisaac.preferences.LisaacPreferencePage"
             id="org.eclipse.lisaac.preferences.LisaacPreferencePage">
       </page>
@@ -63,7 +63,13 @@
             category="org.eclipse.lisaac.preferences.LisaacPreferencePage"
             class="org.eclipse.lisaac.preferences.LisaacTemplatePage"
             id="org.eclipse.lisaac.templatepreferences"
-            name="Lisaac Templates">
+            name="Templates">
+      </page>
+      <page
+            category="org.eclipse.lisaac.preferences.LisaacPreferencePage"
+            class="org.eclipse.lisaac.preferences.LisaacEditorPage"
+            id="org.eclipse.lisaac.editorpreferences"
+            name="Syntax Coloring">
       </page>
    </extension>
    <extension
diff --git a/src/org/eclipse/lisaac/LisaacPlugin.java b/src/org/eclipse/lisaac/LisaacPlugin.java
index 8f292c2..badd587 100644
--- a/src/org/eclipse/lisaac/LisaacPlugin.java
+++ b/src/org/eclipse/lisaac/LisaacPlugin.java
@@ -128,5 +128,4 @@ public class LisaacPlugin extends AbstractUIPlugin {
 	public static void log(final IStatus status) {
 		getDefault().getLog().log(status);
 	}
-
 }
diff --git a/src/org/eclipse/lisaac/actions/CreatePrototype.java b/src/org/eclipse/lisaac/actions/CreatePrototype.java
index 2fa973b..2279ffc 100644
--- a/src/org/eclipse/lisaac/actions/CreatePrototype.java
+++ b/src/org/eclipse/lisaac/actions/CreatePrototype.java
@@ -1,18 +1,30 @@
 package org.eclipse.lisaac.actions;
 
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.lisaac.LisaacPlugin;
-import org.eclipse.lisaac.editors.LisaacEditor;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.lisaac.wizards.NewPrototypeWizard;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
 
-public class CreatePrototype implements IWorkbenchWindowActionDelegate {
-
+public class CreatePrototype extends Action implements IWorkbenchWindowActionDelegate {
 
+	private Shell fShell;
+	private IStructuredSelection fSelection;
+	
+	
+	public CreatePrototype() {
+	}
+	
 	/**
 	 * The action has been activated. The argument of the
 	 * method represents the 'real' action sitting
@@ -20,9 +32,56 @@ public class CreatePrototype implements IWorkbenchWindowActionDelegate {
 	 * @see IWorkbenchWindowActionDelegate#run
 	 */
 	public void run(IAction action) {
-		// TODO start prototype wizard
+		Shell shell= getShell();
+
+		try {
+			INewWizard wizard= createWizard();
+			wizard.init(PlatformUI.getWorkbench(), getSelection());
+			
+			WizardDialog dialog= new WizardDialog(shell, wizard);
+			dialog.create();
+			int res= dialog.open();
+			if (res != Window.OK) {
+				// TODO log error
+			}
+		} catch (CoreException e) {
+			// TODO log error
+		}
 	}
+	
+	/**
+	 * Returns the configured selection. If no selection has been configured using {@link #setSelection(IStructuredSelection)},
+	 * the currently selected element of the active workbench is returned.
+	 * @return the configured selection
+	 */
+	protected IStructuredSelection getSelection() {
+		if (fSelection == null) {
+			return evaluateCurrentSelection();
+		}
+		return fSelection;
+	}
+	
+	private IStructuredSelection evaluateCurrentSelection() {
+		IWorkbenchWindow window = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
 
+		if (window != null) {
+			ISelection selection= window.getSelectionService().getSelection();
+			if (selection instanceof IStructuredSelection) {
+				return (IStructuredSelection) selection;
+			}
+		}
+		return StructuredSelection.EMPTY;
+	}
+	
+	protected Shell getShell() {
+		return fShell;
+	}
+	
+	// make it an abstract method if more wizard shortcuts are created
+	protected final INewWizard createWizard() throws CoreException {
+		return new NewPrototypeWizard();
+	}
+	
 	/**
 	 * Selection in the workbench has been changed. We 
 	 * can change the state of the 'real' action here
diff --git a/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java b/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java
index 7ca9e73..30930e5 100644
--- a/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java
+++ b/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java
@@ -5,18 +5,19 @@ import java.util.ListResourceBundle;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextViewerExtension2;
 import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.lisaac.LisaacPlugin;
 import org.eclipse.lisaac.model.LisaacModel;
 import org.eclipse.lisaac.views.LisaacOutlineView;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.editors.text.TextEditor;
 import org.eclipse.ui.part.FileEditorInput;
 import org.eclipse.ui.texteditor.ContentAssistAction;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 
@@ -28,17 +29,24 @@ public class AbstractLisaacEditor extends TextEditor {
 
 	private ColorManager colorManager;
 
-	 /** the outline view. */
-    private LisaacOutlineView outlineView;
-	
+	/** the outline view. */
+	private LisaacOutlineView outlineView;
+
 	public AbstractLisaacEditor() {
 		super();
-		colorManager = new ColorManager();
-
+		colorManager = new ColorManager(LisaacPlugin.getDefault().getPreferenceStore());
+		
 		setSourceViewerConfiguration(new LisaacConfiguration(colorManager,this));
 		setDocumentProvider(new LisaacDocumentProvider());
+		
+		IPreferenceStore store = LisaacPlugin.getDefault().getPreferenceStore();
+		setPreferenceStore(store);
+		
+		// wide caret
+		store.setDefault(PREFERENCE_USE_CUSTOM_CARETS, true);
+		store.setDefault(PREFERENCE_WIDE_CARET, true);
 	}
-	
+
 	public IDocument getDocument() {
 		return getDocumentProvider().getDocument(getEditorInput());
 	}
@@ -49,38 +57,49 @@ public class AbstractLisaacEditor extends TextEditor {
 	}
 
 	public static class MyResources extends ListResourceBundle {
-        public Object[][] getContents() {
-            return contents;
-        }
+		public Object[][] getContents() {
+			return contents;
+		}
+
+		static final Object[][] contents = { { "CorrectionAssist", "CorrectionAssist" }, { "ContentAssistProposal", "ContentAssistProposal" }, { "TemplateProposals", "TemplateProposals" }, };
+	}
 
-        static final Object[][] contents = { { "CorrectionAssist", "CorrectionAssist" }, { "ContentAssistProposal", "ContentAssistProposal" }, { "TemplateProposals", "TemplateProposals" }, };
-    }
-	
 	protected void createActions() {
 		super.createActions();
-	
+
 		MyResources ressources = new MyResources();
-		
+
 		Action action = new ContentAssistAction(ressources, "ContentAssistProposal.", this); //$NON-NLS-1$
 		String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
 		action.setActionDefinitionId(id);
 		setAction("ContentAssistProposal", action); 
 		markAsStateDependentAction("ContentAssistProposal", true);
 	}
-	
+
 	public void doSave(IProgressMonitor progressMonitor) {
 		super.doSave(progressMonitor);
-		
+
 		LisaacModel model = LisaacModel.getModel(getProject());
 		if (model != null) {
 			model.buildAll(); 
 		}
 	}
-	
+
 	public ISourceViewer getViewer() {
 		return getSourceViewer();
 	}
-	
+
+	protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {	
+		colorManager.handlePreferenceStoreChanged(event);
+		super.handlePreferenceStoreChanged(event);
+	}
+
+	protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+		return super.affectsTextPresentation(event)
+		|| colorManager.affectsTextPresentation(event);
+	}
+
+
 	/**
 	 * Redraw whole text presentation of the editor
 	 */
@@ -99,43 +118,43 @@ public class AbstractLisaacEditor extends TextEditor {
 			ext.invalidateTextPresentation(offset, length);
 		}
 	}
-	
-	 /**
-     * @return the project for the file that's being edited (or null if not available)
-     */
-    public IProject getProject() {
-        IEditorInput editorInput = this.getEditorInput();
-        if (editorInput instanceof FileEditorInput) {
-            IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class);
-            return file.getProject();
-        }
-        return null;
-    }
-    
-    /**
-     * @return the file name for the file that's being edited (or null if not available)
-     */
-    public String getFileName() {
-        IEditorInput editorInput = this.getEditorInput();
-        if (editorInput instanceof FileEditorInput) {
-            IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class);
-            return file.getName();
-        }
-        return null;
-    }
-    
-    /**
-     * @see AbstractTextEditor#getAdapter(java.lang.Class)
-     */
+
+	/**
+	 * @return the project for the file that's being edited (or null if not available)
+	 */
+	public IProject getProject() {
+		IEditorInput editorInput = this.getEditorInput();
+		if (editorInput instanceof FileEditorInput) {
+			IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class);
+			return file.getProject();
+		}
+		return null;
+	}
+
+	/**
+	 * @return the file name for the file that's being edited (or null if not available)
+	 */
+	public String getFileName() {
+		IEditorInput editorInput = this.getEditorInput();
+		if (editorInput instanceof FileEditorInput) {
+			IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class);
+			return file.getName();
+		}
+		return null;
+	}
+
+	/**
+	 * @see AbstractTextEditor#getAdapter(java.lang.Class)
+	 */
 	public Object getAdapter(Class required) {
-        if (IContentOutlinePage.class.equals(required)) {
-            if (outlineView == null) {
-                outlineView = new LisaacOutlineView(getDocumentProvider(), this);
-            }
-            
-            return outlineView;
-         } else {	
-             return super.getAdapter(required);
-         }
-    }
+		if (IContentOutlinePage.class.equals(required)) {
+			if (outlineView == null) {
+				outlineView = new LisaacOutlineView(getDocumentProvider(), this);
+			}
+
+			return outlineView;
+		} else {	
+			return super.getAdapter(required);
+		}
+	}
 }
diff --git a/src/org/eclipse/lisaac/editors/ColorManager.java b/src/org/eclipse/lisaac/editors/ColorManager.java
index a16ed75..56c433d 100644
--- a/src/org/eclipse/lisaac/editors/ColorManager.java
+++ b/src/org/eclipse/lisaac/editors/ColorManager.java
@@ -4,6 +4,13 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.widgets.Display;
@@ -11,11 +18,18 @@ import org.eclipse.swt.widgets.Display;
 public class ColorManager {
 
 	protected Map<RGB,Color> fColorTable = new HashMap<RGB,Color>(10);
+	private Map<String,IToken> tokenTable = new HashMap<String,IToken>(10);
+
+	private final IPreferenceStore preferenceStore;
+
+	public ColorManager(IPreferenceStore preferenceStore) {
+		this.preferenceStore = preferenceStore;
+	}
 
 	public void dispose() {
 		Iterator<Color> e = fColorTable.values().iterator();
 		while (e.hasNext())
-			 ((Color) e.next()).dispose();
+			((Color) e.next()).dispose();
 	}
 	public Color getColor(RGB rgb) {
 		Color color = (Color) fColorTable.get(rgb);
@@ -25,4 +39,50 @@ public class ColorManager {
 		}
 		return color;
 	}
+
+	public IToken getToken(String prefKey) {
+		Token token = (Token) tokenTable.get(prefKey);
+		if (token == null) {
+			String colorName = preferenceStore.getString(prefKey);
+			RGB rgb = StringConverter.asRGB(colorName);
+			token = new Token(new TextAttribute(getColor(rgb)));
+			tokenTable.put(prefKey, token);
+		}
+		return token;
+	}
+	
+	public IToken getToken(String prefKey, String prefKey2) {
+		Token token = (Token) tokenTable.get(prefKey);
+		if (token == null) {
+			String colorName = preferenceStore.getString(prefKey);
+			RGB rgb = StringConverter.asRGB(colorName);
+			String colorName2 = preferenceStore.getString(prefKey2);
+			RGB rgb2 = StringConverter.asRGB(colorName2);
+			token = new Token(new TextAttribute(getColor(rgb2), getColor(rgb), SWT.NORMAL));
+			tokenTable.put(prefKey, token);
+		}
+		return token;
+	}
+
+	public boolean affectsTextPresentation(PropertyChangeEvent event) {
+		Token token = (Token) tokenTable.get(event.getProperty());
+		return (token != null);
+	}
+
+	public void handlePreferenceStoreChanged (PropertyChangeEvent event) {
+		String prefKey = event.getProperty();
+		Token token = (Token) tokenTable.get(prefKey);
+		if (token != null) {      	
+			String colorName = preferenceStore.getString(prefKey);
+			RGB rgb = StringConverter.asRGB(colorName);
+			
+			if (prefKey.equals(ILisaacColor.PREF_EXTERNAL)) {
+				String colorName2 = preferenceStore.getString(ILisaacColor.PREF_DEFAULT_COLOR);
+				RGB rgb2 = StringConverter.asRGB(colorName2);
+				token.setData(new TextAttribute(getColor(rgb2), getColor(rgb), SWT.NORMAL));
+			} else {
+				token.setData(new TextAttribute(getColor(rgb)));
+			}
+		}
+	}
 }
diff --git a/src/org/eclipse/lisaac/editors/ILisaacColor.java b/src/org/eclipse/lisaac/editors/ILisaacColor.java
index 42d27f2..0ff798e 100644
--- a/src/org/eclipse/lisaac/editors/ILisaacColor.java
+++ b/src/org/eclipse/lisaac/editors/ILisaacColor.java
@@ -1,23 +1,32 @@
-package org.eclipse.lisaac.editors;
-
-import org.eclipse.swt.graphics.RGB;
-
-/**
- * Associate a color to each token lexical class.
- * @author Damien Bouvarel
- */
-public interface ILisaacColor {
-	RGB COMMENT = new RGB(200, 50, 0);
-	RGB PROTOTYPE = new RGB(0, 128, 0);
-	RGB PROTOTYPE_STYLE = new RGB(255, 0, 0);
-	RGB KEYWORD = new RGB(128, 0, 255);
-	RGB CHARACTER = new RGB(128, 128, 255);
-	RGB STRING = new RGB(210, 150, 150);
-	RGB NUMBER = new RGB(128, 0, 255);
-	RGB OPERATOR = new RGB(200, 130, 0);
-	RGB EXTERNAL = new RGB(128, 255, 128);
-	RGB UNDEFINED = new RGB(0, 0, 255);
-	RGB DEFAULT = new RGB(0, 0, 0);
-	
-	RGB PROC_INSTR = new RGB(128, 128, 128);// xml a virer
+package org.eclipse.lisaac.editors;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Associate a color to each token lexical class.
+ * @author Damien Bouvarel
+ */
+public interface ILisaacColor {
+	RGB COMMENT = new RGB(200, 50, 0);
+	RGB PROTOTYPE = new RGB(0, 128, 0);
+	RGB PROTOTYPE_STYLE = new RGB(255, 0, 0);
+	RGB KEYWORD = new RGB(128, 0, 255);
+	RGB CHARACTER = new RGB(128, 128, 255);
+	RGB STRING = new RGB(210, 150, 150);
+	RGB NUMBER = new RGB(128, 0, 255);
+	RGB OPERATOR = new RGB(200, 130, 0);
+	RGB EXTERNAL = new RGB(128, 255, 128);
+	RGB UNDEFINED = new RGB(0, 0, 255);
+	RGB DEFAULT = new RGB(0, 0, 0);
+	
+	String PREF_COMMENT = "comment_color";
+	String PREF_PROTOTYPE = "prototype_color";
+	String PREF_PROTOTYPE_STYLE = "prototype_style_color";
+	String PREF_KEYWORD = "keyword_color";
+	String PREF_CHARACTER = "character_color";
+	String PREF_STRING  = "string_color";
+	String PREF_NUMBER = "number_color";
+	String PREF_OPERATOR = "operator_color";
+	String PREF_EXTERNAL = "external_color";
+	String PREF_DEFAULT_COLOR = "default_color";		
 }
\ No newline at end of file
diff --git a/src/org/eclipse/lisaac/editors/LisaacScanner.java b/src/org/eclipse/lisaac/editors/LisaacScanner.java
index bbc622b..75263a0 100644
--- a/src/org/eclipse/lisaac/editors/LisaacScanner.java
+++ b/src/org/eclipse/lisaac/editors/LisaacScanner.java
@@ -99,18 +99,16 @@ public class LisaacScanner extends RuleBasedScanner {
 		 * Create lisaac tokens.
 		 */
 
-		stringToken = new Token(getAttribute(ILisaacColor.STRING));
-		characterToken = new Token(getAttribute(ILisaacColor.CHARACTER));
-		numberToken = new Token(getAttribute(ILisaacColor.NUMBER));
-		prototypeToken = new Token(getAttribute(ILisaacColor.PROTOTYPE));
-		prototypeStyleToken = new Token(
-				getAttribute(ILisaacColor.PROTOTYPE_STYLE));
-		keywordToken = new Token(getAttribute(ILisaacColor.KEYWORD));
-		localVariableToken = new Token(getAttribute(ILisaacColor.DEFAULT));
-		operatorToken = new Token(getAttribute(ILisaacColor.OPERATOR));
-		externalToken = new Token(new TextAttribute(manager
-				.getColor(ILisaacColor.DEFAULT), manager
-				.getColor(ILisaacColor.EXTERNAL), SWT.NORMAL));
+		stringToken = manager.getToken(ILisaacColor.PREF_STRING); //new Token(getAttribute(ILisaacColor.STRING));
+		characterToken = manager.getToken(ILisaacColor.PREF_CHARACTER);
+		numberToken = manager.getToken(ILisaacColor.PREF_NUMBER);
+		prototypeToken = manager.getToken(ILisaacColor.PREF_PROTOTYPE);
+		prototypeStyleToken = manager.getToken(ILisaacColor.PREF_PROTOTYPE_STYLE);
+		keywordToken = manager.getToken(ILisaacColor.PREF_KEYWORD);
+		localVariableToken = manager.getToken(ILisaacColor.PREF_DEFAULT_COLOR);
+		operatorToken = manager.getToken(ILisaacColor.PREF_OPERATOR);
+		externalToken = manager.getToken(ILisaacColor.PREF_EXTERNAL, ILisaacColor.PREF_DEFAULT_COLOR);
+		
 		undefinedToken = new Token(getAttribute(ILisaacColor.UNDEFINED));
 
 		/*
diff --git a/src/org/eclipse/lisaac/preferences/LisaacEditorPage.java b/src/org/eclipse/lisaac/preferences/LisaacEditorPage.java
new file mode 100644
index 0000000..0b087c8
--- /dev/null
+++ b/src/org/eclipse/lisaac/preferences/LisaacEditorPage.java
@@ -0,0 +1,70 @@
+package org.eclipse.lisaac.preferences;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.jface.preference.*;
+import org.eclipse.lisaac.LisaacPlugin;
+import org.eclipse.lisaac.editors.ILisaacColor;
+import org.eclipse.ui.*;
+
+/**
+ * Lisaac Syntax coloring preference page.
+ */
+public class LisaacEditorPage extends FieldEditorPreferencePage
+implements IWorkbenchPreferencePage {
+
+	public LisaacEditorPage() {
+		super(GRID);
+		setPreferenceStore(LisaacPlugin.getDefault().getPreferenceStore());
+	}
+
+	public void createFieldEditors() {   		   	
+		Group g = new Group(getFieldEditorParent(),SWT.SHADOW_ETCHED_IN);
+		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+		gd.horizontalSpan = 3;
+		g.setLayoutData(gd);
+		g.setText("Lisaac Editor Syntax Coloring preferences :");
+
+		Label l1= new Label(g, SWT.LEFT);
+		l1.setText("");
+		gd = new GridData();
+		gd.horizontalSpan = 3;
+		l1.setLayoutData(gd);
+
+		addField(new ColorFieldEditor(
+						ILisaacColor.PREF_COMMENT,
+						"    &Comments:", g));
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_PROTOTYPE,
+				"    &Prototype:", g));
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_PROTOTYPE_STYLE,
+				"    &Prototype Style:", g));
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_KEYWORD,
+				"    &Keywords:", g));
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_CHARACTER,
+				"    &Characters:", g));
+		addField(new ColorFieldEditor(
+						ILisaacColor.PREF_STRING,
+						"    &Strings:", g));
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_NUMBER,
+				"    &Numbers:", g));	
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_OPERATOR,
+				"    &Operators:", g));	
+		addField(new ColorFieldEditor(
+				ILisaacColor.PREF_EXTERNAL,
+				"    &Externals:", g));	
+		addField(new ColorFieldEditor(
+						ILisaacColor.PREF_DEFAULT_COLOR,
+						"    O&thers:", g));		
+	}
+	
+	public void init(IWorkbench workbench) {
+	}
+}
\ No newline at end of file
diff --git a/src/org/eclipse/lisaac/preferences/PreferenceInitializer.java b/src/org/eclipse/lisaac/preferences/PreferenceInitializer.java
index da3e063..72a6fe5 100644
--- a/src/org/eclipse/lisaac/preferences/PreferenceInitializer.java
+++ b/src/org/eclipse/lisaac/preferences/PreferenceInitializer.java
@@ -2,7 +2,9 @@ package org.eclipse.lisaac.preferences;
 
 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
 import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.StringConverter;
 import org.eclipse.lisaac.LisaacPlugin;
+import org.eclipse.lisaac.editors.ILisaacColor;
 
 
 /**
@@ -16,8 +18,40 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
 	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
 	 */
 	public void initializeDefaultPreferences() {
-		//IPreferenceStore store = LisaacPlugin.getDefault().getPreferenceStore();
+		IPreferenceStore store = LisaacPlugin.getDefault().getPreferenceStore();
 		//store.setDefault(PreferenceConstants.P_LISAAC_PATH, "TODO");
-	}
 
+		// Colors for syntax highlighting.
+		store.setDefault(
+				ILisaacColor.PREF_COMMENT,
+				StringConverter.asString(ILisaacColor.COMMENT));
+		store.setDefault(
+				ILisaacColor.PREF_PROTOTYPE,
+				StringConverter.asString(ILisaacColor.PROTOTYPE));
+		store.setDefault(
+				ILisaacColor.PREF_PROTOTYPE_STYLE,
+				StringConverter.asString(ILisaacColor.PROTOTYPE_STYLE));
+		store.setDefault(
+				ILisaacColor.PREF_KEYWORD,
+				StringConverter.asString(ILisaacColor.KEYWORD));
+		store.setDefault(
+				ILisaacColor.PREF_CHARACTER,
+				StringConverter.asString(ILisaacColor.CHARACTER));
+		store.setDefault(
+				ILisaacColor.PREF_STRING,
+				StringConverter.asString(ILisaacColor.STRING));
+		store.setDefault(
+				ILisaacColor.PREF_NUMBER,
+				StringConverter.asString(ILisaacColor.NUMBER));
+		store.setDefault(
+				ILisaacColor.PREF_OPERATOR,
+				StringConverter.asString(ILisaacColor.OPERATOR));
+		store.setDefault(
+				ILisaacColor.PREF_EXTERNAL,
+				StringConverter.asString(ILisaacColor.EXTERNAL));
+		store.setDefault(
+				ILisaacColor.PREF_DEFAULT_COLOR,
+				StringConverter.asString(ILisaacColor.DEFAULT));
+	}
 }
+

-- 
Lisaac eclipse plugin



More information about the Lisaac-commits mailing list