/******************************************************************************* * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * VTT Technical Research Centre of Finland - initial API and implementation *******************************************************************************/ package fi.vtt.simantics.processeditor.actions; import java.util.List; import org.simantics.db.Graph; import org.simantics.db.GraphRequestStatus; import org.simantics.db.Resource; import org.simantics.layer0.utils.EntityFactory; import org.simantics.layer0.utils.IEntity; import org.simantics.proconf.g3d.actions.WriteAction; import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase; import fi.vtt.simantics.processeditor.ProcessResource; import fi.vtt.simantics.processeditor.common.PipingTools2; import fi.vtt.simantics.processeditor.stubs.PipelineComponent; public class ReversePipelineAction extends WriteAction { public ReversePipelineAction(ThreeDimensionalEditorBase parent) { super(parent,false); } @Override public boolean usable(Graph graph, List resources) { if (resources.size() != 1) return false; IEntity t = EntityFactory.create(graph, resources.get(0)); return (t.isInstanceOf(ProcessResource.plant3Dresource.PipelineComponent)); } @Override public GraphRequestStatus doChanges(Graph graph) throws Exception { Resource r = parent.getSelectionAdapter().getSelectedResources().get(0); PipelineComponent comp = new PipelineComponent(graph, r); PipingTools2.reversePipeRun(PipingTools2.getPipeRun(comp)); return GraphRequestStatus.transactionComplete(); } @Override public void init() { this.setText("Reverse pipeline"); } }