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.views;
\r
13 import java.util.Collection;
\r
15 import org.eclipse.swt.widgets.Display;
\r
16 import org.simantics.db.Graph;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.db.management.ISessionContext;
\r
19 import org.simantics.processeditor.ProcessResource;
\r
20 import org.simantics.processeditor.tools.ControlPointContribution;
\r
21 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;
\r
22 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorPart;
\r
23 import org.simantics.proconf.g3d.shapeeditor.views.ShapeEditorBase;
\r
26 public class PipelineComponentEditorPart extends ThreeDimensionalEditorPart {
\r
29 protected ThreeDimensionalEditorBase createEditor(ISessionContext session) {
\r
30 ShapeEditorBase base = new ShapeEditorBase(session);
\r
31 base.addEditorContribution(new ControlPointContribution(base));
\r
36 public void reload(Graph g) {
\r
37 Resource inputResource = getInputResource();
\r
38 Collection<Resource> model = g.getObjects(inputResource, ProcessResource.plant3Dresource.HasGraphics);
\r
39 if (model.size() != 1)
\r
40 throw new RuntimeException("Cannot find model for pipeline component " + inputResource);
\r
41 Resource modelResource = model.iterator().next();
\r
42 if (modelResource != null) {
\r
43 editor.reload(g,modelResource);
\r
46 Display d = getSite().getShell().getDisplay();
\r
47 d.asyncExec(new Runnable() {
\r
49 editor.showMessage("Failed to load model.");
\r
50 getSite().getPage().closeEditor(PipelineComponentEditorPart.this,false);
\r