import java.awt.Color;\r
import java.awt.Font;\r
import java.awt.geom.Point2D;\r
-import java.util.Collection;\r
\r
import org.simantics.diagram.elements.ITextListener;\r
+import org.simantics.diagram.elements.TextEditActivation;\r
import org.simantics.diagram.elements.TextNode;\r
-import org.simantics.diagram.participant.ContextUtil;\r
import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.canvas.IMouseCaptureHandle;\r
import org.simantics.g2d.diagram.DiagramUtils;\r
import org.simantics.g2d.diagram.IDiagram;\r
-import org.simantics.g2d.diagram.participant.ElementInteractor;\r
import org.simantics.g2d.element.ElementUtils;\r
import org.simantics.g2d.element.IElement;\r
import org.simantics.g2d.element.SceneGraphNodeKey;\r
import org.simantics.g2d.utils.Alignment;\r
import org.simantics.scenegraph.g2d.G2DParentNode;\r
import org.simantics.utils.datastructures.Callback;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
import org.simantics.utils.datastructures.hints.IHintListener;\r
import org.simantics.utils.datastructures.hints.IHintObservable;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
\r
/**\r
* ElementHandler for text elements\r
node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
node.setBorderWidth((float) borderWidth);\r
node.setEditable(editable);\r
- \r
+\r
e.addHintListener(new IHintListener() {\r
- \r
+\r
@Override\r
public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
- \r
+\r
}\r
- \r
+\r
@Override\r
public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
IElement e = (IElement)sender;\r
return false;\r
return true;\r
}\r
- \r
- \r
- \r
- \r
- \r
- \r
- \r
- class TextEditActivation {\r
-\r
- ICanvasContext ctx;\r
- IMouseCaptureHandle capture;\r
- ContextUtil ctxUtil;\r
- Collection<String> originalContexts;\r
-\r
- public TextEditActivation(int mouseId, IElement e, ICanvasContext ctx) {\r
- ElementInteractor ei = ctx.getSingleItem(ElementInteractor.class);\r
- this.ctxUtil = ctx.getSingleItem(ContextUtil.class);\r
-\r
- // Capture mouse events (otherwise we would not get mouse events when the cursor is outside the text widget)\r
- this.capture = ei.captureMouse(e, mouseId);\r
-\r
- // activate in-line editing context\r
- this.originalContexts = ctxUtil.getActivatedContextIds();\r
- ctxUtil.deactivateAll();\r
- ctxUtil.activate("org.simantics.modeling.ui.diagramming.inlineEdit");\r
- }\r
-\r
- public void release() {\r
- capture.release();\r
- capture = null;\r
-\r
- // de-activate in-line editing context\r
- ctxUtil.deactivateAll();\r
- ctxUtil.activate(originalContexts);\r
- }\r
-\r
- }\r
\r
}
\ No newline at end of file