KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > bluej > options > BluejAdvancedOption


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.bluej.options;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.io.File JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26 import javax.swing.Icon JavaDoc;
27 import javax.swing.ImageIcon JavaDoc;
28 import javax.swing.JComponent JavaDoc;
29 import org.netbeans.spi.options.OptionsPanelController;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
33 import org.openide.util.Utilities;
34
35 /**
36  *
37  * @author mkleint
38  */

39 public class BluejAdvancedOption extends org.netbeans.spi.options.OptionsCategory {
40
41     /** Creates a new instance of BluejAdvancedOption */
42     public BluejAdvancedOption() {
43     }
44
45     public OptionsPanelController create() {
46         return new Controller();
47     }
48
49     public String JavaDoc getCategoryName() {
50         return NbBundle.getBundle(BluejAdvancedOption.class).getString("AdvanceOption_title"); // NOI18N
51
}
52
53     public String JavaDoc getTitle() {
54         return NbBundle.getBundle(BluejAdvancedOption.class).getString("AdvancedOption_tooltip"); // NOI18N
55
}
56
57     public Icon JavaDoc getIcon() {
58         return new ImageIcon JavaDoc(Utilities.loadImage("org/netbeans/bluej/options/Category.png")); // NOI18N
59
}
60     
61     
62     static class Controller extends OptionsPanelController {
63         private List JavaDoc listeners = new ArrayList JavaDoc();
64         private BlueJPanel panel;
65         
66         public void update() {
67             File JavaDoc fil = BlueJSettings.getDefault().getHome();
68             getPanel().setBlueJHome(fil != null ? fil.getAbsolutePath() : ""); // NOI18N
69
}
70
71         public void applyChanges() {
72             String JavaDoc str = getPanel().getBlueJHome().trim();
73             File JavaDoc fil = null;
74             if (str.length() > 0) {
75                 fil = new File JavaDoc(str);
76             }
77             BlueJSettings.getDefault().setHome(fil);
78         }
79
80         public void cancel() {
81         }
82
83         public boolean isValid() {
84             return getPanel().isValidData();
85         }
86
87         public boolean isChanged() {
88             return getPanel().isChangedData();
89         }
90
91         public JComponent JavaDoc getComponent(Lookup masterLookup) {
92             return getPanel();
93         }
94
95         public HelpCtx getHelpCtx() {
96             return HelpCtx.DEFAULT_HELP;
97         }
98
99         public void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
100             listeners.add(l);
101         }
102
103         public void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
104             listeners.remove(l);
105         }
106
107         private BlueJPanel getPanel() {
108             if(panel == null) {
109                 panel = new BlueJPanel();
110             }
111             return panel;
112         }
113         
114     }
115 }
116
Popular Tags