]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/INode.java
Sync git svn branch with SVN repository r33269.
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / INode.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.scenegraph;
13
14 import java.io.Serializable;
15 import java.lang.annotation.ElementType;
16 import java.lang.annotation.Retention;
17 import java.lang.annotation.RetentionPolicy;
18 import java.lang.annotation.Target;
19
20 /**
21  * @author J-P Laine\r
22  * \r
23  * @see Node\r
24  * @see ParentNode\r
25  */
26 public interface INode extends Serializable {
27     public static enum Location { LOCAL, REMOTE };
28
29     /**\r
30      * Tell the MethodInterceptor to synchronize the given fields after the\r
31      * method call.\r
32      * \r
33      * @author J-P Laine\r
34      */
35     @Retention(RetentionPolicy.RUNTIME)
36     @Target(ElementType.METHOD)
37     public @interface SyncField {
38         String[] value(); // Field name(s)
39     }
40
41     /**\r
42      * Tell the MethodInterceptor to remotely call this method if we are on the\r
43      * client side. Notice that the method type must be void, thus it cannot\r
44      * return value.\r
45      * \r
46      * @author J-P Laine\r
47      */
48     @Retention(RetentionPolicy.RUNTIME)
49     @Target(ElementType.METHOD)
50     public @interface ServerSide {
51     }
52
53     /**\r
54      * Tell the MethodInterceptor to remotely call this method if we are on the\r
55      * server side. Notice that the method type must be void, thus it cannot\r
56      * return value.\r
57      * \r
58      * @author J-P Laine\r
59      */
60     @Retention(RetentionPolicy.RUNTIME)
61     @Target(ElementType.METHOD)
62     public @interface ClientSide {
63     }\r
64 \r
65     /**\r
66      * Tag method as setter for a property identified by string. Basically used\r
67      * by the automatic graph to node property synchronizer.\r
68      * \r
69      * @author J-P Laine\r
70      */\r
71     @Retention(RetentionPolicy.RUNTIME)\r
72     @Target(ElementType.METHOD)\r
73     public @interface PropertySetter {\r
74         String value(); // Property name\r
75     }\r
76 \r
77     /**\r
78      * \r
79      * @return unique node identifier\r
80      */
81     public Long getId();
82 \r
83     /**\r
84      * @return root node of the scene graph or <code>null</code> if this node is\r
85      *         not part of a properly rooted scene graph hierarchy\r
86      */\r
87     public ParentNode<?> getRootNode();\r
88 \r
89     /**\r
90      * @return Parent node reference or <code>null</code> if not set\r
91      */
92     public ParentNode<?> getParent();
93 \r
94     /**\r
95      * Set parent node. This method is for scene graph internal use only and\r
96      * should not be called outside the scene graph structure. This method\r
97      * simply sets the parent node parent field, and does not affect on parent\r
98      * node (i.e., should be called only from parent node).\r
99      */
100     public void setParent(ParentNode<?> parent);
101 \r
102     /**\r
103      * Initialize node. This is called immediately after the node is added to\r
104      * the scene graph tree through any of the node addition methods in\r
105      * {@link ParentNode}.\r
106      * \r
107      * @see ParentNode#addNode(Class)\r
108      * @see ParentNode#addNode(String, Class)\r
109      * @see ParentNode#getOrCreateNode(String, Class)\r
110      */
111     public void init();
112     public void attach();\r
113     \r
114     /**\r
115      * Perform cleanup for this node and for the child nodes. Any resources\r
116      * (including child nodes) related to this node are unusable after this\r
117      * operation. This method is for scene graph internal use only, thus should\r
118      * not be called outside the scene graph structure.\r
119      */
120     public void cleanup();
121 \r
122     /**\r
123      * Remove this node and its children from the scene graph.\r
124      */
125     public void remove();
126 \r
127     /**\r
128      * Delete this node, and move its children under its parent.\r
129      * \r
130      * <p>\r
131      * Note: this method has no effect if the node has no parent.\r
132      */\r
133     public void delete();\r
134 \r
135     /**\r
136      * Append parent node for this node. The new node will be placed between\r
137      * parent node and this node. In order to call this method the node must be\r
138      * a child of another node, hence parent must be not null.\r
139      */\r
140     public <TC> TC appendParent(String id, Class<TC> nc);\r
141
142     @Override
143     public String toString();
144
145     /**\r
146      * @return simple name for this node class\r
147      */\r
148     public String getSimpleClassName();\r
149 \r
150 }