From: Marko Luukkainen Date: Tue, 29 Oct 2019 13:39:29 +0000 (+0200) Subject: Use generics type variable for mapping db object. X-Git-Tag: v1.43.0~161^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F20%2F3420%2F1;p=simantics%2F3d.git Use generics type variable for mapping db object. gitlab #41 Change-Id: I59d5e8bf979ed70808cba17d447c7288599b2c66 --- diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/editor/CSGNodeMap.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/editor/CSGNodeMap.java index c2712b8c..bcd28db4 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/editor/CSGNodeMap.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/editor/CSGNodeMap.java @@ -16,6 +16,7 @@ import java.util.Collection; import java.util.List; import java.util.Set; +import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.g3d.csg.scenegraph2.CSGrootNode; import org.simantics.g3d.csg.scenegraph2.ICSGnode; @@ -27,7 +28,7 @@ import org.simantics.objmap.graph.IMapping; import vtk.vtkProp; import vtk.vtkProp3D; -public class CSGNodeMap extends AbstractVTKNodeMap { +public class CSGNodeMap extends AbstractVTKNodeMap { diff --git a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGrootNode.java b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGrootNode.java index d88b42ed..9ae55a1f 100644 --- a/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGrootNode.java +++ b/org.simantics.g3d.csg/src/org/simantics/g3d/csg/scenegraph2/CSGrootNode.java @@ -19,6 +19,7 @@ import java.util.Stack; import javax.vecmath.Quat4d; import javax.vecmath.Vector3d; +import org.simantics.db.Resource; import org.simantics.g3d.csg.editor.CSGNodeMap; import org.simantics.g3d.csg.ontology.CSG; import org.simantics.g3d.math.MathTools; @@ -36,7 +37,7 @@ import vtk.vtkProp; @GraphType(CSG.URIs.Model) -public class CSGrootNode extends ParentNode implements IG3DNode, NodeMapProvider { +public class CSGrootNode extends ParentNode implements IG3DNode, NodeMapProvider { private CSGNodeMap nodeMap; @@ -46,7 +47,7 @@ public class CSGrootNode extends ParentNode implements IG3DNode, NodeM } @Override - public NodeMap getNodeMap() { + public NodeMap getNodeMap() { return nodeMap; } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java index efb4c07b..953ef198 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java @@ -48,12 +48,12 @@ import org.simantics.utils.ui.ExceptionUtils; import vtk.vtkProp; -public abstract class AbstractVTKNodeMap implements VTKNodeMap, IMappingListener, RenderListener, NodeListener, UndoRedoSupport.ChangeListener{ +public abstract class AbstractVTKNodeMap implements VTKNodeMap, IMappingListener, RenderListener, NodeListener, UndoRedoSupport.ChangeListener{ private static final boolean DEBUG = false; protected Session session; - protected IMapping mapping; + protected IMapping mapping; protected VtkView view; protected MapList nodeToActor = new MapList(); @@ -66,7 +66,7 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< protected int redoOpCount = 0; protected boolean runUndo = false; protected boolean runRedo = false; - public AbstractVTKNodeMap(Session session, IMapping mapping, VtkView view, ParentNode rootNode) { + public AbstractVTKNodeMap(Session session, IMapping mapping, VtkView view, ParentNode rootNode) { this.session = session; this.mapping = mapping; this.view = view; @@ -321,10 +321,11 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< protected void reset(ReadGraph graph) throws MappingException { if (DEBUG) System.out.println("Reset"); + synchronized (syncMutex) { graphUpdates = true; mapping.getRangeModified().clear(); - for (Object o : mapping.getDomain()) + for (DBObject o : mapping.getDomain()) mapping.domainModified(o); mapping.updateRange(graph); graphModified.clear(); @@ -341,7 +342,7 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< } else { synchronized (syncMutex) { graphUpdates = true; - for (Object domainObject : mapping.getDomainModified()) { + for (DBObject domainObject : mapping.getDomainModified()) { E rangeObject = mapping.get(domainObject); if (rangeObject != null) graphModified.add(rangeObject); @@ -664,7 +665,7 @@ public abstract class AbstractVTKNodeMap implements VTKNodeMap< } - public IMapping getMapping() { + public IMapping getMapping() { return mapping; } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java index 9998f5bf..69ed83e2 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/SelectionHighlighter.java @@ -35,19 +35,19 @@ import vtk.vtkMapper; import vtk.vtkProp; import vtk.vtkProperty; -public class SelectionHighlighter implements ISelectionChangedListener{ +public class SelectionHighlighter implements ISelectionChangedListener{ protected VtkView panel; - protected VTKNodeMap nodeMap; + protected VTKNodeMap nodeMap; protected List selectedNodes = new ArrayList(); protected List selectedActors = new ArrayList(); protected HighlightObjectType type = HighlightObjectType.Node; - public SelectionHighlighter(VtkView panel, VTKNodeMap nodeMap) { + public SelectionHighlighter(VtkView panel, VTKNodeMap nodeMap) { this.panel = panel; this.nodeMap = nodeMap; } diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKNodeMap.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKNodeMap.java index 09d380c7..5de2b10d 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKNodeMap.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/VTKNodeMap.java @@ -17,7 +17,7 @@ import org.simantics.g3d.scenegraph.base.INode; import vtk.vtkProp; -public interface VTKNodeMap extends NodeMap{ +public interface VTKNodeMap extends NodeMap{ diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java index e216e5e7..f0fe47ec 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java @@ -339,7 +339,7 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri private TableViewer viewer; private IG3DNode node; - private NodeMap nodeMap; + private NodeMap nodeMap; private List valueColumns = new ArrayList(); @@ -578,8 +578,8 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri nodeMap = null; break; } - if (n instanceof NodeMapProvider) { - nodeMap = ((NodeMapProvider) n).getNodeMap(); + if (n instanceof NodeMapProvider) { + nodeMap = ((NodeMapProvider) n).getNodeMap(); if (nodeMap != null) break; } @@ -733,11 +733,11 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri private static class PropertyEditingSupport extends EditingSupport { AnnotatedPropertyTab tab; int index; - NodeMap nodeMap; + NodeMap nodeMap; TableViewer viewer; CellEditor editor; - public PropertyEditingSupport(AnnotatedPropertyTab tab, TableViewer viewer, int index, NodeMap nodeMap) { + public PropertyEditingSupport(AnnotatedPropertyTab tab, TableViewer viewer, int index, NodeMap nodeMap) { super(viewer); this.tab = tab; this.index = index; diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java index 36ee73a3..8ce1baf7 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMap.java @@ -18,7 +18,7 @@ import org.simantics.g3d.scenegraph.base.NodeListener; import org.simantics.g3d.scenegraph.base.ParentNode; import org.simantics.objmap.graph.IMapping; -public interface NodeMap { +public interface NodeMap { public Collection getRenderObjects(E node); @@ -58,5 +58,5 @@ public interface NodeMap { public void removeListener(NodeListener listener); - public IMapping getMapping(); + public IMapping getMapping(); } diff --git a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMapProvider.java b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMapProvider.java index e9b7d4b4..5de7cc37 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMapProvider.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scenegraph/NodeMapProvider.java @@ -13,7 +13,7 @@ package org.simantics.g3d.scenegraph; import org.simantics.g3d.scenegraph.base.INode; -public interface NodeMapProvider { +public interface NodeMapProvider { - public NodeMap getNodeMap(); + public NodeMap getNodeMap(); } diff --git a/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java b/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java index cd2447b3..d532e1f0 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java +++ b/org.simantics.g3d/src/org/simantics/g3d/scl/ScriptNodeMap.java @@ -42,12 +42,12 @@ import org.simantics.utils.datastructures.Pair; * * @param */ -public abstract class ScriptNodeMap implements NodeMap, IMappingListener, NodeListener { +public abstract class ScriptNodeMap implements NodeMap, IMappingListener, NodeListener { private static final boolean DEBUG = false; protected Session session; - protected IMapping mapping; + protected IMapping mapping; protected ParentNode rootNode; @@ -55,7 +55,7 @@ public abstract class ScriptNodeMap implements NodeMap mapping, ParentNode rootNode) { + public ScriptNodeMap(Session session, IMapping mapping, ParentNode rootNode) { this.session = session; this.mapping = mapping; this.rootNode = rootNode; @@ -242,7 +242,7 @@ public abstract class ScriptNodeMap implements NodeMap implements NodeMap implements NodeMap getMapping() { + public IMapping getMapping() { return mapping; } diff --git a/org.simantics.plant3d.ontology/src/org/simantics/plant3d/ontology/Plant3D.java b/org.simantics.plant3d.ontology/src/org/simantics/plant3d/ontology/Plant3D.java index 41b1aa59..69603a52 100644 --- a/org.simantics.plant3d.ontology/src/org/simantics/plant3d/ontology/Plant3D.java +++ b/org.simantics.plant3d.ontology/src/org/simantics/plant3d/ontology/Plant3D.java @@ -42,6 +42,8 @@ public class Plant3D { public final Resource Builtin_VerticalTank; public final Resource Builtin_VerticalTankGeometryProvider; public final Resource CodeComponent; + public final Resource ComponentLibrary; + public final Resource ComponentLibrary_contains; public final Resource Connects; public final Resource DualConnectedComponent; public final Resource EndComponent; @@ -155,6 +157,8 @@ public class Plant3D { public static final String Builtin_VerticalTank = "http://www.simantics.org/Plant3D-0.1/Builtin/VerticalTank"; public static final String Builtin_VerticalTankGeometryProvider = "http://www.simantics.org/Plant3D-0.1/Builtin/VerticalTankGeometryProvider"; public static final String CodeComponent = "http://www.simantics.org/Plant3D-0.1/CodeComponent"; + public static final String ComponentLibrary = "http://www.simantics.org/Plant3D-0.1/ComponentLibrary"; + public static final String ComponentLibrary_contains = "http://www.simantics.org/Plant3D-0.1/ComponentLibrary/contains"; public static final String Connects = "http://www.simantics.org/Plant3D-0.1/Connects"; public static final String DualConnectedComponent = "http://www.simantics.org/Plant3D-0.1/DualConnectedComponent"; public static final String EndComponent = "http://www.simantics.org/Plant3D-0.1/EndComponent"; @@ -278,6 +282,8 @@ public class Plant3D { Builtin_VerticalTank = getResourceOrNull(graph, URIs.Builtin_VerticalTank); Builtin_VerticalTankGeometryProvider = getResourceOrNull(graph, URIs.Builtin_VerticalTankGeometryProvider); CodeComponent = getResourceOrNull(graph, URIs.CodeComponent); + ComponentLibrary = getResourceOrNull(graph, URIs.ComponentLibrary); + ComponentLibrary_contains = getResourceOrNull(graph, URIs.ComponentLibrary_contains); Connects = getResourceOrNull(graph, URIs.Connects); DualConnectedComponent = getResourceOrNull(graph, URIs.DualConnectedComponent); EndComponent = getResourceOrNull(graph, URIs.EndComponent); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java index ba672104..d4cf0307 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java @@ -6,9 +6,8 @@ import java.awt.event.MouseWheelEvent; import java.util.HashSet; import java.util.Set; -import javax.vecmath.Vector3d; - import org.eclipse.swt.widgets.Display; +import org.simantics.db.Resource; import org.simantics.g3d.scenegraph.NodeMap; import org.simantics.g3d.scenegraph.base.INode; import org.simantics.g3d.vtk.swt.InteractiveVtkComposite; @@ -19,16 +18,11 @@ import org.simantics.plant3d.gizmo.TerminalSelectionGizmo; import org.simantics.plant3d.scenegraph.InlineComponent; import org.simantics.plant3d.scenegraph.Nozzle; import org.simantics.plant3d.scenegraph.P3DRootNode; -import org.simantics.plant3d.scenegraph.PipeRun; import org.simantics.plant3d.scenegraph.PipelineComponent; -import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint; -import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint.Direction; import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint.PositionType; -import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; import org.simantics.plant3d.utils.ComponentUtils; -import org.simantics.plant3d.utils.Item; import org.simantics.plant3d.utils.ComponentUtils.InsertInstruction; -import org.simantics.plant3d.utils.Item.Type; +import org.simantics.plant3d.utils.Item; import org.simantics.utils.threads.ThreadUtils; import org.simantics.utils.ui.ExceptionUtils; @@ -39,7 +33,7 @@ public class AddComponentAction extends vtkSwtAction { private P3DRootNode root; private PipelineComponent component; - private NodeMap nodeMap; + private NodeMap nodeMap; private TerminalSelectionGizmo gizmo; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java index b40d7e0b..a4c04b3e 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/RoutePipeAction.java @@ -13,6 +13,7 @@ import javax.vecmath.Point3d; import javax.vecmath.Tuple3d; import javax.vecmath.Vector3d; +import org.simantics.db.Resource; import org.simantics.g3d.math.MathTools; import org.simantics.g3d.math.Ray; import org.simantics.g3d.scenegraph.NodeMap; @@ -64,7 +65,7 @@ public class RoutePipeAction extends vtkSwtAction { private SplitPointSelectionGizmo splitPointSelectionGizmo; private ConstraintPointGizmo constraintPointGizmo; private TerminalSelectionGizmo terminalSelectionGizmo; - private NodeMap nodeMap; + private NodeMap nodeMap; private enum ToolState{NOT_ACTIVE, INITIALIZING, SELECTING_POSITION, SELECTING_SPLIT, ROUTING}; private ToolState state = ToolState.NOT_ACTIVE; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java index 510956ef..fce61be4 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/P3DNodeMap.java @@ -30,7 +30,7 @@ import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; import vtk.vtkProp; import vtk.vtkProp3D; -public class P3DNodeMap extends AbstractVTKNodeMap { +public class P3DNodeMap extends AbstractVTKNodeMap { private static final boolean DEBUG = false; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java index f80d3be8..d3f3c5e4 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/editor/Plant3DEditor.java @@ -228,8 +228,8 @@ public class Plant3DEditor extends ResourceEditorPart { return new HoverHighlighter(panel,nodeMap); } - protected SelectionHighlighter createSelectionHighlighter() { - return new SelectionHighlighter(panel,nodeMap); + protected SelectionHighlighter createSelectionHighlighter() { + return new SelectionHighlighter(panel,nodeMap); } protected String getLibraryUri() { diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java index 4f00530e..0fb7ed4f 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/P3DRootNode.java @@ -7,6 +7,7 @@ import java.util.Set; import javax.vecmath.Quat4d; import javax.vecmath.Vector3d; +import org.simantics.db.Resource; import org.simantics.g3d.math.MathTools; import org.simantics.g3d.scenegraph.IG3DNode; import org.simantics.g3d.scenegraph.NodeMap; @@ -24,7 +25,7 @@ import org.simantics.plant3d.ontology.Plant3D; import vtk.vtkProp; @GraphType(Plant3D.URIs.Plant) -public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapProvider { +public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapProvider { @RelatedElementsAdd(Plant3D.URIs.children) @@ -51,7 +52,7 @@ public class P3DRootNode extends ParentNode implements IG3DNode, NodeMapP } @Override - public NodeMap getNodeMap() { + public NodeMap getNodeMap() { return nodeMap; } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scl/P3DScriptNodeMap.java b/org.simantics.plant3d/src/org/simantics/plant3d/scl/P3DScriptNodeMap.java index e5726d60..4d1fb18c 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scl/P3DScriptNodeMap.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scl/P3DScriptNodeMap.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.Set; import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; import org.simantics.g3d.ontology.G3D; @@ -24,7 +25,7 @@ import org.simantics.plant3d.scenegraph.controlpoint.PipingRules; import vtk.vtkProp3D; -public class P3DScriptNodeMap extends ScriptNodeMap{ +public class P3DScriptNodeMap extends ScriptNodeMap{ private static final boolean DEBUG = false;