KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > editors > Int0Editor


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 package org.netbeans.modules.j2ee.sun.ide.editors;
20
21 import java.awt.*;
22 import java.beans.*;
23 import org.openide.util.NbBundle;
24 import org.openide.explorer.propertysheet.editors.*;
25
26 public class Int0Editor extends PropertyEditorSupport implements EnhancedPropertyEditor {
27
28     public String JavaDoc prev = "null"; // NOI18N
29
private String JavaDoc curValue;
30     private String JavaDoc errorMessage;
31
32     public Int0Editor() {
33     curValue = null;
34     
35     }
36
37     public String JavaDoc getAsText () {
38         if (curValue==null || curValue.equals("")) {// NOI18N
39
curValue = prev;
40         }
41         if (errorMessage != null) {
42            // String title = NbBundle.getMessage(Int0Editor.class, "TTL_Input_Error");
43
errorMessage = null;
44         }
45         return curValue;
46     }
47
48     public String JavaDoc checkValid(String JavaDoc string) {
49         if (EditorUtils.isValidInt0(string))
50             return null; //no error message
51
else
52             return NbBundle.getMessage(Int0Editor.class, "MSG_RangeForInt0");
53     }
54     
55     public void setAsText (String JavaDoc string) throws IllegalArgumentException JavaDoc {
56         prev = curValue;
57         if((string==null)||(string.equals(""))) {// NOI18N
58
return;
59         }
60
61         errorMessage = checkValid(string);
62         if (errorMessage == null) {
63             prev = curValue;
64             curValue = string;
65             firePropertyChange();
66         }
67         else
68             curValue = prev;
69     }
70     
71     public void setValue (Object JavaDoc v) {
72         if(!(v.equals(""))){ // NOI18N
73
prev = (String JavaDoc)v;
74         }
75         curValue = (String JavaDoc)v;
76     
77     }
78
79     public Object JavaDoc getValue () {
80        return curValue;
81     }
82
83     public Component getInPlaceCustomEditor () {
84         return null;
85     }
86
87     public boolean hasInPlaceCustomEditor () {
88         return false;
89     }
90
91     public boolean supportsEditingTaggedValues () {
92         return false;
93     }
94                    
95 }
96
97
98   
99       
100   
101
Popular Tags