]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
git-svn-id: https://www.simantics.org/svn/simantics/3d/branches/dev@8680 ac1ea38d...
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 19 Jan 2009 12:37:41 +0000 (12:37 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 19 Jan 2009 12:37:41 +0000 (12:37 +0000)
org.simantics.proconf.processeditor/META-INF/MANIFEST.MF
org.simantics.proconf.processeditor/src/org/simantics/processeditor/adapters/ProcessEditorAdapter.java [new file with mode: 0644]
org.simantics.proconf.processeditor/src/org/simantics/processeditor/adapters/ProcessEditorSelectionAdapter.java [new file with mode: 0644]
org.simantics.proconf.processeditor/src/org/simantics/processeditor/views/ProcessEditor.java

index 132bac2ce2eadc55fa4b40431f59dcd04e643140..f6ed1f0b2edf26edecaebc84ef5188af462034af 100644 (file)
@@ -24,5 +24,7 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.ui.views,
  org.simantics.animation
 Eclipse-LazyStart: true
-Export-Package: org.simantics.processeditor.stubs,
+Export-Package: org.simantics.processeditor.adapters,
+ org.simantics.processeditor.common,
+ org.simantics.processeditor.stubs,
  org.simantics.processeditor.tools
diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/adapters/ProcessEditorAdapter.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/adapters/ProcessEditorAdapter.java
new file mode 100644 (file)
index 0000000..05587e5
--- /dev/null
@@ -0,0 +1,307 @@
+package org.simantics.processeditor.adapters;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.Graph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.layer0.utils.EntityFactory;\r
+import org.simantics.layer0.utils.IEntity;\r
+import org.simantics.layer0.utils.Property;\r
+import org.simantics.processeditor.ProcessResource;\r
+import org.simantics.processeditor.common.ControlPointTools;\r
+import org.simantics.processeditor.common.PipingRules;\r
+import org.simantics.processeditor.scenegraph.NonVisibleNode;\r
+import org.simantics.processeditor.scenegraph.PipeComponentNode;\r
+import org.simantics.processeditor.scenegraph.PipeRunNode;\r
+import org.simantics.processeditor.scenegraph.PipelineComponentNode;\r
+import org.simantics.processeditor.stubs.PipeControlPoint;\r
+import org.simantics.processeditor.stubs.PipeRun;\r
+import org.simantics.processeditor.stubs.Plant3DResource;\r
+import org.simantics.proconf.g3d.base.JmeRenderingComponent;\r
+import org.simantics.proconf.g3d.base.ScenegraphAdapterImpl;\r
+import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
+import org.simantics.proconf.g3d.scenegraph.IGeometryNode;\r
+import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;\r
+import org.simantics.proconf.g3d.scenegraph.ISelectableNode;\r
+import org.simantics.proconf.g3d.scenegraph.ParameterizedModelNode;\r
+import org.simantics.proconf.g3d.stubs.G3DNode;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+\r
+public class ProcessEditorAdapter extends ScenegraphAdapterImpl {\r
+       private ThreeDimensionalEditorBase editor;\r
+       \r
+        public ProcessEditorAdapter(ThreeDimensionalEditorBase editor, Session session, JmeRenderingComponent component) {\r
+               super(session, component);\r
+               this.editor = editor;\r
+        }\r
+        \r
+        private class NormalScenegraphQuery extends ScenegraphQuery {\r
+               \r
+               public NormalScenegraphQuery(Resource node) {\r
+                       super(node);\r
+               } \r
+                \r
+                \r
+                @Override\r
+               public void shapeAdded(Graph graph, IGraphicsNode node) {\r
+                        // FIXME : this won't work like in previous ProConf\r
+               }\r
+        }\r
+        \r
+        private Map<Resource,PipeRunControlPointQuery> pipeRunQueries = new HashMap<Resource, PipeRunControlPointQuery>();\r
+\r
+       protected ScenegraphQuery newSubnodeListener(G3DNode node) {\r
+               if (node.isInstanceOf(ProcessResource.plant3Dresource.PipeRun)) {\r
+                   PipeRunControlPointQuery query = new PipeRunControlPointQuery(node.getResource());\r
+                   pipeRunQueries.put(node.getResource(), query);\r
+                   node.getGraph().performQuery(query);\r
+               }\r
+               return new NormalScenegraphQuery(node.getResource());\r
+                \r
+           }\r
+       \r
+       @Override\r
+       protected NodePropertyQuery newRootPropertyListener(G3DNode root) {\r
+               // currently Plant does not have any properties.\r
+               return null;\r
+       }\r
+       \r
+       private class TransformationQuery extends NodeTransformationQuery {\r
+               \r
+               public TransformationQuery(Resource res) {\r
+                       super(res);\r
+               }\r
+               \r
+               @Override\r
+               public void shapeUpdated(Graph graph, IGraphicsNode shape) {\r
+                       //if (shape instanceof IGeometryNode) {\r
+           //    updateGeometry((IGeometryNode)shape);\r
+           //} else {\r
+               shape.updateTransform(graph);\r
+           //}\r
+               }\r
+       }\r
+       \r
+       @Override\r
+       protected NodeTransformationQuery newTransformationListener(G3DNode root) {\r
+               return new TransformationQuery(root.getResource());\r
+       }\r
+       \r
+       private class NormalNodePropertyQuery extends org.simantics.proconf.g3d.base.ScenegraphAdapterImpl.NodePropertyQuery {\r
+               \r
+               public NormalNodePropertyQuery(Resource resource) {\r
+                       super(resource);\r
+               }\r
+\r
+               @Override\r
+               public void shapeUpdated(Graph graph,IGraphicsNode shape) {\r
+                       if (shape instanceof IGeometryNode) {\r
+               updateGeometry((IGeometryNode)shape);\r
+           } else {\r
+               shape.updateTransform(graph);\r
+           }\r
+               }\r
+       }\r
+        @Override\r
+       protected NodePropertyQuery newPropertyListener(G3DNode node) {\r
+               return new NormalNodePropertyQuery(node.getResource());\r
+       }\r
+\r
+        @Override\r
+       protected IGraphicsNode instantiateNode(IGraphicsNode parent,\r
+                       G3DNode node) {\r
+               Plant3DResource p3r = ProcessResource.plant3Dresource;\r
+               IGraphicsNode newNode = null;\r
+               try {\r
+                       if (node.isInstanceOf(p3r.Equipment)) {\r
+                               newNode = new ParameterizedModelNode(\r
+                                               editor, parent, node.getGraph(),\r
+                                               node.getResource(), p3r.HasGraphics);\r
+                       } else if (node.isInstanceOf(p3r.PipeRun)) {\r
+                               newNode = new PipeRunNode(parent, node.getGraph(), node.getResource());\r
+                       } else if (node.isInstanceOf(p3r.Nozzle)) {\r
+                               newNode = new ParameterizedModelNode(\r
+                                               editor, parent, node.getGraph(),\r
+                                               node.getResource(), p3r.HasGraphics);\r
+                               // CodedComponent must be handled first since it uses\r
+                               // hard-coded geometries\r
+                               // TODO : is this really necessary, or could we unify\r
+                               // PipeComponentNode, InlineComponentNode,...\r
+                       } else if (node.isInstanceOf(p3r.CodedComponent)) {\r
+                               newNode = new PipeComponentNode(editor,\r
+                                               parent, node.getGraph(), node.getResource());\r
+                       } else if (node.isInstanceOf(p3r.NonVisibleComponent)) {\r
+                               newNode = new NonVisibleNode(parent, node.getGraph(), node.getResource());\r
+                       } else if (node.isInstanceOf(p3r.PipelineComponent)) {\r
+                               newNode = new PipelineComponentNode(editor,\r
+                                               parent, node.getGraph(), node.getResource());\r
+                       } \r
+\r
+                       // } else if (node instanceof Shape) // Markers (ar/mobile)\r
+                       // needed this\r
+                       // newNode = new ShapeNode(TestProcessEditor.this,parent,node);\r
+                       if (newNode != null) {\r
+                               if (newNode instanceof ISelectableNode)\r
+                                       ((ISelectableNode) newNode).setVisible(true);\r
+                               if (newNode instanceof IGeometryNode) {\r
+                                       updateGeometry((IGeometryNode) newNode);\r
+                               }\r
+                               return newNode;\r
+                       }\r
+               } catch (Exception e) {\r
+                       ErrorLogger.defaultLogError("Cannot handle node " + node.getResource(), e);\r
+                       return null;\r
+               }\r
+               ErrorLogger.defaultLogError("Cannot handle node " + node.getResource(), null);\r
+               return null;\r
+\r
+       }\r
+\r
+       /**\r
+        * This is used to create elbows and straight pipes to pipeline TODO :\r
+        * this should be done with rule-engine!\r
+        * \r
+        * \r
+        * @author Marko Luukkainen\r
+        * \r
+        */\r
+       protected class PipeRunControlPointQuery extends NodeQuery {\r
+               private List<Resource> removed = new ArrayList<Resource>();\r
+               private List<Resource> added = new ArrayList<Resource>();\r
+\r
+               public PipeRunControlPointQuery(Resource r) {\r
+                       super(r);\r
+                       if (DEBUG) System.out.println("Created PipeRunControlPointQuery for " + r);\r
+\r
+               }\r
+\r
+               @Override\r
+               protected Object compute2(Graph graph) {\r
+                       PipeRun run = new PipeRun(graph, nodeResource);\r
+                       Collection<IEntity> cps = run\r
+                                       .getRelatedObjects(ProcessResource.plant3Dresource.HasControlPoints);\r
+                       List<Resource> res = new ArrayList<Resource>();\r
+                       for (IEntity t : cps)\r
+                               res.add(t.getResource());\r
+                       return res;\r
+               }\r
+\r
+               @Override\r
+               public boolean updated(Graph graph, Object oldResult,\r
+                               Object newResult) {\r
+                       \r
+                       removed.clear();\r
+                       added.clear();\r
+\r
+                       List<Resource> oldCps = (List<Resource>) oldResult;\r
+                       List<Resource> newCps = (List<Resource>) newResult;\r
+                       if (oldCps == null)\r
+                               oldCps = new ArrayList<Resource>();\r
+\r
+                       for (Resource r : oldCps) {\r
+                               if (!newCps.contains(r))\r
+                                       removed.add(r);\r
+                       }\r
+\r
+                       for (Resource r : newCps) {\r
+                               if (!oldCps.contains(r))\r
+                                       added.add(r);\r
+                       }\r
+                       for (Resource r : removed)\r
+                               removeControlPoint(graph, r);\r
+                       for (Resource r : added) {\r
+                               addControlPoint(graph, r);\r
+                               // ControlPointTools.addControlPoint(new\r
+                               // PipeRun(graph,pipeRun), new PipeControlPoint(graph, r));\r
+                       }\r
+\r
+                       return (added.size() > 0 || removed.size() > 0);\r
+               }\r
+               \r
+               @Override\r
+               public void dispose() {\r
+                       super.dispose();\r
+                       for (ControlPointPropertyQuery q : controlPointPropertyQueries.values())\r
+                               q.dispose();\r
+                       controlPointPropertyQueries.clear();\r
+               }\r
+               \r
+               private Map<Resource,ControlPointPropertyQuery> controlPointPropertyQueries = new HashMap<Resource, ControlPointPropertyQuery>();\r
+               \r
+               private void addControlPoint(Graph graph, Resource resource) {\r
+                       ControlPointPropertyQuery query = new ControlPointPropertyQuery(resource);\r
+                       graph.performQuery(query);\r
+                       controlPointPropertyQueries.put(resource,query);\r
+               }\r
+               \r
+               private void removeControlPoint(Graph graph, Resource resource) {\r
+                       ControlPointPropertyQuery query = controlPointPropertyQueries.remove(resource);\r
+                       query.dispose();\r
+                       ControlPointTools.removeControlPoint(new PipeControlPoint(\r
+                                       graph, resource));\r
+               }\r
+\r
+       }\r
+\r
+       protected class ControlPointPropertyQuery extends NodeQuery {\r
+               boolean initialized = false;\r
+               \r
+               public ControlPointPropertyQuery(Resource r) {\r
+                       super(r);\r
+                       if (DEBUG) System.out.println("Created ControlPointPropertyQuery for " + r);\r
+               }\r
+               \r
+               @Override\r
+       public List<Object> compute2(Graph g) {\r
+               IEntity t = EntityFactory.create(g,nodeResource);\r
+               \r
+               Collection<Property> properties = t.getRelatedProperties(ProcessResource.builtins.HasProperty);\r
+               List<Object> propertyValues = new ArrayList<Object>();\r
+               p(properties,propertyValues);\r
+\r
+               return propertyValues;\r
+       }\r
+       \r
+       private void p(Collection<Property> properties, List<Object> propertyValues) {\r
+               for (Property p : properties) {\r
+                       Collection<Property> subProperties = p.getRelatedProperties(p.getGraph().getBuiltins().HasProperty);\r
+                       if (subProperties.size() != 0) {\r
+                               p(subProperties,propertyValues);\r
+                       } \r
+                       if (p.hasValue()){\r
+                               propertyValues.add(p.getValue());\r
+                       }\r
+               }\r
+       }\r
+               \r
+               @Override\r
+               public boolean updated(Graph graph, Object oldResult, Object newResult) {\r
+                       PipingRules.pipeControlPointPositionUpdate(graph, this.nodeResource);\r
+                       if (initialized) {\r
+                               //PipingRules.pipeControlPointPositionUpdate(graph, this.nodeResource);\r
+                       } else {\r
+                               initialized = true;\r
+                       }\r
+                       return true;\r
+               }\r
+       }\r
+       \r
+       @Override\r
+       protected void removeNode(Resource parent, Resource r) {\r
+               super.removeNode(parent, r);\r
+               PipeRunControlPointQuery q = pipeRunQueries.get(r);\r
+               if (q != null)\r
+                       q.dispose();\r
+       }\r
+       \r
+       @Override\r
+       public void dispose() {\r
+               super.dispose();\r
+       }\r
+\r
+}\r
diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/adapters/ProcessEditorSelectionAdapter.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/adapters/ProcessEditorSelectionAdapter.java
new file mode 100644 (file)
index 0000000..cffd073
--- /dev/null
@@ -0,0 +1,56 @@
+package org.simantics.processeditor.adapters;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.proconf.g3d.base.ScenegraphAdapter;\r
+import org.simantics.proconf.g3d.base.SelectionAdapter;\r
+import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;\r
+import org.simantics.proconf.g3d.scenegraph.ISelectableNode;\r
+\r
+public class ProcessEditorSelectionAdapter extends SelectionAdapter {\r
+       \r
+       \r
+        public ProcessEditorSelectionAdapter(ScenegraphAdapter adapter) {\r
+               super(adapter);\r
+        }\r
+\r
+           @Override\r
+           public void setEditorSelection() {\r
+               List<IGraphicsNode> sel = getSelectedObjects();\r
+               for (IGraphicsNode o : adapter.getNodes())\r
+                       if (o instanceof ISelectableNode) {\r
+                               if (sel.contains(o)) {\r
+                               ((ISelectableNode)o).setSelected(true);\r
+                       } else {\r
+                               ((ISelectableNode)o).setSelected(false);\r
+                       }\r
+                       }\r
+           }\r
+           \r
+           public void setEditorSelection(boolean addShapes) {\r
+\r
+               List<IGraphicsNode> sel = getSelectedObjects();\r
+               for (IGraphicsNode o : adapter.getNodes())\r
+                       if (o instanceof ISelectableNode) {\r
+                               if (sel.contains(o)) {\r
+                               ((ISelectableNode)o).setSelected(true);\r
+                       } else {\r
+                               ((ISelectableNode)o).setSelected(false);\r
+                       }\r
+                       }\r
+           }\r
+\r
+           @Override\r
+           protected void setEditorHighlightSelection() {\r
+               List<IGraphicsNode> sel = getInteractiveSelectedObjects();\r
+               for (IGraphicsNode o : adapter.getNodes())\r
+                       if (o instanceof ISelectableNode) {\r
+                               if (sel.contains(o)) {\r
+                               ((ISelectableNode)o).setHighlighted(true);\r
+                       } else {\r
+                               ((ISelectableNode)o).setHighlighted(false);\r
+                       }\r
+                       }\r
+           }\r
+\r
+}\r
index b28ae1c5d10c99fc282e6dba365ee8b0d33fcdf7..699bd1e345fbed861786e9af95bfb8a069bbb3ec 100644 (file)
  *******************************************************************************/\r
 package org.simantics.processeditor.views;\r
 \r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
 import org.eclipse.jface.viewers.ISelection;\r
 import org.eclipse.jface.viewers.ISelectionChangedListener;\r
 import org.eclipse.jface.viewers.SelectionChangedEvent;\r
@@ -24,42 +18,27 @@ import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;\r
 import org.simantics.db.Graph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
 import org.simantics.db.management.ISessionContext;\r
-import org.simantics.layer0.utils.EntityFactory;\r
 import org.simantics.layer0.utils.IEntity;\r
-import org.simantics.layer0.utils.Property;\r
 import org.simantics.processeditor.ProcessResource;\r
 import org.simantics.processeditor.actions.ConfigureFloorAction;\r
 import org.simantics.processeditor.actions.InsertComponentAction;\r
 import org.simantics.processeditor.actions.InsertEquipmentAction;\r
 import org.simantics.processeditor.actions.InsertNozzleAction;\r
 import org.simantics.processeditor.actions.RoutePipeAction;\r
+import org.simantics.processeditor.adapters.ProcessEditorAdapter;\r
+import org.simantics.processeditor.adapters.ProcessEditorSelectionAdapter;\r
 import org.simantics.processeditor.common.ControlPointTools;\r
-import org.simantics.processeditor.common.PipingRules;\r
-import org.simantics.processeditor.scenegraph.NonVisibleNode;\r
-import org.simantics.processeditor.scenegraph.PipeComponentNode;\r
-import org.simantics.processeditor.scenegraph.PipeRunNode;\r
-import org.simantics.processeditor.scenegraph.PipelineComponentNode;\r
-import org.simantics.processeditor.stubs.PipeControlPoint;\r
-import org.simantics.processeditor.stubs.PipeRun;\r
 import org.simantics.processeditor.stubs.Plant;\r
-import org.simantics.processeditor.stubs.Plant3DResource;\r
 import org.simantics.processeditor.tools.PlantEditContribution;\r
 import org.simantics.processeditor.tools.PlantVisualizationContribution;\r
 import org.simantics.proconf.g3d.base.JmeRenderingComponent;\r
 import org.simantics.proconf.g3d.base.ScenegraphAdapter;\r
-import org.simantics.proconf.g3d.base.ScenegraphAdapterImpl;\r
 import org.simantics.proconf.g3d.base.SelectionAdapter;\r
 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
 import org.simantics.proconf.g3d.common.StructuredResourceSelection;\r
-import org.simantics.proconf.g3d.scenegraph.IGeometryNode;\r
-import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;\r
-import org.simantics.proconf.g3d.scenegraph.ISelectableNode;\r
-import org.simantics.proconf.g3d.scenegraph.ParameterizedModelNode;\r
 import org.simantics.proconf.g3d.shapes.FloorShape;\r
 import org.simantics.proconf.g3d.stubs.G3DNode;\r
-import org.simantics.utils.ui.ErrorLogger;\r
 import org.simantics.utils.ui.jface.MenuTools;\r
 \r
 import com.jme.math.Vector3f;\r
@@ -88,7 +67,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase {
     \r
     @Override\r
     protected ScenegraphAdapter createScenegraphAdapter() {\r
-       return new ProcessEditorAdapter(session,getRenderingComponent());\r
+       return new ProcessEditorAdapter(this,session,getRenderingComponent());\r
     }\r
     \r
     @Override\r
@@ -120,277 +99,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase {
        MenuTools.getOrCreate(getMenuID(),"Advanced", menuManager).add(configureFloorAction);\r
     }\r
     \r
-    protected class ProcessEditorAdapter extends ScenegraphAdapterImpl {\r
-       \r
-        public ProcessEditorAdapter(Session session, JmeRenderingComponent component) {\r
-                       super(session, component);\r
-        }\r
-        \r
-        private class NormalScenegraphQuery extends ScenegraphQuery {\r
-               \r
-               public NormalScenegraphQuery(Resource node) {\r
-                               super(node);\r
-                       } \r
-                \r
-                \r
-                @Override\r
-               public void shapeAdded(Graph graph, IGraphicsNode node) {\r
-                        // FIXME : this won't work like in previous ProConf\r
-               }\r
-        }\r
-        \r
-        private Map<Resource,PipeRunControlPointQuery> pipeRunQueries = new HashMap<Resource, PipeRunControlPointQuery>();\r
-\r
-               protected ScenegraphQuery newSubnodeListener(G3DNode node) {\r
-               if (node.isInstanceOf(ProcessResource.plant3Dresource.PipeRun)) {\r
-                   PipeRunControlPointQuery query = new PipeRunControlPointQuery(node.getResource());\r
-                   pipeRunQueries.put(node.getResource(), query);\r
-                   node.getGraph().performQuery(query);\r
-               }\r
-               return new NormalScenegraphQuery(node.getResource());\r
-                \r
-           }\r
-               \r
-               @Override\r
-               protected NodePropertyQuery newRootPropertyListener(G3DNode root) {\r
-                       // currently Plant does not have any properties.\r
-                       return null;\r
-               }\r
-               \r
-               private class TransformationQuery extends NodeTransformationQuery {\r
-                       \r
-                       public TransformationQuery(Resource res) {\r
-                               super(res);\r
-                       }\r
-                       \r
-                       @Override\r
-                       public void shapeUpdated(Graph graph, IGraphicsNode shape) {\r
-                               //if (shape instanceof IGeometryNode) {\r
-                //    updateGeometry((IGeometryNode)shape);\r
-                //} else {\r
-                       shape.updateTransform(graph);\r
-                //}\r
-                       }\r
-               }\r
-               \r
-               @Override\r
-               protected NodeTransformationQuery newTransformationListener(G3DNode root) {\r
-                       return new TransformationQuery(root.getResource());\r
-               }\r
-               \r
-               private class NormalNodePropertyQuery extends org.simantics.proconf.g3d.base.ScenegraphAdapterImpl.NodePropertyQuery {\r
-                       \r
-                       public NormalNodePropertyQuery(Resource resource) {\r
-                               super(resource);\r
-                       }\r
-\r
-                       @Override\r
-                       public void shapeUpdated(Graph graph,IGraphicsNode shape) {\r
-                               if (shape instanceof IGeometryNode) {\r
-                    updateGeometry((IGeometryNode)shape);\r
-                } else {\r
-                       shape.updateTransform(graph);\r
-                }\r
-                       }\r
-               }\r
-        @Override\r
-       protected NodePropertyQuery newPropertyListener(G3DNode node) {\r
-               return new NormalNodePropertyQuery(node.getResource());\r
-       }\r
-   \r
-        @Override\r
-               protected IGraphicsNode instantiateNode(IGraphicsNode parent,\r
-                               G3DNode node) {\r
-                       Plant3DResource p3r = ProcessResource.plant3Dresource;\r
-                       IGraphicsNode newNode = null;\r
-                       try {\r
-                               if (node.isInstanceOf(p3r.Equipment)) {\r
-                                       newNode = new ParameterizedModelNode(\r
-                                                       ProcessEditor.this, parent, node.getGraph(),\r
-                                                       node.getResource(), p3r.HasGraphics);\r
-                               } else if (node.isInstanceOf(p3r.PipeRun)) {\r
-                                       newNode = new PipeRunNode(parent, node.getGraph(), node.getResource());\r
-                               } else if (node.isInstanceOf(p3r.Nozzle)) {\r
-                                       newNode = new ParameterizedModelNode(\r
-                                                       ProcessEditor.this, parent, node.getGraph(),\r
-                                                       node.getResource(), p3r.HasGraphics);\r
-                                       // CodedComponent must be handled first since it uses\r
-                                       // hard-coded geometries\r
-                                       // TODO : is this really necessary, or could we unify\r
-                                       // PipeComponentNode, InlineComponentNode,...\r
-                               } else if (node.isInstanceOf(p3r.CodedComponent)) {\r
-                                       newNode = new PipeComponentNode(ProcessEditor.this,\r
-                                                       parent, node.getGraph(), node.getResource());\r
-                               } else if (node.isInstanceOf(p3r.NonVisibleComponent)) {\r
-                                       newNode = new NonVisibleNode(parent, node.getGraph(), node.getResource());\r
-                               } else if (node.isInstanceOf(p3r.PipelineComponent)) {\r
-                                       newNode = new PipelineComponentNode(ProcessEditor.this,\r
-                                                       parent, node.getGraph(), node.getResource());\r
-                               } \r
-\r
-                               // } else if (node instanceof Shape) // Markers (ar/mobile)\r
-                               // needed this\r
-                               // newNode = new ShapeNode(TestProcessEditor.this,parent,node);\r
-                               if (newNode != null) {\r
-                                       if (newNode instanceof ISelectableNode)\r
-                                               ((ISelectableNode) newNode).setVisible(true);\r
-                                       if (newNode instanceof IGeometryNode) {\r
-                                               updateGeometry((IGeometryNode) newNode);\r
-                                       }\r
-                                       return newNode;\r
-                               }\r
-                       } catch (Exception e) {\r
-                               ErrorLogger.defaultLogError("Cannot handle node " + node.getResource(), e);\r
-                               return null;\r
-                       }\r
-                       ErrorLogger.defaultLogError("Cannot handle node " + node.getResource(), null);\r
-                       return null;\r
-\r
-               }\r
-\r
-               /**\r
-                * This is used to create elbows and straight pipes to pipeline TODO :\r
-                * this should be done with rule-engine!\r
-                * \r
-                * \r
-                * @author Marko Luukkainen\r
-                * \r
-                */\r
-               protected class PipeRunControlPointQuery extends NodeQuery {\r
-                       private List<Resource> removed = new ArrayList<Resource>();\r
-                       private List<Resource> added = new ArrayList<Resource>();\r
-\r
-                       public PipeRunControlPointQuery(Resource r) {\r
-                               super(r);\r
-                               if (DEBUG) System.out.println("Created PipeRunControlPointQuery for " + r);\r
-\r
-                       }\r
-\r
-                       @Override\r
-                       protected Object compute2(Graph graph) {\r
-                               PipeRun run = new PipeRun(graph, nodeResource);\r
-                               Collection<IEntity> cps = run\r
-                                               .getRelatedObjects(ProcessResource.plant3Dresource.HasControlPoints);\r
-                               List<Resource> res = new ArrayList<Resource>();\r
-                               for (IEntity t : cps)\r
-                                       res.add(t.getResource());\r
-                               return res;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean updated(Graph graph, Object oldResult,\r
-                                       Object newResult) {\r
-                               \r
-                               removed.clear();\r
-                               added.clear();\r
-\r
-                               List<Resource> oldCps = (List<Resource>) oldResult;\r
-                               List<Resource> newCps = (List<Resource>) newResult;\r
-                               if (oldCps == null)\r
-                                       oldCps = new ArrayList<Resource>();\r
-\r
-                               for (Resource r : oldCps) {\r
-                                       if (!newCps.contains(r))\r
-                                               removed.add(r);\r
-                               }\r
-\r
-                               for (Resource r : newCps) {\r
-                                       if (!oldCps.contains(r))\r
-                                               added.add(r);\r
-                               }\r
-                               for (Resource r : removed)\r
-                                       removeControlPoint(graph, r);\r
-                               for (Resource r : added) {\r
-                                       addControlPoint(graph, r);\r
-                                       // ControlPointTools.addControlPoint(new\r
-                                       // PipeRun(graph,pipeRun), new PipeControlPoint(graph, r));\r
-                               }\r
-\r
-                               return (added.size() > 0 || removed.size() > 0);\r
-                       }\r
-                       \r
-                       @Override\r
-                       public void dispose() {\r
-                               super.dispose();\r
-                               for (ControlPointPropertyQuery q : controlPointPropertyQueries.values())\r
-                                       q.dispose();\r
-                               controlPointPropertyQueries.clear();\r
-                       }\r
-                       \r
-                       private Map<Resource,ControlPointPropertyQuery> controlPointPropertyQueries = new HashMap<Resource, ControlPointPropertyQuery>();\r
-                       \r
-                       private void addControlPoint(Graph graph, Resource resource) {\r
-                               ControlPointPropertyQuery query = new ControlPointPropertyQuery(resource);\r
-                               graph.performQuery(query);\r
-                               controlPointPropertyQueries.put(resource,query);\r
-                       }\r
-                       \r
-                       private void removeControlPoint(Graph graph, Resource resource) {\r
-                               ControlPointPropertyQuery query = controlPointPropertyQueries.remove(resource);\r
-                               query.dispose();\r
-                               ControlPointTools.removeControlPoint(new PipeControlPoint(\r
-                                               graph, resource));\r
-                       }\r
-\r
-               }\r
-\r
-               protected class ControlPointPropertyQuery extends NodeQuery {\r
-                       boolean initialized = false;\r
-                       \r
-                       public ControlPointPropertyQuery(Resource r) {\r
-                               super(r);\r
-                               if (DEBUG) System.out.println("Created ControlPointPropertyQuery for " + r);\r
-                       }\r
-                       \r
-                       @Override\r
-               public List<Object> compute2(Graph g) {\r
-                       IEntity t = EntityFactory.create(g,nodeResource);\r
-                       \r
-                       Collection<Property> properties = t.getRelatedProperties(ProcessResource.builtins.HasProperty);\r
-                       List<Object> propertyValues = new ArrayList<Object>();\r
-                       p(properties,propertyValues);\r
 \r
-                       return propertyValues;\r
-               }\r
-               \r
-               private void p(Collection<Property> properties, List<Object> propertyValues) {\r
-                       for (Property p : properties) {\r
-                               Collection<Property> subProperties = p.getRelatedProperties(p.getGraph().getBuiltins().HasProperty);\r
-                               if (subProperties.size() != 0) {\r
-                                       p(subProperties,propertyValues);\r
-                               } \r
-                               if (p.hasValue()){\r
-                                       propertyValues.add(p.getValue());\r
-                               }\r
-                       }\r
-               }\r
-                       \r
-                       @Override\r
-                       public boolean updated(Graph graph, Object oldResult, Object newResult) {\r
-                               PipingRules.pipeControlPointPositionUpdate(graph, this.nodeResource);\r
-                               if (initialized) {\r
-                                       //PipingRules.pipeControlPointPositionUpdate(graph, this.nodeResource);\r
-                               } else {\r
-                                       initialized = true;\r
-                               }\r
-                               return true;\r
-                       }\r
-               }\r
-               \r
-               @Override\r
-               protected void removeNode(Resource parent, Resource r) {\r
-                       super.removeNode(parent, r);\r
-                       PipeRunControlPointQuery q = pipeRunQueries.get(r);\r
-                       if (q != null)\r
-                               q.dispose();\r
-               }\r
-               \r
-               @Override\r
-               public void dispose() {\r
-                       super.dispose();\r
-               }\r
-       }\r
-    \r
     @Override\r
     protected void pageSelectionChanged(IWorkbenchPart part, ISelection selection) {\r
         if (!(selection instanceof StructuredResourceSelection)) {\r
@@ -448,54 +157,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase {
     protected SelectionAdapter createSelectionAdapter() {\r
        return new ProcessEditorSelectionAdapter(adapter);\r
     }\r
-    \r
-    protected class ProcessEditorSelectionAdapter extends SelectionAdapter {\r
-       \r
-       \r
-        public ProcessEditorSelectionAdapter(ScenegraphAdapter adapter) {\r
-                       super(adapter);\r
-        }\r
-\r
-           @Override\r
-           public void setEditorSelection() {\r
-               List<IGraphicsNode> sel = getSelectedObjects();\r
-               for (IGraphicsNode o : adapter.getNodes())\r
-                       if (o instanceof ISelectableNode) {\r
-                               if (sel.contains(o)) {\r
-                               ((ISelectableNode)o).setSelected(true);\r
-                       } else {\r
-                               ((ISelectableNode)o).setSelected(false);\r
-                       }\r
-                       }\r
-           }\r
-           \r
-           public void setEditorSelection(boolean addShapes) {\r
 \r
-               List<IGraphicsNode> sel = getSelectedObjects();\r
-               for (IGraphicsNode o : adapter.getNodes())\r
-                       if (o instanceof ISelectableNode) {\r
-                               if (sel.contains(o)) {\r
-                               ((ISelectableNode)o).setSelected(true);\r
-                       } else {\r
-                               ((ISelectableNode)o).setSelected(false);\r
-                       }\r
-                       }\r
-           }\r
-\r
-           @Override\r
-           protected void setEditorHighlightSelection() {\r
-               List<IGraphicsNode> sel = getInteractiveSelectedObjects();\r
-               for (IGraphicsNode o : adapter.getNodes())\r
-                       if (o instanceof ISelectableNode) {\r
-                               if (sel.contains(o)) {\r
-                               ((ISelectableNode)o).setHighlighted(true);\r
-                       } else {\r
-                               ((ISelectableNode)o).setHighlighted(false);\r
-                       }\r
-                       }\r
-           }\r
-    }\r
-    \r
     @Override\r
     protected void hookDragAndDrop() {\r
        super.hookDragAndDrop();\r