]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.plant3d/src/org/simantics/plant3d/actions/ReversePipeRunAction.java
PipeRun reverse action
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / actions / ReversePipeRunAction.java
1 package org.simantics.plant3d.actions;
2
3 import org.eclipse.jface.action.Action;
4 import org.simantics.g3d.scenegraph.base.INode;
5 import org.simantics.g3d.vtk.common.VTKNodeMap;
6 import org.simantics.plant3d.Activator;
7 import org.simantics.plant3d.scenegraph.PipeRun;
8 import org.simantics.plant3d.scenegraph.controlpoint.PipingRules;
9
10 public class ReversePipeRunAction extends Action{
11     
12     private VTKNodeMap<?, ? extends INode> nodeMap;
13     PipeRun run;
14     
15     public ReversePipeRunAction(VTKNodeMap<?, ? extends INode> nodeMap) {
16         setText("Reverse");
17         setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/arrow_refresh.png"));
18         this.nodeMap = nodeMap;
19     }
20     
21     public void setNode(INode node) {
22         if (node instanceof PipeRun) {
23             run = (PipeRun)node;
24             setEnabled(true);
25         } else {
26             setEnabled(false);
27         }
28            
29     }
30     
31     @Override
32     public void run() {
33         PipingRules.reverse(run);
34         nodeMap.commit("Reverse run " + run.getName());
35     }
36
37 }