KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > wminstaller > screens > ScreenWMSetup


1 package de.webman.wminstaller.screens;
2
3 import de.webman.wminstaller.app.*;
4 import javax.swing.*;
5 import java.awt.*;
6
7 /**
8  * Implementierung des Webman Setup (Ports, Webman-Instanznamen, etc.)
9  *
10  * @author <a HREF="mailto:ulf@webman.de">Ulf Goldammer</a>
11  * @version $Revision: 1.3 $
12  **/

13 public class ScreenWMSetup extends InstallerScreen
14 {
15     /* $Id: ScreenWMSetup.java,v 1.3 2002/03/08 14:39:54 gregor Exp $ */
16
17     final JPanel wmPanel = new JPanel();
18     
19     JComboBox optWMPort1 = null;
20     JTextField optWMPort2 = null;
21     JTextField optWMPort3 = null;
22     JTextField optWMWebAppName = null;
23     
24     private void addLine( String JavaDoc label, Component c) {
25         JPanel helper = new JPanel( new BorderLayout());
26         helper.add( c, BorderLayout.WEST);
27         wmPanel.add( new JLabel( label, javax.swing.SwingConstants.RIGHT));
28         wmPanel.add( helper);
29     }
30
31     public ScreenWMSetup( Installer wmi, int bt) {
32         
33         super( wmi, bt);
34         
35         wmPanel.setLayout( new GridLayout( 4, 2, 5, 8));
36         
37         String JavaDoc[] wmPort1 = {"80", "8080"};
38         optWMPort1 = new JComboBox(wmPort1);
39         optWMPort1.setEditable(true);
40         addLine("Webman-Port", optWMPort1);
41         
42         optWMPort2 = new JTextField("8007", 4);
43         optWMPort2.setEditable(false);
44         addLine("Hilfs-Port1", optWMPort2);
45         
46         optWMPort3 = new JTextField("8009", 4);
47         optWMPort3.setEditable(false);
48         addLine("Hilfs-Port2", optWMPort3);
49
50         optWMWebAppName = new JTextField("webman", 16);
51         optWMWebAppName.setEditable(true);
52         addLine("Instanzname", optWMWebAppName);
53         
54         
55         JPanel optionsPanel = new JPanel( new BorderLayout());
56         optionsPanel.add( wmPanel, BorderLayout.NORTH);
57         // optionsPanel.setBackground( Color.blue);
58
addScreen( "Auswahl der Webman-Ports", optionsPanel);
59     }
60     
61     public boolean storeValues() {
62         String JavaDoc port1 = (String JavaDoc)optWMPort1.getSelectedItem();
63         String JavaDoc port2 = optWMPort2.getText();
64         String JavaDoc port3 = optWMPort3.getText();
65         String JavaDoc webapp = optWMWebAppName.getText();
66
67         int port = 0;
68         boolean retv = true;
69         StringBuffer JavaDoc errmsgs = new StringBuffer JavaDoc();
70
71         try {
72             port = Integer.parseInt(port1);
73             if (port <= 0) {
74                 errmsgs.append("- kein oder unmöglicher Web-Port\n");
75                 retv = false;
76             }
77         }
78         catch (NumberFormatException JavaDoc nfe) {
79             errmsgs.append("- kein oder unmöglicher Web-Port\n");
80             retv = false;
81         }
82         
83
84         if (webapp == null || webapp.length() == 0) {
85             errmsgs.append("- kein Instanzname\n");
86             retv = false;
87         }
88         
89         if (!retv) {
90             Object JavaDoc[] options = {"Korregieren", "Abbrechen"};
91             int n = JOptionPane.showOptionDialog(wmPanel,
92                                                  "Einige Angaben waren falsch oder nicht\n" +
93                                                  "vollständig. Bitte überprüfen sie die\n" +
94                                                  "folgenden Felder:\n" + errmsgs.toString(),
95                                                  "Fehlerhafte Eingabe",
96                                                  JOptionPane.YES_NO_OPTION,
97                                                  JOptionPane.QUESTION_MESSAGE,
98                                                  null, //don't use a custom Icon
99
options, //the titles of buttons
100
options[0]); //default button title
101
switch (n) {
102             case JOptionPane.YES_OPTION:
103                 return false;
104             case JOptionPane.NO_OPTION:
105                 wmi.leave(-1);
106                 break;
107             }
108         }
109      
110         wmi.getDictionary().put(DictConstants.WEB_PORT, new Integer JavaDoc(port));
111         wmi.getDictionary().put(DictConstants.WEB_INSTANCE, webapp);
112         
113         return retv;
114     }
115
116     public void onEnter() {
117     }
118 }
119
Popular Tags