Permalink
Browse files

Soft tabs for the conf editor

  • Loading branch information...
erwan committed May 21, 2010
1 parent c3cb350 commit 7c177806069a5417da97a2264e4bd0a918a7cf9b
@@ -1,15 +1,28 @@
package org.playframework.playclipse.editors;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.playframework.playclipse.PlayPlugin;
public class ConfEditor extends PlayEditor {
public static final String COMMENT_COLOR = "conf_comment_color";
public static final String KEY_COLOR = "conf_key_color";
public static final String DEFAULT_COLOR = "conf_default_color";
public static final String SOFT_TABS = "conf_soft_tabs";
public static final String SOFT_TABS_WIDTH = "conf_soft_tabs_width";
public ConfEditor() {
super();
IPreferenceStore store = PlayPlugin.getDefault().getPreferenceStore();
useSoftTabs = store.getBoolean(SOFT_TABS);
softTabsWidth = store.getInt(SOFT_TABS_WIDTH);
}
@Override
public String autoClose(char pc, char c, char nc) {
if(c == '{') {
@@ -84,6 +97,15 @@ public String scan() {
return null;
}
@Override
public void propertyChange(PropertyChangeEvent event) {
String key = event.getProperty();
if (key.equals(SOFT_TABS)) {
useSoftTabs = ((Boolean)event.getNewValue()).booleanValue();
}
super.propertyChange(event);
}
@Override
public void templates(String contentType, String ctx) {
}
@@ -3,6 +3,8 @@
import java.util.LinkedHashMap;
import java.util.Map;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.playframework.playclipse.editors.ConfEditor;
/**
@@ -35,4 +37,11 @@ public ConfEditorPreferencePage() {
return fields;
}
@Override
public void createFieldEditors() {
super.createFieldEditors();
addField(new BooleanFieldEditor(ConfEditor.SOFT_TABS, "Indent with spaces (soft tabs)", getFieldEditorParent()));
addField(new IntegerFieldEditor(ConfEditor.SOFT_TABS_WIDTH, "Soft tabs length", getFieldEditorParent()));
}
}
@@ -36,6 +36,8 @@ public void initializeDefaultPreferences() {
PreferenceConverter.setDefault(store, ConfEditor.COMMENT_COLOR, new RGB(90, 90, 90));
PreferenceConverter.setDefault(store, ConfEditor.KEY_COLOR, new RGB(150, 0, 0));
PreferenceConverter.setDefault(store, ConfEditor.DEFAULT_COLOR, new RGB(0, 0, 0));
store.setDefault(ConfEditor.SOFT_TABS, false);
store.setDefault(ConfEditor.SOFT_TABS_WIDTH, 4);
PreferenceConverter.setDefault(store, HTMLEditor.ACTION_COLOR, new RGB(255, 0, 192));
PreferenceConverter.setDefault(store, HTMLEditor.DEFAULT_COLOR, new RGB(0, 0, 0));

0 comments on commit 7c17780

Please sign in to comment.