]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/color/ColorGradientDialog.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / color / ColorGradientDialog.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 /*
13  *
14  * @author Toni Kalajainen
15  */
16 package org.simantics.utils.ui.color;
17
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;
26
27 public class ColorGradientDialog extends Dialog {
28
29     ColorGradientComposite composite;
30     ColorGradient value;
31     
32     protected ColorGradientDialog(Shell parentShell, ColorGradient initialValue) {
33         super(parentShell);
34         setShellStyle( getShellStyle() | SWT.RESIZE );        
35         value = new ColorGradient(initialValue);
36     }
37     
38     @Override
39     protected Point getInitialSize() {
40         return new Point(400, 400);
41     }
42     
43     @Override
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);
49         return composite;
50     }
51     
52     @Override
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);
59     }
60     
61     @Override
62     protected void okPressed() {
63         value = composite.getGradient();
64         super.okPressed();
65     }
66     
67     public ColorGradient getGradient() {
68         return value;
69     }
70
71     public void setGradient(ColorGradient gradient) {
72         this.value = gradient;
73     }
74     
75 }