1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
14 * @author Toni Kalajainen
16 package org.simantics.utils.ui.color;
18 import org.eclipse.jface.dialogs.Dialog;
19 import org.eclipse.jface.dialogs.IDialogConstants;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.graphics.Point;
22 import org.eclipse.swt.layout.GridData;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.swt.widgets.Control;
25 import org.eclipse.swt.widgets.Shell;
27 public class ColorGradientDialog extends Dialog {
29 ColorGradientComposite composite;
32 protected ColorGradientDialog(Shell parentShell, ColorGradient initialValue) {
34 setShellStyle( getShellStyle() | SWT.RESIZE );
35 value = new ColorGradient(initialValue);
39 protected Point getInitialSize() {
40 return new Point(400, 400);
44 protected Control createDialogArea(Composite parent) {
45 composite = new ColorGradientComposite(parent, 0);
46 GridData childData = new GridData(GridData.FILL_BOTH);
47 composite.setLayoutData(childData);
48 composite.setGradient(value);
53 protected void createButtonsForButtonBar(Composite parent) {
54 // create OK and Cancel buttons by default
55 createButton(parent, IDialogConstants.OK_ID,
56 IDialogConstants.OK_LABEL, true);
57 createButton(parent, IDialogConstants.CANCEL_ID,
58 IDialogConstants.CANCEL_LABEL, false);
62 protected void okPressed() {
63 value = composite.getGradient();
67 public ColorGradient getGradient() {
71 public void setGradient(ColorGradient gradient) {
72 this.value = gradient;