KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > versioning > system > cvss > ui > wizards > CvsRootPanel


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.versioning.system.cvss.ui.wizards;
21
22 import java.awt.Dimension JavaDoc;
23 import javax.swing.JLabel JavaDoc;
24 import javax.swing.text.PlainDocument JavaDoc;
25 import javax.swing.text.AttributeSet JavaDoc;
26 import javax.swing.text.BadLocationException JavaDoc;
27
28 /**
29  * CVS Root field by field customizer UI.
30  *
31  * @author Petr Kuzel
32  */

33 public class CvsRootPanel extends javax.swing.JPanel JavaDoc {
34
35     /** Creates new form CvsRootPanel */
36     public CvsRootPanel() {
37         initComponents();
38
39         // some components are dynamically hidden, set constant width
40
// to avoid user visible relayouting
41
int w = accessLabel.getPreferredSize().width;
42         w = Math.max(w, userLabel.getPreferredSize().width);
43         w = Math.max(w, hostLabel.getPreferredSize().width);
44         w = Math.max(w, repositoryLabel.getPreferredSize().width);
45         
46         setPreferredWidth(accessLabel, w);
47         setPreferredWidth(userLabel, w);
48         setPreferredWidth(hostLabel, w);
49         setPreferredWidth(repositoryLabel, w);
50
51         portTextField.setDocument(new PortDocument());
52     }
53     
54     private void setPreferredWidth(JLabel JavaDoc label, int width) {
55         Dimension JavaDoc dim = label.getPreferredSize();
56         dim.width = width;
57         label.setPreferredSize(dim);
58     }
59
60      static class PortDocument extends PlainDocument JavaDoc {
61
62          public void insertString(int offs, String JavaDoc str, AttributeSet JavaDoc a) throws BadLocationException JavaDoc {
63
64              if (str == null) return;
65
66              char[] upper = str.toCharArray();
67              for (int i = 0; i < upper.length; i++) {
68                  if ("1234567890".indexOf(upper[i]) == -1) { // NOI18N
69
return;
70                  }
71              }
72              super.insertString(offs, new String JavaDoc(upper), a);
73          }
74      }
75     /** This method is called from within the constructor to
76      * initialize the form.
77      * WARNING: Do NOT modify this code. The content of this method is
78      * always regenerated by the Form Editor.
79      */

80     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
81
private void initComponents() {
82         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
83
84         setLayout(new java.awt.GridBagLayout JavaDoc());
85
86         accessLabel.setLabelFor(accessComboBox);
87         org.openide.awt.Mnemonics.setLocalizedText(accessLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1006"));
88         accessLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_AccessMethod"));
89         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
90         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
91         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 3, 3);
92         add(accessLabel, gridBagConstraints);
93
94         accessComboBox.setModel(new javax.swing.DefaultComboBoxModel JavaDoc(new String JavaDoc[] { "pserver", "ext", "local", "fork" }));
95         accessComboBox.setMinimumSize(new java.awt.Dimension JavaDoc(120, 24));
96         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
97         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
98         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
99         gridBagConstraints.weightx = 1.0;
100         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 3, 3, 0);
101         add(accessComboBox, gridBagConstraints);
102
103         userLabel.setLabelFor(userTextField);
104         org.openide.awt.Mnemonics.setLocalizedText(userLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1007"));
105         userLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_Username"));
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
108         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 0, 3, 3);
109         add(userLabel, gridBagConstraints);
110
111         userTextField.setColumns(12);
112         userTextField.setMinimumSize(new java.awt.Dimension JavaDoc(120, 19));
113         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
114         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
115         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
116         gridBagConstraints.weightx = 10.0;
117         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
118         add(userTextField, gridBagConstraints);
119
120         hostLabel.setLabelFor(hostTextField);
121         org.openide.awt.Mnemonics.setLocalizedText(hostLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1008"));
122         hostLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_CVSHost"));
123         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
124         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
125         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 0, 3, 3);
126         add(hostLabel, gridBagConstraints);
127
128         hostTextField.setColumns(30);
129         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
130         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131         gridBagConstraints.weightx = 20.0;
132         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
133         add(hostTextField, gridBagConstraints);
134
135         portLabel.setLabelFor(portTextField);
136         org.openide.awt.Mnemonics.setLocalizedText(portLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1009"));
137         portLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_CVSPort"));
138         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
139         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 3);
140         add(portLabel, gridBagConstraints);
141
142         portTextField.setColumns(5);
143         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
144         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
145         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
146         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
147         gridBagConstraints.weightx = 3.0;
148         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 3, 0);
149         add(portTextField, gridBagConstraints);
150
151         repositoryLabel.setLabelFor(repositoryTextField);
152         org.openide.awt.Mnemonics.setLocalizedText(repositoryLabel, org.openide.util.NbBundle.getMessage(CvsRootPanel.class, "BK1005"));
153         repositoryLabel.setToolTipText(java.util.ResourceBundle.getBundle("org/netbeans/modules/versioning/system/cvss/ui/wizards/Bundle").getString("TT_Repository"));
154         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
155         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
156         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 0, 0, 3);
157         add(repositoryLabel, gridBagConstraints);
158
159         repositoryTextField.setColumns(30);
160         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
161         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
162         gridBagConstraints.weightx = 20.0;
163         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 0, 3);
164         add(repositoryTextField, gridBagConstraints);
165
166         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
167         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
168         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
169         gridBagConstraints.weightx = 1.0;
170         add(jPanel1, gridBagConstraints);
171
172         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
173         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
174         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
175         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
176         gridBagConstraints.weightx = 1.0;
177         gridBagConstraints.weighty = 1.0;
178         add(jPanel2, gridBagConstraints);
179
180     }
181     // </editor-fold>//GEN-END:initComponents
182

183     
184     // Variables declaration - do not modify//GEN-BEGIN:variables
185
final javax.swing.JComboBox JavaDoc accessComboBox = new javax.swing.JComboBox JavaDoc();
186     final javax.swing.JLabel JavaDoc accessLabel = new javax.swing.JLabel JavaDoc();
187     final javax.swing.JLabel JavaDoc hostLabel = new javax.swing.JLabel JavaDoc();
188     final javax.swing.JTextField JavaDoc hostTextField = new javax.swing.JTextField JavaDoc();
189     final javax.swing.JPanel JavaDoc jPanel1 = new javax.swing.JPanel JavaDoc();
190     final javax.swing.JPanel JavaDoc jPanel2 = new javax.swing.JPanel JavaDoc();
191     final javax.swing.JLabel JavaDoc portLabel = new javax.swing.JLabel JavaDoc();
192     final javax.swing.JTextField JavaDoc portTextField = new javax.swing.JTextField JavaDoc();
193     final javax.swing.JLabel JavaDoc repositoryLabel = new javax.swing.JLabel JavaDoc();
194     final javax.swing.JTextField JavaDoc repositoryTextField = new javax.swing.JTextField JavaDoc();
195     final javax.swing.JLabel JavaDoc userLabel = new javax.swing.JLabel JavaDoc();
196     final javax.swing.JTextField JavaDoc userTextField = new javax.swing.JTextField JavaDoc();
197     // End of variables declaration//GEN-END:variables
198

199 }
200
Popular Tags