KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > rubyproject > RubyOptionsAdvancedPanel


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.ruby.rubyproject;
20
21 import java.beans.PropertyChangeListener JavaDoc;
22
23 import javax.swing.JComponent JavaDoc;
24 import org.netbeans.modules.ruby.rubyproject.api.RubyInstallation;
25
26 import org.netbeans.spi.options.AdvancedOption;
27 import org.netbeans.spi.options.OptionsPanelController;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.Lookup;
30 import org.openide.util.Mutex;
31 import org.openide.util.NbBundle;
32
33
34 /**
35  * Based on options panel in stripwhitespace module by Andrei Badea
36  *
37  * @author Tor Norbye
38  */

39 public class RubyOptionsAdvancedPanel extends AdvancedOption {
40     public String JavaDoc getTooltip() {
41         return getDisplayName();
42     }
43
44     public String JavaDoc getDisplayName() {
45         return NbBundle.getMessage(RubyOptionsAdvancedPanel.class, "LBL_OptionsPanelName");
46     }
47
48     public OptionsPanelController create() {
49         return new Controller();
50     }
51
52     private static final class Controller extends OptionsPanelController {
53         private RubyHomeOptionsPanel component;
54
55         public JComponent JavaDoc getComponent(Lookup masterLookup) {
56             if (component == null) {
57                 component = new RubyHomeOptionsPanel();
58             }
59
60             return component;
61         }
62
63         public void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
64         }
65
66         public void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
67         }
68
69         public void update() {
70             Mutex.EVENT.readAccess(new Runnable JavaDoc() {
71                     public void run() {
72                         component.setRuby(RubyInstallation.getInstance().getRuby());
73                         component.setRake(RubyInstallation.getInstance().getRake());
74                         component.setRDoc(RubyInstallation.getInstance().getRDoc());
75                         component.setRails(RubyInstallation.getInstance().getRails());
76                     }
77                 });
78         }
79
80         public boolean isValid() {
81             return true;
82         }
83
84         public boolean isChanged() {
85             return false;
86         }
87
88         public HelpCtx getHelpCtx() {
89             return HelpCtx.DEFAULT_HELP;
90         }
91
92         public void cancel() {
93         }
94
95         public void applyChanges() {
96             Mutex.EVENT.readAccess(new Runnable JavaDoc() {
97                     public void run() {
98                         RubyInstallation config = RubyInstallation.getInstance();
99                         config.setRuby(component.getRuby());
100                         config.setRake(component.getRake());
101                         config.setRDoc(component.getRDoc());
102                         config.setRails(component.getRails());
103                     }
104                 });
105         }
106     }
107 }
108
Popular Tags