g3d.vtk plug-in upgraded to Java 1.8.
gitlab #29
Change-Id: I2ef5f1da94b1c026b0af53029803765e68fd9b29
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
final IMenuManager m = manager;
- List<IG3DNode> selected = selectionProvider.getSelectedNodes();
+ List<INode> selected = selectionProvider.getSelectedNodes();
if (selected.size() == 0) {
m.add(new AddPrimitiveAction2(rootNode, BarrelNode.class));
m.add(new AddPrimitiveAction2(rootNode, BoxNode.class));
} else if (selected.size() == 2) {
if (selected.get(0).getParent().equals(rootNode) && selected.get(1).getParent().equals(rootNode)) {
Collection<ICSGnode> nodes = new ArrayList<ICSGnode>();
- for (IG3DNode n : selected)
+ for (INode n : selected)
nodes.add((ICSGnode)n);
m.add(new AddBooleanOpAction2(rootNode, DifferenceNode.class, nodes));
m.add(new AddBooleanOpAction2(rootNode, IntersectionNode.class, nodes));
-#Thu Mar 29 15:34:08 EEST 2012\r
-eclipse.preferences.version=1\r
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
-org.eclipse.jdt.core.compiler.compliance=1.6\r
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
-org.eclipse.jdt.core.compiler.source=1.6\r
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
org.simantics.utils.ui;bundle-version="1.1.0",
vtk.rendering;bundle-version="8.2.0",
org.simantics.utils.thread.swt;bundle-version="1.1.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.simantics.g3d.vtk.action,
org.simantics.g3d.vtk.awt,
import org.eclipse.jface.action.Action;
import org.simantics.g3d.scenegraph.IG3DNode;
+import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.g3d.scenegraph.structural.IStructuralNode;
import org.simantics.g3d.vtk.Activator;
import org.simantics.g3d.vtk.common.VTKNodeMap;
public class RemoveAction extends Action {
private VTKNodeMap nodeMap;
- protected IG3DNode node;
+ protected INode node;
public RemoveAction(VTKNodeMap nodeMap) {
setText("Remove");
this.nodeMap = nodeMap;
}
- public void setNode(IG3DNode node) {
+ public void setNode(INode node) {
this.node = node;
setEnabled(isRemovable(node));
}
- public boolean isRemovable(IG3DNode node) {
+ public boolean isRemovable(INode node) {
if ((node instanceof IStructuralNode) && ((IStructuralNode)node).isPartOfInstantiatedModel() && !((IStructuralNode)node).isInstantiatedModelRoot())
return false;
return true;
node = null;
}
- protected void doRemove(IG3DNode node) {
+ protected void doRemove(INode node) {
node.remove();
}
}
protected ISelection selection = new StructuredSelection();
protected List<ISelectionChangedListener> listeners = new ArrayList<ISelectionChangedListener>();
- protected List<IG3DNode> selectedNodes = new ArrayList<IG3DNode>(); // selection is ordered
+ protected List<INode> selectedNodes = new ArrayList<>(); // selection is ordered
//List<Resource> selectedResources = new ArrayList<Resource>();
protected List<VTKSelectionItem<DBObject>> selectedItems = new ArrayList<VTKSelectionItem<DBObject>>();
}
processSelection(new StructuredSelection(nodes.toArray()));
fireSelectionChanged(this);
+ } else {
+ processSelection(selection);
+ fireSelectionChanged(this);
}
}
protected void processSelection(ISelection s) {
selectedNodes.clear();
selectedItems.clear();
-
- Collection<vtkProp> selectedActors = AdaptationUtils.adaptToCollection(s, vtkProp.class);
- if (selectedActors.size() > 0) {
- for (vtkProp a : selectedActors) {
- IG3DNode node = (IG3DNode)nodeMap.getNode((vtkProp)a);
- if (node == null)
- continue;
- if (!selectedNodes.contains(node))
- selectedNodes.add(node);
- DBObject r = mapping.inverseGet((JavaObject)node);
- selectedItems.add(new VTKSelectionItem<DBObject>(a, node,r));
- }
- } else {
- Collection<IG3DNode> selectedNds = AdaptationUtils.adaptToCollection(s, IG3DNode.class);
- for (INode node : selectedNds) {
- if (!selectedNodes.contains(node))
- selectedNodes.add((IG3DNode)node);
- DBObject r = mapping.inverseGet((JavaObject)node);
- selectedItems.add(new VTKSelectionItem<DBObject>(null, (IG3DNode)node,r));
- }
- }
-
-
- selection = new StructuredSelection(selectedItems);
+ _processSelection(s);
+ }
+
+ protected void _processSelection(ISelection s) {
+ Collection<vtkProp> selectedActors = AdaptationUtils.adaptToCollection(s, vtkProp.class);
+ if (selectedActors.size() > 0) {
+ for (vtkProp a : selectedActors) {
+ IG3DNode node = (IG3DNode)nodeMap.getNode((vtkProp)a);
+ if (node == null)
+ continue;
+ if (!selectedNodes.contains(node))
+ selectedNodes.add(node);
+ DBObject r = mapping.inverseGet((JavaObject)node);
+ selectedItems.add(new VTKSelectionItem<DBObject>(a, node,r));
+ }
+ } else {
+ Collection<IG3DNode> selectedNds = AdaptationUtils.adaptToCollection(s, IG3DNode.class);
+ for (INode node : selectedNds) {
+ if (!selectedNodes.contains(node))
+ selectedNodes.add((IG3DNode)node);
+ DBObject r = mapping.inverseGet((JavaObject)node);
+ selectedItems.add(new VTKSelectionItem<DBObject>(null, (IG3DNode)node,r));
+ }
+ }
+
+
+ selection = new StructuredSelection(selectedItems);
}
protected void fireSelectionChanged(Object source) {
}
- public List<IG3DNode> getSelectedNodes() {
+ public List<INode> getSelectedNodes() {
return selectedNodes;
}
+ public List<VTKSelectionItem<DBObject>> getSelectedItems() {
+ return selectedItems;
+ }
+
@SuppressWarnings("unchecked")
public List<DBObject> getSelectedResources() {
public class VTKSelectionItem<DBObject> implements IAdaptable{
private vtkProp prop;
- private IG3DNode node;
+ private INode node;
private DBObject resource;
- public VTKSelectionItem(vtkProp prop, IG3DNode node, DBObject res) {
+ public VTKSelectionItem(vtkProp prop, INode node, DBObject res) {
this.prop = prop;
this.node = node;
this.resource = res;
return null;
if (adapter == vtkProp.class)
return prop;
- if (adapter == IG3DNode.class)
+ if (adapter == IG3DNode.class && node instanceof IG3DNode)
return node;
if (adapter == INode.class)
return node;
package org.simantics.plant3d.actions;
-import org.simantics.g3d.scenegraph.IG3DNode;
+import org.simantics.g3d.scenegraph.base.INode;
import org.simantics.g3d.vtk.action.RemoveAction;
import org.simantics.g3d.vtk.common.VTKNodeMap;
import org.simantics.plant3d.scenegraph.PipelineComponent;
}
@Override
- public boolean isRemovable(IG3DNode node) {
+ public boolean isRemovable(INode node) {
if (!super.isRemovable(node))
return false;
if (!(node instanceof PipelineComponent))
@Override
- protected void doRemove(IG3DNode node) {
+ protected void doRemove(INode node) {
PipelineComponent pc = (PipelineComponent)node;
pc.removeAndSplit();
}
private P3DRootNode rootNode;
private IMapping<Resource,Object> mapping;
- private NodeSelectionProvider2<Resource,Object> selectionProvider;
+ protected NodeSelectionProvider2<Resource,Object> selectionProvider;
protected vtkCameraAndSelectorAction cameraAction;
protected TranslateAction translateAction;
}
protected void createContextMenu(IMenuManager m) {
- List<IG3DNode> selected = selectionProvider.getSelectedNodes();
+ List<INode> selected = selectionProvider.getSelectedNodes();
try {
if (selected.size() == 0) {
for (Item eq : P3DUtil.getEquipments(getLibraryUri())) {