-/*******************************************************************************\r
- * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.proconf.g3d.actions;\r
-\r
-import java.util.List;\r
-\r
-import org.simantics.db.Graph;\r
-import org.simantics.db.GraphRequestStatus;\r
-import org.simantics.db.Resource;\r
-import org.simantics.layer0.utils.IEntity;\r
-import org.simantics.layer0.utils.EntityFactory;\r
-import org.simantics.proconf.g3d.Activator;\r
-import org.simantics.proconf.g3d.Resources;\r
-import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
-import org.simantics.proconf.g3d.common.StructuredResourceSelection;\r
-\r
-public class RemoveAction extends WriteAction {\r
- \r
- public RemoveAction(ThreeDimensionalEditorBase parent) {\r
- super(parent,false);\r
- }\r
- \r
- public void init() {\r
- setText("Remove");\r
- setToolTipText("Remove the object");\r
- this.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/delete.png"));\r
- }\r
- public GraphRequestStatus doChanges(Graph graph) {\r
- StructuredResourceSelection sel = parent.getSelectionAdapter().getCurrentSelection();\r
- List<Resource> res = sel.getSelectionList();\r
- for (Resource r : res) {\r
- IEntity t = EntityFactory.create(graph, r);\r
- if (t.isInstanceOf(Resources.g3dResource.G3DNode)) {\r
- IEntity parentNode = t.getSingleRelatedObject(Resources.g3dResource.HasParent);\r
- parentNode.removeStatement(Resources.g3dResource.HasChild, t);\r
- }\r
-\r
- }\r
- return GraphRequestStatus.transactionComplete();\r
- \r
- }\r
- \r
- @Override\r
- public boolean usable(Graph graph,List<Resource> resources) {\r
- return resources.size() > 0;\r
- }\r
-\r
-}\r