KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javawebstart > CustomizerRunComponent


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.modules.javawebstart;
21
22 import java.awt.event.ActionEvent JavaDoc;
23 import java.awt.event.ActionListener JavaDoc;
24
25 import java.util.HashMap JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import org.netbeans.modules.java.j2seproject.api.J2SERunConfigProvider;
29
30 /**
31  *
32  * @author Milan Kubec
33  */

34 public class CustomizerRunComponent extends javax.swing.JPanel JavaDoc implements ActionListener JavaDoc {
35     
36     private Map JavaDoc<String JavaDoc,String JavaDoc> runSelectedMap = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
37     private Map JavaDoc<String JavaDoc,String JavaDoc> runUnselectedMap = new HashMap JavaDoc<String JavaDoc,String JavaDoc>();
38     
39     private J2SERunConfigProvider.ConfigChangeListener listener;
40     
41     public CustomizerRunComponent() {
42         initComponents();
43         runCheckBox.addActionListener(this);
44     }
45     
46     /** This method is called from within the constructor to
47      * initialize the form.
48      * WARNING: Do NOT modify this code. The content of this method is
49      * always regenerated by the Form Editor.
50      */

51     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
52
private void initComponents() {
53         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
54
55         runCheckBox = new javax.swing.JCheckBox JavaDoc();
56         hintLabel = new javax.swing.JLabel JavaDoc();
57
58         setLayout(new java.awt.GridBagLayout JavaDoc());
59
60         runCheckBox.setText(org.openide.util.NbBundle.getMessage(CustomizerRunComponent.class, "LBL_Run_with_JWS")); // NOI18N
61
runCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
62         runCheckBox.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
63         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
64         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
65         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
66         add(runCheckBox, gridBagConstraints);
67
68         hintLabel.setText(org.openide.util.NbBundle.getMessage(CustomizerRunComponent.class, "HINT_Run_with_JWS")); // NOI18N
69
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
70         gridBagConstraints.gridx = 0;
71         gridBagConstraints.gridy = 1;
72         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
73         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
74         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
75         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 22, 0, 0);
76         add(hintLabel, gridBagConstraints);
77     }// </editor-fold>//GEN-END:initComponents
78

79     public void addListener(J2SERunConfigProvider.ConfigChangeListener l) {
80         listener = l;
81     }
82     
83     public void setCheckboxEnabled(boolean b) {
84         runCheckBox.setEnabled(b);
85     }
86     
87     public void setCheckboxSelected(boolean b) {
88         runCheckBox.setSelected(b);
89     }
90     
91     public void setHintVisible(boolean b) {
92         hintLabel.setVisible(b);
93     }
94     
95     public void actionPerformed(ActionEvent JavaDoc e) {
96         initMaps();
97         if (runCheckBox.isSelected()) {
98             listener.propertiesChanged(runSelectedMap);
99         } else {
100             listener.propertiesChanged(runUnselectedMap);
101         }
102     }
103     
104     private void initMaps() {
105         runUnselectedMap.put("$target.run", null);
106         runUnselectedMap.put("$target.debug", null);
107         runSelectedMap.put("$target.run", "jws-run");
108         runSelectedMap.put("$target.debug", "jws-debug");
109     }
110     
111     // Variables declaration - do not modify//GEN-BEGIN:variables
112
private javax.swing.JLabel JavaDoc hintLabel;
113     private javax.swing.JCheckBox JavaDoc runCheckBox;
114     // End of variables declaration//GEN-END:variables
115

116 }
117
Popular Tags