From c053c1a41880f9aacd4673c85a5d4fd49fe647f6 Mon Sep 17 00:00:00 2001 From: luukkainen Date: Mon, 19 Jan 2009 09:36:34 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/3d/branches/dev@8675 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../dialogs/FloorConfigureDialog.java | 99 ++++++++++++ .../processeditor/views/ProcessEditor.java | 144 +----------------- 2 files changed, 101 insertions(+), 142 deletions(-) create mode 100644 org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/FloorConfigureDialog.java diff --git a/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/FloorConfigureDialog.java b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/FloorConfigureDialog.java new file mode 100644 index 00000000..22b9100e --- /dev/null +++ b/org.simantics.proconf.processeditor/src/org/simantics/processeditor/dialogs/FloorConfigureDialog.java @@ -0,0 +1,99 @@ +package org.simantics.processeditor.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +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; + +public 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; + } + +} 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..cab340f5 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 @@ -17,23 +17,10 @@ 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; @@ -51,6 +38,7 @@ 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; @@ -84,8 +72,6 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { private Resource plantResource = null; - //private List animationControllers = new ArrayList(); - private Action configureFloorAction = null; private Geometry floorShape = null; @@ -146,10 +132,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 +163,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 +471,7 @@ public class ProcessEditor extends ThreeDimensionalEditorBase { public ProcessEditorSelectionAdapter(ScenegraphAdapter adapter) { super(adapter); - // TODO Auto-generated constructor stub - } + } @Override public void setEditorSelection() { @@ -513,17 +484,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 +497,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 +513,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(); -- 2.47.1