From: lempinen Date: Tue, 27 Nov 2012 12:10:20 +0000 (+0000) Subject: Removed immediate text edit activation on element select. (fixes #3880) X-Git-Tag: simantics-1.10.1~101 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ccd040a59164b5399d273745a8a0919b99120d29;p=simantics%2Fsysdyn.git Removed immediate text edit activation on element select. (fixes #3880) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26460 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextElementNoBounds.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextElementNoBounds.java index c7f76857..1aa2651c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextElementNoBounds.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextElementNoBounds.java @@ -15,8 +15,10 @@ import java.awt.Color; import java.awt.Font; import java.awt.geom.AffineTransform; +import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.ReadRequest; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.diagram.elements.ITextListener; @@ -102,7 +104,7 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif if(!VariableNameUtils.isValid(component, node.getText(), false)) { node.setColor(Color.RED); } else { - node.setColor(Color.BLACK); + node.setColor(ElementUtils.getTextColor(e, Color.BLACK)); } @@ -118,10 +120,10 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif Object o = e.getHint(ElementHints.KEY_OBJECT); if(o != null && o instanceof Resource) { final Resource element = (Resource)o; - SimanticsUI.getSession().asyncRequest(new WriteRequest() { + SimanticsUI.getSession().asyncRequest(new ReadRequest() { @Override - public void perform(WriteGraph graph) throws DatabaseException { + public void run(ReadGraph graph) throws DatabaseException { component = graph.getPossibleObject(element, ModelingResources.getInstance(graph).ElementToComponent); } }); @@ -133,7 +135,7 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif TextNode node = (TextNode) e.getHint(SG_NODE); if (node != null) { if(VariableNameUtils.isValid(component, node.getText(), false)) - node.setColor(Color.BLACK); + node.setColor(ElementUtils.getTextColor(e, Color.BLACK)); endEdit(node); } } @@ -148,7 +150,7 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif text = textBeforeEdit; node.setText(text); if(VariableNameUtils.isValid(component, text, false)) - node.setColor(Color.BLACK); + node.setColor(ElementUtils.getTextColor(e, Color.BLACK)); } else { Object o = e.getHint(ElementHints.KEY_OBJECT); final String textAfterEdit = text; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextNode.java index 8bef287f..76717577 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextNode.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextNode.java @@ -61,12 +61,6 @@ public class HoverTextNode extends TextNode implements ISelectionPainterNode { super.render(g, false); g.setTransform(ot); } - - @Override - public void init() { - super.init(); - addEventHandler(this); - } @Override public void remove() { @@ -88,5 +82,5 @@ public class HoverTextNode extends TextNode implements ISelectionPainterNode { } return false; } - + } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java index cbd30d5d..506e7a75 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java @@ -50,9 +50,9 @@ import org.simantics.sysdyn.ui.properties.widgets.ValveTextLocationGroup; import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory; import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier; import org.simantics.ui.SimanticsUI; -import org.simantics.ui.utils.AdaptionUtils; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.datastructures.Triple; +import org.simantics.utils.ui.AdaptionUtils; import org.simantics.utils.ui.ISelectionUtils; import org.simantics.utils.ui.validators.DoubleValidator; @@ -309,6 +309,14 @@ public class VariableInformationTab extends LabelPropertyTabContributor implemen @Override public void run() { + try { + if(sample.getWidget().isDisposed()) + return; + } catch (SWTException e) { + // Widget is disposed, the GUI probably did'n function as fast as the user commanded. + // Thus do nothing. + return; + } if(result.first != null) { FontData fd = toSwtFontData(result.first); sample.setFont(new Font(device, fd));