--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\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
+/*\r
+ *\r
+ * @author Toni Kalajainen\r
+ */\r
+package org.simantics.utils.ui.color;\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.graphics.Point;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Shell;\r
+\r
+public class ColorGradientDialog extends Dialog {\r
+\r
+ ColorGradientComposite composite;\r
+ ColorGradient value;\r
+ \r
+ protected ColorGradientDialog(Shell parentShell, ColorGradient initialValue) {\r
+ super(parentShell);\r
+ setShellStyle( getShellStyle() | SWT.RESIZE ); \r
+ value = new ColorGradient(initialValue);\r
+ }\r
+ \r
+ @Override\r
+ protected Point getInitialSize() {\r
+ return new Point(400, 400);\r
+ }\r
+ \r
+ @Override\r
+ protected Control createDialogArea(Composite parent) {\r
+ composite = new ColorGradientComposite(parent, 0);\r
+ GridData childData = new GridData(GridData.FILL_BOTH);\r
+ composite.setLayoutData(childData); \r
+ composite.setGradient(value);\r
+ return composite;\r
+ }\r
+ \r
+ @Override\r
+ protected void createButtonsForButtonBar(Composite parent) {\r
+ // create OK and Cancel buttons by default\r
+ createButton(parent, IDialogConstants.OK_ID,\r
+ IDialogConstants.OK_LABEL, true);\r
+ createButton(parent, IDialogConstants.CANCEL_ID,\r
+ IDialogConstants.CANCEL_LABEL, false);\r
+ }\r
+ \r
+ @Override\r
+ protected void okPressed() {\r
+ value = composite.getGradient();\r
+ super.okPressed();\r
+ }\r
+ \r
+ public ColorGradient getGradient() {\r
+ return value;\r
+ }\r
+\r
+ public void setGradient(ColorGradient gradient) {\r
+ this.value = gradient;\r
+ }\r
+ \r
+}\r