KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > rubyproject > gems > InstallationSettingsPanel


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.ruby.rubyproject.gems;
21
22 import javax.swing.DefaultComboBoxModel JavaDoc;
23 import org.netbeans.modules.ruby.rubyproject.gems.GemManager.Gem;
24 import org.openide.util.NbBundle;
25
26 /**
27  *
28  * @author Tor Norbye
29  */

30 public class InstallationSettingsPanel extends javax.swing.JPanel JavaDoc {
31     private final String JavaDoc LATEST = NbBundle.getMessage(InstallationSettingsPanel.class, "Latest");
32     
33     /** Creates new form InstallationSettingsPanel */
34     public InstallationSettingsPanel(Gem gem) {
35         initComponents();
36         nameField.setText(gem.getName());
37         DefaultComboBoxModel JavaDoc model = new DefaultComboBoxModel JavaDoc();
38         model.addElement(LATEST);
39         String JavaDoc versions = gem.getVersions();
40         if (versions != null) {
41             String JavaDoc[] v = versions.split(", ");
42             for (String JavaDoc version : v) {
43                 if (version.length() != 0) {
44                     model.addElement(version);
45                 }
46             }
47         }
48         versionCombo.setModel(model);
49     }
50     
51     public void setMessage(String JavaDoc message) {
52         messageLabel.setText(message);
53     }
54     
55     public boolean getIncludeDepencies() {
56         return includeToggle.isSelected();
57     }
58     
59     public String JavaDoc getVersion() {
60         String JavaDoc s = versionCombo.getSelectedItem().toString().trim();
61         if (s == LATEST) {
62             return null;
63         } else {
64             return s;
65         }
66     }
67     
68     public String JavaDoc getName() {
69         return nameField.getText().trim();
70     }
71     
72     /** This method is called from within the constructor to
73      * initialize the form.
74      * WARNING: Do NOT modify this code. The content of this method is
75      * always regenerated by the Form Editor.
76      */

77     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
78
private void initComponents() {
79
80         dependencyGroup = new javax.swing.ButtonGroup JavaDoc();
81         jLabel1 = new javax.swing.JLabel JavaDoc();
82         nameField = new javax.swing.JTextField JavaDoc();
83         jLabel2 = new javax.swing.JLabel JavaDoc();
84         versionCombo = new javax.swing.JComboBox JavaDoc();
85         jLabel3 = new javax.swing.JLabel JavaDoc();
86         includeToggle = new javax.swing.JRadioButton JavaDoc();
87         excludeToggle = new javax.swing.JRadioButton JavaDoc();
88         messageLabel = new javax.swing.JLabel JavaDoc();
89
90         jLabel1.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.jLabel1.text")); // NOI18N
91

92         nameField.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.nameField.text")); // NOI18N
93

94         jLabel2.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.jLabel2.text")); // NOI18N
95

96         versionCombo.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(new String JavaDoc[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
97
98         jLabel3.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.jLabel3.text")); // NOI18N
99

100         dependencyGroup.add(includeToggle);
101         includeToggle.setSelected(true);
102         includeToggle.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.includeToggle.text")); // NOI18N
103
includeToggle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
104         includeToggle.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
105
106         dependencyGroup.add(excludeToggle);
107         excludeToggle.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.excludeToggle.text")); // NOI18N
108
excludeToggle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
109         excludeToggle.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
110
111         messageLabel.setText(org.openide.util.NbBundle.getMessage(InstallationSettingsPanel.class, "InstallationSettingsPanel.messageLabel.text")); // NOI18N
112

113         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
114         this.setLayout(layout);
115         layout.setHorizontalGroup(
116             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
117             .add(layout.createSequentialGroup()
118                 .addContainerGap()
119                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
120                     .add(layout.createSequentialGroup()
121                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
122                             .add(jLabel1)
123                             .add(jLabel2)
124                             .add(jLabel3))
125                         .add(10, 10, 10)
126                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
127                             .add(layout.createSequentialGroup()
128                                 .add(includeToggle)
129                                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
130                                 .add(excludeToggle))
131                             .add(versionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
132                             .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)))
133                     .add(messageLabel))
134                 .addContainerGap())
135         );
136         layout.setVerticalGroup(
137             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
138             .add(layout.createSequentialGroup()
139                 .addContainerGap()
140                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
141                     .add(jLabel1)
142                     .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
143                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
144                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
145                     .add(jLabel2)
146                     .add(versionCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
147                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
148                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
149                     .add(jLabel3)
150                     .add(includeToggle)
151                     .add(excludeToggle))
152                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
153                 .add(messageLabel)
154                 .addContainerGap(84, Short.MAX_VALUE))
155         );
156     }// </editor-fold>//GEN-END:initComponents
157

158     
159     // Variables declaration - do not modify//GEN-BEGIN:variables
160
private javax.swing.ButtonGroup JavaDoc dependencyGroup;
161     private javax.swing.JRadioButton JavaDoc excludeToggle;
162     private javax.swing.JRadioButton JavaDoc includeToggle;
163     private javax.swing.JLabel JavaDoc jLabel1;
164     private javax.swing.JLabel JavaDoc jLabel2;
165     private javax.swing.JLabel JavaDoc jLabel3;
166     private javax.swing.JLabel JavaDoc messageLabel;
167     private javax.swing.JTextField JavaDoc nameField;
168     private javax.swing.JComboBox JavaDoc versionCombo;
169     // End of variables declaration//GEN-END:variables
170

171 }
172
Popular Tags