001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.tomcat5.customizer;
043:
044: import org.openide.awt.Mnemonics;
045: import org.openide.DialogDisplayer;
046: import org.openide.NotifyDescriptor;
047: import org.openide.util.NbBundle;
048: import javax.swing.JTextField;
049: import javax.swing.JSpinner;
050: import javax.accessibility.AccessibleContext;
051: import java.awt.Font;
052:
053: /**
054: * Customizer general (connection) tab.
055: *
056: * @author sherold
057: */
058: public class CustomizerGeneral extends javax.swing.JPanel {
059:
060: private final CustomizerDataSupport custData;
061: private boolean passwordVisible;
062: private char originalEchoChar;
063: private Font originalFont;
064:
065: /** Creates new form CustomizerGeneral */
066: public CustomizerGeneral(CustomizerDataSupport custData) {
067: this .custData = custData;
068: initComponents();
069:
070: JTextField serverPortTextField = ((JSpinner.NumberEditor) serverPortSpinner
071: .getEditor()).getTextField();
072: AccessibleContext ac = serverPortTextField
073: .getAccessibleContext();
074: ac.setAccessibleName(NbBundle.getMessage(
075: CustomizerGeneral.class, "ASCN_ServerPort"));
076: ac.setAccessibleDescription(NbBundle.getMessage(
077: CustomizerGeneral.class, "ASCD_ServerPort"));
078:
079: JTextField shutdownPortTextField = ((JSpinner.NumberEditor) shutdownPortSpinner
080: .getEditor()).getTextField();
081: ac = shutdownPortTextField.getAccessibleContext();
082: ac.setAccessibleName(NbBundle.getMessage(
083: CustomizerGeneral.class, "ASCN_ShutdownPort"));
084: ac.setAccessibleDescription(NbBundle.getMessage(
085: CustomizerGeneral.class, "ASCD_ShutdownPort"));
086:
087: // work-around for jspinner incorrect fonts
088: Font font = usernameTextField.getFont();
089: serverPortSpinner.setFont(font);
090: shutdownPortSpinner.setFont(font);
091: }
092:
093: /** This method is called from within the constructor to
094: * initialize the form.
095: * WARNING: Do NOT modify this code. The content of this method is
096: * always regenerated by the Form Editor.
097: */
098: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
099: private void initComponents() {
100:
101: homeLabel = new javax.swing.JLabel();
102: homeTextField = new javax.swing.JTextField();
103: baseLabel = new javax.swing.JLabel();
104: baseTextField = new javax.swing.JTextField();
105: credentialsLabel = new javax.swing.JLabel();
106: usernameLabel = new javax.swing.JLabel();
107: usernameTextField = new javax.swing.JTextField();
108: passwordLabel = new javax.swing.JLabel();
109: passwordField = new javax.swing.JPasswordField();
110: showButton = new javax.swing.JButton();
111: serverPortLabel = new javax.swing.JLabel();
112: serverPortSpinner = new javax.swing.JSpinner();
113: shutdownPortLabel = new javax.swing.JLabel();
114: shutdownPortSpinner = new javax.swing.JSpinner();
115: monitorCheckBox = new javax.swing.JCheckBox();
116: NoteChangesLabel = new javax.swing.JLabel();
117:
118: homeLabel.setLabelFor(homeTextField);
119: org.openide.awt.Mnemonics.setLocalizedText(homeLabel,
120: org.openide.util.NbBundle.getMessage(
121: CustomizerGeneral.class,
122: "CustomizerGeneral.homeLabel.text")); // NOI18N
123:
124: homeTextField.setColumns(30);
125: homeTextField.setDocument(custData.getCatalinaHomeModel());
126: homeTextField.setEditable(false);
127:
128: baseLabel.setLabelFor(baseTextField);
129: org.openide.awt.Mnemonics.setLocalizedText(baseLabel,
130: org.openide.util.NbBundle.getMessage(
131: CustomizerGeneral.class,
132: "CustomizerGeneral.baseLabel.text")); // NOI18N
133:
134: baseTextField.setColumns(30);
135: baseTextField.setDocument(custData.getCatalinaBaseModel());
136: baseTextField.setEditable(false);
137:
138: org.openide.awt.Mnemonics.setLocalizedText(credentialsLabel,
139: org.openide.util.NbBundle.getMessage(
140: CustomizerGeneral.class,
141: "CustomizerGeneral.credentialsLabel.text")); // NOI18N
142: credentialsLabel
143: .setToolTipText(org.openide.util.NbBundle
144: .getMessage(CustomizerGeneral.class,
145: "CustomizerGeneral.credentialsLabel.toolTipText")); // NOI18N
146:
147: usernameLabel.setLabelFor(usernameTextField);
148: org.openide.awt.Mnemonics.setLocalizedText(usernameLabel,
149: org.openide.util.NbBundle.getMessage(
150: CustomizerGeneral.class,
151: "CustomizerGeneral.usernameLabel.text")); // NOI18N
152: usernameLabel.setToolTipText(org.openide.util.NbBundle
153: .getMessage(CustomizerGeneral.class,
154: "CustomizerGeneral.usernameLabel.toolTipText")); // NOI18N
155:
156: usernameTextField.setColumns(15);
157: usernameTextField.setDocument(custData.getUsernameModel());
158:
159: passwordLabel.setLabelFor(passwordField);
160: org.openide.awt.Mnemonics.setLocalizedText(passwordLabel,
161: org.openide.util.NbBundle.getMessage(
162: CustomizerGeneral.class,
163: "CustomizerGeneral.passwordLabel.text")); // NOI18N
164: passwordLabel.setToolTipText(org.openide.util.NbBundle
165: .getMessage(CustomizerGeneral.class,
166: "CustomizerGeneral.passwordLabel.toolTipText")); // NOI18N
167:
168: passwordField.setColumns(15);
169: passwordField.setDocument(custData.getPasswordModel());
170:
171: org.openide.awt.Mnemonics.setLocalizedText(showButton,
172: org.openide.util.NbBundle.getMessage(
173: CustomizerGeneral.class,
174: "CustomizerGeneral.showButton.text")); // NOI18N
175: showButton.setToolTipText(org.openide.util.NbBundle.getMessage(
176: CustomizerGeneral.class,
177: "CustomizerGeneral.showButton.toolTipText")); // NOI18N
178: showButton
179: .addActionListener(new java.awt.event.ActionListener() {
180: public void actionPerformed(
181: java.awt.event.ActionEvent evt) {
182: showButtonActionPerformed(evt);
183: }
184: });
185:
186: serverPortLabel.setLabelFor(serverPortSpinner);
187: org.openide.awt.Mnemonics.setLocalizedText(serverPortLabel,
188: org.openide.util.NbBundle.getMessage(
189: CustomizerGeneral.class,
190: "CustomizerGeneral.serverPortLabel.text")); // NOI18N
191:
192: serverPortSpinner.setModel(custData.getServerPortModel());
193: serverPortSpinner.setEditor(new JSpinner.NumberEditor(
194: serverPortSpinner, "#"));
195:
196: shutdownPortLabel.setLabelFor(shutdownPortSpinner);
197: org.openide.awt.Mnemonics.setLocalizedText(shutdownPortLabel,
198: org.openide.util.NbBundle.getMessage(
199: CustomizerGeneral.class,
200: "CustomizerGeneral.shutdownPortLabel.text")); // NOI18N
201:
202: shutdownPortSpinner.setModel(custData.getShutdownPortModel());
203: shutdownPortSpinner.setEditor(new JSpinner.NumberEditor(
204: shutdownPortSpinner, "#"));
205:
206: org.openide.awt.Mnemonics.setLocalizedText(monitorCheckBox,
207: org.openide.util.NbBundle.getMessage(
208: CustomizerGeneral.class,
209: "CustomizerGeneral.monitorCheckBox.text")); // NOI18N
210: monitorCheckBox.setBorder(javax.swing.BorderFactory
211: .createEmptyBorder(0, 0, 0, 0));
212: monitorCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0));
213: monitorCheckBox.setModel(custData.getMonitorModel());
214:
215: org.openide.awt.Mnemonics.setLocalizedText(NoteChangesLabel,
216: org.openide.util.NbBundle.getMessage(
217: CustomizerGeneral.class,
218: "CustomizerGeneral.NoteChangesLabel.text")); // NOI18N
219:
220: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
221: this );
222: this .setLayout(layout);
223: layout
224: .setHorizontalGroup(layout
225: .createParallelGroup(
226: org.jdesktop.layout.GroupLayout.LEADING)
227: .add(
228: layout
229: .createSequentialGroup()
230: .add(
231: layout
232: .createParallelGroup(
233: org.jdesktop.layout.GroupLayout.LEADING)
234: .add(
235: layout
236: .createSequentialGroup()
237: .addContainerGap()
238: .add(
239: layout
240: .createParallelGroup(
241: org.jdesktop.layout.GroupLayout.LEADING)
242: .add(
243: homeLabel)
244: .add(
245: baseLabel)
246: .add(
247: serverPortLabel)
248: .add(
249: shutdownPortLabel)
250: .add(
251: usernameLabel)
252: .add(
253: passwordLabel))
254: .addPreferredGap(
255: org.jdesktop.layout.LayoutStyle.RELATED)
256: .add(
257: layout
258: .createParallelGroup(
259: org.jdesktop.layout.GroupLayout.LEADING)
260: .add(
261: shutdownPortSpinner,
262: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
263: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
264: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
265: .add(
266: serverPortSpinner,
267: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
268: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
269: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
270: .add(
271: baseTextField,
272: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
273: 395,
274: Short.MAX_VALUE)
275: .add(
276: homeTextField,
277: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
278: 395,
279: Short.MAX_VALUE)
280: .add(
281: layout
282: .createSequentialGroup()
283: .add(
284: layout
285: .createParallelGroup(
286: org.jdesktop.layout.GroupLayout.TRAILING,
287: false)
288: .add(
289: org.jdesktop.layout.GroupLayout.LEADING,
290: usernameTextField,
291: 0,
292: 0,
293: Short.MAX_VALUE)
294: .add(
295: org.jdesktop.layout.GroupLayout.LEADING,
296: passwordField,
297: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
298: 168,
299: Short.MAX_VALUE))
300: .addPreferredGap(
301: org.jdesktop.layout.LayoutStyle.RELATED)
302: .add(
303: showButton)
304: .add(
305: 59,
306: 59,
307: 59))))
308: .add(
309: layout
310: .createSequentialGroup()
311: .add(
312: 12,
313: 12,
314: 12)
315: .add(
316: credentialsLabel))
317: .add(
318: layout
319: .createSequentialGroup()
320: .addContainerGap()
321: .add(
322: monitorCheckBox))
323: .add(
324: layout
325: .createSequentialGroup()
326: .addContainerGap()
327: .add(
328: NoteChangesLabel)))
329: .addContainerGap()));
330: layout
331: .setVerticalGroup(layout
332: .createParallelGroup(
333: org.jdesktop.layout.GroupLayout.LEADING)
334: .add(
335: layout
336: .createSequentialGroup()
337: .addContainerGap()
338: .add(
339: layout
340: .createParallelGroup(
341: org.jdesktop.layout.GroupLayout.BASELINE)
342: .add(homeLabel)
343: .add(
344: homeTextField,
345: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
346: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
347: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
348: .addPreferredGap(
349: org.jdesktop.layout.LayoutStyle.RELATED)
350: .add(
351: layout
352: .createParallelGroup(
353: org.jdesktop.layout.GroupLayout.BASELINE)
354: .add(baseLabel)
355: .add(
356: baseTextField,
357: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
358: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
359: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
360: .add(25, 25, 25)
361: .add(credentialsLabel)
362: .addPreferredGap(
363: org.jdesktop.layout.LayoutStyle.RELATED)
364: .add(
365: layout
366: .createParallelGroup(
367: org.jdesktop.layout.GroupLayout.BASELINE)
368: .add(
369: usernameTextField,
370: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
371: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
372: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
373: .add(
374: usernameLabel))
375: .addPreferredGap(
376: org.jdesktop.layout.LayoutStyle.RELATED)
377: .add(
378: layout
379: .createParallelGroup(
380: org.jdesktop.layout.GroupLayout.BASELINE)
381: .add(showButton)
382: .add(
383: passwordField,
384: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
385: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
386: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
387: .add(
388: passwordLabel))
389: .add(14, 14, 14)
390: .add(
391: layout
392: .createParallelGroup(
393: org.jdesktop.layout.GroupLayout.TRAILING)
394: .add(
395: serverPortLabel)
396: .add(
397: serverPortSpinner,
398: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
399: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
400: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
401: .addPreferredGap(
402: org.jdesktop.layout.LayoutStyle.RELATED)
403: .add(
404: layout
405: .createParallelGroup(
406: org.jdesktop.layout.GroupLayout.BASELINE)
407: .add(
408: shutdownPortLabel)
409: .add(
410: shutdownPortSpinner,
411: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
412: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
413: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
414: .add(15, 15, 15)
415: .add(monitorCheckBox)
416: .addPreferredGap(
417: org.jdesktop.layout.LayoutStyle.RELATED,
418: 31, Short.MAX_VALUE)
419: .add(NoteChangesLabel)
420: .addContainerGap()));
421:
422: homeTextField.getAccessibleContext().setAccessibleName(
423: org.openide.util.NbBundle.getMessage(
424: CustomizerGeneral.class, "ACSN_CatalinaHome")); // NOI18N
425: homeTextField.getAccessibleContext().setAccessibleDescription(
426: org.openide.util.NbBundle.getMessage(
427: CustomizerGeneral.class, "ACSD_CatalinaHome")); // NOI18N
428: baseTextField.getAccessibleContext().setAccessibleName(
429: org.openide.util.NbBundle.getMessage(
430: CustomizerGeneral.class, "ACSN_CatalinaBase")); // NOI18N
431: baseTextField.getAccessibleContext().setAccessibleDescription(
432: org.openide.util.NbBundle.getMessage(
433: CustomizerGeneral.class, "ACSD_CatalinaBase")); // NOI18N
434: usernameTextField.getAccessibleContext().setAccessibleName(
435: org.openide.util.NbBundle.getMessage(
436: CustomizerGeneral.class, "ACSN_Username")); // NOI18N
437: usernameTextField.getAccessibleContext()
438: .setAccessibleDescription(
439: org.openide.util.NbBundle.getMessage(
440: CustomizerGeneral.class,
441: "ACSD_Username")); // NOI18N
442: passwordField.getAccessibleContext().setAccessibleName(
443: org.openide.util.NbBundle.getMessage(
444: CustomizerGeneral.class, "ACSN_Password")); // NOI18N
445: passwordField.getAccessibleContext().setAccessibleDescription(
446: org.openide.util.NbBundle.getMessage(
447: CustomizerGeneral.class, "ACSD_Password")); // NOI18N
448: }// </editor-fold>//GEN-END:initComponents
449:
450: private void showButtonActionPerformed(
451: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showButtonActionPerformed
452: if (!passwordVisible) {
453: passwordVisible = true;
454: originalFont = passwordField.getFont();
455: passwordField.setFont(usernameTextField.getFont());
456: originalEchoChar = passwordField.getEchoChar();
457: passwordField.setEchoChar((char) 0);
458: Mnemonics.setLocalizedText(showButton, NbBundle.getMessage(
459: CustomizerGeneral.class, "LBL_ShowButtonHide"));
460: showButton.setToolTipText(NbBundle.getMessage(
461: CustomizerGeneral.class,
462: "LBL_ShowButtonHide_ToolTip"));
463: } else {
464: passwordVisible = false;
465: passwordField.setFont(originalFont);
466: passwordField.setEchoChar(originalEchoChar);
467: Mnemonics.setLocalizedText(showButton, NbBundle.getMessage(
468: CustomizerGeneral.class,
469: "CustomizerGeneral.showButton.text"));
470: showButton.setToolTipText(NbBundle.getMessage(
471: CustomizerGeneral.class,
472: "CustomizerGeneral.showButton.toolTipText"));
473:
474: }
475: }//GEN-LAST:event_showButtonActionPerformed
476:
477: // Variables declaration - do not modify//GEN-BEGIN:variables
478: private javax.swing.JLabel NoteChangesLabel;
479: private javax.swing.JLabel baseLabel;
480: private javax.swing.JTextField baseTextField;
481: private javax.swing.JLabel credentialsLabel;
482: private javax.swing.JLabel homeLabel;
483: private javax.swing.JTextField homeTextField;
484: private javax.swing.JCheckBox monitorCheckBox;
485: private javax.swing.JPasswordField passwordField;
486: private javax.swing.JLabel passwordLabel;
487: private javax.swing.JLabel serverPortLabel;
488: private javax.swing.JSpinner serverPortSpinner;
489: private javax.swing.JButton showButton;
490: private javax.swing.JLabel shutdownPortLabel;
491: private javax.swing.JSpinner shutdownPortSpinner;
492: private javax.swing.JLabel usernameLabel;
493: private javax.swing.JTextField usernameTextField;
494: // End of variables declaration//GEN-END:variables
495:
496: }
|