KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > projects > FileStateEditor


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 package org.netbeans.core.projects;
21
22 import org.netbeans.beaninfo.editors.ListImageEditor;
23 import org.openide.util.NbBundle;
24 import org.openide.nodes.Node;
25 import org.openide.explorer.propertysheet.PropertyEnv;
26
27 import java.lang.reflect.InvocationTargetException JavaDoc;
28
29 import org.netbeans.core.projects.SettingChildren.FileStateProperty;
30
31 /**
32  *
33  * @author Vitezslav Stejskal
34  */

35 class FileStateEditor extends ListImageEditor {
36
37     private String JavaDoc action_define = null;
38     private String JavaDoc action_revert = null;
39     private String JavaDoc action_delete = null;
40     
41     private Node.Property prop = null;
42
43     /** Creates new FileStatePropertyEditor */
44     public FileStateEditor () {
45         super ();
46         
47         action_define = NbBundle.getMessage (FileStateEditor.class, "LBL_action_define");
48         action_revert = NbBundle.getMessage (FileStateEditor.class, "LBL_action_revert");
49         action_delete = NbBundle.getMessage (FileStateEditor.class, "LBL_action_delete");
50     }
51
52     public void attachEnv (PropertyEnv env) {
53         super.attachEnv (env);
54         
55         try {
56             prop = (Node.Property)env.getFeatureDescriptor ();
57         } catch (ClassCastException JavaDoc cce) {
58             ClassCastException JavaDoc cce2 = new ClassCastException JavaDoc("Expected a Node.Property but got a " + env.getFeatureDescriptor() + " descriptor " + env.getFeatureDescriptor().getClass().getName());
59             throw cce2;
60         }
61     }
62     
63     public String JavaDoc getAsText () {
64         return null;
65     }
66
67     public void setAsText (String JavaDoc str) throws java.lang.IllegalArgumentException JavaDoc {
68         try {
69             Integer JavaDoc value = null;
70             if (action_define.equals (str)) {
71                 value = Integer.valueOf (SettingChildren.FileStateProperty.ACTION_DEFINE);
72             }
73             if (action_revert.equals (str)) {
74                 value = Integer.valueOf (FileStateProperty.ACTION_REVERT);
75             }
76             if (action_delete.equals (str)) {
77                 value = Integer.valueOf (FileStateProperty.ACTION_DELETE);
78             }
79             if (value != null) {
80                 prop.setValue (value);
81                 super.setValue(value);
82             }
83         } catch (IllegalAccessException JavaDoc e) {
84         } catch (InvocationTargetException JavaDoc e) {
85         }
86     }
87     
88     public String JavaDoc[] getTags () {
89         Integer JavaDoc val = (Integer JavaDoc) getValue ();
90
91         if (SettingChildren.PROP_LAYER_MODULES.equals (prop.getName ())) {
92             return new String JavaDoc [] {
93                 action_revert
94             };
95         }
96         if (val != null &&
97             val.intValue () == FileStateManager.FSTATE_IGNORED) {
98             return new String JavaDoc [] {
99                 action_define,
100                 action_revert,
101                 action_delete
102             };
103         }
104         return new String JavaDoc [] {
105             action_define
106         };
107     }
108 }
109
Popular Tags