private static final boolean DEBUG = false;
protected Session session;
- protected IMapping<DBObject,E> mapping;
+ protected IMapping<DBObject, INode> mapping;
protected VtkView view;
private MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
protected int redoOpCount = 0;
protected boolean runUndo = false;
protected boolean runRedo = false;
- public AbstractVTKNodeMap(Session session, IMapping<DBObject,E> mapping, VtkView view, ParentNode<E> rootNode) {
+ public AbstractVTKNodeMap(Session session, IMapping<DBObject,INode> mapping, VtkView view, ParentNode<E> rootNode) {
this.session = session;
this.mapping = mapping;
this.view = view;
synchronized (syncMutex) {
graphUpdates = true;
for (DBObject domainObject : mapping.getDomainModified()) {
- E rangeObject = mapping.get(domainObject);
+ @SuppressWarnings("unchecked")
+ E rangeObject = (E) mapping.get(domainObject);
if (rangeObject != null)
graphModified.add(rangeObject);
}
}
- public IMapping<DBObject,E> getMapping() {
+ public IMapping<DBObject,INode> getMapping() {
return mapping;
}
public interface NodeMap<DBObject,T,E extends INode> {
- public Collection<T> getRenderObjects(E node);
+ public Collection<T> getRenderObjects(INode node);
public void updateRenderObjectsFor(E node);
public void removeListener(NodeListener listener);
- public IMapping<DBObject, E> getMapping();
+ public IMapping<DBObject, INode> getMapping();
}
private static final boolean DEBUG = false;
protected Session session;
- protected IMapping<DBObject,E> mapping;
+ protected IMapping<DBObject,INode> mapping;
protected ParentNode<E> rootNode;
private boolean dirty = false;
- public ScriptNodeMap(Session session, IMapping<DBObject,E> mapping, ParentNode<E> rootNode) {
+ public ScriptNodeMap(Session session, IMapping<DBObject,INode> mapping, ParentNode<E> rootNode) {
this.session = session;
this.mapping = mapping;
this.rootNode = rootNode;
return Collections.EMPTY_LIST;
}
- @SuppressWarnings("unchecked")
@Override
public ParentNode<E> getRootNode() {
return (ParentNode<E>)rootNode;
}
-
-
@Override
public boolean isChangeTracking() {
return changeTracking;
private boolean rangeModified = false;
- @SuppressWarnings("unchecked")
@Override
public void updateRenderObjectsFor(E node) {
- nodes.add((E)node);
-
+ nodes.add(node);
}
@SuppressWarnings("unchecked")
repaint();
}
- @SuppressWarnings("unchecked")
private void receiveUpdate(E node, String id, boolean db) {
if (DEBUG) System.out.println("receiveUpdate " + debugString(node) + " " + id + " " + db);
synchronized (syncMutex) {
synchronized (syncMutex) {
graphUpdates = true;
for (DBObject domainObject : mapping.getDomainModified()) {
- E rangeObject = mapping.get(domainObject);
+ @SuppressWarnings("unchecked")
+ E rangeObject = (E) mapping.get(domainObject);
if (rangeObject != null)
graphModified.add(rangeObject);
}
doCommit();
}
session.syncRequest(new ReadRequest() {
- @SuppressWarnings("unchecked")
@Override
public void run(ReadGraph graph) throws DatabaseException {
update(graph);
* This code here synchronizes removed and added objects to collect deletable objects. (a deletable object is one which is removed but not added).
*
*/
+ @SuppressWarnings("unused")
protected void syncDeletes() {
deleteUC.clear();
for (Pair<E, String> n : removed) {
/**
* Clears deletable objects from mapping cache.
*/
+ @SuppressWarnings("unused")
protected void clearDeletes() {
if (DEBUG && delete.size() > 0) System.out.println("Delete");
for (E n : delete) {
}
- public IMapping<DBObject,E> getMapping() {
+ @Override
+ public IMapping<DBObject,INode> getMapping() {
return mapping;
}
import org.simantics.plant3d.scenegraph.TurnComponent;
import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint;
-public class P3DContentOutlinePage extends VTKContentOutlinePage<Resource, Object>{
+public class P3DContentOutlinePage extends VTKContentOutlinePage<Resource, INode>{
private static final boolean DEBUG = true;
protected Menu contextMenu;
private Image elbowImage;
private Image componentImage;
- public P3DContentOutlinePage(ParentNode<? extends INode> rootNode, NodeSelectionProvider2<Resource,Object> provider) {
+ public P3DContentOutlinePage(ParentNode<? extends INode> rootNode, NodeSelectionProvider2<Resource,INode> provider) {
super(rootNode,provider);
nozzleImage = manager.createImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/Nozzle.png"));
private static final boolean DEBUG = false;
- public P3DNodeMap(Session session, IMapping mapping, VtkView panel, P3DRootNode rootNode) {
+ public P3DNodeMap(Session session, IMapping<Resource,INode> mapping, VtkView panel, P3DRootNode rootNode) {
super(session, mapping, panel, rootNode);
rootNode.setNodeMap(this);
}
import org.simantics.db.Session;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.exception.DatabaseException;
-import org.simantics.g3d.scenegraph.IG3DNode;
import org.simantics.g3d.scenegraph.NodeMap;
import org.simantics.g3d.scenegraph.RenderListener;
import org.simantics.g3d.scenegraph.base.INode;
private InteractiveVtkComposite panel;
private P3DRootNode rootNode;
- private IMapping<Resource,Object> mapping;
+ private IMapping<Resource,INode> mapping;
- protected NodeSelectionProvider2<Resource,Object> selectionProvider;
+ protected NodeSelectionProvider2<Resource, INode> selectionProvider;
protected vtkCameraAndSelectorAction cameraAction;
try {
getSession().syncRequest(new ReadRequest() {
- @SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void run(ReadGraph graph) throws DatabaseException {
System.out.println("START PLANT3D LOAD");
PipingRules.setEnabled(false);
- IMappingSchema<Resource, Object> schema = getSchema(graph);
+ IMappingSchema<Resource,INode> schema = getSchema(graph);
mapping = Mappings.createWithListening(schema);
rootNode = (P3DRootNode)mapping.map(graph, input);
// update control points.
return new vtkCameraAndSelectorAction(panel);
}
- protected NodeSelectionProvider2<Resource,Object> createSelectionProvider() {
- return new NodeSelectionProvider2<Resource,Object>(this,mapping,nodeMap);
+ protected NodeSelectionProvider2<Resource,INode> createSelectionProvider() {
+ return new NodeSelectionProvider2<Resource,INode>(this,mapping,nodeMap);
}
protected HoverHighlighter createHoverHighlhighter() {
translateInlineAction = new TranslateInlineAction(panel, nodeMap);
translateFreeVariableLengthAction = new TranslateFreeVariableLengthAction(panel, getRootNode());
rotateAction = new RotateAction(panel,nodeMap);
- removeAction = new RemoveAction(nodeMap) {
- public void setNode(IG3DNode node) {
- super.setNode(node);
- }
- };
-
+ removeAction = new RemoveAction(nodeMap);
removeSplitAction = new RemoveAndSplitAction(nodeMap);
routePipeAction = new RoutePipeAction(panel,rootNode);
addComponentAction = new AddComponentAction(panel, rootNode, getLibraryUri());
}
- protected IMappingSchema<Resource, Object> getSchema(ReadGraph graph) throws DatabaseException {
- IMappingSchema<Resource,Object> schema = SchemaBuilder.getSchema(graph);
+ protected IMappingSchema<Resource, INode> getSchema(ReadGraph graph) throws DatabaseException {
+ IMappingSchema<Resource,INode> schema = SchemaBuilder.getSchema(graph);
return schema;
}
- protected P3DNodeMap createNodeMap(Session session, IMapping<Resource, Object> mapping, VtkView panel, P3DRootNode rootNode) {
+ protected P3DNodeMap createNodeMap(Session session, IMapping<Resource, INode> mapping, VtkView panel, P3DRootNode rootNode) {
return new P3DNodeMap(session, mapping, panel,rootNode);
}
return rootNode;
}
- public IMapping<Resource, Object> getMapping() {
+ public IMapping<Resource, INode> getMapping() {
return mapping;
}
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.Read;
import org.simantics.g3d.scenegraph.GeometryProvider;
+import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.objmap.graph.schema.IMappingSchema;
import org.simantics.objmap.graph.schema.MappingSchemas;
import org.simantics.objmap.graph.schema.SimpleSchema;
import org.simantics.plant3d.ontology.Plant3D;
public class SchemaBuilder {
- public static IMappingSchema<Resource,Object> getSchema() throws DatabaseException{
- return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,Object>>() {
+ public static IMappingSchema<Resource,INode> getSchema() throws DatabaseException{
+ return Simantics.getSession().syncRequest(new Read<IMappingSchema<Resource,INode>>() {
@Override
- public IMappingSchema<Resource,Object> perform(ReadGraph g)
+ public IMappingSchema<Resource,INode> perform(ReadGraph g)
throws DatabaseException {
return getSchema(g);
}
});
}
- public static IMappingSchema<Resource,Object> getSchema(ReadGraph g) throws DatabaseException{
+ @SuppressWarnings("unchecked")
+ public static IMappingSchema<Resource,INode> getSchema(ReadGraph g) throws DatabaseException{
try {
SimpleSchema schema = new SimpleSchema();
schema.addLinkType(MappingSchemas.fromAnnotations(g, Equipment.class));
schema.addLinkType(MappingSchemas.fromAnnotations(g, PipeRun.class));
schema.addLinkType(MappingSchemas.fromAdaptable(g, Plant3D.URIs.GeometryProvider, GeometryProvider.class));
- return schema;
+ return (IMappingSchema<Resource, INode>)(IMappingSchema<Resource, ?>)schema;
} catch (IllegalAccessException e) {
throw new DatabaseException(e);
} catch (InstantiationException e) {
import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.Read;
+import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.objmap.graph.IMapping;
import org.simantics.objmap.graph.Mappings;
import org.simantics.objmap.graph.schema.IMappingSchema;
public class SCLUtil {
public static interface SchemaProvider {
- IMappingSchema<Resource,Object> get(ReadGraph graph) throws DatabaseException;
+ IMappingSchema<Resource,INode> get(ReadGraph graph) throws DatabaseException;
}
public static interface NodeMapProvider {
- P3DScriptNodeMap get(IMapping<Resource, Object> mapping, P3DRootNode rootNode);
+ P3DScriptNodeMap get(IMapping<Resource, INode> mapping, P3DRootNode rootNode);
}
public static P3DScriptNodeMap load(final Resource root) throws DatabaseException {
@Override
public NodeMap perform(ReadGraph graph) throws DatabaseException {
PipingRules.setEnabled(false);
- IMappingSchema<Resource, Object> schema = schemaProvider.get(graph);
- IMapping<Resource, Object> mapping = Mappings.createWithListening(schema);
+ IMappingSchema<Resource, INode> schema = schemaProvider.get(graph);
+ IMapping<Resource, INode> mapping = Mappings.createWithListening(schema);
P3DRootNode rootNode = (P3DRootNode) mapping.map(graph, root);
- rootNode.setMapping((IMapping)mapping);
+ rootNode.setMapping(mapping);
try {
P3DUtil.finalizeDBLoad(rootNode);
// FIXME: Something needs to be done here...
@Override
public Root perform(ReadGraph graph) throws DatabaseException {
PipingRules.setEnabled(false);
- IMappingSchema<Resource, Object> schema = schemaProvider.get(graph);
- IMapping<Resource, Object> mapping = Mappings.createWithoutListening(schema);
+ IMappingSchema<Resource, INode> schema = schemaProvider.get(graph);
+ IMapping<Resource, INode> mapping = Mappings.createWithoutListening(schema);
@SuppressWarnings("unchecked")
Root rootNode = (Root) mapping.map(graph, root);
- rootNode.setMapping((IMapping)mapping);
+ rootNode.setMapping(mapping);
try {
P3DUtil.finalizeDBLoad(rootNode);
P3DUtil.finalizeDBLoad2(rootNode);