Changeset 20908

Show
Ignore:
Timestamp:
04.11.2009 20:15:41 (10 years ago)
Author:
ak19
Message:

Updated to display the URL when the browser fails to launch (and also when it launches successfully). Most of the previous commit to BrowserLauncher?.java have been reverted now, and some additional changes have been made to it.

Location:
greenstone3/trunk/src/java/org/greenstone/server
Files:
3 modified

Legend:

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

    r20899 r20908  
    99import java.io.InputStreamReader; 
    1010import java.util.Properties; 
     11import javax.swing.JOptionPane; 
    1112 
    1213import org.apache.log4j.*; 
     
    184185 
    185186    public void launchBrowser() { 
    186         server_state_ = -1; 
     187    server_state_ = -1; 
    187188        server_control_.updateControl();    
     189    String url = getBrowserURL(); 
    188190        String message = dictionary.get("ServerControl.LaunchingBrowser"); 
    189191        server_control_.displayMessage(message);  
    190     String url = getBrowserURL(); 
    191192    //recordError("**** browserURL: " + url); 
    192     BrowserLauncher launcher = new BrowserLauncher(config_properties.getProperty(BaseServer.Property.BROWSER_PATH, ""), 
    193                                url, 
    194                                dictionary.get("ServerSettings.NoBrowserFound"), 
    195                                dictionary.get("ServerSettings.BrowserLaunchFailed")); 
     193    BrowserLauncher launcher = new BrowserLauncher(config_properties.getProperty(BaseServer.Property.BROWSER_PATH, ""), url); 
    196194        logger_.info(message); 
    197195 
     
    206204        logger_.error(e); 
    207205        } 
    208          }  
    209  
     206    } 
     207     
    210208    if (launcher.getBrowserState() != BrowserLauncher.LAUNCHSUCCESS ){ 
    211209        recordError(dictionary.get("ServerControl.LaunchBrowser"));  
    212         server_state_ = BROWSER_LAUNCH_FAILED;  
     210        server_state_ = BROWSER_LAUNCH_FAILED; 
    213211    } 
    214212    else{ 
  • greenstone3/trunk/src/java/org/greenstone/server/BaseServerControl.java

    r19792 r20908  
    7575        info_label.setVerticalAlignment(SwingConstants.CENTER); 
    7676        info_label.setFont(new Font("SansSerif",Font.PLAIN,14)); 
    77     info_label.setBorder(BorderFactory.createEmptyBorder(5,10,5,10));            
    78          
     77    info_label.setBorder(BorderFactory.createEmptyBorder(5,10,5,10)); 
     78             
    7979        JPanel button_panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); 
    8080    enter_button = new JButton(); 
     
    159159    case BaseServer.BROWSER_LAUNCHED: 
    160160        { 
    161         info_label.setText(stringToHTML(BaseServer.dictionary.get("ServerControl.Help_RestartLibrary"))); 
     161        info_label.setText(stringToHTML(BaseServer.dictionary.get("ServerControl.BrowserLaunched",new String[]{server.getBrowserURL()}) 
     162                        + BaseServer.dictionary.get("ServerControl.Help_RestartLibrary"))); 
    162163        enter_button.setText(stringToHTML(BaseServer.dictionary.get("ServerControl.RestartLibrary"))); 
    163164        thisframe.setState(Frame.ICONIFIED); 
     
    168169    case BaseServer.BROWSER_LAUNCH_FAILED: 
    169170        { 
    170         enter_button.setText(stringToHTML(BaseServer.dictionary.get("ServerControl.EnterLibrary") 
    171                           + "(URL: " + server.getBrowserURL() + ")")); 
     171        info_label.setText(stringToHTML(BaseServer.dictionary.get("ServerControl.BrowserLaunchFailed",new String[]{server.getBrowserURL()}))); 
     172        enter_button.setText(stringToHTML(BaseServer.dictionary.get("ServerControl.EnterLibrary"))); 
    172173        enter_button.setEnabled(true); 
    173174        fMenu.setEnabled(true); 
  • greenstone3/trunk/src/java/org/greenstone/server/BrowserLauncher.java

    r20899 r20908  
    11package org.greenstone.server; 
    22 
    3 import javax.swing.JOptionPane; 
    43import java.io.BufferedReader; 
    54import java.io.InputStream; 
     
    1110public class BrowserLauncher  
    1211    extends Thread { 
    13     private String browserNotFound; 
    14     private String browserLaunchFailed; 
    15      
    1612    private String url = "about:blank" ; 
    1713    static Logger logger = Logger.getLogger(org.greenstone.server.BrowserLauncher.class.getName()); 
     
    2319    private String browserPath = "";  
    2420 
    25     public BrowserLauncher(String browserPath, String url, String browserNotFound, String browserLaunchFailed) { 
     21    public BrowserLauncher(String browserPath, String url) { 
    2622    this.url = url; 
    27     this.browserNotFound = browserNotFound; 
    28     this.browserLaunchFailed = browserLaunchFailed; 
    2923        this.browserPath = browserPath; 
    3024        //use the default browser 
     
    9286        state = LAUNCHFAILED; 
    9387            logger.error("launching command is empty: no browser found."); 
    94         JOptionPane.showMessageDialog(null, browserNotFound, "Warning", JOptionPane.WARNING_MESSAGE); 
    9588        return; 
    9689    } 
     
    129122        logger.info("ExitCode:" + exitCode); 
    130123        if (exitCode != 0) { // if trying to launch the browser above failed 
    131         logger.info(browserLaunchFailed); 
    132         JOptionPane.showMessageDialog(null, browserLaunchFailed, "Warning", JOptionPane.WARNING_MESSAGE); 
     124        state = LAUNCHFAILED; 
     125        logger.error("Failed to launch web browser.");       
    133126        } 
    134127    }