Changeset 18667

Show
Ignore:
Timestamp:
13.03.2009 13:05:45 (10 years ago)
Author:
ak19
Message:

Removed duplicated code that is already there in the superclass (BaseServerSettings?)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/server/Server3Settings.java

    r18558 r18667  
    6666    comb_panel.add(servlet_label); 
    6767    comb_panel.add(servlet_combobox); 
    68     comb_panel.setBackground(bg_color); 
    6968 
    7069    return comb_panel; 
    7170    } 
    7271 
    73  
    74  
    75     private class BrowseActionListener  
    76     implements ActionListener { 
    77      
    78     public void actionPerformed(ActionEvent ev) { 
    79         JFileChooser chooser = new JFileChooser(); 
    80            int returnVal = chooser.showOpenDialog(self);         
    81         
    82         if(returnVal == JFileChooser.APPROVE_OPTION) { 
    83                 File program_path = chooser.getSelectedFile(); 
    84         program_path_field.setText(program_path.getPath()); 
    85         }  
    86     } 
    87  
    88      } 
    89  
    90     private class BrowserSelectionListener  
    91     implements ActionListener { 
    92      
    93     public void actionPerformed(ActionEvent ev) { 
    94         if (default_browser_button.isSelected()){ 
    95         program_path_field.setEnabled(false); 
    96                 browse_button.setEnabled(false); 
    97         } 
    98             else{ 
    99         program_path_field.setEnabled(true); 
    100                 browse_button.setEnabled(true); 
    101         } 
    102     } 
    103  
    104      } 
    105      
    106  
    107     private class SaveActionListener 
    108     implements ActionListener { 
    109      
    110     public void actionPerformed(ActionEvent ev) { 
    111         // save everything to build_properties if things have changed 
    112          boolean has_changed = false; 
    113              boolean require_restart = false; 
    114         if (portNum != ((Integer)portNumber_spinner.getValue()).intValue()) { 
    115         has_changed = true; 
    116                 require_restart = true;  
    117                 server.reconfigRequired(); 
    118                 portNum = ((Integer)portNumber_spinner.getValue()).intValue(); 
    119                 logger.info("port changed, new port is "+portNumber_spinner.getValue()); 
    120         } 
    121         if (autoStart != autoEnter.isSelected()) { 
    122                 has_changed = true; 
    123         } 
    124         if (!servletDefault.equals(servlet_combobox.getSelectedItem())) { 
    125             has_changed = true; 
    126                 require_restart = true;  
    127         } 
    128             //changed to use other browser 
    129             if (useDefaultBrowser && other_browser_button.isSelected()){ 
    130         browserPath = program_path_field.getText(); 
    131         has_changed = true; 
    132         }  
    133         //the browser path has been changed  
    134         if ( !useDefaultBrowser && !browserPath.equals(program_path_field.getText())){ 
    135         browserPath = program_path_field.getText(); 
    136          has_changed = true; 
    137         } 
    138          
    139             //changed to use the default browser 
    140         if ( default_browser_button.isSelected() && !useDefaultBrowser){ 
    141         browserPath = ""; 
    142         has_changed = true; 
    143         } 
    144               
    145  
    146         if (has_changed) { 
    147         ArrayList oldFileLines = null; 
    148         ArrayList newFileLines = null; 
    149          
    150         ScriptReadWrite scriptReadWrite = new ScriptReadWrite(); 
    151         oldFileLines = scriptReadWrite.readInFile(BaseServer.build_properties_file); 
    152          
    153         newFileLines = scriptReadWrite.queryReplace(oldFileLines, BaseServer.Property.WEB_PORT, portNum+""); 
    154          
    155         String newAutoEnter = (new Boolean(autoEnter.isSelected())).toString(); 
    156         newFileLines = scriptReadWrite.queryReplace(newFileLines, BaseServer.Property.AUTOSTART, newAutoEnter); 
    157          
    158         String newServletDef = (String) servlet_combobox.getSelectedItem(); 
    159         newFileLines = scriptReadWrite.queryReplace(newFileLines,BaseServer.Property.DEFAULT_SERVLET, (String) url_mappings.get(newServletDef)); 
    160  
    161         String osName = System.getProperty("os.name"); 
    162                 if (osName.startsWith("Windows")){ 
    163             browserPath = browserPath.replaceAll("\\\\","/"); 
    164         } 
    165                  newFileLines = scriptReadWrite.queryReplace(newFileLines,BaseServer.Property.BROWSER_PATH, browserPath); 
    166  
    167         scriptReadWrite.writeOutFile(BaseServer.build_properties_file, 
    168                          newFileLines); 
    169         server.reloadBuildProperties(); 
    170         if (require_restart){ 
    171             JOptionPane.showMessageDialog(null,server.dictionary.get("ServerSetting.SettingChanged"),"Info", JOptionPane.INFORMATION_MESSAGE); 
    172         } 
    173         }  
    174  
    175         self.dispose(); 
    176     } 
    177     } 
    178  
    17972}