KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > editors > DummyPropertyEditor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * WebPropertyEditor.java
21  *
22  * Created on August 25, 2003, 12:23 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.editors;
26
27 import java.awt.Color JavaDoc;
28 import java.awt.Component JavaDoc;
29 import java.awt.Graphics JavaDoc;
30 import java.awt.Rectangle JavaDoc;
31 import java.awt.FontMetrics JavaDoc;
32
33 import javax.swing.JPanel JavaDoc;
34
35 import java.beans.PropertyEditorSupport JavaDoc;
36
37 import org.openide.explorer.propertysheet.ExPropertyEditor;
38 import org.openide.explorer.propertysheet.PropertyEnv;
39
40 import org.netbeans.modules.j2ee.sun.dd.api.web.WebProperty;
41
42
43 //import org.openide.explorer.propertysheet.editors.*;
44

45 /**
46  *
47  * @author User
48  */

49 public class DummyPropertyEditor extends PropertyEditorSupport JavaDoc implements ExPropertyEditor {
50
51     private WebProperty curValue;
52
53     public DummyPropertyEditor() {
54         curValue = null;
55     }
56     
57     public DummyPropertyEditor(WebProperty object) {
58         curValue = object;
59     }
60     
61     public String JavaDoc getAsText() {
62         return null;
63     }
64
65     public void setAsText(String JavaDoc text) {
66          throw new IllegalArgumentException JavaDoc();
67     }
68
69     public void setValue(Object JavaDoc value) {
70         if(value == null) {
71             curValue = null;
72             return;
73         }
74
75         if(value instanceof WebProperty) {
76             curValue = (WebProperty) value;
77         } else if(curValue != null) {
78             curValue.setDescription(value.toString());
79         }
80     }
81
82     public Object JavaDoc getValue () {
83         return curValue;
84     }
85
86     public String JavaDoc getJavaInitializationString() {
87         return getAsText();
88     }
89
90     public String JavaDoc[] getTags() {
91         return null;
92     }
93
94     public Component JavaDoc getInPlaceCustomEditor() {
95         return null;
96     }
97
98     public boolean hasInPlaceCustomEditor() {
99         return false;
100     }
101
102     protected String JavaDoc getPaintableString() {
103         if(curValue == null) {
104             return "(null)";
105         } else {
106             return curValue.toString();
107         }
108     }
109
110     public boolean isPaintable() {
111         return true;
112     }
113     
114     public void paintValue(Graphics JavaDoc gfx, Rectangle JavaDoc box) {
115         FontMetrics JavaDoc fm = gfx.getFontMetrics();
116         gfx.setColor(Color.red);
117         gfx.drawString(getPaintableString(), 4, (box.height - fm.getHeight()) / 2 + 1 + fm.getMaxAscent());
118     }
119     
120     public boolean supportsCustomEditor() {
121         return true;
122     }
123     
124     public Component JavaDoc getCustomEditor () {
125         //return new WebPropertyEditorPanel();
126
return new JPanel JavaDoc();
127     }
128     
129     /** -----------------------------------------------------------------------
130      * ExPropertyEditor support
131      */

132     private PropertyEnv myPropertyEnv = null;
133
134     public void attachEnv(PropertyEnv env) {
135         myPropertyEnv = env;
136     }
137 }
138
Popular Tags