*/\r
public DataSet getDataSet(String name) {\r
for(DataSet set : variables)\r
- if(set.name.equals(name))\r
+ if(set.name.equalsIgnoreCase(name))\r
return set;\r
for(DataSet set : initials)\r
- if(set.name.equals(name))\r
+ if(set.name.equalsIgnoreCase(name))\r
return set;\r
return null;\r
}\r
"http://www.simantics.org/Sysdyn-1.1" : L0.URI
"http://www.simantics.org/Layer0-1.1" : L0.URI
"http://www.simantics.org/SelectionView-1.2" : L0.URI
-// "http://www.simantics.org/Documentation-1.1" : L0.URI // Experimental documentation tool
-// "http://www.simantics.org/DocumentWorkbench-1.0" : L0.URI // Experimental documentation tool
+ //"http://www.semantum.fi/Simupedia-1.0" : L0.URI // Experimental Simupedia
+ //"http://www.semantum.fi/SimupediaWorkbench-1.0" : L0.URI // Experimental Simupedia
SYSDYN.SharedFunctionOntology <T L0.Ontology
SYSDYN.SharedModuleOntology <T L0.Ontology
//#####################################################################
//#####################################################################
+//#####################################################################
+// Defaults
+//#####################################################################
+ //G2D.HasFont _ : G2D.Font
+SYSDYN.DefaultFont : G2D.Font
+ G2D.HasFontFamily "Tahoma"
+ G2D.HasFontSize 12
+ G2D.HasFontStyle G2D.FontStyle.normal_font_style
+
+SYSDYN.SysdynSymbol <T DIA.FontProvider <T DIA.ColorProvider
+ @L0.assert G2D.HasFont SYSDYN.DefaultFont
+
+
//#####################################################################
// Component types
//#####################################################################
SYSDYN.Bottom <T SYSDYN.Location
SYSDYN.Center <T SYSDYN.Location
-SYSDYN.ValveSymbol <T DIA.FontProvider <T DIA.ColorProvider
+SYSDYN.ValveSymbol <T SYSDYN.SysdynSymbol
@MOD.defSymbol "Valve" SYSDYN.Valve
>-- SYSDYN.ValveSymbol.orientation --> SYSDYN.Orientation <R L0.IsWeaklyRelatedTo : L0.FunctionalRelation
@L0.assert SYSDYN.ValveSymbol.orientation SYSDYN.Horizontal
@MOD.connection SYSDYN.Variable.isTailOf
@MOD.connection SYSDYN.Variable.isHeadOf
-SYSDYN.AuxiliarySymbol <T DIA.FontProvider <T DIA.ColorProvider
+SYSDYN.AuxiliarySymbol <T SYSDYN.SysdynSymbol
@MOD.defSymbol "Auxiliary" SYSDYN.Auxiliary
L0.IsDependencyOf BasicSymbols
STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
@MOD.connection SYSDYN.Variable.isTailOf
@MOD.connection SYSDYN.Variable.isHeadOf
-SYSDYN.CloudSymbol <T DIA.FontProvider <T DIA.ColorProvider
+SYSDYN.CloudSymbol <T SYSDYN.SysdynSymbol
@MOD.defSymbol "Cloud" SYSDYN.Cloud
L0.IsDependencyOf BasicSymbols
STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
@MOD.connection SYSDYN.Variable.isTailOf
@MOD.connection SYSDYN.Variable.isHeadOf
-SYSDYN.InputSymbol <T DIA.FontProvider <T DIA.ColorProvider
+SYSDYN.InputSymbol <T SYSDYN.SysdynSymbol
@MOD.defSymbol "Input" SYSDYN.Input
L0.IsDependencyOf BasicSymbols
STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
@MOD.connection SYSDYN.Variable.isTailOf
@MOD.connection SYSDYN.Variable.isHeadOf
-SYSDYN.StockSymbol <T DIA.FontProvider <T DIA.ColorProvider
+SYSDYN.StockSymbol <T SYSDYN.SysdynSymbol
@MOD.defSymbol "Stock" SYSDYN.Stock
L0.IsDependencyOf BasicSymbols
STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
@MOD.connection SYSDYN.Variable.isTailOf
@MOD.connection SYSDYN.Variable.isHeadOf
-SYSDYN.ShadowSymbol <T DIA.FontProvider <T DIA.ColorProvider
+SYSDYN.ShadowSymbol <T SYSDYN.SysdynSymbol
@MOD.defSymbol "Shadow" SYSDYN.Shadow
L0.IsDependencyOf BasicSymbols
STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext
SYSDYN.FlowConnection <T DIA.RouteGraphConnection <T DIA.FontProvider <T DIA.ColorProvider
MOD.DiagramConnectionTypeToConnectionType
SYSDYN.Flow
+ @L0.assert G2D.HasFont SYSDYN.DefaultFont
SYSDYN.DependencyConnection <T DIA.Connection <T DIA.FontProvider <T DIA.ColorProvider
@L0.singleProperty SYSDYN.Dependency.angle
@L0.assert SYSDYN.Dependency.angle 0.1
MOD.DiagramConnectionTypeToConnectionType
SYSDYN.Dependency
+ @L0.assert G2D.HasFont SYSDYN.DefaultFont
+ @L0.assert G2D.HasColor
+ [0.0,0.0,1.0,1.0] : G2D.Color
// TODO: Browser URIs
public final Resource ConfigurationDiagram_selection;\r
public final Resource ConfigurationDiagram_selection_Inverse;\r
public final Resource ConstantExpression;\r
+ public final Resource DefaultFont;\r
public final Resource DefaultProfile;\r
public final Resource DefaultRealization;\r
public final Resource DelayExpression;\r
public final Resource SysdynModelicaFunction_outputs_Inverse;\r
public final Resource SysdynModuleLibrary;\r
public final Resource SysdynOperationBrowser;\r
+ public final Resource SysdynSymbol;\r
public final Resource SysdynTerminal;\r
public final Resource Top;\r
public final Resource UniformDistribution;\r
public static final String ConfigurationDiagram_selection = "http://www.simantics.org/Sysdyn-1.1/ConfigurationDiagram/selection";\r
public static final String ConfigurationDiagram_selection_Inverse = "http://www.simantics.org/Sysdyn-1.1/ConfigurationDiagram/selection/Inverse";\r
public static final String ConstantExpression = "http://www.simantics.org/Sysdyn-1.1/ConstantExpression";\r
+ public static final String DefaultFont = "http://www.simantics.org/Sysdyn-1.1/DefaultFont";\r
public static final String DefaultProfile = "http://www.simantics.org/Sysdyn-1.1/DefaultProfile";\r
public static final String DefaultRealization = "http://www.simantics.org/Sysdyn-1.1/DefaultRealization";\r
public static final String DelayExpression = "http://www.simantics.org/Sysdyn-1.1/DelayExpression";\r
public static final String SysdynModelicaFunction_outputs_Inverse = "http://www.simantics.org/Sysdyn-1.1/SysdynModelicaFunction/outputs/Inverse";\r
public static final String SysdynModuleLibrary = "http://www.simantics.org/Sysdyn-1.1/SysdynModuleLibrary";\r
public static final String SysdynOperationBrowser = "http://www.simantics.org/Sysdyn-1.1/SysdynOperationBrowser";\r
+ public static final String SysdynSymbol = "http://www.simantics.org/Sysdyn-1.1/SysdynSymbol";\r
public static final String SysdynTerminal = "http://www.simantics.org/Sysdyn-1.1/SysdynTerminal";\r
public static final String Top = "http://www.simantics.org/Sysdyn-1.1/Top";\r
public static final String UniformDistribution = "http://www.simantics.org/Sysdyn-1.1/UniformDistribution";\r
ConfigurationDiagram_selection = getResourceOrNull(graph, URIs.ConfigurationDiagram_selection);\r
ConfigurationDiagram_selection_Inverse = getResourceOrNull(graph, URIs.ConfigurationDiagram_selection_Inverse);\r
ConstantExpression = getResourceOrNull(graph, URIs.ConstantExpression);\r
+ DefaultFont = getResourceOrNull(graph, URIs.DefaultFont);\r
DefaultProfile = getResourceOrNull(graph, URIs.DefaultProfile);\r
DefaultRealization = getResourceOrNull(graph, URIs.DefaultRealization);\r
DelayExpression = getResourceOrNull(graph, URIs.DelayExpression);\r
SysdynModelicaFunction_outputs_Inverse = getResourceOrNull(graph, URIs.SysdynModelicaFunction_outputs_Inverse);\r
SysdynModuleLibrary = getResourceOrNull(graph, URIs.SysdynModuleLibrary);\r
SysdynOperationBrowser = getResourceOrNull(graph, URIs.SysdynOperationBrowser);\r
+ SysdynSymbol = getResourceOrNull(graph, URIs.SysdynSymbol);\r
SysdynTerminal = getResourceOrNull(graph, URIs.SysdynTerminal);\r
Top = getResourceOrNull(graph, URIs.Top);\r
UniformDistribution = getResourceOrNull(graph, URIs.UniformDistribution);\r
id="org.simantics.modelica.preferences"\r
name="Modelica">\r
</page>\r
+ <page\r
+ class="org.simantics.sysdyn.ui.preferences.SysdynDiagramPreferencePage"\r
+ id="org.simantics.sysdyn.diagram.preferences"\r
+ name="Sysdyn Diagrams">\r
+ </page> \r
</extension>\r
<extension\r
point="org.eclipse.core.runtime.preferences">\r
<initializer\r
class="org.simantics.modelica.preferences.ModelicaPreferenceInitializer">\r
</initializer>\r
+ <initializer\r
+ class="org.simantics.sysdyn.ui.preferences.SysdynDiagramPreferencesInitializer">\r
+ </initializer> \r
</extension>\r
</plugin>\r
\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.Statement;\r
import org.simantics.db.common.utils.OrderedSetUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
ElementUtils.setTextFont(e, G2DUtils.getFont(graph, fontResource));\r
}\r
if (graph.isInstanceOf(element, dr.ColorProvider)) {\r
- Resource colorResource = graph.getPossibleObject(element, g2d.HasColor);\r
- if (colorResource != null)\r
- ElementUtils.setTextColor(e, G2DUtils.getColor(graph, colorResource));\r
+ Statement colorStatement = graph.getPossibleStatement(element, g2d.HasColor);\r
+ if (colorStatement != null && !colorStatement.isAsserted(element))\r
+ ElementUtils.setTextColor(e, G2DUtils.getColor(graph, colorStatement.getObject()));\r
+ else {\r
+ \r
+ }\r
}\r
\r
Resource component = graph.getPossibleObject(element, mr.ElementToComponent);\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.elements.connections;\r
\r
+import java.awt.Color;\r
import java.util.HashMap;\r
import java.util.concurrent.ConcurrentSkipListMap;\r
import java.util.concurrent.atomic.AtomicInteger;\r
\r
+import org.eclipse.jface.resource.StringConverter;\r
+import org.eclipse.swt.graphics.RGB;\r
import org.simantics.databoard.Bindings;\r
import org.simantics.db.AsyncReadGraph;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.Statement;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.procedure.AsyncMultiProcedure;\r
import org.simantics.db.procedure.AsyncProcedure;\r
import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
+import org.simantics.sysdyn.ui.preferences.SysdynDiagramPreferences;\r
+import org.simantics.sysdyn.ui.preferences.SysdynDiagramPropertyExternalRead;\r
import org.simantics.utils.datastructures.Pair;\r
\r
/**\r
});\r
\r
// Find possible color\r
- graph.forPossibleObject(elementResource, G2D.HasColor, new SyncProcedure<Resource>() {\r
+ graph.forPossibleStatement(elementResource, G2D.HasColor, new SyncProcedure<Statement>() {\r
\r
@Override\r
- public void execute(ReadGraph graph, Resource result) throws DatabaseException {\r
- if(result != null) {\r
- element.setHint(ElementHints.KEY_TEXT_COLOR, G2DUtils.getColor(graph, result));\r
+ public void execute(ReadGraph graph, Statement result) throws DatabaseException {\r
+ if(result != null && !result.isAsserted(elementResource)) {\r
+ element.setHint(ElementHints.KEY_TEXT_COLOR, G2DUtils.getColor(graph, result.getObject()));\r
+ } else {\r
+ String color = graph.syncRequest(new SysdynDiagramPropertyExternalRead(new Pair<Resource, String>(elementResource, SysdynDiagramPreferences.ARROW_COLOR)));\r
+ if(color != null) {\r
+ RGB rgb = StringConverter.asRGB(color, null);\r
+ if(rgb != null) {\r
+ Color c = new Color(rgb.red, rgb.green, rgb.blue);\r
+ element.setHint(ElementHints.KEY_TEXT_COLOR, c);\r
+ }\r
+ }\r
+\r
}\r
}\r
\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy\r
+ *******************************************************************************/\r
+\r
+package org.simantics.sysdyn.ui.preferences;\r
+\r
+import org.eclipse.jface.preference.ColorFieldEditor;\r
+import org.eclipse.jface.preference.FieldEditorPreferencePage;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.IWorkbench;\r
+import org.eclipse.ui.IWorkbenchPage;\r
+import org.eclipse.ui.IWorkbenchPreferencePage;\r
+import org.eclipse.ui.IWorkbenchWindow;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.simantics.g2d.diagram.DiagramUtils;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.modeling.ui.diagramEditor.DiagramEditor;\r
+import org.simantics.sysdyn.ui.Activator;\r
+\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SysdynDiagramPreferencePage extends FieldEditorPreferencePage implements\r
+IWorkbenchPreferencePage {\r
+\r
+ public SysdynDiagramPreferencePage() {\r
+ super(GRID);\r
+ setDescription("System dynamics diagram preferences");\r
+ }\r
+\r
+ @Override\r
+ public void init(IWorkbench workbench) {\r
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());\r
+ }\r
+\r
+ @Override\r
+ protected void createFieldEditors() {\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
+ }\r
+\r
+ @Override\r
+ public boolean performOk() {\r
+ IEditorPart editor = null;\r
+ IWorkbench workbench = PlatformUI.getWorkbench();\r
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();\r
+ // To ask for the active window doesn't work, so browse through all\r
+ // windows and when an active editor is found, use that\r
+ for (IWorkbenchWindow window : windows) {\r
+ IWorkbenchPage page = window.getActivePage();\r
+ if (page != null) {\r
+ editor = (IEditorPart)page.getActiveEditor();\r
+ if (editor != null)\r
+ break;\r
+ }\r
+ }\r
+ if (editor != null) {\r
+ if (editor instanceof DiagramEditor) {\r
+ DiagramEditor diagramEditor = (DiagramEditor) editor;\r
+ IDiagram o = (IDiagram) diagramEditor.getViewer().getAdapter(IDiagram.class);\r
+// ICanvasContext o = (ICanvasContext) diagramEditor.getViewer().getAdapter(ICanvasContext.class);\r
+ if(o != null) {\r
+ DiagramUtils.invalidate(o);\r
+ DiagramUtils.validateAndFix(o, o.getElements());\r
+ \r
+// o.getContentContext().setDirty();\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ return super.performOk();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.preferences;\r
+\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SysdynDiagramPreferences {\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
+\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.preferences;\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.swt.graphics.RGB;\r
+import org.simantics.sysdyn.ui.Activator;\r
+\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SysdynDiagramPreferencesInitializer extends AbstractPreferenceInitializer { \r
+\r
+ @Override \r
+ public void initializeDefaultPreferences() {\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
+\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.preferences;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ParametrizedPrimitiveRead;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SysdynDiagramPropertyExternalRead extends ParametrizedPrimitiveRead<Pair<Resource, String>, String> {\r
+\r
+ private SysdynDiagramPropertySubscription subscription;\r
+\r
+ public SysdynDiagramPropertyExternalRead(Pair<Resource, String> input) {\r
+ super(input);\r
+ }\r
+\r
+ @Override\r
+ public void register(ReadGraph graph, Listener<String> procedure) {\r
+ subscription = new SysdynDiagramPropertySubscription(procedure, parameter.second);\r
+ SysdynDiagramPropertySupport.INSTANCE.register(subscription);\r
+ procedure.execute(Activator.getDefault().getPreferenceStore().getString(parameter.second));\r
+ }\r
+ \r
+ @Override\r
+ public void unregistered() {\r
+ if(subscription != null) {\r
+ SysdynDiagramPropertySupport.INSTANCE.unregister(subscription);\r
+ subscription = null;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.preferences;\r
+\r
+import org.simantics.db.procedure.Listener;\r
+\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SysdynDiagramPropertySubscription {\r
+ \r
+ private Listener<String> listener;\r
+ private String propertyName;\r
+ \r
+ public SysdynDiagramPropertySubscription(Listener<String> listener, String propertyName) {\r
+ this.listener = listener;\r
+ this.propertyName = propertyName;\r
+ }\r
+\r
+ public Listener<String> getListener() {\r
+ return listener;\r
+ }\r
+ \r
+ public String getPropertyName() {\r
+ return propertyName;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * Semantum Oy\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.preferences;\r
+\r
+import gnu.trove.set.hash.THashSet;\r
+\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.resource.StringConverter;\r
+import org.eclipse.jface.util.IPropertyChangeListener;\r
+import org.eclipse.jface.util.PropertyChangeEvent;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.simantics.sysdyn.ui.Activator;\r
+\r
+/**\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class SysdynDiagramPropertySupport {\r
+ \r
+ public static SysdynDiagramPropertySupport INSTANCE = new SysdynDiagramPropertySupport();\r
+ \r
+ private Set<String> diagramProperties;\r
+ private THashSet<SysdynDiagramPropertySubscription> subscriptions = new THashSet<SysdynDiagramPropertySubscription>();\r
+ private SysdynDiagramPropertySubscription[] subscriptionSnapshot = null;\r
+ \r
+ private void add(String property) {\r
+ diagramProperties.add(property);\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
+ \r
+ Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {\r
+ @Override\r
+ public void propertyChange(PropertyChangeEvent event) {\r
+ String propertyName = event.getProperty();\r
+ if(diagramProperties.contains(propertyName)){\r
+ for(SysdynDiagramPropertySubscription subscription : getSubscriptionSnapshot()) {\r
+ if(propertyName.equals(subscription.getPropertyName())) {\r
+ Object newValue = event.getNewValue();\r
+ String result = newValue.toString();\r
+ if(newValue instanceof RGB) \r
+ result = StringConverter.asString((RGB)newValue);\r
+ subscription.getListener().execute(result);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ public void register(SysdynDiagramPropertySubscription subscription) {\r
+ assert subscription != null;\r
+ synchronized (subscriptions) {\r
+ subscriptions.add(subscription);\r
+ subscriptionSnapshot = null;\r
+ }\r
+ }\r
+\r
+ public void unregister(SysdynDiagramPropertySubscription subscription) {\r
+ assert subscription != null;\r
+ synchronized (subscriptions) {\r
+ subscriptions.remove(subscription);\r
+ subscriptionSnapshot = null;\r
+ }\r
+\r
+ }\r
+ \r
+ public SysdynDiagramPropertySubscription[] getSubscriptionSnapshot() {\r
+ SysdynDiagramPropertySubscription[] snapshot = subscriptionSnapshot;\r
+ if (snapshot == null) {\r
+ synchronized (subscriptions) {\r
+ snapshot = subscriptionSnapshot;\r
+ if (snapshot == null) {\r
+ snapshot = subscriptionSnapshot = \r
+ subscriptions.toArray(new SysdynDiagramPropertySubscription[subscriptions.size()]);\r
+ }\r
+ }\r
+ }\r
+ return snapshot;\r
+ } \r
+\r
+}\r
\r
<launcherArgs>\r
<programArgs>-fixerrors\r
---launcher.XXMaxPermSize 192m</programArgs>\r
+--launcher.XXMaxPermSize 192m\r
+-data @noDefault</programArgs>\r
<vmArgs>-ea -Xmx768M -XX:MaxPermSize=192m -Xshare:off</vmArgs>\r
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>\r
</launcherArgs>\r
</win>\r
</launcher>\r
\r
-\r
<vm>\r
<windows include="true">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</windows>\r
</vm>\r