1 /*******************************************************************************
\r
2 * Copyright (c) 2007- VTT Technical Research Centre of Finland.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.processeditor.actions;
\r
13 import java.util.List;
\r
15 import org.simantics.db.Graph;
\r
16 import org.simantics.db.GraphRequestStatus;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.layer0.utils.EntityFactory;
\r
19 import org.simantics.layer0.utils.IEntity;
\r
20 import org.simantics.processeditor.ProcessResource;
\r
21 import org.simantics.processeditor.common.PipingTools2;
\r
22 import org.simantics.processeditor.stubs.PipelineComponent;
\r
23 import org.simantics.proconf.g3d.actions.WriteAction;
\r
24 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;
\r
28 public class ReversePipelineAction extends WriteAction {
\r
30 public ReversePipelineAction(ThreeDimensionalEditorBase parent) {
\r
31 super(parent,false);
\r
35 public boolean usable(Graph graph, List<Resource> resources) {
\r
36 if (resources.size() != 1)
\r
38 IEntity t = EntityFactory.create(graph, resources.get(0));
\r
39 return (t.isInstanceOf(ProcessResource.plant3Dresource.PipelineComponent));
\r
43 public GraphRequestStatus doChanges(Graph graph) throws Exception {
\r
44 Resource r = parent.getSelectionAdapter().getSelectedResources().get(0);
\r
45 PipelineComponent comp = new PipelineComponent(graph, r);
\r
46 PipingTools2.reversePipeRun(PipingTools2.getPipeRun(comp));
\r
48 return GraphRequestStatus.transactionComplete();
\r
53 public void init() {
\r
54 this.setText("Reverse pipeline");
\r