]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/action/RemoveAction.java
Fix parallel perspective toggle to keep view direction
[simantics/3d.git] / org.simantics.g3d.vtk / src / org / simantics / g3d / vtk / action / RemoveAction.java
1 /*******************************************************************************
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g3d.vtk.action;
13
14 import org.eclipse.jface.action.Action;
15 import org.simantics.g3d.scenegraph.IG3DNode;
16 import org.simantics.g3d.scenegraph.base.INode;
17 import org.simantics.g3d.scenegraph.structural.IStructuralNode;
18 import org.simantics.g3d.vtk.Activator;
19 import org.simantics.g3d.vtk.common.VTKNodeMap;
20
21 public class RemoveAction extends Action {
22
23         private VTKNodeMap nodeMap;
24         protected INode node;
25         
26         public RemoveAction(VTKNodeMap nodeMap) {
27                 setText("Remove");
28                 setImageDescriptor(Activator.imageDescriptorFromPlugin("com.famfamfam.silk", "icons/delete.png"));
29                 this.nodeMap = nodeMap;
30         }
31         
32         public void setNode(INode node) {
33                 this.node = node;
34                 setEnabled(isRemovable(node));
35         }
36         
37         public boolean isRemovable(INode node) {
38                 if ((node instanceof IStructuralNode) && ((IStructuralNode)node).isPartOfInstantiatedModel() && !((IStructuralNode)node).isInstantiatedModelRoot())
39                         return false;
40                 return true;
41         }
42         
43         @Override
44         public void run() {
45                 
46                 doRemove(node);
47                 nodeMap.commit("Remove");
48                 node = null;
49         }
50         
51         protected void doRemove(INode node) {
52                 node.remove();
53         }
54 }