--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.proconf.g3d.dialogs;\r
+\r
+import org.eclipse.jface.dialogs.Dialog;\r
+import org.eclipse.jface.dialogs.IDialogConstants;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseAdapter;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.ColorDialog;\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
+\r
+public class JMEDialog extends Dialog {\r
+ private boolean bounds;\r
+ private boolean normals;\r
+ private boolean wireframe;\r
+ private float[] floatColor = null;\r
+ private Button boundsButton;\r
+ private Button normalsButton;\r
+ private Button wireframeButton;\r
+ private Composite colorComposite;\r
+ private Color color = null;\r
+ \r
+ public JMEDialog(Shell parentShell) {\r
+ super(parentShell);\r
+ }\r
+\r
+ \r
+ @Override\r
+ protected void configureShell(Shell newShell) {\r
+ super.configureShell(newShell);\r
+ newShell.setText("Configure new pipeline");\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("JME Configuration");\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
+ boundsButton = new Button(composite,SWT.CHECK);\r
+ boundsButton.setText("Show bounds");\r
+ boundsButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ bounds = boundsButton.getSelection();\r
+ }\r
+ });\r
+ boundsButton.setSelection(bounds);\r
+ normalsButton = new Button(composite,SWT.CHECK);\r
+ normalsButton.setText("Show normals");\r
+ normalsButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ normals = normalsButton.getSelection();\r
+ }\r
+ });\r
+ normalsButton.setSelection(normals);\r
+ wireframeButton = new Button(composite,SWT.CHECK);\r
+ wireframeButton.setText("Show wireframe");\r
+ wireframeButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ wireframe = wireframeButton.getSelection();\r
+ }\r
+ });\r
+ wireframeButton.setSelection(wireframe);\r
+ \r
+ colorComposite = new Composite(composite,SWT.BORDER);\r
+ colorComposite.addMouseListener(new MouseAdapter() {\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ ColorDialog dialog = new ColorDialog(JMEDialog.this.getShell());\r
+ RGB rgb = dialog.open();\r
+ if (rgb != null) {\r
+ if (color != null)\r
+ color.dispose();\r
+ color = new Color(JMEDialog.this.getShell().getDisplay(),rgb);\r
+ colorComposite.setBackground(color);\r
+ floatColor = new float[]{rgb.red/255.f,rgb.green/255.f,rgb.blue/255.f};\r
+ }\r
+ }\r
+ });\r
+ updateColor();\r
+ \r
+ return composite;\r
+ }\r
+ \r
+ @Override\r
+ public int open() {\r
+ return super.open();\r
+ }\r
+\r
+\r
+ public boolean isBounds() {\r
+ return bounds;\r
+ }\r
+\r
+\r
+ public void setBounds(boolean bounds) {\r
+ this.bounds = bounds;\r
+ }\r
+\r
+\r
+ public boolean isNormals() {\r
+ return normals;\r
+ }\r
+\r
+\r
+ public void setNormals(boolean normals) {\r
+ this.normals = normals;\r
+ }\r
+\r
+\r
+ public boolean isWireframe() {\r
+ return wireframe;\r
+ }\r
+\r
+\r
+ public void setWireframe(boolean wireframe) {\r
+ this.wireframe = wireframe;\r
+ }\r
+ \r
+ \r
+ public float[] getFloatColor() {\r
+ return floatColor;\r
+ }\r
+\r
+ public void setFloatColor(float[] c) {\r
+ this.floatColor = c;\r
+ if (floatColor == null)\r
+ return;\r
+ \r
+ updateColor();\r
+ }\r
+ \r
+ private void updateColor() {\r
+ if (colorComposite == null)\r
+ return;\r
+ if (color != null)\r
+ color.dispose();\r
+ RGB rgb = new RGB((int)(floatColor[0]*255.f),(int)(floatColor[1]*255.f),(int)(floatColor[2]*255.f));\r
+ color = new Color(JMEDialog.this.getShell().getDisplay(),rgb);\r
+ colorComposite.setBackground(color);\r
+ }\r
+\r
+ \r
+\r
+\r
+ \r
+ \r
+ \r
+}\r