Changeset 20868


Ignore:
Timestamp:
2009-10-30T19:53:03+13:00 (13 years ago)
Author:
ak19
Message:

Fixed a bug that Diego Spano found: in the Settings dialog, the browser path for the Other Browser option was not getting saved previously.

File:
1 edited

Legend:

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

    r20866 r20868  
    1212import org.apache.log4j.*;
    1313
    14 public abstract class BaseServerSettings extends JDialog
     14public abstract class BaseServerSettings extends JDialog implements ActionListener
    1515{
    1616    static Logger logger = Logger.getLogger(BaseServerSettings.class.getName());
    1717    static final int DEFPORT = 8080;
    18 
    19     JCheckBox autoEnter;
     18    static final Color bg_color = Color.white;
     19
     20    protected JCheckBox autoEnter;
    2021
    2122    protected JSpinner portNumber_spinner = null;
     
    2526    protected JRadioButton other_browser_button = null;
    2627    protected Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    27 
    28     static final Color bg_color = Color.white;
    2928
    3029    protected int portNum = DEFPORT;
     
    125124        default_browser_button = new JRadioButton(BaseServer.dictionary.get("ServerSettings.DefaultBrowser"));
    126125        other_browser_button = new JRadioButton(BaseServer.dictionary.get("ServerSettings.OtherBrowser"));
    127         other_browser_button.addActionListener(new BrowserSelectionListener());
    128         default_browser_button.addActionListener(new BrowserSelectionListener());
     126    default_browser_button.addActionListener(this);
     127    other_browser_button.addActionListener(this);   
    129128
    130129    ButtonGroup bg = new ButtonGroup();
     
    157156        other_browser_button.setSelected(true);
    158157    }
    159         browse_button.addActionListener(new BrowseActionListener());       
     158    browse_button.addActionListener(this);
    160159       
    161160        JPanel down_panel = new JPanel();
     
    186185
    187186
    188     private class BrowseActionListener
    189     implements ActionListener {
    190    
    191     public void actionPerformed(ActionEvent ev) {
     187    public void actionPerformed(ActionEvent ev) {
     188    if(ev.getSource() == browse_button) {
    192189        JFileChooser chooser = new JFileChooser();
    193            int returnVal = chooser.showOpenDialog(self);       
    194        
     190        int returnVal = chooser.showOpenDialog(self);       
     191        
    195192        if(returnVal == JFileChooser.APPROVE_OPTION) {
    196                 File program_path = chooser.getSelectedFile();
     193        File program_path = chooser.getSelectedFile();
    197194        program_path_field.setText(program_path.getPath());
    198         }
    199     }
    200 
    201      }
    202 
    203     private class BrowserSelectionListener
    204     implements ActionListener {
    205    
    206     public void actionPerformed(ActionEvent ev) {
     195       }
     196    } else { // one of the two Choose Browser radiobuttons
    207197        if (default_browser_button.isSelected()){
    208198        program_path_field.setEnabled(false);
    209                 browse_button.setEnabled(false);
    210         }
    211             else{
     199        browse_button.setEnabled(false);
     200        }
     201        else{
    212202        program_path_field.setEnabled(true);
    213                 browse_button.setEnabled(true);
    214         }
    215     }
    216 
    217      }
     203        browse_button.setEnabled(true);
     204        }
     205    }       
     206    }
    218207   
    219208
     
    277266            browserPath = browserPath.replaceAll("\\\\","/");
    278267        }
    279         newFileLines = scriptReadWrite.queryReplace(newFileLines,BaseServer.Property.BROWSER_PATH, browserPath);
    280 
    281         scriptReadWrite.writeOutFile(BaseServer.config_properties_file,
    282                          newFileLines);
     268        newFileLines = scriptReadWrite.replaceOrAddLine(newFileLines, BaseServer.Property.BROWSER_PATH, browserPath, true);
     269
     270        scriptReadWrite.writeOutFile(BaseServer.config_properties_file, newFileLines);
     271
    283272        server.reloadConfigProperties();
    284273        server.reload(); // work out the URL again in case it has changed
Note: See TracChangeset for help on using the changeset viewer.