001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.testtools.wizards;
021:
022: /*
023: * TestWorkspaceSettingsPanel.java
024: *
025: * Created on April 10, 2002, 1:43 PM
026: */
027:
028: import java.io.File;
029: import java.awt.Component;
030: import java.awt.CardLayout;
031: import javax.swing.JPanel;
032: import javax.swing.JFileChooser;
033: import javax.swing.SwingUtilities;
034: import javax.swing.event.ChangeListener;
035: import javax.swing.event.DocumentListener;
036: import javax.swing.event.DocumentEvent;
037: import javax.swing.event.ChangeEvent;
038:
039: import org.openide.WizardDescriptor;
040: import org.openide.util.HelpCtx;
041: import org.openide.util.Utilities;
042: import org.openide.loaders.DataFolder;
043: import org.openide.loaders.TemplateWizard;
044: import org.openide.filesystems.FileUtil;
045: import org.openide.util.NbBundle;
046:
047: /** Wizard Panel with Test Workspace Settings configuration
048: * @author <a href="mailto:adam.sotona@sun.com">Adam Sotona</a>
049: */
050: public class TestWorkspaceSettingsPanel extends JPanel {
051:
052: static final long serialVersionUID = 6910738027583517330L;
053:
054: private boolean stop = true;
055: private static final String netbeansPath = "../../../nb_all/nbbuild/netbeans"; // NOI18N
056: private static final String xtestPath = "../../../nb_all/xtest"; // NOI18N
057: private static final String jemmyPath = "../../../nb_all/jemmy/builds"; // NOI18N
058: private static final String jellyPath = "../../../nb_all/jellytools/builds"; // NOI18N
059: private String jemmyHome = jemmyPath;
060: private String jellyHome = jellyPath;
061: private TemplateWizard wizard;
062: private ChangeListener listener = null;
063: private static File netHome = new File(System.getProperty(
064: "netbeans.home", ".")); // NOI18N
065:
066: public final Panel panel = new Panel();
067:
068: private class Panel extends Object implements
069: WizardDescriptor.FinishPanel {
070:
071: /** adds ChangeListener of current Panel
072: * @param changeListener ChangeListener */
073: public void addChangeListener(ChangeListener changeListener) {
074: if (listener != null)
075: throw new IllegalStateException();
076: listener = changeListener;
077: }
078:
079: /** returns current Panel
080: * @return Component */
081: public Component getComponent() {
082: return TestWorkspaceSettingsPanel.this ;
083: }
084:
085: /** returns Help Context
086: * @return HelpCtx */
087: public HelpCtx getHelp() {
088: return new HelpCtx(TestWorkspaceSettingsPanel.class);
089: }
090:
091: /** read settings from given Object
092: * @param obj TemplateWizard with settings */
093: public void readSettings(Object obj) {
094: WizardSettings set = WizardSettings.get(obj);
095: wizard = (TemplateWizard) obj;
096: DataFolder df = null;
097: stop = true;
098: try {
099: df = wizard.getTargetFolder();
100: stop = (wizard.getTargetName() != null && wizard
101: .getTargetName().indexOf(' ') >= 0)
102: || WizardIterator.detectBuildScript(df);
103: } catch (Exception e) {
104: }
105: if (stop)
106: ((CardLayout) getLayout()).show(
107: TestWorkspaceSettingsPanel.this , "stop"); // NOI18N
108: else {
109: ((CardLayout) getLayout()).show(
110: TestWorkspaceSettingsPanel.this , "ok"); // NOI18N
111: if (set.workspaceLevel < 0)
112: levelCombo.setSelectedIndex(WizardIterator
113: .detectWorkspaceLevel(df));
114: if (set.defaultType != null)
115: typeField.setText(set.defaultType);
116: if (set.defaultAttributes != null)
117: attrField.setText(set.defaultAttributes);
118: updatePanel();
119: }
120: }
121:
122: /** removes Change Listener of current Panel
123: * @param changeListener ChangeListener */
124: public void removeChangeListener(ChangeListener changeListener) {
125: listener = null;
126: }
127:
128: /** stores settings to given Object
129: * @param obj TemplateWizard with settings */
130: public void storeSettings(Object obj) {
131: WizardSettings set = WizardSettings.get(obj);
132: set.workspaceLevel = levelCombo.getSelectedIndex();
133: set.netbeansHome = netbeansField.getText();
134: set.xtestHome = xtestField.getText();
135: set.defaultType = typeField.getText();
136: set.defaultAttributes = attrField.getText();
137: set.typeJemmyHome = jemmyHome;
138: set.typeJellyHome = jellyHome;
139: }
140:
141: /** test current Panel state for data validity
142: * @return boolean true if data are valid and Wizard can continue */
143: public boolean isValid() {
144: return (!stop)
145: && (!netHome.equals(new File(netbeansField
146: .getText())));
147: }
148:
149: private void fireStateChanged() {
150: SwingUtilities.invokeLater(new Runnable() {
151: public void run() {
152: if (listener != null) {
153: listener.stateChanged(new ChangeEvent(this ));
154: }
155: }
156: });
157: }
158: }
159:
160: /** Creates new form TestWorkspacePanel */
161: public TestWorkspaceSettingsPanel() {
162: setName(NbBundle.getMessage(TestWorkspaceSettingsPanel.class,
163: "LBL_TestWorkspacePanelName")); // NOI18N
164: initComponents();
165: DocumentListener list = new DocumentListener() {
166: public void insertUpdate(DocumentEvent e) {
167: panel.fireStateChanged();
168: }
169:
170: public void removeUpdate(DocumentEvent e) {
171: panel.fireStateChanged();
172: }
173:
174: public void changedUpdate(DocumentEvent e) {
175: panel.fireStateChanged();
176: }
177: };
178: netbeansField.getDocument().addDocumentListener(list);
179: panel.fireStateChanged();
180: }
181:
182: /** This method is called from within the constructor to
183: * initialize the form.
184: * WARNING: Do NOT modify this code. The content of this method is
185: * always regenerated by the Form Editor.
186: */
187: private void initComponents() {//GEN-BEGIN:initComponents
188: java.awt.GridBagConstraints gridBagConstraints;
189:
190: panel2 = new javax.swing.JPanel();
191: levelLabel = new javax.swing.JLabel();
192: levelCombo = new javax.swing.JComboBox();
193: typeLabel = new javax.swing.JLabel();
194: typeField = new javax.swing.JTextField();
195: attrLabel = new javax.swing.JLabel();
196: attrField = new javax.swing.JTextField();
197: separator1 = new javax.swing.JSeparator();
198: advancedCheck = new javax.swing.JCheckBox();
199: netbeansLabel = new javax.swing.JLabel();
200: netbeansField = new javax.swing.JTextField();
201: xtestLabel = new javax.swing.JLabel();
202: xtestField = new javax.swing.JTextField();
203: netbeansButton = new javax.swing.JButton();
204: xtestButton = new javax.swing.JButton();
205: separator2 = new javax.swing.JSeparator();
206: stopLabel = new javax.swing.JLabel();
207:
208: setLayout(new java.awt.CardLayout());
209:
210: panel2.setLayout(new java.awt.GridBagLayout());
211:
212: levelLabel.setDisplayedMnemonic(NbBundle.getMessage(
213: TestWorkspaceSettingsPanel.class,
214: "MNM_TestWorkspaceLevel").charAt(0));
215: levelLabel.setLabelFor(levelCombo);
216: levelLabel.setText(org.openide.util.NbBundle.getMessage(
217: TestWorkspaceSettingsPanel.class,
218: "LBL_TestWorkspaceLevel"));
219: levelLabel.setToolTipText(org.openide.util.NbBundle.getMessage(
220: TestWorkspaceSettingsPanel.class,
221: "TTT_TestWorkspaceLevel"));
222: gridBagConstraints = new java.awt.GridBagConstraints();
223: gridBagConstraints.gridx = 0;
224: gridBagConstraints.gridy = 0;
225: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
226: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
227: gridBagConstraints.weightx = 1.0;
228: gridBagConstraints.weighty = 1.0;
229: gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 11);
230: panel2.add(levelLabel, gridBagConstraints);
231:
232: levelCombo
233: .setModel(new javax.swing.DefaultComboBoxModel(
234: new String[] {
235: "On top of the module (repository / module)",
236: "One level lower (repository / module / package)",
237: "Two levels lower (repository / module / package / package)",
238: "Out of CVS structute (for local use only)" }));
239: levelCombo.setToolTipText(org.openide.util.NbBundle.getMessage(
240: TestWorkspaceSettingsPanel.class,
241: "TTT_TestWorkspaceLevel"));
242: levelCombo
243: .addActionListener(new java.awt.event.ActionListener() {
244: public void actionPerformed(
245: java.awt.event.ActionEvent evt) {
246: levelComboActionPerformed(evt);
247: }
248: });
249:
250: gridBagConstraints = new java.awt.GridBagConstraints();
251: gridBagConstraints.gridx = 0;
252: gridBagConstraints.gridy = 1;
253: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
254: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
255: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
256: gridBagConstraints.weightx = 1.0;
257: gridBagConstraints.weighty = 1.0;
258: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 11);
259: panel2.add(levelCombo, gridBagConstraints);
260:
261: typeLabel.setDisplayedMnemonic(NbBundle.getMessage(
262: TestWorkspaceSettingsPanel.class,
263: "MNM_TestWorkspaceDefaultType").charAt(0));
264: typeLabel.setLabelFor(typeField);
265: typeLabel.setText(org.openide.util.NbBundle.getMessage(
266: TestWorkspaceSettingsPanel.class,
267: "LBL_TestWorkspaceDefaultTestType"));
268: typeLabel.setToolTipText(org.openide.util.NbBundle.getMessage(
269: TestWorkspaceSettingsPanel.class,
270: "TTT_TestWorkspaceDefaultTT"));
271: typeLabel.setEnabled(false);
272: gridBagConstraints = new java.awt.GridBagConstraints();
273: gridBagConstraints.gridx = 0;
274: gridBagConstraints.gridy = 3;
275: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
276: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
277: gridBagConstraints.weightx = 1.0;
278: gridBagConstraints.weighty = 1.0;
279: gridBagConstraints.insets = new java.awt.Insets(11, 12, 0, 11);
280: panel2.add(typeLabel, gridBagConstraints);
281:
282: typeField.setToolTipText(org.openide.util.NbBundle.getMessage(
283: TestWorkspaceSettingsPanel.class,
284: "TTT_TestWorkspaceDefaultTT"));
285: typeField.setEnabled(false);
286: typeField.addFocusListener(new java.awt.event.FocusAdapter() {
287: public void focusGained(java.awt.event.FocusEvent evt) {
288: typeFieldFocusGained(evt);
289: }
290: });
291:
292: gridBagConstraints = new java.awt.GridBagConstraints();
293: gridBagConstraints.gridx = 0;
294: gridBagConstraints.gridy = 4;
295: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
296: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
297: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
298: gridBagConstraints.weightx = 1.0;
299: gridBagConstraints.weighty = 1.0;
300: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 11);
301: panel2.add(typeField, gridBagConstraints);
302:
303: attrLabel.setDisplayedMnemonic(NbBundle.getMessage(
304: TestWorkspaceSettingsPanel.class,
305: "MNM_TestWorkspaceDefaultAttrs").charAt(0));
306: attrLabel.setLabelFor(attrField);
307: attrLabel.setText(org.openide.util.NbBundle.getMessage(
308: TestWorkspaceSettingsPanel.class,
309: "LBL_TestWorkspaceDefaultAttributes"));
310: attrLabel.setToolTipText(org.openide.util.NbBundle.getMessage(
311: TestWorkspaceSettingsPanel.class,
312: "TTT_TestWorkspaceAttrs"));
313: attrLabel.setEnabled(false);
314: gridBagConstraints = new java.awt.GridBagConstraints();
315: gridBagConstraints.gridx = 0;
316: gridBagConstraints.gridy = 5;
317: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
318: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
319: gridBagConstraints.weightx = 1.0;
320: gridBagConstraints.weighty = 1.0;
321: gridBagConstraints.insets = new java.awt.Insets(11, 12, 0, 11);
322: panel2.add(attrLabel, gridBagConstraints);
323:
324: attrField.setToolTipText(org.openide.util.NbBundle.getMessage(
325: TestWorkspaceSettingsPanel.class,
326: "TTT_TestWorkspaceAttrs"));
327: attrField.setEnabled(false);
328: attrField.addFocusListener(new java.awt.event.FocusAdapter() {
329: public void focusGained(java.awt.event.FocusEvent evt) {
330: attrFieldFocusGained(evt);
331: }
332: });
333:
334: gridBagConstraints = new java.awt.GridBagConstraints();
335: gridBagConstraints.gridx = 0;
336: gridBagConstraints.gridy = 6;
337: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
338: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
339: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
340: gridBagConstraints.weightx = 1.0;
341: gridBagConstraints.weighty = 1.0;
342: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 11);
343: panel2.add(attrField, gridBagConstraints);
344:
345: gridBagConstraints = new java.awt.GridBagConstraints();
346: gridBagConstraints.gridx = 2;
347: gridBagConstraints.gridy = 2;
348: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
349: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
350: gridBagConstraints.weightx = 0.01;
351: gridBagConstraints.weighty = 0.01;
352: gridBagConstraints.insets = new java.awt.Insets(17, 0, 0, 11);
353: panel2.add(separator1, gridBagConstraints);
354:
355: advancedCheck.setMnemonic(NbBundle.getMessage(
356: TestWorkspaceSettingsPanel.class,
357: "MNM_TestWorkspaceAdvanced").charAt(0));
358: advancedCheck.setText(org.openide.util.NbBundle.getMessage(
359: TestWorkspaceSettingsPanel.class,
360: "LBL_AdvancedSettings"));
361: advancedCheck.setToolTipText(org.openide.util.NbBundle
362: .getMessage(TestWorkspaceSettingsPanel.class,
363: "TTT_AdvancedSettings"));
364: advancedCheck
365: .addActionListener(new java.awt.event.ActionListener() {
366: public void actionPerformed(
367: java.awt.event.ActionEvent evt) {
368: advancedCheckActionPerformed(evt);
369: }
370: });
371:
372: gridBagConstraints = new java.awt.GridBagConstraints();
373: gridBagConstraints.gridx = 0;
374: gridBagConstraints.gridy = 2;
375: gridBagConstraints.weightx = 0.01;
376: gridBagConstraints.weighty = 1.0;
377: gridBagConstraints.insets = new java.awt.Insets(17, 12, 0, 0);
378: panel2.add(advancedCheck, gridBagConstraints);
379:
380: netbeansLabel.setDisplayedMnemonic(NbBundle.getMessage(
381: TestWorkspaceSettingsPanel.class,
382: "MNM_TestWorkspaceNetbeansHome").charAt(0));
383: netbeansLabel.setLabelFor(netbeansField);
384: netbeansLabel.setText(org.openide.util.NbBundle.getMessage(
385: TestWorkspaceSettingsPanel.class,
386: "LBL_TestWorkspaceNetbeansHome"));
387: netbeansLabel.setToolTipText(org.openide.util.NbBundle
388: .getMessage(TestWorkspaceSettingsPanel.class,
389: "TTT_NetbeansHome"));
390: netbeansLabel.setEnabled(false);
391: gridBagConstraints = new java.awt.GridBagConstraints();
392: gridBagConstraints.gridx = 0;
393: gridBagConstraints.gridy = 7;
394: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
395: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
396: gridBagConstraints.weightx = 1.0;
397: gridBagConstraints.weighty = 1.0;
398: gridBagConstraints.insets = new java.awt.Insets(11, 12, 0, 11);
399: panel2.add(netbeansLabel, gridBagConstraints);
400:
401: netbeansField.setToolTipText(org.openide.util.NbBundle
402: .getMessage(TestWorkspaceSettingsPanel.class,
403: "TTT_NetbeansHome"));
404: netbeansField.setEnabled(false);
405: netbeansField
406: .addFocusListener(new java.awt.event.FocusAdapter() {
407: public void focusGained(
408: java.awt.event.FocusEvent evt) {
409: netbeansFieldFocusGained(evt);
410: }
411: });
412:
413: gridBagConstraints = new java.awt.GridBagConstraints();
414: gridBagConstraints.gridx = 0;
415: gridBagConstraints.gridy = 8;
416: gridBagConstraints.gridwidth = 2;
417: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
418: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
419: gridBagConstraints.weightx = 1.0;
420: gridBagConstraints.weighty = 1.0;
421: gridBagConstraints.insets = new java.awt.Insets(5, 12, 0, 0);
422: panel2.add(netbeansField, gridBagConstraints);
423:
424: xtestLabel.setDisplayedMnemonic(NbBundle.getMessage(
425: TestWorkspaceSettingsPanel.class,
426: "MNM_TestWorkspaceXTestHome").charAt(0));
427: xtestLabel.setLabelFor(xtestField);
428: xtestLabel.setText(org.openide.util.NbBundle.getMessage(
429: TestWorkspaceSettingsPanel.class,
430: "LBL_TestWorkspaceXTestHome"));
431: xtestLabel.setToolTipText(org.openide.util.NbBundle.getMessage(
432: TestWorkspaceSettingsPanel.class, "TTT_XTestHome"));
433: xtestLabel.setEnabled(false);
434: gridBagConstraints = new java.awt.GridBagConstraints();
435: gridBagConstraints.gridx = 0;
436: gridBagConstraints.gridy = 9;
437: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
438: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
439: gridBagConstraints.weightx = 1.0;
440: gridBagConstraints.weighty = 1.0;
441: gridBagConstraints.insets = new java.awt.Insets(11, 12, 0, 11);
442: panel2.add(xtestLabel, gridBagConstraints);
443:
444: xtestField.setToolTipText(org.openide.util.NbBundle.getMessage(
445: TestWorkspaceSettingsPanel.class, "TTT_XTestHome"));
446: xtestField.setEnabled(false);
447: xtestField.addFocusListener(new java.awt.event.FocusAdapter() {
448: public void focusGained(java.awt.event.FocusEvent evt) {
449: xtestFieldFocusGained(evt);
450: }
451: });
452:
453: gridBagConstraints = new java.awt.GridBagConstraints();
454: gridBagConstraints.gridx = 0;
455: gridBagConstraints.gridy = 10;
456: gridBagConstraints.gridwidth = 2;
457: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
458: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
459: gridBagConstraints.weightx = 1.0;
460: gridBagConstraints.weighty = 1.0;
461: gridBagConstraints.insets = new java.awt.Insets(5, 12, 11, 0);
462: panel2.add(xtestField, gridBagConstraints);
463:
464: netbeansButton.setText("...");
465: netbeansButton.setToolTipText(org.openide.util.NbBundle
466: .getMessage(TestWorkspaceSettingsPanel.class,
467: "TTT_NetbeansHome"));
468: netbeansButton.setMinimumSize(new java.awt.Dimension(30, 20));
469: netbeansButton.setPreferredSize(new java.awt.Dimension(30, 20));
470: netbeansButton.setEnabled(false);
471: netbeansButton
472: .addActionListener(new java.awt.event.ActionListener() {
473: public void actionPerformed(
474: java.awt.event.ActionEvent evt) {
475: netbeansButtonActionPerformed(evt);
476: }
477: });
478:
479: gridBagConstraints = new java.awt.GridBagConstraints();
480: gridBagConstraints.gridx = 2;
481: gridBagConstraints.gridy = 8;
482: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
483: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
484: gridBagConstraints.weightx = 0.01;
485: gridBagConstraints.weighty = 1.0;
486: gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 11);
487: panel2.add(netbeansButton, gridBagConstraints);
488: netbeansButton.getAccessibleContext().setAccessibleName(
489: org.openide.util.NbBundle.getMessage(
490: TestWorkspaceSettingsPanel.class,
491: "CTL_NetbeansHomeCust"));
492:
493: xtestButton.setText("...");
494: xtestButton.setToolTipText(org.openide.util.NbBundle
495: .getMessage(TestWorkspaceSettingsPanel.class,
496: "TTT_XTestHome"));
497: xtestButton.setMinimumSize(new java.awt.Dimension(30, 20));
498: xtestButton.setPreferredSize(new java.awt.Dimension(30, 20));
499: xtestButton.setEnabled(false);
500: xtestButton
501: .addActionListener(new java.awt.event.ActionListener() {
502: public void actionPerformed(
503: java.awt.event.ActionEvent evt) {
504: xtestButtonActionPerformed(evt);
505: }
506: });
507:
508: gridBagConstraints = new java.awt.GridBagConstraints();
509: gridBagConstraints.gridx = 2;
510: gridBagConstraints.gridy = 10;
511: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
512: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
513: gridBagConstraints.weightx = 0.01;
514: gridBagConstraints.weighty = 1.0;
515: gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 11);
516: panel2.add(xtestButton, gridBagConstraints);
517: xtestButton.getAccessibleContext().setAccessibleName(
518: org.openide.util.NbBundle.getMessage(
519: TestWorkspaceSettingsPanel.class,
520: "TTT_XTestHomeCust"));
521:
522: gridBagConstraints = new java.awt.GridBagConstraints();
523: gridBagConstraints.gridx = 1;
524: gridBagConstraints.gridy = 2;
525: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
526: gridBagConstraints.weightx = 1.0;
527: gridBagConstraints.weighty = 0.01;
528: gridBagConstraints.insets = new java.awt.Insets(17, 5, 0, 0);
529: panel2.add(separator2, gridBagConstraints);
530:
531: add(panel2, "ok");
532:
533: stopLabel
534: .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
535: stopLabel.setText(org.openide.util.NbBundle.getMessage(
536: TestWorkspaceSettingsPanel.class,
537: "MSG_TestWorkspaceExists"));
538: add(stopLabel, "stop");
539:
540: }//GEN-END:initComponents
541:
542: private void xtestButtonActionPerformed(
543: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xtestButtonActionPerformed
544: File home = WizardIterator.showFileChooser(this , NbBundle
545: .getMessage(TestWorkspaceSettingsPanel.class,
546: "TITLE_SelectXTestHome"), true, false); // NOI18N
547: if (home != null)
548: xtestField.setText(home.getAbsolutePath());
549: }//GEN-LAST:event_xtestButtonActionPerformed
550:
551: private void netbeansButtonActionPerformed(
552: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_netbeansButtonActionPerformed
553: File home = WizardIterator.showFileChooser(this , NbBundle
554: .getMessage(TestWorkspaceSettingsPanel.class,
555: "Title_SelectNetbeansHome"), true, false); // NOI18N
556: if (home != null)
557: netbeansField.setText(home.getAbsolutePath());
558: }//GEN-LAST:event_netbeansButtonActionPerformed
559:
560: private void xtestFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_xtestFieldFocusGained
561: xtestField.selectAll();
562: }//GEN-LAST:event_xtestFieldFocusGained
563:
564: private void netbeansFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_netbeansFieldFocusGained
565: netbeansField.selectAll();
566: }//GEN-LAST:event_netbeansFieldFocusGained
567:
568: private void attrFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_attrFieldFocusGained
569: attrField.selectAll();
570: }//GEN-LAST:event_attrFieldFocusGained
571:
572: private void typeFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_typeFieldFocusGained
573: typeField.selectAll();
574: }//GEN-LAST:event_typeFieldFocusGained
575:
576: private void levelComboActionPerformed(
577: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_levelComboActionPerformed
578: updatePanel();
579: }//GEN-LAST:event_levelComboActionPerformed
580:
581: private void advancedCheckActionPerformed(
582: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_advancedCheckActionPerformed
583: updatePanel();
584: }//GEN-LAST:event_advancedCheckActionPerformed
585:
586: private void updatePanel() {
587: boolean advanced = advancedCheck.isSelected();
588: levelLabel.setEnabled(!advanced);
589: levelCombo.setEnabled(!advanced);
590: typeLabel.setEnabled(advanced);
591: typeField.setEnabled(advanced);
592: attrLabel.setEnabled(advanced);
593: attrField.setEnabled(advanced);
594: netbeansLabel.setEnabled(advanced);
595: netbeansField.setEnabled(advanced);
596: netbeansButton.setEnabled(advanced);
597: xtestLabel.setEnabled(advanced);
598: xtestField.setEnabled(advanced);
599: xtestButton.setEnabled(advanced);
600: if (!advanced) {
601: switch (levelCombo.getSelectedIndex()) {
602: case 0:
603: netbeansField.setText(netbeansPath);
604: xtestField.setText(xtestPath);
605: jemmyHome = jemmyPath;
606: jellyHome = jellyPath;
607: break;
608: case 1:
609: netbeansField.setText("../" + netbeansPath); // NOI18N
610: xtestField.setText("../" + xtestPath); // NOI18N
611: jemmyHome = "../" + jemmyPath; // NOI18N
612: jellyHome = "../" + jellyPath; // NOI18N
613: break;
614: case 2:
615: netbeansField.setText("../../" + netbeansPath); // NOI18N
616: xtestField.setText("../../" + xtestPath); // NOI18N
617: jemmyHome = "../../" + jemmyPath; // NOI18N
618: jellyHome = "../../" + jellyPath; // NOI18N
619: break;
620: case 3:
621: String home = System.getProperty("netbeans.home"); // NOI18N
622: netbeansLabel.setEnabled(true);
623: netbeansField.setEnabled(true);
624: netbeansButton.setEnabled(true);
625: if (!new File(home + File.separator
626: + "xtest-distribution").exists()) // NOI18N
627: home = System.getProperty("netbeans.user"); // NOI18N
628: xtestField.setText(home + File.separator
629: + "xtest-distribution"); // NOI18N
630: jemmyHome = home + File.separator + "modules"
631: + File.separator + "ext"; // NOI18N
632: jellyHome = jemmyHome;
633: break;
634: }
635: }
636: }
637:
638: // Variables declaration - do not modify//GEN-BEGIN:variables
639: private javax.swing.JPanel panel2;
640: private javax.swing.JSeparator separator2;
641: private javax.swing.JSeparator separator1;
642: private javax.swing.JComboBox levelCombo;
643: private javax.swing.JTextField typeField;
644: private javax.swing.JButton xtestButton;
645: private javax.swing.JLabel typeLabel;
646: private javax.swing.JButton netbeansButton;
647: private javax.swing.JTextField netbeansField;
648: private javax.swing.JLabel stopLabel;
649: private javax.swing.JTextField xtestField;
650: private javax.swing.JLabel levelLabel;
651: private javax.swing.JLabel netbeansLabel;
652: private javax.swing.JLabel xtestLabel;
653: private javax.swing.JTextField attrField;
654: private javax.swing.JCheckBox advancedCheck;
655: private javax.swing.JLabel attrLabel;
656: // End of variables declaration//GEN-END:variables
657:
658: }
|