001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.lenya.config.impl;
020:
021: import java.awt.Container;
022: import java.awt.FlowLayout;
023: import java.awt.GridBagConstraints;
024: import java.awt.GridBagLayout;
025: import java.awt.Insets;
026: import java.awt.Toolkit;
027: import java.awt.event.ActionEvent;
028: import java.awt.event.ActionListener;
029: import java.awt.event.MouseEvent;
030: import java.awt.event.MouseListener;
031:
032: import javax.swing.BoxLayout;
033: import javax.swing.ButtonGroup;
034: import javax.swing.JButton;
035: import javax.swing.JCheckBox;
036: import javax.swing.JComboBox;
037: import javax.swing.JFrame;
038: import javax.swing.JLabel;
039: import javax.swing.JOptionPane;
040: import javax.swing.JPanel;
041: import javax.swing.JRadioButton;
042: import javax.swing.JTextField;
043: import javax.swing.UIManager;
044:
045: import org.apache.lenya.config.core.FileConfiguration;
046: import org.apache.lenya.config.core.ContextEventQueue;
047: import org.apache.lenya.config.core.Parameter;
048:
049: /**
050: * A GUI tool to configure the Lenya build
051: */
052: public class ConfigureGUI {
053:
054: protected JFrame frame;
055: private JPanel contentPanel;
056: private JPanel checkBoxPanel;
057: private JPanel buttonPanel;
058: private JCheckBox[] checkBoxes;
059: private JLabel defaultValueLabel;
060: private JLabel localValueLabel;
061: private JLabel newLocalValueLabel;
062: private JLabel stepsLabel;
063: private JLabel paraValueLabel;
064: private JLabel warning1;
065: private JLabel warning2;
066: private JLabel saveMessage;
067: private JRadioButton radioButtonDefault;
068: private JRadioButton radioButtonLocal;
069: private JRadioButton radioButtonNewLocal;
070: private JTextField localValueTextField;
071: private JTextField defaultValueTextField;
072: private JTextField newLocalValueTextField;
073: private JTextField defaultValueCTextField;
074: private JTextField localValueCTextField;
075: private JComboBox newLocalValueComboBox;
076: private JButton cancelButton;
077: protected JButton backButton;
078: protected JButton nextButton;
079: private JButton saveButton;
080: private JButton yesButton;
081: private JButton noButton;
082: private JButton exitButton;
083: private Parameter[] params;
084: private Parameter[] tmpParams;
085: private Parameter[] tmpSubParams;
086: protected Parameter[] subParams;
087: private int steps = 0;
088: private String rootDir;
089: private SubParamsGUI spGui;
090: private FileConfiguration buildProperties;
091: protected FileConfiguration tmpBuildProperties;
092:
093: /**
094: * Main method which creates the GUI
095: *
096: * @param args
097: */
098: public static void main(String[] args) {
099:
100: System.out
101: .println("\nWelcome to the GUI to configure the building process of Apache Lenya");
102:
103: if (args.length != 1) {
104:
105: System.err
106: .println("No root dir specified (e.g. /home/USERNAME/src/lenya/trunk)!");
107: return;
108: }
109: String rootDir = args[0];
110:
111: new ConfigureGUI(rootDir);
112: }
113:
114: /**
115: * .ctor
116: *
117: * @param rootDir
118: */
119: public ConfigureGUI(String rootDir) {
120:
121: // pushes the eventQueue which will take care of copy/paste operations
122: Toolkit.getDefaultToolkit().getSystemEventQueue().push(
123: new ContextEventQueue());
124:
125: this .rootDir = rootDir;
126: System.out.println("Starting GUI ...");
127:
128: buildProperties = new BuildPropertiesConfiguration();
129: buildProperties.setFilenameDefault(rootDir
130: + "/build.properties");
131: buildProperties.setFilenameLocal(rootDir
132: + "/local.build.properties");
133:
134: buildProperties.read();
135: params = buildProperties.getConfigurableParameters();
136:
137: tmpBuildProperties = new BuildPropertiesConfiguration();
138: tmpBuildProperties.setFilenameDefault(rootDir
139: + "/build.properties");
140: tmpBuildProperties.setFilenameLocal(rootDir
141: + "/local.build.properties");
142: tmpBuildProperties.read();
143: tmpParams = tmpBuildProperties.getConfigurableParameters();
144: // Empty temporary local fields of temporary parameters
145: for (int k = 0; k < tmpParams.length; k++) {
146: tmpParams[k].setLocalValue("");
147: }
148:
149: JFrame.setDefaultLookAndFeelDecorated(true);
150: try {
151: UIManager.setLookAndFeel(UIManager
152: .getCrossPlatformLookAndFeelClassName());
153: } catch (Exception e) {
154: e.getMessage();
155: }
156:
157: frame = new JFrame("Apache Lenya Configuration");
158: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
159: frame.getContentPane().setLayout(
160: new FlowLayout(FlowLayout.LEFT));
161:
162: contentPanel = new JPanel();
163: checkBoxPanel = new JPanel();
164: buttonPanel = new JPanel();
165:
166: defaultValueLabel = new JLabel();
167: localValueLabel = new JLabel();
168: newLocalValueLabel = new JLabel();
169:
170: defaultValueTextField = new JTextField(20);
171: localValueTextField = new JTextField(20);
172: newLocalValueTextField = new JTextField(20);
173:
174: defaultValueCTextField = new JTextField();
175: localValueCTextField = new JTextField();
176: newLocalValueComboBox = new JComboBox();
177:
178: radioButtonDefault = new JRadioButton();
179: radioButtonLocal = new JRadioButton();
180: radioButtonNewLocal = new JRadioButton();
181: ButtonGroup g = new ButtonGroup();
182:
183: cancelButton = new JButton();
184: backButton = new JButton();
185: nextButton = new JButton();
186: saveButton = new JButton();
187: noButton = new JButton();
188: yesButton = new JButton();
189: exitButton = new JButton();
190:
191: warning1 = new JLabel();
192: warning2 = new JLabel();
193:
194: saveMessage = new JLabel();
195:
196: Container contentPane = frame.getContentPane();
197: contentPane.setLayout(new FlowLayout(FlowLayout.LEFT));
198:
199: contentPanel.setLayout(new GridBagLayout());
200: GridBagConstraints c = new GridBagConstraints();
201:
202: stepsLabel = new JLabel();
203: stepsLabel.setText("Parameters");
204: c.gridx = 0;
205: c.gridy = 0;
206: contentPanel.add(stepsLabel, c);
207:
208: checkBoxPanel = new JPanel();
209: checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel,
210: BoxLayout.Y_AXIS));
211: c.gridx = 0;
212: c.gridy = 1;
213: c.gridheight = 4;
214: c.ipadx = 20;
215: contentPanel.add(checkBoxPanel, c);
216:
217: checkBoxes = new JCheckBox[params.length];
218:
219: for (int i = 0; i < params.length; ++i) {
220: checkBoxes[i] = new JCheckBox();
221: checkBoxes[i].setEnabled(false);
222: checkBoxes[i].setText(params[i].getName());
223: checkBoxes[0].setSelected(true);
224: checkBoxPanel.add(checkBoxes[i]);
225: }
226:
227: c.gridx = 1;
228: c.gridy = 0;
229: c.gridwidth = 1;
230: c.gridheight = 1;
231: paraValueLabel = new JLabel(params[0].getName());
232: contentPanel.add(paraValueLabel, c);
233:
234: defaultValueLabel.setText("Default Value:");
235: contentPanel.add(defaultValueLabel, new GridBagConstraints(1,
236: 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
237: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
238: contentPanel.add(defaultValueTextField, new GridBagConstraints(
239: 2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
240: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
241: defaultValueTextField.setText(params[0].getDefaultValue());
242: defaultValueTextField.setEditable(false);
243: defaultValueTextField.addMouseListener(new MouseListener() {
244:
245: public void mouseClicked(MouseEvent event) {
246: radioButtonDefault.setSelected(true);
247: }
248:
249: public void mousePressed(MouseEvent event) {
250: }
251:
252: public void mouseReleased(MouseEvent event) {
253: }
254:
255: public void mouseEntered(MouseEvent event) {
256: }
257:
258: public void mouseExited(MouseEvent event) {
259: }
260: });
261:
262: contentPanel.add(radioButtonDefault, new GridBagConstraints(3,
263: 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
264: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
265: g.add(radioButtonDefault);
266:
267: localValueLabel.setText("Local Value:");
268: contentPanel.add(localValueLabel, new GridBagConstraints(1, 2,
269: 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
270: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
271: contentPanel.add(localValueTextField, new GridBagConstraints(2,
272: 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
273: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
274: localValueTextField.setText(params[0].getLocalValue());
275: localValueTextField.setEditable(false);
276: localValueTextField.addMouseListener(new MouseListener() {
277:
278: public void mouseClicked(MouseEvent event) {
279: }
280:
281: public void mousePressed(MouseEvent event) {
282: radioButtonLocal.setSelected(true);
283: }
284:
285: public void mouseReleased(MouseEvent event) {
286: }
287:
288: public void mouseEntered(MouseEvent event) {
289: }
290:
291: public void mouseExited(MouseEvent event) {
292: }
293: });
294:
295: contentPanel.add(radioButtonLocal, new GridBagConstraints(3, 2,
296: 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
297: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
298: g.add(radioButtonLocal);
299: radioButtonLocal.setSelected(true);
300:
301: newLocalValueLabel.setText("New Local Value:");
302: contentPanel.add(newLocalValueLabel, new GridBagConstraints(1,
303: 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
304: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
305: contentPanel.add(newLocalValueTextField,
306: new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0,
307: GridBagConstraints.CENTER,
308: GridBagConstraints.BOTH,
309: new Insets(0, 0, 0, 0), 0, 0));
310: newLocalValueTextField.addMouseListener(new MouseListener() {
311:
312: public void mouseClicked(MouseEvent event) {
313: }
314:
315: public void mousePressed(MouseEvent event) {
316: radioButtonNewLocal.setSelected(true);
317: }
318:
319: public void mouseEntered(MouseEvent event) {
320: }
321:
322: public void mouseExited(MouseEvent event) {
323: }
324:
325: public void mouseReleased(MouseEvent event) {
326: }
327: });
328:
329: contentPanel.add(radioButtonNewLocal, new GridBagConstraints(3,
330: 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
331: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
332: g.add(radioButtonNewLocal);
333:
334: buttonPanel = new JPanel();
335: buttonPanel.setLayout(new BoxLayout(buttonPanel,
336: BoxLayout.X_AXIS));
337:
338: cancelButton.setText("Cancel");
339: cancelButton.setPreferredSize(new java.awt.Dimension(74, 22));
340: cancelButton.addActionListener(new ActionListener() {
341:
342: public void actionPerformed(ActionEvent evt) {
343:
344: int n = JOptionPane.showConfirmDialog(contentPanel,
345: "Do you want to Exit?", "Exit...",
346: JOptionPane.YES_NO_OPTION,
347: JOptionPane.QUESTION_MESSAGE);
348:
349: if (n == JOptionPane.YES_OPTION) {
350: System.exit(0);
351: }
352: }
353: });
354:
355: backButton.setText("<Back");
356: backButton.setPreferredSize(new java.awt.Dimension(74, 22));
357: backButton.addActionListener(new ActionListener() {
358:
359: public void actionPerformed(ActionEvent e) {
360: backButton.setEnabled(true);
361: if (contentPanel.isVisible())
362: backButton.setEnabled(true);
363: if (getStep() != params.length) {
364: saveButton.setVisible(false);
365: }
366: moveBack();
367: }
368: });
369:
370: backButton.setEnabled(false);
371:
372: nextButton.setText("Next>");
373: nextButton.setPreferredSize(new java.awt.Dimension(74, 22));
374: nextButton.addActionListener(new ActionListener() {
375:
376: public void actionPerformed(ActionEvent e) {
377: backButton.setEnabled(true);
378: if (contentPanel.isVisible())
379: nextButton.setEnabled(true);
380: moveNext();
381: }
382: });
383:
384: buttonPanel.add(cancelButton);
385: buttonPanel.add(backButton);
386: buttonPanel.add(nextButton);
387:
388: contentPanel.add(buttonPanel, new GridBagConstraints(1, 4, 6,
389: 0, 0.0, 0.0, GridBagConstraints.CENTER,
390: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
391: contentPane.add(contentPanel);
392: contentPanel.revalidate();
393: frame.pack();
394: frame.setVisible(true);
395: }
396:
397: /**
398: * Controls behavior if back button is pressed
399: */
400: public void moveBack() {
401: steps--;
402: frame.repaint();
403: nextButton.setVisible(true);
404: checkFirst();
405: currentStep("down");
406: showNormalOptions();
407: comboBox();
408: checkLast();
409: newLocalValueTextField.setText(tmpParams[getStep()]
410: .getLocalValue());
411: setRadioButton();
412: }
413:
414: /**
415: * Controls behavior if next button is pressed
416: */
417: public void moveNext() {
418:
419: setLocalValue();
420: String[] av = params[getStep()].getAvailableValues();
421:
422: if (av != null) {
423:
424: String selectedComboBoxValue = "";
425: // Grab the correct value out of the combobox
426: if (radioButtonDefault.isSelected())
427: selectedComboBoxValue = defaultValueCTextField
428: .getText();
429: if (radioButtonLocal.isSelected())
430: selectedComboBoxValue = localValueCTextField.getText();
431: if (radioButtonNewLocal.isSelected())
432: selectedComboBoxValue = newLocalValueComboBox
433: .getSelectedItem().toString();
434:
435: subParams = params[getStep()].getSubsequentParameters(
436: selectedComboBoxValue, buildProperties);
437: tmpSubParams = params[getStep()].getSubsequentParameters(
438: selectedComboBoxValue, tmpBuildProperties);
439:
440: spGui = new SubParamsGUI(this , tmpSubParams, subParams,
441: selectedComboBoxValue);
442: }
443:
444: steps++;
445: frame.repaint();
446: checkFirst();
447: currentStep("up");
448: showNormalOptions();
449: comboBox();
450: checkLast();
451: newLocalValueTextField.setText(tmpParams[getStep()]
452: .getLocalValue());
453: setRadioButton();
454: }
455:
456: /**
457: * Set radio button
458: */
459: public void setRadioButton() {
460: if (tmpParams[getStep()].getLocalValue() != "") {
461: radioButtonNewLocal.setSelected(true);
462: } else if (params[getStep()].getLocalValue() != "") {
463: radioButtonLocal.setSelected(true);
464: } else {
465: radioButtonDefault.setSelected(true);
466: }
467: }
468:
469: /**
470: * Set local value depending on chosen value
471: */
472: public void setLocalValue() {
473: String[] av = params[getStep()].getAvailableValues();
474:
475: if (av == null) {
476: if (radioButtonDefault.isSelected()) {
477: tmpParams[getStep()]
478: .setLocalValue(defaultValueTextField.getText());
479: } else if (radioButtonLocal.isSelected()) {
480: tmpParams[getStep()].setLocalValue(localValueTextField
481: .getText());
482: } else if (radioButtonNewLocal.isSelected()) {
483: tmpParams[getStep()]
484: .setLocalValue(newLocalValueTextField.getText());
485: } else {
486: System.err.println("Fatal Error 0123456789!");
487: }
488: }
489: }
490:
491: /**
492: * Takes care about the steps progress (list on left side)
493: *
494: * @param direction
495: */
496: public void currentStep(String direction) {
497: if (direction.equals("up")) {
498: for (int i = 1; i <= getStep(); ++i) {
499: checkBoxes[i].setSelected(true);
500: }
501: }
502: if (direction.equals("down")) {
503: checkBoxes[getStep() + 1].setSelected(false);
504: }
505: }
506:
507: /**
508: * Checks if its first step and disables the back button
509: */
510: public void checkFirst() {
511:
512: if (getStep() == 0) {
513: backButton.setEnabled(false);
514: } else {
515: backButton.setEnabled(true);
516: }
517: }
518:
519: /**
520: * Checks if its last step and disables next button but adding a save button
521: */
522: public void checkLast() {
523: saveButton = new JButton("Save");
524:
525: warning1 = new JLabel(
526: "WARNING: Local configuration already exists!");
527: warning2 = new JLabel("Do you want to overwrite?");
528: if (getStep() == params.length - 1) {
529: nextButton.setEnabled(false);
530: nextButton.setVisible(false);
531:
532: buttonPanel.add(saveButton);
533: contentPanel.revalidate();
534:
535: saveButton.setPreferredSize(new java.awt.Dimension(74, 22));
536: saveButton.addActionListener(new ActionListener() {
537:
538: public void actionPerformed(ActionEvent e) {
539: setLocalValue();
540: showSaveScreen();
541: showWarningScreen();
542: }
543: });
544:
545: } else {
546: nextButton.setEnabled(true);
547: warning1.setVisible(false);
548: warning2.setVisible(false);
549:
550: if (spGui != null && spGui.subFrame.isVisible()) {
551: frame.setEnabled(false);
552: }
553: }
554: }
555:
556: /**
557: * Shows the normal options (paramaters)
558: */
559: public void showNormalOptions() {
560:
561: if (getStep() < params.length) {
562: defaultValueTextField.setText(params[getStep()]
563: .getDefaultValue());
564: localValueTextField.setText(params[getStep()]
565: .getLocalValue());
566: paraValueLabel.setText(params[getStep()].getName());
567: frame.pack();
568: }
569: }
570:
571: /**
572: * Shows the save screen
573: */
574: private void showSaveScreen() {
575:
576: paraValueLabel.setVisible(false);
577: defaultValueLabel.setVisible(false);
578: localValueLabel.setVisible(false);
579: newLocalValueLabel.setVisible(false);
580:
581: defaultValueTextField.setVisible(false);
582: localValueTextField.setVisible(false);
583: newLocalValueTextField.setVisible(false);
584:
585: radioButtonDefault.setVisible(false);
586: radioButtonLocal.setVisible(false);
587: radioButtonNewLocal.setVisible(false);
588: cancelButton.setVisible(false);
589: nextButton.setVisible(false);
590: backButton.setVisible(false);
591: saveButton.setVisible(false);
592:
593: yesButton.setVisible(true);
594: noButton.setVisible(true);
595:
596: warning1.setVisible(true);
597: warning2.setVisible(true);
598: }
599:
600: /**
601: * Shows the Warning screen
602: */
603: private void showWarningScreen() {
604: contentPanel.add(warning1, new GridBagConstraints(2, 1, 1, 1,
605: 0.0, 0.0, GridBagConstraints.CENTER,
606: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
607: contentPanel.add(warning2, new GridBagConstraints(2, 2, 1, 1,
608: 0.0, 0.0, GridBagConstraints.CENTER,
609: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
610: yesButton.setText("yes");
611: buttonPanel.add(yesButton);
612: yesButton.addActionListener(new ActionListener() {
613:
614: public void actionPerformed(ActionEvent e) {
615:
616: showYesScreen();
617:
618: }
619: });
620:
621: noButton.setText("no");
622: buttonPanel.add(noButton);
623: noButton.addActionListener(new ActionListener() {
624:
625: public void actionPerformed(ActionEvent e) {
626:
627: showNoScreen();
628:
629: }
630: });
631: }
632:
633: /**
634: * Screen if Yes is pressed
635: */
636: private void showYesScreen() {
637:
638: // TODO: Why doesn't it work with the reference only?
639: for (int k = 0; k < tmpParams.length; k++) {
640: tmpBuildProperties.setParameter(tmpParams[k]);
641: }
642: tmpBuildProperties.writeLocal();
643:
644: saveMessage.setText("Successful saved to: " + rootDir
645: + "/local.build.properties");
646: contentPanel.add(saveMessage, new GridBagConstraints(2, 2, 1,
647: 1, 0.0, 0.0, GridBagConstraints.SOUTH,
648: GridBagConstraints.PAGE_END, new Insets(0, 0, 0, 0), 0,
649: 0));
650: saveMessage.setVisible(true);
651:
652: yesButton.setVisible(false);
653: noButton.setVisible(false);
654: warning1.setVisible(false);
655: warning2.setVisible(false);
656: exitButton.setPreferredSize(new java.awt.Dimension(74, 22));
657: exitButton.setText("Exit");
658: contentPanel.add(exitButton, new GridBagConstraints(2, 3, 1, 1,
659: 0.0, 0.0, GridBagConstraints.SOUTH,
660: GridBagConstraints.PAGE_END, new Insets(0, 0, 0, 0), 0,
661: 0));
662: exitButton.addActionListener(new ActionListener() {
663:
664: public void actionPerformed(ActionEvent evt) {
665:
666: System.exit(0);
667: }
668: });
669:
670: contentPanel.revalidate();
671: contentPanel.repaint();
672: frame.pack();
673: }
674:
675: /**
676: * Screen if No is pressed
677: */
678: private void showNoScreen() {
679:
680: saveMessage.setVisible(false);
681: paraValueLabel.setVisible(true);
682: defaultValueLabel.setVisible(true);
683: localValueLabel.setVisible(true);
684: newLocalValueLabel.setVisible(true);
685: defaultValueTextField.setVisible(true);
686: localValueTextField.setVisible(true);
687: newLocalValueTextField.setVisible(true);
688:
689: radioButtonDefault.setVisible(true);
690: radioButtonLocal.setVisible(true);
691: radioButtonNewLocal.setVisible(true);
692: cancelButton.setVisible(true);
693: nextButton.setVisible(false);
694:
695: backButton.setVisible(true);
696: saveButton.setVisible(true);
697:
698: yesButton.setVisible(false);
699: noButton.setVisible(false);
700:
701: saveMessage.setVisible(false);
702: frame.pack();
703: }
704:
705: /**
706: * Method to create the Comboboxes
707: */
708: public void comboBox() {
709: String[] availableValues = params[getStep()]
710: .getAvailableValues();
711:
712: if (availableValues != null && availableValues.length > 0) {
713:
714: defaultValueTextField.setVisible(false);
715: localValueTextField.setVisible(false);
716: newLocalValueTextField.setVisible(false);
717:
718: // TODO: not nice solved, we need to exclude subParams without
719: // Values like WLS
720: String[] labels = new String[availableValues.length - 1];
721: for (int i = 0; i < availableValues.length; i++) {
722: if (availableValues[i].equals("WLS")) {
723: continue;
724: }
725: labels[i] = availableValues[i];
726: }
727:
728: defaultValueCTextField = new JTextField(params[getStep()]
729: .getDefaultValue());
730: defaultValueCTextField
731: .setPreferredSize(new java.awt.Dimension(204, 22));
732: defaultValueCTextField.setEditable(false);
733:
734: // MouseListener takes care to place radio button
735: defaultValueCTextField
736: .addMouseListener(new MouseListener() {
737:
738: public void mouseClicked(MouseEvent event) {
739: radioButtonDefault.setSelected(true);
740: }
741:
742: public void mousePressed(MouseEvent event) {
743: }
744:
745: public void mouseReleased(MouseEvent event) {
746: }
747:
748: public void mouseEntered(MouseEvent event) {
749: }
750:
751: public void mouseExited(MouseEvent event) {
752: }
753:
754: });
755: // ActionListener which looks what is selected in the Dropdown list
756: defaultValueCTextField
757: .addActionListener(new ActionListener() {
758:
759: public void actionPerformed(ActionEvent event) {
760: JComboBox cb = (JComboBox) event
761: .getSource();
762: tmpParams[getStep()].setLocalValue(cb
763: .getSelectedItem().toString());
764: subParams = params[getStep()]
765: .getSubsequentParameters(cb
766: .getSelectedItem()
767: .toString(),
768: tmpBuildProperties);
769: }
770: });
771:
772: contentPanel.add(defaultValueCTextField,
773: new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
774: GridBagConstraints.CENTER,
775: GridBagConstraints.BOTH, new Insets(0, 0,
776: 0, 0), 0, 0));
777:
778: localValueCTextField = new JTextField(params[getStep()]
779: .getLocalValue());
780: localValueCTextField
781: .setPreferredSize(new java.awt.Dimension(204, 22));
782: localValueCTextField.setEditable(false);
783:
784: localValueCTextField.addMouseListener(new MouseListener() {
785:
786: public void mouseClicked(MouseEvent event) {
787: radioButtonLocal.setSelected(true);
788: }
789:
790: public void mousePressed(MouseEvent event) {
791: }
792:
793: public void mouseReleased(MouseEvent event) {
794: }
795:
796: public void mouseEntered(MouseEvent event) {
797: }
798:
799: public void mouseExited(MouseEvent event) {
800: }
801: });
802: // ActionListener which looks what is selected in the Dropdown list
803: localValueCTextField
804: .addActionListener(new ActionListener() {
805:
806: public void actionPerformed(ActionEvent event) {
807: JComboBox cb = (JComboBox) event
808: .getSource();
809: tmpParams[getStep()].setLocalValue(cb
810: .getSelectedItem().toString());
811: subParams = params[getStep()]
812: .getSubsequentParameters(cb
813: .getSelectedItem()
814: .toString(),
815: tmpBuildProperties);
816: }
817: });
818: contentPanel.add(localValueCTextField,
819: new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
820: GridBagConstraints.CENTER,
821: GridBagConstraints.BOTH, new Insets(0, 0,
822: 0, 0), 0, 0));
823:
824: newLocalValueComboBox = new JComboBox(labels);
825: newLocalValueComboBox.setSelectedItem(tmpParams[getStep()]
826: .getLocalValue());
827:
828: newLocalValueComboBox.addMouseListener(new MouseListener() {
829:
830: public void mouseClicked(MouseEvent event) {
831: radioButtonNewLocal.setSelected(true);
832: }
833:
834: public void mousePressed(MouseEvent event) {
835: }
836:
837: public void mouseEntered(MouseEvent event) {
838: }
839:
840: public void mouseExited(MouseEvent event) {
841: }
842:
843: public void mouseReleased(MouseEvent event) {
844: }
845: });
846: // ActionListener which looks what is selected in the Dropdown list
847: newLocalValueComboBox
848: .addActionListener(new ActionListener() {
849:
850: public void actionPerformed(ActionEvent event) {
851: JComboBox cb = (JComboBox) event
852: .getSource();
853: tmpParams[getStep()].setLocalValue(cb
854: .getSelectedItem().toString());
855: subParams = params[getStep()]
856: .getSubsequentParameters(cb
857: .getSelectedItem()
858: .toString(),
859: tmpBuildProperties);
860: }
861: });
862: newLocalValueComboBox
863: .setMaximumRowCount(availableValues.length);
864: newLocalValueComboBox
865: .setPreferredSize(new java.awt.Dimension(204, 22));
866: contentPanel.add(newLocalValueComboBox,
867: new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0,
868: GridBagConstraints.CENTER,
869: GridBagConstraints.BOTH, new Insets(0, 0,
870: 0, 0), 0, 0));
871:
872: contentPanel.revalidate();
873: } else {
874: defaultValueCTextField.setVisible(false);
875: localValueCTextField.setVisible(false);
876: newLocalValueComboBox.setVisible(false);
877: defaultValueTextField.setVisible(true);
878: localValueTextField.setVisible(true);
879: newLocalValueTextField.setVisible(true);
880:
881: warning1.setVisible(false);
882: warning2.setVisible(false);
883: }
884: frame.pack();
885: }
886:
887: /**
888: * Returns the current step
889: *
890: * @return steps
891: */
892: public int getStep() {
893: return steps;
894: }
895: }
|