From: lehtonen Date: Thu, 29 Jul 2010 10:13:29 +0000 (+0000) Subject: Refactored duplicate code contained SGFocusParticipant/TextEditActivation into Contex... X-Git-Tag: simantics-1.2.0~153 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=8c3f77eadb2c3e7f5e660d76892d50658c2c9361;p=simantics%2Fsysdyn.git Refactored duplicate code contained SGFocusParticipant/TextEditActivation into ContextState +DiagramCommandBindings. Deprecated old EditTextHandler and removed it from all diagram viewers. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16867 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java index ffab9354..ebdea3bf 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java @@ -14,16 +14,13 @@ package org.simantics.sysdyn.ui.elements2; import java.awt.Color; import java.awt.Font; import java.awt.geom.Point2D; -import java.util.Collection; import org.simantics.diagram.elements.ITextListener; +import org.simantics.diagram.elements.TextEditActivation; import org.simantics.diagram.elements.TextNode; -import org.simantics.diagram.participant.ContextUtil; import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.canvas.IMouseCaptureHandle; import org.simantics.g2d.diagram.DiagramUtils; import org.simantics.g2d.diagram.IDiagram; -import org.simantics.g2d.diagram.participant.ElementInteractor; import org.simantics.g2d.element.ElementUtils; import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.SceneGraphNodeKey; @@ -36,9 +33,9 @@ import org.simantics.g2d.participant.MouseUtil.MouseClickEvent; import org.simantics.g2d.utils.Alignment; import org.simantics.scenegraph.g2d.G2DParentNode; import org.simantics.utils.datastructures.Callback; +import org.simantics.utils.datastructures.hints.IHintContext.Key; import org.simantics.utils.datastructures.hints.IHintListener; import org.simantics.utils.datastructures.hints.IHintObservable; -import org.simantics.utils.datastructures.hints.IHintContext.Key; /** * ElementHandler for text elements @@ -130,14 +127,14 @@ public class HoverTextElementNoBounds implements SceneGraph, HandleMouseEvent { node.setHorizontalAlignment((byte) horizontalAlignment.ordinal()); node.setBorderWidth((float) borderWidth); node.setEditable(editable); - + e.addHintListener(new IHintListener() { - + @Override public void hintRemoved(IHintObservable sender, Key key, Object oldValue) { - + } - + @Override public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) { IElement e = (IElement)sender; @@ -230,42 +227,5 @@ public class HoverTextElementNoBounds implements SceneGraph, HandleMouseEvent { return false; return true; } - - - - - - - - class TextEditActivation { - - ICanvasContext ctx; - IMouseCaptureHandle capture; - ContextUtil ctxUtil; - Collection originalContexts; - - public TextEditActivation(int mouseId, IElement e, ICanvasContext ctx) { - ElementInteractor ei = ctx.getSingleItem(ElementInteractor.class); - this.ctxUtil = ctx.getSingleItem(ContextUtil.class); - - // Capture mouse events (otherwise we would not get mouse events when the cursor is outside the text widget) - this.capture = ei.captureMouse(e, mouseId); - - // activate in-line editing context - this.originalContexts = ctxUtil.getActivatedContextIds(); - ctxUtil.deactivateAll(); - ctxUtil.activate("org.simantics.modeling.ui.diagramming.inlineEdit"); - } - - public void release() { - capture.release(); - capture = null; - - // de-activate in-line editing context - ctxUtil.deactivateAll(); - ctxUtil.activate(originalContexts); - } - - } } \ No newline at end of file