1 package de.webman.wminstaller.screens; 2 3 import de.webman.wminstaller.app.*; 4 import javax.swing.*; 5 import java.awt.*; 6 7 13 public class ScreenWMSetup extends InstallerScreen 14 { 15 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 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 [] 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 addScreen( "Auswahl der Webman-Ports", optionsPanel); 59 } 60 61 public boolean storeValues() { 62 String port1 = (String )optWMPort1.getSelectedItem(); 63 String port2 = optWMPort2.getText(); 64 String port3 = optWMPort3.getText(); 65 String webapp = optWMWebAppName.getText(); 66 67 int port = 0; 68 boolean retv = true; 69 StringBuffer errmsgs = new StringBuffer (); 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 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 [] 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, options, options[0]); 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 (port)); 111 wmi.getDictionary().put(DictConstants.WEB_INSTANCE, webapp); 112 113 return retv; 114 } 115 116 public void onEnter() { 117 } 118 } 119 | Popular Tags |