KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > properties > ColorPropertyDescriptor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.views.properties;
12
13 import org.eclipse.jface.viewers.CellEditor;
14 import org.eclipse.jface.viewers.ColorCellEditor;
15 import org.eclipse.swt.widgets.Composite;
16
17 /**
18  * Descriptor for a property that has a color value which should be edited
19  * with a color cell editor.
20  * <p>
21  * This class may be instantiated; it is not intended to be subclassed.
22  * </p>
23  * <p>
24  * Example:
25  * <pre>
26  * IPropertyDescriptor pd = new ColorPropertyDescriptor("fg", "Foreground Color");
27  * </pre>
28  * </p>
29  */

30 public class ColorPropertyDescriptor extends PropertyDescriptor {
31     /**
32      * Creates an property descriptor with the given id and display name.
33      *
34      * @param id the id of the property
35      * @param displayName the name to display for the property
36      */

37     public ColorPropertyDescriptor(Object JavaDoc id, String JavaDoc displayName) {
38         super(id, displayName);
39     }
40
41     /**
42      * The <code>ColorPropertyDescriptor</code> implementation of this
43      * <code>IPropertyDescriptor</code> method creates and returns a new
44      * <code>ColorCellEditor</code>.
45      * <p>
46      * The editor is configured with the current validator if there is one.
47      * </p>
48      */

49     public CellEditor createPropertyEditor(Composite parent) {
50         CellEditor editor = new ColorCellEditor(parent);
51         if (getValidator() != null) {
52             editor.setValidator(getValidator());
53         }
54         return editor;
55     }
56 }
57
Popular Tags