- Timestamp:
- 2009-09-17T16:24:39+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/server/Server2Settings.java
r20604 r20618 13 13 import org.greenstone.server.BaseServerSettings; 14 14 15 public class Server2Settings extends BaseServerSettings implements ActionListener15 public class Server2Settings extends BaseServerSettings 16 16 { 17 17 protected JComboBox prefix_combobox; … … 41 41 allowConnections = new JCheckBox(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".ExternalAccess"), allowCons); 42 42 allowConnections.setBackground(bg_color); 43 allowConnections.addActionListener(this);44 43 45 44 JPanel connect_panel = new JPanel(new GridLayout(4, 1)); 46 45 connect_panel.setBackground(bg_color); 47 connect_panel.setBorder(BorderFactory.createTitledBorder( "Connection configuration"));46 connect_panel.setBorder(BorderFactory.createTitledBorder(server.dictionary.get(BaseServer.Property.SERVER_SETTINGS+".AddressResolutionMethod"))); 48 47 49 48 hostRadioButtons = new JRadioButton[4]; … … 58 57 hostGroup.add(hostRadioButtons[i]); 59 58 hostRadioButtons[i].setBackground(bg_color); 60 hostRadioButtons[i].setEnabled(!allowCons); 61 } 62 59 } 63 60 64 61 String addressResolutionMethod = server.config_properties.getProperty("address_resolution_method").trim(); … … 114 111 115 112 // work out the host (default is address_resolution_method 2: localhost) 116 String host = "localhost"; 113 String hosts = "127.0.0.1 localhost"; 114 String fixedHostIP = "127.0.0.1"; 117 115 InetAddress inetAddress = null; 118 116 try { 119 117 inetAddress = InetAddress.getLocalHost(); 118 119 fixedHostIP = inetAddress.getHostAddress(); // used for all cases unless things go wrong 120 hosts = "127.0.0.1 " + fixedHostIP; // for address_resolution_methods 1 and 3 121 122 if(address_resolution_method == 2) { 123 hosts = hosts + " localhost"; 124 } else if(address_resolution_method == 0) { 125 hosts = hosts + " " + inetAddress.getHostName() + " localhost"; 126 } 120 127 } catch(UnknownHostException e) { 121 128 logger.error(e); 122 logger.info("Server2.java reload(): Defaulting host IP to "+ host); // use the default 129 logger.info("Server2.java reload(): Defaulting host IP to localhost"); 130 fixedHostIP = "127.0.0.1"; 123 131 address_resolution_method = 2; 132 hosts = "127.0.0.1 localhost"; 124 133 } 125 switch(address_resolution_method) { 126 case 0: 127 host = inetAddress.getHostName(); 128 break; 129 case 1: 130 host = inetAddress.getHostAddress(); 131 break; 132 case 3: 133 host = "127.0.0.1"; 134 break; 135 case 2: default: 136 host = "localhost"; 137 } 138 newFileLines = scriptReadWrite.queryReplace(newFileLines, "host", host); 134 135 newFileLines = scriptReadWrite.queryReplace(newFileLines, "hosts", hosts); 136 newFileLines = scriptReadWrite.queryReplace(newFileLines, "hostIP", fixedHostIP); 139 137 140 138 // address resolution method - onSave() would have updated … … 142 140 newFileLines = scriptReadWrite.queryReplace(newFileLines, "address_resolution_method", Integer.toString(address_resolution_method)); 143 141 144 } 145 146 public void actionPerformed(ActionEvent e) { 147 boolean toggle = !allowConnections.isSelected(); 148 if(e.getSource() == allowConnections) { 149 for(int i = 0; i < hostRadioButtons.length; i++) { 150 hostRadioButtons[i].setEnabled(toggle); 151 } 152 } 153 } 154 142 } 155 143 }
Note:
See TracChangeset
for help on using the changeset viewer.