SysdynElementUtils.setInputReference(e, inputReference);\r
\r
Font font = ElementUtils.getTextFont(e);\r
- font = font.deriveFont(font.getStyle() + Font.ITALIC);\r
+ font = font.deriveFont(font.getStyle());\r
ElementUtils.setTextFont(e, font);\r
ElementUtils.setHover(e, false);\r
}\r
TextNode node = ElementUtils.getOrCreateNode(e, parent, INPUT_SG_NODE, "input", TextNode.class);\r
Font font = ElementUtils.getTextFont(e);\r
font = font.deriveFont((float) 10.0);\r
- font = font.deriveFont(Font.ITALIC);\r
+// font = font.deriveFont(Font.ITALIC);\r
Color color = new Color(150, 150, 150);\r
Color fillColor = ElementUtils.getFillColor(e);\r
Color borderColor = ElementUtils.getBorderColor(e, Color.BLACK);\r
\r
package org.simantics.sysdyn.ui.preferences;\r
\r
+import java.util.HashMap;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.preference.BooleanFieldEditor;\r
import org.eclipse.jface.preference.ColorFieldEditor;\r
+import org.eclipse.jface.preference.FieldEditor;\r
import org.eclipse.jface.preference.FieldEditorPreferencePage;\r
import org.eclipse.jface.preference.FontFieldEditor;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
import org.eclipse.ui.IWorkbench;\r
import org.eclipse.ui.IWorkbenchPreferencePage;\r
import org.simantics.sysdyn.ui.Activator;\r
*/\r
public class SysdynDiagramPreferencePage extends FieldEditorPreferencePage implements\r
IWorkbenchPreferencePage {\r
+ \r
+ private HashMap<FieldEditor, Composite> fieldParents;\r
+ private Group colorEditors, fontEditors;\r
\r
public SysdynDiagramPreferencePage() {\r
super(GRID);\r
setDescription("System dynamics diagram preferences");\r
+ fieldParents = new HashMap<FieldEditor, Composite>();\r
}\r
\r
@Override\r
\r
@Override\r
protected void createFieldEditors() {\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.DEFAULT_COLOR, "Default", getFieldEditorParent()));\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.DEFAULT_FONT, "Default", getFieldEditorParent()));\r
+ Composite parent = new Composite(getFieldEditorParent(), SWT.NONE);\r
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);\r
+ \r
+ // DEFAULTS\r
+ Group defaults = new Group(parent, SWT.NONE);\r
+ defaults.setText("Default settings");\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(defaults);\r
+ addField(new ColorFieldEditor(SysdynDiagramPreferences.DEFAULT_COLOR, "Color", defaults));\r
+ addField(new CustomFontFieldEditor(SysdynDiagramPreferences.DEFAULT_FONT, "Font", defaults));\r
+ GridLayout layout = (GridLayout) defaults.getLayout();\r
+ layout.marginHeight = 3;\r
+ layout.marginWidth = 3;\r
+ defaults.setLayout(layout);\r
\r
+ // COLORS\r
+ colorEditors = new Group(parent, SWT.NONE);\r
+ colorEditors.setText("Colors");\r
+ GridDataFactory.fillDefaults().applyTo(colorEditors);\r
+ GridDataFactory.fillDefaults().applyTo(colorEditors);\r
+ Label label = new Label(colorEditors, SWT.NONE);\r
+ GridDataFactory.fillDefaults().span(3, 1).applyTo(label);\r
\r
+ label = new Label(colorEditors, SWT.NONE);\r
+ label.setText("Use default");\r
+ GridDataFactory.fillDefaults().applyTo(label);\r
\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.ARROW_COLOR, "&Dependency", getFieldEditorParent()));\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.FLOW_COLOR, "&Flow", getFieldEditorParent()));\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.AUXILIARY_COLOR, "&Auxiliary", getFieldEditorParent()));\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.STOCK_COLOR, "&Stock", getFieldEditorParent()));\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.VALVE_COLOR, "&Valve", getFieldEditorParent()));\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.CLOUD_COLOR, "&Cloud", getFieldEditorParent()));\r
- addField(new ColorFieldEditor(SysdynDiagramPreferences.MODULE_COLOR, "&Module", getFieldEditorParent()));\r
+ addColorFieldEditor(SysdynDiagramPreferences.ARROW_COLOR, "&Dependency", SysdynDiagramPreferences.ARROW_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.FLOW_COLOR, "&Flow", SysdynDiagramPreferences.FLOW_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.AUXILIARY_COLOR, "&Auxiliary", SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.STOCK_COLOR, "&Stock", SysdynDiagramPreferences.STOCK_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.VALVE_COLOR, "&Valve", SysdynDiagramPreferences.VALVE_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.INPUT_COLOR, "&Input", SysdynDiagramPreferences.VALVE_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.CLOUD_COLOR, "&Cloud", SysdynDiagramPreferences.CLOUD_USE_DEFAULT_COLOR);\r
+ addColorFieldEditor(SysdynDiagramPreferences.MODULE_COLOR, "&Module", SysdynDiagramPreferences.MODULE_USE_DEFAULT_COLOR);\r
\r
+ // FONTS\r
+ fontEditors = new Group(parent, SWT.NONE);\r
+ fontEditors.setText("Fonts");\r
+ GridDataFactory.fillDefaults().applyTo(fontEditors);\r
+ GridLayoutFactory.fillDefaults().applyTo(fontEditors);\r
\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.ARROW_FONT, "Dependency", getFieldEditorParent()));\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.AUXILIARY_FONT, "Auxiliary", getFieldEditorParent()));\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.STOCK_FONT, "Stock", getFieldEditorParent()));\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.VALVE_FONT, "Valve", getFieldEditorParent()));\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.CLOUD_FONT, "Cloud", getFieldEditorParent()));\r
- addField(new FontFieldEditor(SysdynDiagramPreferences.MODULE_FONT, "Module", getFieldEditorParent()));\r
- }\r
+ label = new Label(fontEditors, SWT.NONE);\r
+ GridDataFactory.fillDefaults().span(3, 1).applyTo(label);\r
+ \r
+ label = new Label(fontEditors, SWT.NONE);\r
+ label.setText("Use default");\r
+ GridDataFactory.fillDefaults().applyTo(label);\r
\r
+ addFontFieldEditor(SysdynDiagramPreferences.ARROW_FONT, "Dependency", SysdynDiagramPreferences.ARROW_USE_DEFAULT_FONT);\r
+ addFontFieldEditor(SysdynDiagramPreferences.AUXILIARY_FONT, "Auxiliary", SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_FONT);\r
+ addFontFieldEditor(SysdynDiagramPreferences.STOCK_FONT, "Stock", SysdynDiagramPreferences.STOCK_USE_DEFAULT_FONT);\r
+ addFontFieldEditor(SysdynDiagramPreferences.VALVE_FONT, "Valve", SysdynDiagramPreferences.VALVE_USE_DEFAULT_FONT);\r
+ addFontFieldEditor(SysdynDiagramPreferences.INPUT_FONT, "Input", SysdynDiagramPreferences.INPUT_USE_DEFAULT_FONT);\r
+ addFontFieldEditor(SysdynDiagramPreferences.CLOUD_FONT, "Cloud", SysdynDiagramPreferences.CLOUD_USE_DEFAULT_FONT);\r
+ addFontFieldEditor(SysdynDiagramPreferences.MODULE_FONT, "Module", SysdynDiagramPreferences.MODULE_USE_DEFAULT_FONT);\r
+\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(colorEditors);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(4).applyTo(fontEditors);\r
+ }\r
+ \r
+ \r
+ private void addColorFieldEditor(String property, String label, String defaultBoolean) {\r
+ ColorFieldEditor colorField = new ColorFieldEditor(property, label, colorEditors);\r
+ colorField.setEnabled(!getPreferenceStore().getBoolean(defaultBoolean), colorEditors);\r
+ Composite c = new Composite(colorEditors, SWT.NONE);\r
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(c);\r
+ GridLayoutFactory.fillDefaults().applyTo(c);\r
+ BooleanFieldEditor useDefault = new DefaultBooleanFiedEditor(colorField, defaultBoolean, c);\r
+ fieldParents.put(colorField, colorEditors);\r
+ addField(useDefault);\r
+ addField(colorField);\r
+ }\r
+ \r
+ private void addFontFieldEditor(String property, String label, String defaultBoolean) {\r
+ CustomFontFieldEditor fontField = new CustomFontFieldEditor(property, label, fontEditors);\r
+ fontField.setEnabled(!getPreferenceStore().getBoolean(defaultBoolean), fontEditors);\r
+ Composite c = new Composite(fontEditors, SWT.NONE);\r
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(c);\r
+ GridLayoutFactory.fillDefaults().applyTo(c);\r
+ BooleanFieldEditor useDefault = new DefaultBooleanFiedEditor(fontField, defaultBoolean, c);\r
+ \r
+ \r
+ \r
+ fieldParents.put(fontField, fontEditors);\r
+ addField(useDefault);\r
+ addField(fontField);\r
+ }\r
+ \r
+ private class DefaultBooleanFiedEditor extends BooleanFieldEditor {\r
+ private FieldEditor fieldEditor;\r
+ \r
+ public DefaultBooleanFiedEditor(FieldEditor fieldEditor, String name, Composite parent) {\r
+ super(name, "", parent);\r
+ this.fieldEditor = fieldEditor;\r
+ }\r
+ \r
+ @Override\r
+ protected void valueChanged(boolean oldValue, boolean newValue) {\r
+ super.valueChanged(oldValue, newValue);\r
+ fieldEditor.setEnabled(!newValue, fieldParents.get(fieldEditor));\r
+ }\r
+ }\r
+ \r
+ private class CustomFontFieldEditor extends FontFieldEditor {\r
+ \r
+ public CustomFontFieldEditor(String name, String labelText, Composite parent) {\r
+ super(name, labelText, parent);\r
+ \r
+ GridDataFactory.fillDefaults().applyTo(getChangeControl(parent));\r
+ setChangeButtonText("...");\r
+ getChangeControl(parent).setToolTipText("Change");\r
+ \r
+ \r
+ }\r
+ }\r
}\r
\r
import java.util.HashMap;\r
\r
+import org.eclipse.jface.preference.IPreferenceStore;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
\r
/**\r
* \r
*/\r
public class SysdynDiagramPreferences {\r
\r
+ public static String DEFAULT_COLOR = "Default color";\r
+ public static String DEFAULT_FONT = "Default font";\r
+ \r
public static String ARROW_COLOR = "Arrow color";\r
public static String FLOW_COLOR = "Flow color";\r
public static String AUXILIARY_COLOR = "Auxiliary color";\r
public static String CLOUD_COLOR = "Cloud color";\r
public static String STOCK_COLOR = "Stock color";\r
public static String VALVE_COLOR = "Valve color";\r
+ public static String INPUT_COLOR = "Input color";\r
public static String MODULE_COLOR = "Module color";\r
+ \r
+ public static HashMap<String, String> colorPreferenceNames;\r
+ \r
+ static {\r
+ colorPreferenceNames = new HashMap<String, String>();\r
+ colorPreferenceNames.put(SysdynResource.URIs.DependencyConnection, ARROW_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.FlowConnection, FLOW_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.AuxiliarySymbol, AUXILIARY_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.CloudSymbol, CLOUD_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.StockSymbol, STOCK_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.ValveSymbol, VALVE_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.InputSymbol, INPUT_COLOR);\r
+ colorPreferenceNames.put(SysdynResource.URIs.ModuleSymbol, MODULE_COLOR);\r
+ }\r
+ \r
+ public static String getColorPreferenceName(ReadGraph graph, Resource resource) \r
+ throws DatabaseException {\r
+ String preference = colorPreferenceNames.get(getSymbolUri(graph, resource));\r
+ return preference;\r
+ }\r
+ \r
+ public static String ARROW_USE_DEFAULT_COLOR = "Arrow use default color";\r
+ public static String FLOW_USE_DEFAULT_COLOR = "Flow use default color";\r
+ public static String AUXILIARY_USE_DEFAULT_COLOR = "Auxiliary use default color";\r
+ public static String CLOUD_USE_DEFAULT_COLOR = "Cloud use default color";\r
+ public static String STOCK_USE_DEFAULT_COLOR = "Stock use default color";\r
+ public static String VALVE_USE_DEFAULT_COLOR = "Valve use default color";\r
+ public static String INPUT_USE_DEFAULT_COLOR = "Input use default color";\r
+ public static String MODULE_USE_DEFAULT_COLOR = "Module use default color";\r
+ \r
+ public static HashMap<String, String> colorDefaults;\r
+ \r
+ static {\r
+ colorDefaults = new HashMap<String, String>();\r
+ colorDefaults.put(ARROW_COLOR, ARROW_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(FLOW_COLOR, FLOW_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(AUXILIARY_COLOR, AUXILIARY_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(CLOUD_COLOR, CLOUD_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(STOCK_COLOR, STOCK_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(VALVE_COLOR, VALVE_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(INPUT_COLOR, INPUT_USE_DEFAULT_COLOR);\r
+ colorDefaults.put(MODULE_COLOR, MODULE_USE_DEFAULT_COLOR);\r
\r
- public static String DEFAULT_COLOR = "Default color";\r
- public static String DEFAULT_FONT = "Default font";\r
+ }\r
\r
public static String ARROW_FONT = "Arrow font";\r
public static String AUXILIARY_FONT = "Auxiliary font";\r
public static String CLOUD_FONT = "Cloud font";\r
public static String STOCK_FONT = "Stock font";\r
public static String VALVE_FONT = "Valve font";\r
+ public static String INPUT_FONT = "Input font";\r
public static String MODULE_FONT = "Module font";\r
\r
- private static HashMap<String, String> fontPreferenceNames;\r
+ public static HashMap<String, String> fontPreferenceNames;\r
\r
static {\r
fontPreferenceNames = new HashMap<String, String>();\r
fontPreferenceNames.put(SysdynResource.URIs.CloudSymbol, CLOUD_FONT);\r
fontPreferenceNames.put(SysdynResource.URIs.StockSymbol, STOCK_FONT);\r
fontPreferenceNames.put(SysdynResource.URIs.ValveSymbol, VALVE_FONT);\r
+ fontPreferenceNames.put(SysdynResource.URIs.InputSymbol, INPUT_FONT);\r
fontPreferenceNames.put(SysdynResource.URIs.ModuleSymbol, MODULE_FONT);\r
-\r
}\r
\r
public static String getFontPreferenceName(ReadGraph graph, Resource resource) \r
throws DatabaseException {\r
- return fontPreferenceNames.get(getSymbolUri(graph, resource));\r
+ \r
+ String preference = fontPreferenceNames.get(getSymbolUri(graph, resource));\r
+ return preference;\r
}\r
\r
- private static HashMap<String, String> colorPreferenceNames;\r
+ public static String ARROW_USE_DEFAULT_FONT = "Arrow use default font";\r
+ public static String AUXILIARY_USE_DEFAULT_FONT = "Auxiliary use default font";\r
+ public static String CLOUD_USE_DEFAULT_FONT = "Cloud use default font";\r
+ public static String STOCK_USE_DEFAULT_FONT = "Stock use default font";\r
+ public static String VALVE_USE_DEFAULT_FONT = "Valve use default font";\r
+ public static String INPUT_USE_DEFAULT_FONT = "Input use default font";\r
+ public static String MODULE_USE_DEFAULT_FONT = "Module use default font";\r
+ \r
+ \r
+ public static HashMap<String, String> fontDefaults;\r
\r
static {\r
- colorPreferenceNames = new HashMap<String, String>();\r
- colorPreferenceNames.put(SysdynResource.URIs.DependencyConnection, ARROW_COLOR);\r
- colorPreferenceNames.put(SysdynResource.URIs.FlowConnection, FLOW_COLOR);\r
- colorPreferenceNames.put(SysdynResource.URIs.AuxiliarySymbol, AUXILIARY_COLOR);\r
- colorPreferenceNames.put(SysdynResource.URIs.CloudSymbol, CLOUD_COLOR);\r
- colorPreferenceNames.put(SysdynResource.URIs.StockSymbol, STOCK_COLOR);\r
- colorPreferenceNames.put(SysdynResource.URIs.ValveSymbol, VALVE_COLOR);\r
- colorPreferenceNames.put(SysdynResource.URIs.ModuleSymbol, MODULE_COLOR);\r
+ fontDefaults = new HashMap<String, String>();\r
+ fontDefaults.put(ARROW_FONT, ARROW_USE_DEFAULT_FONT);\r
+ fontDefaults.put(AUXILIARY_FONT, AUXILIARY_USE_DEFAULT_FONT);\r
+ fontDefaults.put(CLOUD_FONT, CLOUD_USE_DEFAULT_FONT);\r
+ fontDefaults.put(STOCK_FONT, STOCK_USE_DEFAULT_FONT);\r
+ fontDefaults.put(VALVE_FONT, VALVE_USE_DEFAULT_FONT);\r
+ fontDefaults.put(INPUT_FONT, INPUT_USE_DEFAULT_FONT);\r
+ fontDefaults.put(MODULE_FONT, MODULE_USE_DEFAULT_FONT);\r
}\r
\r
- public static String getColorPreferenceName(ReadGraph graph, Resource resource) \r
- throws DatabaseException {\r
- return colorPreferenceNames.get(getSymbolUri(graph, resource));\r
- }\r
+\r
\r
private static String getSymbolUri(ReadGraph graph, Resource resource)\r
throws DatabaseException {\r
return graph.getURI(symbol);\r
}\r
\r
- \r
+ /**\r
+ * Get the name of the property that decides whether to use default value or not\r
+ * @param property\r
+ * @return\r
+ */\r
+ public static String getUseDefaultProperty(String property) {\r
+ String result = colorDefaults.get(property);\r
+ if(result == null)\r
+ result = fontDefaults.get(property);\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Returns default property if USE DEFAULT is set, otherwise returns the \r
+ * same property as given as argument.\r
+ * @param property\r
+ * @return\r
+ */\r
+ public static String getPreferenceName(String property) {\r
+ String useDefault = fontDefaults.get(property);\r
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();\r
+ if(useDefault != null && store.getBoolean(useDefault)) {\r
+ return DEFAULT_FONT;\r
+ }\r
+ \r
+ useDefault = colorDefaults.get(property);\r
+ if(useDefault != null && store.getBoolean(useDefault)) {\r
+ return DEFAULT_COLOR;\r
+ }\r
+ \r
+ return property;\r
+ }\r
}\r
\r
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\r
import org.eclipse.jface.preference.IPreferenceStore;\r
-import org.eclipse.jface.resource.StringConverter;\r
+import org.eclipse.jface.preference.PreferenceConverter;\r
+import org.eclipse.swt.graphics.FontData;\r
import org.eclipse.swt.graphics.RGB;\r
import org.simantics.sysdyn.ui.Activator;\r
\r
+import com.lowagie.text.Font;\r
+\r
/**\r
* \r
* @author Teemu Lempinen\r
\r
@Override \r
public void initializeDefaultPreferences() {\r
+ RGB black = new RGB(0, 0, 0);\r
+ RGB arrow = new RGB(0,128,192);\r
+ \r
IPreferenceStore store = Activator.getDefault().getPreferenceStore();\r
- store.setDefault(SysdynDiagramPreferences.ARROW_COLOR, StringConverter.asString(new RGB(0, 0, 255)));\r
- store.setDefault(SysdynDiagramPreferences.FLOW_COLOR, StringConverter.asString(new RGB(0, 0, 0)));\r
- store.setDefault(SysdynDiagramPreferences.AUXILIARY_COLOR, StringConverter.asString(new RGB(0, 0, 0)));\r
- store.setDefault(SysdynDiagramPreferences.STOCK_COLOR, StringConverter.asString(new RGB(0, 0, 0)));\r
- store.setDefault(SysdynDiagramPreferences.VALVE_COLOR, StringConverter.asString(new RGB(0, 0, 0)));\r
- store.setDefault(SysdynDiagramPreferences.CLOUD_COLOR, StringConverter.asString(new RGB(0, 0, 0)));\r
+ \r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.DEFAULT_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.ARROW_COLOR, arrow);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.FLOW_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.AUXILIARY_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.STOCK_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.VALVE_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.INPUT_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.CLOUD_COLOR, black);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.MODULE_COLOR, black);\r
+ \r
+\r
+ store.setDefault(SysdynDiagramPreferences.ARROW_USE_DEFAULT_COLOR, false);\r
+ store.setDefault(SysdynDiagramPreferences.FLOW_USE_DEFAULT_COLOR, true);\r
+ store.setDefault(SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_COLOR, true);\r
+ store.setDefault(SysdynDiagramPreferences.STOCK_USE_DEFAULT_COLOR, true);\r
+ store.setDefault(SysdynDiagramPreferences.VALVE_USE_DEFAULT_COLOR, true);\r
+ store.setDefault(SysdynDiagramPreferences.INPUT_USE_DEFAULT_COLOR, true);\r
+ store.setDefault(SysdynDiagramPreferences.CLOUD_USE_DEFAULT_COLOR, true);\r
+ store.setDefault(SysdynDiagramPreferences.MODULE_USE_DEFAULT_COLOR, true);\r
+ \r
+ FontData[] basicFont = new FontData[] {new FontData("Tahoma", 12, Font.NORMAL)};\r
+ FontData[] italicFont = new FontData[] {new FontData("Tahoma", 12, Font.ITALIC)};\r
+ FontData[] moduleFont = new FontData[] {new FontData("Tahoma", 16, Font.NORMAL)};\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.DEFAULT_FONT, basicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.ARROW_FONT, basicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.AUXILIARY_FONT, basicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.STOCK_FONT, basicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.VALVE_FONT, basicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.INPUT_FONT, italicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.CLOUD_FONT, basicFont);\r
+ PreferenceConverter.setDefault(store, SysdynDiagramPreferences.MODULE_FONT, moduleFont);\r
+\r
+ store.setDefault(SysdynDiagramPreferences.ARROW_USE_DEFAULT_FONT, true);\r
+ store.setDefault(SysdynDiagramPreferences.AUXILIARY_USE_DEFAULT_FONT, true);\r
+ store.setDefault(SysdynDiagramPreferences.STOCK_USE_DEFAULT_FONT, true);\r
+ store.setDefault(SysdynDiagramPreferences.VALVE_USE_DEFAULT_FONT, true);\r
+ store.setDefault(SysdynDiagramPreferences.INPUT_USE_DEFAULT_FONT, false);\r
+ store.setDefault(SysdynDiagramPreferences.CLOUD_USE_DEFAULT_FONT, true);\r
+ store.setDefault(SysdynDiagramPreferences.MODULE_USE_DEFAULT_FONT, false);\r
+\r
} \r
\r
\r
\r
private void add(String property) {\r
diagramProperties.add(property);\r
+ String useDefault = SysdynDiagramPreferences.getUseDefaultProperty(property);\r
+ if(useDefault != null)\r
+ diagramProperties.add(useDefault);\r
}\r
\r
public SysdynDiagramPropertySupport() {\r
diagramProperties = new HashSet<String>();\r
- add(SysdynDiagramPreferences.ARROW_COLOR);\r
- add(SysdynDiagramPreferences.AUXILIARY_COLOR);\r
- add(SysdynDiagramPreferences.CLOUD_COLOR);\r
- add(SysdynDiagramPreferences.FLOW_COLOR);\r
- add(SysdynDiagramPreferences.STOCK_COLOR);\r
- add(SysdynDiagramPreferences.VALVE_COLOR);\r
- add(SysdynDiagramPreferences.MODULE_COLOR);\r
+ for(String property : SysdynDiagramPreferences.colorPreferenceNames.values())\r
+ add(property);\r
\r
add(SysdynDiagramPreferences.DEFAULT_COLOR);\r
add(SysdynDiagramPreferences.DEFAULT_FONT);\r
\r
- add(SysdynDiagramPreferences.ARROW_FONT);\r
- add(SysdynDiagramPreferences.AUXILIARY_FONT);\r
- add(SysdynDiagramPreferences.CLOUD_FONT);\r
- add(SysdynDiagramPreferences.STOCK_FONT);\r
- add(SysdynDiagramPreferences.VALVE_FONT);\r
- add(SysdynDiagramPreferences.MODULE_FONT);\r
+ \r
+ for(String property : SysdynDiagramPreferences.fontPreferenceNames.values())\r
+ add(property);\r
\r
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {\r
@Override\r
String propertyName = event.getProperty();\r
if(diagramProperties.contains(propertyName)){\r
for(SysdynDiagramPropertySubscription subscription : getSubscriptionSnapshot()) {\r
- if(propertyName.equals(subscription.getPropertyName())) {\r
+ String p = subscription.getPropertyName();\r
+ String p2 = SysdynDiagramPreferences.getPreferenceName(p);\r
+ String dp = SysdynDiagramPreferences.getUseDefaultProperty(subscription.getPropertyName());\r
+ if(propertyName.equals(p) ||\r
+ propertyName.equals(p2) ||\r
+ propertyName.equals(dp)) {\r
IPreferenceStore store = Activator.getDefault().getPreferenceStore();\r
- String result = store.getString(subscription.getPropertyName());\r
+ String result = store.getString(p2);\r
subscription.getListener().execute(result);\r
}\r
}\r