From 51f5155f82136f16116bf26036bc221a3bbb4fda Mon Sep 17 00:00:00 2001 From: luukkainen Date: Mon, 19 Jan 2009 11:04:43 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/3d/branches/dev@8676 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../actions/ConfigureFloorAction.java | 42 +++++++++++++++++++ .../processeditor/views/ProcessEditor.java | 29 +++---------- 2 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/actions/ConfigureFloorAction.java diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/actions/ConfigureFloorAction.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/actions/ConfigureFloorAction.java new file mode 100644 index 00000000..3cca9158 --- /dev/null +++ b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/actions/ConfigureFloorAction.java @@ -0,0 +1,42 @@ +package org.simantics.processeditor.actions; + +import org.eclipse.jface.action.Action; +import org.simantics.processeditor.Activator; +import org.simantics.processeditor.dialogs.FloorConfigureDialog; +import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase; + +import com.jme.math.Vector3f; +import com.jme.scene.Geometry; + +public class ConfigureFloorAction extends Action { + + Geometry floorShape; + ThreeDimensionalEditorBase editor; + + public ConfigureFloorAction(ThreeDimensionalEditorBase editor) { + setText("Configure floor"); + setImageDescriptor(Activator.imageDescriptorFromPlugin("fi.vtt.proconf.ode", "icons/silk/shape_align_bottom.png")); + this.editor = editor; + } + + public void run() { + if (floorShape == null) + throw new NullPointerException("FloorShape is null"); + FloorConfigureDialog dialog = new FloorConfigureDialog(editor.getRenderingComposite().getShell()); + if (dialog.open() == FloorConfigureDialog.CANCEL) + return; + if (dialog.isFloorEnabled()) { + if (floorShape.getParent() == null) + editor.getRenderingComponent().getNoCastRoot().attachChild(floorShape); + } else { + floorShape.removeFromParent(); + } + floorShape.setLocalTranslation(new Vector3f(0.f,(float)dialog.getFloorHeight(),0.f)); + + } + + public void setFloorShape(Geometry floorShape) { + this.floorShape = floorShape; + } + +} diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/views/ProcessEditor.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/views/ProcessEditor.java index cab340f5..b28ae1c5 100644 --- a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/views/ProcessEditor.java +++ b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/views/ProcessEditor.java @@ -16,7 +16,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; @@ -30,15 +29,14 @@ import org.simantics.db.management.ISessionContext; import org.simantics.layer0.utils.EntityFactory; import org.simantics.layer0.utils.IEntity; import org.simantics.layer0.utils.Property; -import org.simantics.processeditor.Activator; import org.simantics.processeditor.ProcessResource; +import org.simantics.processeditor.actions.ConfigureFloorAction; import org.simantics.processeditor.actions.InsertComponentAction; import org.simantics.processeditor.actions.InsertEquipmentAction; import org.simantics.processeditor.actions.InsertNozzleAction; import org.simantics.processeditor.actions.RoutePipeAction; import org.simantics.processeditor.common.ControlPointTools; import org.simantics.processeditor.common.PipingRules; -import org.simantics.processeditor.dialogs.FloorConfigureDialog; import org.simantics.processeditor.scenegraph.NonVisibleNode; import org.simantics.processeditor.scenegraph.PipeComponentNode; import org.simantics.processeditor.scenegraph.PipeRunNode; @@ -72,7 +70,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { private Resource plantResource = null; - private Action configureFloorAction = null; + private ConfigureFloorAction configureFloorAction = null; private Geometry floorShape = null; @@ -100,6 +98,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { floorShape = FloorShape.getShape(getRenderingComponent().getDisplaySystem().getRenderer(), 100.f,0.2f); getRenderingComponent().getNoCastRoot().attachChild(floorShape); floorShape.setLocalTranslation(new Vector3f(0.f,-0.01f,0.f)); + configureFloorAction.setFloorShape(floorShape); } @Override @@ -108,23 +107,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { //actions.add(new ShowTrendsAction(this)); - configureFloorAction = new Action() { - public void run() { - FloorConfigureDialog dialog = new FloorConfigureDialog(ProcessEditor.this.parent.getShell()); - if (dialog.open() == FloorConfigureDialog.CANCEL) - return; - if (dialog.isFloorEnabled()) { - if (floorShape.getParent() == null) - getRenderingComponent().getNoCastRoot().attachChild(floorShape); - } else { - floorShape.removeFromParent(); - } - floorShape.setLocalTranslation(new Vector3f(0.f,(float)dialog.getFloorHeight(),0.f)); - - } - }; - configureFloorAction.setText("Configure floor"); - configureFloorAction.setImageDescriptor(Activator.imageDescriptorFromPlugin("fi.vtt.proconf.ode", "icons/silk/shape_align_bottom.png")); + configureFloorAction = new ConfigureFloorAction(this); // ContextActionFactory extended[] = ContextActionRegistry.getActions("fi.vtt.proconf.shapeeditor.processeditorview"); // for (ContextActionFactory c : extended) { @@ -547,9 +530,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { }); } }); - - - + return page; } return null; -- 2.47.1