import java.awt.Font;\r
import java.awt.geom.AffineTransform;\r
\r
+import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.diagram.elements.ITextListener;\r
if(!VariableNameUtils.isValid(component, node.getText(), false)) {\r
node.setColor(Color.RED);\r
} else {\r
- node.setColor(Color.BLACK);\r
+ node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
}\r
\r
\r
Object o = e.getHint(ElementHints.KEY_OBJECT);\r
if(o != null && o instanceof Resource) {\r
final Resource element = (Resource)o;\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
\r
@Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
component = graph.getPossibleObject(element, ModelingResources.getInstance(graph).ElementToComponent);\r
}\r
});\r
TextNode node = (TextNode) e.getHint(SG_NODE);\r
if (node != null) {\r
if(VariableNameUtils.isValid(component, node.getText(), false))\r
- node.setColor(Color.BLACK);\r
+ node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
endEdit(node);\r
}\r
}\r
text = textBeforeEdit;\r
node.setText(text);\r
if(VariableNameUtils.isValid(component, text, false))\r
- node.setColor(Color.BLACK);\r
+ node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
} else {\r
Object o = e.getHint(ElementHints.KEY_OBJECT);\r
final String textAfterEdit = text;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
import org.simantics.utils.datastructures.Pair;\r
import org.simantics.utils.datastructures.Triple;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
import org.simantics.utils.ui.ISelectionUtils;\r
import org.simantics.utils.ui.validators.DoubleValidator;\r
\r
\r
@Override\r
public void run() {\r
+ try {\r
+ if(sample.getWidget().isDisposed())\r
+ return;\r
+ } catch (SWTException e) {\r
+ // Widget is disposed, the GUI probably did'n function as fast as the user commanded.\r
+ // Thus do nothing.\r
+ return;\r
+ }\r
if(result.first != null) {\r
FontData fd = toSwtFontData(result.first);\r
sample.setFont(new Font(device, fd));\r