X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.proconf.processeditor%2Fsrc%2Forg%2Fsimantics%2Fprocesseditor%2Fviews%2FProcessEditor.java;h=b28ae1c5d10c99fc282e6dba365ee8b0d33fcdf7;hb=51f5155f82136f16116bf26036bc221a3bbb4fda;hp=8681125e3f9df8059d77c17e74e632b5387df865;hpb=570ba60e83221385f16bb2a7abb33cfc15ac2b06;p=simantics%2F3d.git 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 8681125e..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,24 +16,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.simantics.db.Graph; @@ -43,8 +29,8 @@ 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; @@ -84,9 +70,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { private Resource plantResource = null; - //private List animationControllers = new ArrayList(); - - private Action configureFloorAction = null; + private ConfigureFloorAction configureFloorAction = null; private Geometry floorShape = null; @@ -114,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 @@ -122,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) { @@ -146,10 +115,6 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { // } } -// protected void stopAnimations() { -// animationSystem.stop(); -// } - protected void fillLocalPullDown() { super.fillLocalPullDown(); MenuTools.getOrCreate(getMenuID(),"Advanced", menuManager).add(configureFloorAction); @@ -181,16 +146,6 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { PipeRunControlPointQuery query = new PipeRunControlPointQuery(node.getResource()); pipeRunQueries.put(node.getResource(), query); node.getGraph().performQuery(query); -// return new SubnodeListener(node) { -// @Override -// public void shapeAdded(IGraphicsNode node) { -// if (node instanceof IGeometryNode) { -// updateGeometry((IGeometryNode)node); -// -// } -// node.setVisible(true); -// } -// }; } return new NormalScenegraphQuery(node.getResource()); @@ -499,8 +454,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { public ProcessEditorSelectionAdapter(ScenegraphAdapter adapter) { super(adapter); - // TODO Auto-generated constructor stub - } + } @Override public void setEditorSelection() { @@ -513,17 +467,6 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { ((ISelectableNode)o).setSelected(false); } } - List selected = getSelectedResources(); - // TODO : don't know why this code is here, but it seems unnecessary -// for (Resource r : selected) { -// if (!adapter.hasNode(r)) { -// // instantiating a new resource : usin this editor's tc -// Resource resource = graph.getResource(r.getId()); -// adapter.addInbound(resource).setSelected(true); -// -// } -// } - } public void setEditorSelection(boolean addShapes) { @@ -537,23 +480,6 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { ((ISelectableNode)o).setSelected(false); } } - if (addShapes) { - // TODO : don't know why this code is here, but it seems unnecessary -// List selected = getSelectedResources(); -// for (Resource r : selected) { -// if (!adapter.hasNode(r)) { -// if (r.isInstanceOf(GlobalIdMap.get(PSK3DModelingOntologyMapping.EQUIPMENT))) { -// Resource group = GraphicsNodeTools.getModelFromResource(r); -// if (group != null && group.getId() == plant.getResource().getId()) { -//// instantiating a new resource : usin this editor's tc -// Resource resource = graph.getResource(r.getId()); -// adapter.addInbound(resource).setSelected(true); -// } -// -// } -// } -// } - } } @Override @@ -570,89 +496,6 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { } } - private class FloorConfigureDialog extends Dialog implements KeyListener,SelectionListener { - - private boolean floorEnabled = true; - private double floorHeight = 0.0; - - private Text floorHeightText = null; - private Button floorEnabledButton = null; - - public FloorConfigureDialog(Shell shell) { - super(shell); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - Label label = new Label(composite, SWT.WRAP); - label.setText("Configure floor"); - GridData data = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL - | GridData.VERTICAL_ALIGN_CENTER); - - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - label.setLayoutData(data); - label.setFont(parent.getFont()); - floorEnabledButton = new Button(composite,SWT.CHECK); - floorEnabledButton.setText("Enabled"); - label = new Label(composite, SWT.WRAP); - label.setText("Height"); - label.setLayoutData(data); - label.setFont(parent.getFont()); - floorHeightText = new Text(composite,SWT.NONE); - - - floorHeightText.addKeyListener(this); - floorEnabledButton.addSelectionListener(this); - floorEnabledButton.setSelection(floorEnabled); - floorHeightText.setText(Double.toString(floorHeight)); - - return composite; - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText("Configure floor"); - } - - public void keyPressed(KeyEvent e) { - - } - - public void keyReleased(KeyEvent e) { - boolean ok = true; - try { - floorHeight = Double.parseDouble(floorHeightText.getText()); - } catch (NumberFormatException err) { - ok = false; - } - if (ok) { - this.getButton(IDialogConstants.OK_ID).setEnabled(true); - } else { - this.getButton(IDialogConstants.OK_ID).setEnabled(false); - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - - } - - public void widgetSelected(SelectionEvent e) { - floorEnabled = floorEnabledButton.getSelection(); - } - - public boolean isFloorEnabled() { - return floorEnabled; - } - - public double getFloorHeight() { - return floorHeight; - } - - } - @Override protected void hookDragAndDrop() { super.hookDragAndDrop(); @@ -687,9 +530,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { }); } }); - - - + return page; } return null;