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