1 /*******************************************************************************
2 * Copyright (c) 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.elements;
14 import java.awt.Graphics2D;
15 import java.awt.geom.Rectangle2D;
17 import org.simantics.g2d.scenegraph.SceneGraphConstants;
18 import org.simantics.scenegraph.ILookupService;
19 import org.simantics.scenegraph.INode;
20 import org.simantics.scenegraph.g2d.G2DNode;
21 import org.simantics.scenegraph.g2d.nodes.DataNode;
22 import org.simantics.scenegraph.utils.NodeUtil;
25 * @author Tuukka Lehtonen
27 public class EditDataNode extends G2DNode {
30 * Used for naming and identifying (see {@link #setLookupId(String)})
31 * GridNode instances in scene graphs.
33 public static final String NODE_ID = "edit";
35 private static final long serialVersionUID = -6446582030817143221L;
37 private transient TextEditActivation activation;
44 public void setTextEditActivation(TextEditActivation a) {
48 public TextEditActivation getTextEditActivation() {
53 public void render(Graphics2D g2d) {
57 public Rectangle2D getBoundsInLocal() {
61 public static EditDataNode getNode(INode node) {
62 return getEditDataNode( NodeUtil.getLookupService(node) );
65 public static EditDataNode getEditDataNode(ILookupService lookup) {
66 EditDataNode node = (EditDataNode) lookup.lookupNode(EditDataNode.NODE_ID);
68 DataNode data = (DataNode) lookup.lookupNode(SceneGraphConstants.DATA_NODE_NAME);
70 throw new IllegalStateException("No '" + SceneGraphConstants.DATA_NODE_NAME + "' node in lookup " + lookup);
71 node = data.getOrCreateNode(EditDataNode.NODE_ID, EditDataNode.class);
72 node.setLookupId(EditDataNode.NODE_ID);