Ignore:
Timestamp:
2005-10-31T12:18:08+13:00 (18 years ago)
Author:
chi
Message:

The latest development of GAI when Chi leave 31/10/2005.

Location:
branches/ant-install-branch/gsdl3/src/java/org/greenstone/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ant-install-branch/gsdl3/src/java/org/greenstone/admin/GAI.java

    r9968 r10792  
    2525 *########################################################################
    2626 */
    27 
    2827// Graphical Adminstration Interface
    2928package org.greenstone.admin;
     
    4140import org.greenstone.admin.GAIManager;
    4241import org.greenstone.core.Configuration;
     42import org.greenstone.core.Dictionary;
    4343import org.greenstone.admin.gui.SetServerPane;
    4444
     
    5858    public static String admin_path;
    5959    public static String tomcat_file_path;
     60    public static String images_path;
    6061    public static File build_file;
     62    public static File site_conf;
     63    public static File interface_conf;
    6164    /** A public reference to the GAIManager. */
    6265    static public GAIManager ga_man;
     
    6770    this.admin_path = this.gsdl3_path + "/src/java/org/greenstone/admin/";
    6871    this.tomcat_file_path = this.gsdl3_path + "/comms/jakarta/tomcat/logs/";
     72    this.images_path = this.admin_path + "images/";
    6973        this.build_file = new File(gsdl3_path, "build.properties");
     74    this.site_conf = new File (gsdl3_path,"/web/sites/localsite/siteConfig.xml");
     75    this.interface_conf = new File (gsdl3_path, "/web/interfaces/default/interfaceConfig.xml");
     76    init();
    7077    }
    7178   
     
    7582    new Configuration (admin_path);
    7683    GAI gai = new GAI();
     84   
     85    ga_man  = new GAIManager(screen_size);
     86    ga_man.display();
     87    }
    7788
    78     /*Check if the user want to set up their own TOMCAT/MYSQL server
    79      * when they first time run GAI*/
    80     GAIFirstSettingFrame first_setting = new GAIFirstSettingFrame();
     89    public void init (){
     90    // Read Dictionary
     91    new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true));
     92
    8193    }
    8294}
     95
     96
  • branches/ant-install-branch/gsdl3/src/java/org/greenstone/admin/GAIManager.java

    r9968 r10792  
    5454    implements ActionListener, ChangeListener{
    5555   
    56     //private static final Dimension SIZE = new Dimension (800, 600);
    5756    private Dimension size = null;
    58     //public static String gsdl3_path = null;
    59    
    60     private JTabbedPane tab_pane = null;
    61 
    62     // Call the ConfPane
     57    // The ConfPane contains the configuration details of Greenstone III build and installation
    6358    public ConfPane conf_pane = null;
    64    
     59    // The LogPane contains the log details for Tomcat Server used by gsdl3
     60    public LogPane log_pane = null;
     61    // Not designed yet
    6562    public JPanel ext_pane = null;
     63    // Not designed yet
     64    public JPanel monitor_pane = null;
    6665       
    67     public JPanel monitor_pane = null;
    68    
    69     // Call the LogPane
    70     public LogPane log_pane = null;
    71    
    7266    static public ImageIcon CONF_ICON = null;
    7367    static public ImageIcon EXT_ICON = null;
     
    7771    // Create a menu bar in the main Pane
    7872    public MenuBar menu_bar = null;
    79     // Setting up the MenuItem
    80     public JMenu menu = null;
     73
     74    // HelpFrame
    8175   
    8276    private JPanel previous_pane = null;
    8377    private JPanel content_pane = null;
    84     //public static String admin_path = null;
     78    private JTabbedPane tab_pane = null;
     79
     80    /** A threaded tab changer to try and avoid NPE on exit. */
     81    private TabUpdater tab_updater = null;
    8582   
    8683    //Contructor
     
    8885    super();
    8986    this.size = size;
    90     this.setDefaultCloseOperation(EXIT_ON_CLOSE);
     87    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    9188    this.setTitle("GreenStone 3 Administration Tool");
    92    
    93     display();
    94     }
    95 
    96     //private createMenuEvent (){
    97 
    98     public void actionPerformed (ActionEvent event){
    99     Object esrc = event.getSource();
    100     // File Options
    101     if (esrc == menu_bar.file_exit){
    102         System.exit(1);
    103     }   
    104     //Edit Options
    105     //Help Options
    106     else if (esrc == menu_bar.help_conf){
    107     }
    108     else if (esrc == menu_bar.help_ext){
    109     }
    110     else if (esrc == menu_bar.help_monitor){
    111     }
    112     else if (esrc == menu_bar.help_log){
    113     }
    114     else if (esrc == menu_bar.help_about) {
    115     }
    116     }
    117 
    118     public void destory (){
    119     // Destroying create pane ensures the latest log has been closed
    120     //if (status_pane != null) {
    121     //}
    122     }
    123 
    124     // Listens to actions upon the menu bar
    125     private class MenuListenerImpl
    126     implements MenuListener {
    127 
    128     public void menuCanceled (MenuEvent e) {
    129     }
    130    
    131     public void menuDeselected (MenuEvent e){
    132     }
    133    
    134     public void menuSelected (MenuEvent e){
    135         if (e.getSource() == menu_bar.help){
    136         if (menu_bar.help.isSelected()){
    137             menu_bar.help.doClick(10);
    138         }
    139         }
    140     }
    141     }
    142 
    143     public void display(){
    144     CONF_ICON = new ImageIcon (GAI.admin_path+"images/properties24.gif");
    145     EXT_ICON = new ImageIcon (""); 
    146     MONITOR_ICON = new ImageIcon (GAI.admin_path+ "images/examine.gif");
    147     LOG_ICON = new ImageIcon (GAI.admin_path+"images/collection.gif");
    148    
     89    /* Add a focus listener to ourselves. Thus if we gain focus when a Modal Dialog should
     90     * instead have it, we can try to bring the modal dialog to the front*/
     91    //this.addFocusListener(new GAIGUIFocusListener());
     92    //display();
     93    }
     94
     95    private class GAIGUIFocusListener
     96    extends FocusAdapter {
     97    public void focusGained(FocusEvent e) {
     98        /*  if (ModalDialog.current_modal != null) {
     99        ModalDialog.current_modal.makeVisible();
     100        ModalDialog.current_modal.toFront();
     101        }*/
     102    }
     103    }
     104
     105   public void display(){
     106    CONF_ICON = new ImageIcon (GAI.images_path + "create.gif");
     107    EXT_ICON = new ImageIcon (GAI.images_path + "toolbarButtonGraphics/general/Information16.gif");
     108    MONITOR_ICON = new ImageIcon (GAI.images_path + "toolbarButtonGraphics/general/Zoom16.gif");
     109    LOG_ICON = new ImageIcon (GAI.images_path + "toolbarButtonGraphics/general/History16.gif");
    149110    content_pane = (JPanel) this.getContentPane();
    150111
    151112    try {
    152113        this.setSize(size);
    153 
    154114        //create a menuBar
    155         menu_bar = new MenuBar();
     115        menu_bar = new MenuBar(new MenuListenerImpl());
     116        this.setJMenuBar(menu_bar);
    156117       
    157         this.setJMenuBar(menu_bar);
    158118        //Create the tabbed pane and put it in the center
    159119        tab_pane = new JTabbedPane();
     
    202162    }
    203163
     164    /** Any implementation of <i>ActionListener</i> must include this method so that we can be informed
     165     *  when an action has occured. In this case we are listening to actions from the menu-bar, and should
     166     *  react appropriately.
     167     * @param event An <strong>ActionEvent</strong> containing information about the action that has occured.
     168     */
     169   
     170    public void actionPerformed (ActionEvent event){
     171    Object esrc = event.getSource();
     172    boolean project_conf_changed = false;
     173    boolean site_conf_changed = false;
     174    boolean interface_conf_changed = false;
     175    if (esrc == menu_bar.file_exit){
     176        project_conf_changed = conf_pane.ProjectConfChanged();
     177        site_conf_changed = conf_pane.site_conf.confChanged();
     178        interface_conf_changed = conf_pane.interface_conf.confChanged();
     179        /* Check if the Project and Site configuration files have been changed,
     180         * if changed, prompt to users if they want to save*/
     181        if (project_conf_changed || site_conf_changed || interface_conf_changed) {
     182        int result = JOptionPane.showConfirmDialog((Component) null, "The Configuration files have been changed, do you want to save the change", "Save Confirmation", JOptionPane.YES_NO_OPTION);
     183        if ( result == JOptionPane.YES_OPTION) {
     184            conf_pane.saveProjectConf(GAI.build_file);
     185            conf_pane.site_conf.saveFile(GAI.site_conf);
     186            conf_pane.interface_conf.saveFile(GAI.interface_conf);
     187        }
     188        }
     189        exit();
     190    }
     191    else if (esrc == menu_bar.file_save){
     192        /* sliently and Globally save Project and Site configuration*/
     193        project_conf_changed = conf_pane.ProjectConfChanged();
     194        site_conf_changed = conf_pane.site_conf.confChanged();
     195        interface_conf_changed = conf_pane.interface_conf.confChanged();
     196        if (project_conf_changed) {
     197        conf_pane.saveProjectConf(GAI.build_file);
     198        }
     199        if (site_conf_changed){
     200        conf_pane.site_conf.saveFile(GAI.site_conf);
     201        }
     202        if (interface_conf_changed) {
     203        conf_pane.interface_conf.saveFile(GAI.interface_conf);
     204        }
     205    }
     206    else if (esrc == menu_bar.help_conf){
     207    }
     208    else if (esrc == menu_bar.help_ext){
     209    }
     210    else if (esrc == menu_bar.help_monitor){
     211    }
     212    else if (esrc == menu_bar.help_log){
     213    }
     214    else if (esrc == menu_bar.help_about) {
     215    }
     216    }
     217   
     218   
     219    public void destory (){
     220    // Destroying create pane ensures the latest log has been closed
     221    //if (status_pane != null) {
     222    //}
     223    }
     224    /**Overridden from JFrame so we can exit safely when window is closed
     225     *(or destroyed). @param event A <strong>WindowEvent</strong> containing
     226     *information about the event that fired this call.
     227     */
     228    protected void processWindowEvent(WindowEvent event) {
     229    if(event.getID() == WindowEvent.WINDOW_CLOSING) {
     230        exit();
     231    }
     232    }
     233
     234
     235    /** Listens to actions upon the menu bar, and if it detects a click over
     236     *the help menu brings the help window to the front if it has become hidden.
     237     */
     238    private class MenuListenerImpl
     239    implements MenuListener {
     240    public void menuCanceled (MenuEvent e) {
     241    }
     242   
     243    public void menuDeselected (MenuEvent e){
     244    }
     245   
     246    public void menuSelected (MenuEvent e){
     247        if (e.getSource() == menu_bar.file_exit) {
     248        exit();
     249        }
     250     
     251        if (e.getSource() == menu_bar.help){
     252        if (menu_bar.help.isSelected()){
     253            menu_bar.help.doClick(10);
     254        }
     255        }
     256    }
     257    }
     258
     259
     260    /** This method ensures that all the things needing saving
     261     *  are saved before GAIManager.exit() is called.
     262     */
     263    public void exit() {
     264    System.exit(0);
     265    }
     266
     267
    204268    /** Any implementation of ChangeListener must include this method
    205269     **so we can be informed when the state of one of the registered
     
    223287    }
    224288   
    225     public void exit(){
    226     DebugStream.println("****exit called");
    227     System.exit(1);
    228     }
    229    
    230289    public void modeChanged (int mode){
    231290    if (log_pane != null){
     
    241300    if (log_pane != null ){
    242301    }
    243     //if (status_pane != null) {
    244     //}
    245302    }
    246303
     
    250307    }
    251308    }
     309    public void wait(boolean waiting) {
     310    Component glass_pane = getGlassPane();
     311    if(waiting) {
     312        // Show wait cursor.
     313        //glass_pane.addMouseListener(mouse_blocker_listener);
     314        glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     315        glass_pane.setVisible(true);
     316    }
     317    else {
     318        // Hide wait cursor.
     319        glass_pane.setVisible(false);
     320        glass_pane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     321        //glass_pane.removeMouseListener(mouse_blocker_listener);
     322    }
     323    glass_pane = null;
     324    }
     325
    252326    private class TabUpdater
    253327    implements Runnable {
     
    304378    }
    305379}
    306 
    307 
Note: See TracChangeset for help on using the changeset viewer.