import java.util.List;\r
import java.util.Map;\r
\r
-import org.eclipse.jface.action.Action;\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
import org.eclipse.jface.viewers.ISelection;\r
import org.eclipse.jface.viewers.ISelectionChangedListener;\r
import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.KeyEvent;\r
-import org.eclipse.swt.events.KeyListener;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.widgets.Button;\r
import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Text;\r
import org.eclipse.ui.IWorkbenchPart;\r
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;\r
import org.simantics.db.Graph;\r
import org.simantics.layer0.utils.EntityFactory;\r
import org.simantics.layer0.utils.IEntity;\r
import org.simantics.layer0.utils.Property;\r
-import org.simantics.processeditor.Activator;\r
import org.simantics.processeditor.ProcessResource;\r
+import org.simantics.processeditor.actions.ConfigureFloorAction;\r
import org.simantics.processeditor.actions.InsertComponentAction;\r
import org.simantics.processeditor.actions.InsertEquipmentAction;\r
import org.simantics.processeditor.actions.InsertNozzleAction;\r
\r
private Resource plantResource = null;\r
\r
- //private List<AnimationController> animationControllers = new ArrayList<AnimationController>();\r
-\r
- private Action configureFloorAction = null;\r
+ private ConfigureFloorAction configureFloorAction = null;\r
\r
private Geometry floorShape = null;\r
\r
floorShape = FloorShape.getShape(getRenderingComponent().getDisplaySystem().getRenderer(), 100.f,0.2f);\r
getRenderingComponent().getNoCastRoot().attachChild(floorShape);\r
floorShape.setLocalTranslation(new Vector3f(0.f,-0.01f,0.f));\r
+ configureFloorAction.setFloorShape(floorShape);\r
}\r
\r
@Override\r
\r
//actions.add(new ShowTrendsAction(this));\r
\r
- configureFloorAction = new Action() {\r
- public void run() {\r
- FloorConfigureDialog dialog = new FloorConfigureDialog(ProcessEditor.this.parent.getShell());\r
- if (dialog.open() == FloorConfigureDialog.CANCEL)\r
- return;\r
- if (dialog.isFloorEnabled()) {\r
- if (floorShape.getParent() == null)\r
- getRenderingComponent().getNoCastRoot().attachChild(floorShape);\r
- } else {\r
- floorShape.removeFromParent();\r
- }\r
- floorShape.setLocalTranslation(new Vector3f(0.f,(float)dialog.getFloorHeight(),0.f));\r
- \r
- }\r
- };\r
- configureFloorAction.setText("Configure floor");\r
- configureFloorAction.setImageDescriptor(Activator.imageDescriptorFromPlugin("fi.vtt.proconf.ode", "icons/silk/shape_align_bottom.png"));\r
+ configureFloorAction = new ConfigureFloorAction(this);\r
\r
// ContextActionFactory extended[] = ContextActionRegistry.getActions("fi.vtt.proconf.shapeeditor.processeditorview");\r
// for (ContextActionFactory c : extended) {\r
// }\r
}\r
\r
-// protected void stopAnimations() {\r
-// animationSystem.stop();\r
-// }\r
- \r
protected void fillLocalPullDown() {\r
super.fillLocalPullDown();\r
MenuTools.getOrCreate(getMenuID(),"Advanced", menuManager).add(configureFloorAction);\r
PipeRunControlPointQuery query = new PipeRunControlPointQuery(node.getResource());\r
pipeRunQueries.put(node.getResource(), query);\r
node.getGraph().performQuery(query);\r
-// return new SubnodeListener(node) {\r
-// @Override\r
-// public void shapeAdded(IGraphicsNode node) {\r
-// if (node instanceof IGeometryNode) {\r
-// updateGeometry((IGeometryNode)node);\r
-// \r
-// }\r
-// node.setVisible(true);\r
-// }\r
-// };\r
}\r
return new NormalScenegraphQuery(node.getResource());\r
\r
\r
public ProcessEditorSelectionAdapter(ScenegraphAdapter adapter) {\r
super(adapter);\r
- // TODO Auto-generated constructor stub\r
- }\r
+ }\r
\r
@Override\r
public void setEditorSelection() {\r
((ISelectableNode)o).setSelected(false);\r
}\r
}\r
- List<Resource> selected = getSelectedResources();\r
- // TODO : don't know why this code is here, but it seems unnecessary\r
-// for (Resource r : selected) {\r
-// if (!adapter.hasNode(r)) {\r
-// // instantiating a new resource : usin this editor's tc\r
-// Resource resource = graph.getResource(r.getId());\r
-// adapter.addInbound(resource).setSelected(true);\r
-//\r
-// }\r
-// }\r
- \r
}\r
\r
public void setEditorSelection(boolean addShapes) {\r
((ISelectableNode)o).setSelected(false);\r
}\r
}\r
- if (addShapes) {\r
- // TODO : don't know why this code is here, but it seems unnecessary\r
-// List<Resource> selected = getSelectedResources();\r
-// for (Resource r : selected) {\r
-// if (!adapter.hasNode(r)) {\r
-// if (r.isInstanceOf(GlobalIdMap.get(PSK3DModelingOntologyMapping.EQUIPMENT))) {\r
-// Resource group = GraphicsNodeTools.getModelFromResource(r);\r
-// if (group != null && group.getId() == plant.getResource().getId()) {\r
-//// instantiating a new resource : usin this editor's tc\r
-// Resource resource = graph.getResource(r.getId());\r
-// adapter.addInbound(resource).setSelected(true);\r
-// }\r
-// \r
-// }\r
-// }\r
-// }\r
- }\r
}\r
\r
@Override\r
}\r
}\r
\r
- private class FloorConfigureDialog extends Dialog implements KeyListener,SelectionListener {\r
- \r
- private boolean floorEnabled = true;\r
- private double floorHeight = 0.0;\r
- \r
- private Text floorHeightText = null;\r
- private Button floorEnabledButton = null;\r
- \r
- public FloorConfigureDialog(Shell shell) {\r
- super(shell);\r
- }\r
- \r
- @Override\r
- protected Control createDialogArea(Composite parent) {\r
- Composite composite = (Composite) super.createDialogArea(parent);\r
- Label label = new Label(composite, SWT.WRAP);\r
- label.setText("Configure floor");\r
- GridData data = new GridData(GridData.GRAB_HORIZONTAL\r
- | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL\r
- | GridData.VERTICAL_ALIGN_CENTER);\r
- \r
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);\r
- label.setLayoutData(data);\r
- label.setFont(parent.getFont());\r
- floorEnabledButton = new Button(composite,SWT.CHECK);\r
- floorEnabledButton.setText("Enabled");\r
- label = new Label(composite, SWT.WRAP);\r
- label.setText("Height");\r
- label.setLayoutData(data);\r
- label.setFont(parent.getFont());\r
- floorHeightText = new Text(composite,SWT.NONE);\r
- \r
- \r
- floorHeightText.addKeyListener(this);\r
- floorEnabledButton.addSelectionListener(this);\r
- floorEnabledButton.setSelection(floorEnabled);\r
- floorHeightText.setText(Double.toString(floorHeight));\r
- \r
- return composite;\r
- }\r
- \r
- @Override\r
- protected void configureShell(Shell newShell) {\r
- super.configureShell(newShell);\r
- newShell.setText("Configure floor");\r
- }\r
- \r
- public void keyPressed(KeyEvent e) {\r
- \r
- }\r
- \r
- public void keyReleased(KeyEvent e) {\r
- boolean ok = true;\r
- try {\r
- floorHeight = Double.parseDouble(floorHeightText.getText()); \r
- } catch (NumberFormatException err) {\r
- ok = false;\r
- }\r
- if (ok) {\r
- this.getButton(IDialogConstants.OK_ID).setEnabled(true);\r
- } else {\r
- this.getButton(IDialogConstants.OK_ID).setEnabled(false);\r
- }\r
- }\r
- \r
- public void widgetDefaultSelected(SelectionEvent e) {\r
- \r
- }\r
- \r
- public void widgetSelected(SelectionEvent e) {\r
- floorEnabled = floorEnabledButton.getSelection();\r
- }\r
-\r
- public boolean isFloorEnabled() {\r
- return floorEnabled;\r
- }\r
-\r
- public double getFloorHeight() {\r
- return floorHeight;\r
- }\r
-\r
- }\r
- \r
@Override\r
protected void hookDragAndDrop() {\r
super.hookDragAndDrop();\r
});\r
}\r
});\r
- \r
- \r
- \r
+\r
return page;\r
}\r
return null;\r