Changeset 25162


Ignore:
Timestamp:
2012-03-01T09:47:58+13:00 (12 years ago)
Author:
sjm84
Message:

Refomatting this file ahead of some changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/admin/gui/ConfPane.java

    r24408 r25162  
    6464import org.greenstone.gsdl3.util.GSFile;
    6565
    66 /** The Configuration pane is to view the status of relevant configure files in GSIII
     66/**
     67 * The Configuration pane is to view the status of relevant configure files in
     68 * GSIII
     69 *
    6770 * @author Chi-Yu Huang, Greenstone Digital Library, University of Waikato
    6871 * @version
    6972 */
    70 public class ConfPane
    71     extends JPanel
    72     implements ActionListener {
    73 
    74     /* The pane to demonstrate Configuration information, including the build property file
    75      * being monitored and their content, and control functions */
    76     protected JSplitPane main_conf_pane = null;
    77    
    78     protected JPanel main_contentPane = null;
    79     public Hashtable conf_table;
    80    
    81     /** The panel that contains a Conf_list */
    82     private JPanel confList_pane =  null;
    83    
    84     /** The panel that contains the conf content. */
    85     private JPanel confContent_pane =  null;
    86     private JScrollPane conf_table_pane = null;
    87    
    88     /** The List showing all the Configuration files concerned. */
    89     private JList conf_list=null;
    90     private JTree conf_tree = null;
    91 
    92     /** The label at the top of the confList_pane. */
    93     private JLabel confList_label =  null;
    94     /** The label shown at the top of the confContent Pane. */
    95     private JLabel confContent_label  =  null;
    96 
    97     // The control buttons used to manipulate Configuration Pane
    98     protected JPanel inner_button_pane = null;
    99     protected JPanel inner_control_pane = null;
    100     protected JPanel tomcat_button_pane = null;
    101     protected JPanel mysql_button_pane = null;
    102     protected JPanel setting_shown_pane = null;
    103    
    104     /**Buttons in inner button pane */
    105     private JButton startup_tomcat_button = null;
    106     private JButton shutdown_tomcat_button = null;
    107     private JButton restart_tomcat_button = null;
    108     private JButton startup_mysql_button = null;
    109     private JButton shutdown_mysql_button = null;
    110     private JButton restart_mysql_button = null;
    111 
    112     private JButton save_button = null;
    113 
    114     private JLabel conf_label = null;
    115     private JLabel conf_setting_label = null;
    116    
    117     /* ConfPane empty AREA to show XML configuration file*/
    118     //private JTextArea conf_xml_area = null;
    119 
    120     //control tomcat and mysql server running status
    121     private String tomcat_server;
    122     private String tomcat_port;
    123     private String mysql_adminuser;
    124     private String mysql_server;
    125     private String mysql_port;
    126     private String conf_pane_name;
    127  
    128     private boolean tomcat_server_up = false;
    129     private boolean mysql_server_up = false;
    130 
    131     /** The scrollable area into which the configuration content is placed. */
    132     //private JScrollPane conf_xml_content = null;
    133    
    134     public SiteConfSetting site_conf = null;
    135     public SiteConfSetting interface_conf = null;
    136 
    137     /** The various sizes for the screen layout*/
    138     static private Dimension MIN_SIZE = new Dimension( 90,  90);
    139     static private Dimension LIST_SIZE  = new Dimension(200, 450);
    140     static private Dimension CONTENT_SIZE = new Dimension (600,450);
    141     static private Dimension TABLE_SIZE = new Dimension(500,200);
    142     static private int MINIMUM_TABLE_HEADER_SIZE = 15;
    143    
    144     private JTable conf_setting_table = null;
    145 
    146     private int num_of_setting;
    147 
    148     //The details display in the table
    149     int display_row_count = 5;
    150     int rowLength = 20;
    151     int colLength = 3;
    152     private Object[][] conf_display = new Object [rowLength][colLength];
    153     private Object[][] conf_setting;
    154    
    155     //An array to store all the details in the build.properties file
    156     private ArrayList conf_array;
    157    
    158     //Site configuration
    159     // TODO!! there are more than one site and interface - need to extend this
    160     public File site_conf_file = new File(GSFile.siteConfigFile(GSFile.siteHome(GAI.gsdl3_web_home, "localsite")));
    161     public File interface_conf_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GAI.gsdl3_web_home, "default")));
    162     public boolean  project_conf_changed = false;
    163 
    164     ConfSettingTableModel conf_table_model = null;
    165     DefaultMutableTreeNode top = new DefaultMutableTreeNode("Configuration Files");
    166     //Constructor
    167     public ConfPane() {
    168     conf_table = new Hashtable();
    169     // create all the control button panes
    170     inner_control_pane = new JPanel();
    171     inner_button_pane = new JPanel();
    172     tomcat_button_pane = new JPanel();
    173     mysql_button_pane = new JPanel();
    174    
    175     /*the class for showing the site configurations including
    176      * siteConfig.xml and interfaceConfig.xml
     73public class ConfPane extends JPanel implements ActionListener
     74{
     75
     76    /*
     77     * The pane to demonstrate Configuration information, including the build
     78     * property file being monitored and their content, and control functions
    17779     */
    178     site_conf = new SiteConfSetting("siteConfig", site_conf_file);
    179     interface_conf =  new SiteConfSetting("interfaceConfig", interface_conf_file);
    180    
    181     // Main Configuration Pane
    182     main_conf_pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    183         // Main pane for Configuration Content Pane
    184     main_contentPane = new JPanel();
    185    
    186     //Create a tree for a list Configuration files we are interested
    187     //DefaultMutableTreeNode child1 = new DefaultMutableTreeNode();
    188     DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Project Configuration");
    189 
    190     DefaultMutableTreeNode compile = new DefaultMutableTreeNode("Compile");
    191     DefaultMutableTreeNode tomcat = new DefaultMutableTreeNode("Tomcat");
    192     DefaultMutableTreeNode proxy = new DefaultMutableTreeNode("Proxy");
    193     DefaultMutableTreeNode mysql = new DefaultMutableTreeNode("MySQL");
    194     DefaultMutableTreeNode gsdl = new DefaultMutableTreeNode("GSDL");
    195     child1.add(compile);
    196     child1.add(tomcat);
    197     child1.add(proxy);
    198     child1.add(mysql);
    199     child1.add(gsdl);
    200 
    201     DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Site Configuration");
    202     //DefaultMutableTreeNode child2 = new DefaultMutableTreeNode();
    203     DefaultMutableTreeNode siteConf = new DefaultMutableTreeNode("SiteConfig");
    204     DefaultMutableTreeNode interfaceConf = new DefaultMutableTreeNode("InterfaceConfig");
    205     child2.add(siteConf);
    206     child2.add(interfaceConf);
    207 
    208     //DefaultMutableTreeNode child3 = new DefaultMutableTreeNode("Conf 3");
    209     top.add(child1);
    210     top.add(child2);
    211     //top.add(child3);
    212     conf_tree = new JTree(top);
    213     conf_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    214     conf_tree.addTreeSelectionListener(new ConfTreeListener());
    215 
    216     // inner button_pane Buttons
    217     StartupTomcatButtonListener stbl = new StartupTomcatButtonListener();
    218     ShutdownTomcatButtonListener stdbl = new ShutdownTomcatButtonListener();
    219     RestartTomcatButtonListener rtbl = new RestartTomcatButtonListener();
    220 
    221     StartupMysqlButtonListener smbl = new StartupMysqlButtonListener();
    222     ShutdownMysqlButtonListener smdbl = new ShutdownMysqlButtonListener();
    223     RestartMysqlButtonListener rmbl = new RestartMysqlButtonListener();
    224        
    225     ImageIcon startupTomcatButtonIcon = new ImageIcon(GAI.images_path + "redo.gif");
    226     ImageIcon shutdownTomcatButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
    227     ImageIcon restartTomcatButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
    228    
    229     ImageIcon startupMysqlButtonIcon = new ImageIcon(GAI.images_path + "redo.gif");
    230     ImageIcon shutdownMysqlButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
    231     ImageIcon restartMysqlButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
    232     ImageIcon saveButtonIcon = new ImageIcon(GAI.images_path  + "save.gif");
    233 
    234     startup_tomcat_button = new JButton(); 
    235     startup_tomcat_button.addActionListener(stbl);
    236     startup_tomcat_button.setMnemonic(KeyEvent.VK_S);
    237     startup_tomcat_button.setEnabled(false);
    238     startup_tomcat_button.setText(GAI.dictionary.get("ConfPane.Tomcat_Startup"));
    239     startup_tomcat_button.setToolTipText(GAI.dictionary.get("ConfPane.Tomcat_Startup_Tooltip"));
    240 
    241     shutdown_tomcat_button = new JButton();
    242     shutdown_tomcat_button.addActionListener(stdbl);
    243     shutdown_tomcat_button.setEnabled(false);
    244     shutdown_tomcat_button.setText(GAI.dictionary.get("ConfPane.Tomcat_Shutdown"));
    245     shutdown_tomcat_button.setToolTipText(GAI.dictionary.get("ConfPane.Tomcat_Shutdown_Tooltip"));
    246 
    247     restart_tomcat_button = new JButton();
    248     restart_tomcat_button.addActionListener(rtbl);
    249     restart_tomcat_button.setEnabled(false);
    250     restart_tomcat_button.setText(GAI.dictionary.get("ConfPane.Tomcat_Restart"));
    251     restart_tomcat_button.setToolTipText(GAI.dictionary.get("ConfPane.Tomcat_Restart_Tooltip"));
    252 
    253     startup_mysql_button = new JButton();
    254     startup_mysql_button.addActionListener(smbl);
    255     startup_mysql_button.setMnemonic(KeyEvent.VK_S);
    256     startup_mysql_button.setEnabled(false);
    257     startup_mysql_button.setText(GAI.dictionary.get("ConfPane.MySQL_Startup"));
    258     startup_mysql_button.setToolTipText(GAI.dictionary.get("ConfPane.MySQL_Startup_Tooltip"));
    259 
    260     shutdown_mysql_button = new JButton();
    261     shutdown_mysql_button.addActionListener(smdbl);
    262     shutdown_mysql_button.setEnabled(false);
    263     shutdown_mysql_button.setText(GAI.dictionary.get("ConfPane.MySQL_Shutdown"));
    264     shutdown_mysql_button.setToolTipText(GAI.dictionary.get("ConfPane.MySQL_Shutdown_Tooltip"));
    265    
    266     restart_mysql_button = new JButton();
    267     restart_mysql_button.addActionListener(rmbl);
    268     restart_mysql_button.setEnabled(false);
    269     restart_mysql_button.setText(GAI.dictionary.get("ConfPane.MySQL_Restart"));
    270     restart_mysql_button.setToolTipText(GAI.dictionary.get("ConfPane.MySQL_Restart_Tooltip"));
    271 
    272     //tomcat control buttons
    273     stbl = null;
    274     stdbl = null;
    275     rtbl = null;
    276    
    277     //mysql control button
    278     smbl = null;
    279     smdbl = null;
    280     rmbl = null;
    281    
    282     //read in build properties
    283     getConfContent();
    284     }
    285 
    286     /** Any implementation of ActionListener requires this method so that when an
    287      **action is performed the appropriate effect can occur.*/
    288     public void actionPerformed(ActionEvent event) {
    289     }
    290    
    291    
    292     /** This method is called to actually layout the components.*/
    293     public void display() {
    294     //Create Components.
    295     //KeyListenerImpl key_listener = new KeyListenerImpl();
    296     //MouseListenerImpl mouse_listener = new MouseListenerImpl();
    297     //this.addKeyListener(key_listener);
    298    
    299     //confList_Pane
    300     confList_pane = new JPanel();
    301     confList_pane.setBorder(BorderFactory.createLoweredBevelBorder());
    302     confList_pane.setPreferredSize(LIST_SIZE);
    303     confList_pane.setSize(LIST_SIZE);
    304     confList_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
    305     confList_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
    306    
    307     confList_label = new JLabel();
    308     confList_label.setOpaque(true);
    309     confList_label.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
    310     confList_label.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
    311     confList_label.setText(GAI.dictionary.get("ConfPane.Conf_List"));
    312 
    313     // confContent_Pane
    314     confContent_pane = new JPanel();
    315     confContent_pane.setBorder(BorderFactory.createEmptyBorder(10,20,10,20));
    316     confContent_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
    317     confContent_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
    318 
    319     confContent_label = new JLabel();
    320     confContent_label.setOpaque(true);
    321     confContent_label.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
    322     confContent_label.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
    323     confContent_label.setText(GAI.dictionary.get("ConfPane.Conf_Content"));
    324        
    325     conf_table_model = new ConfSettingTableModel();
    326     conf_setting_table = new JTable(conf_table_model){
    327         public String getToolTipText(MouseEvent e){
    328             String tip = null;
    329             Point p = e.getPoint();
    330             int rowIndex = rowAtPoint(p);
    331             int colIndex = columnAtPoint(p);
    332             int realColumnIndex = convertColumnIndexToModel(colIndex);
    333             if (realColumnIndex == 0){
    334             tip = conf_display[rowIndex][realColumnIndex].toString();
    335             } else {
    336             tip = super.getToolTipText(e);
    337             }
    338             return tip;
    339         }
    340         public Component prepareRenderer (TableCellRenderer renderer,
    341                           int rowIndex, int colIndex){
    342             Component c = super.prepareRenderer(renderer, rowIndex, colIndex);
    343             if (colIndex == 0) {
    344             c.setBackground(Configuration.getColor("coloring.table_noneditable_background"));
    345             } else {
    346             c.setBackground(Configuration.getColor("coloring.table_editable_background"));
    347             }
    348             return c;
    349         }
    350         };
    351    
    352     //When the MySQL and TOMCAT servers are still running and detect double-clicking occuring (editing mode)
    353     conf_setting_table.addMouseListener(new MouseAdapter(){
    354         public void mouseClicked(MouseEvent e){
    355             if (e.getClickCount() == 2){
    356             if (conf_pane_name.matches("MYSQL")){
    357                 mysql_server_up = false;
    358                 mysql_server_up = checkMysqlServer();
    359                 if (mysql_server_up) {
    360                 JOptionPane.showMessageDialog((Component) null,"MySQL is running, shutdown the MySQL server before making any changes");
    361                 }
    362             }
    363             if (conf_pane_name.matches("TOMCAT")){
    364                 tomcat_server_up = false;
    365                 tomcat_server_up = checkTomcatServer();
    366                 if (tomcat_server_up) {
    367                 JOptionPane.showMessageDialog((Component) null,"TOMCAT is running, shutdown the TOMCAT server before making any changes");
    368                 }
    369             }   
    370             }
    371         }
    372         });
    373     conf_setting_table.addKeyListener(new KeyAdapter(){
    374         public void keyPressed(KeyEvent ke){
    375             if (ke.getKeyCode() == KeyEvent.VK_F2){
    376             if (conf_pane_name.matches("MYSQL")){
    377                 mysql_server_up = checkMysqlServer();
    378                 if (mysql_server_up) {
    379                 JOptionPane.showMessageDialog((Component) null,"MySQL is running, shutdown the MySQL server before making any changes");
    380                 }
    381             }
    382             if (conf_pane_name.matches("TOMCAT")){
    383                 tomcat_server_up = checkTomcatServer();
    384                 if (tomcat_server_up) {
    385                 JOptionPane.showMessageDialog((Component) null,"TOMCAT is running, shutdown the TOMCAT server before making any changes");
    386                 }
    387             }
    388             }
    389         }
    390         });
    391    
    392     //Set up tableHeader
    393     JTableHeader table_header = conf_setting_table.getTableHeader();
    394     Dimension table_header_preferred_size = table_header.getPreferredSize();
    395     if (table_header_preferred_size.height < MINIMUM_TABLE_HEADER_SIZE) {
    396         table_header_preferred_size.setSize(table_header_preferred_size.width, MINIMUM_TABLE_HEADER_SIZE);
    397         table_header.setPreferredSize(table_header_preferred_size);
    398     }
    399 
    400     table_header.setFont(new Font("Arial", Font.BOLD, 13));
    401     conf_setting_table.setRowHeight(30);
    402     conf_table_pane = new JScrollPane(conf_setting_table);
    403     conf_table_pane.setVisible(false);
    404     conf_table_pane.getViewport().setBackground(Configuration.getColor("coloring.collection_tree_background"));
    405    
    406     // Layout Components
    407     confList_pane.setLayout(new BorderLayout());
    408     JScrollPane conf_treeView = new JScrollPane(conf_tree);
    409     confList_pane.add(conf_treeView, BorderLayout.CENTER);
    410     confList_pane.add(confList_label, BorderLayout.NORTH);
    411     confContent_pane.setLayout(new BorderLayout());
    412     confContent_pane.add(conf_table_pane, BorderLayout.CENTER);
    413    
    414     inner_button_pane.setLayout(new GridLayout(1,2));
    415     inner_control_pane.setLayout (new BorderLayout());
    416     inner_control_pane.setBorder(BorderFactory.createEmptyBorder(5,10,5,10));
    417     inner_control_pane.setPreferredSize(new Dimension(50,50));
    418     inner_control_pane.setSize(new Dimension(50,50));
    419     inner_control_pane.add (inner_button_pane, BorderLayout.CENTER);
    420    
    421     main_contentPane.setLayout (new BorderLayout());
    422     main_contentPane.add(confContent_label, BorderLayout.NORTH);
    423     main_contentPane.add(confContent_pane, BorderLayout.CENTER);
    424     main_contentPane.add(inner_control_pane, BorderLayout.SOUTH);
    425     main_conf_pane.add(confList_pane, JSplitPane.LEFT);
    426     main_conf_pane.add(main_contentPane, JSplitPane.RIGHT);
    427     main_conf_pane.setDividerLocation(LIST_SIZE.width - 10);
    428    
    429     this.setLayout(new BorderLayout());
    430     this.add(main_conf_pane, BorderLayout.CENTER);
    431     }
    432 
    433     public void save() {
    434     if (project_conf_changed) {
    435         saveProjectConf(GAI.build_properties_file);
    436     }
    437     if (site_conf.confChanged()){
    438         site_conf.saveFile(site_conf_file);
    439     }
    440     if (interface_conf.confChanged()) {
    441         interface_conf.saveFile(interface_conf_file);
    442     }
    443    
    444 
    445     }
    446    
    447     public boolean configurationChanged() {
    448     return (project_conf_changed || site_conf.confChanged() ||
    449         interface_conf.confChanged());
    450 
    451     }
    452 
    453     private class StartupTomcatButtonListener
    454     implements ActionListener {
    455     public void actionPerformed(ActionEvent event) {
    456         /*before startup Tomcat server, we want to make sure project and Site configuration
    457          * files are saved*/
    458         if (project_conf_changed) {
    459         saveProjectConf(GAI.build_properties_file);
    460         }
    461         /*boolean site_conf_changed = site_conf.confChanged();
    462         boolean interface_conf_changed=interface_conf.confChanged();
    463         if (site_conf_changed) {
    464         site_conf.saveFile(site_conf_file);
    465         }
    466         if (interface_conf_changed) {
    467         interface_conf.saveFile(interface_conf_file);
    468         }*/
    469         tomcat_server_up = checkTomcatServer();
    470         if (!tomcat_server_up) {
    471         ThreadControl threadControl = new ThreadControl();
    472         Runnable startupTomcatThread = threadControl.new startupTomcatServer("start-tomcat");
    473         new Thread(startupTomcatThread).start();
    474         threadControl.destroy();
    475         tomcat_server_up = true;
    476         JOptionPane.showMessageDialog((Component) null,"Tomcat server has been Startup successfully!"); 
    477         } else {
    478         JOptionPane.showMessageDialog((Component) null,"Tomcat server is running");
    479         }
    480         changeTomcatButtonPane1();
    481     }
    482     }
    483    
    484     private class ShutdownTomcatButtonListener
    485     implements ActionListener {
    486     public void actionPerformed(ActionEvent event) {
    487         tomcat_server_up = checkTomcatServer();
    488         if (tomcat_server_up){
    489         ThreadControl threadControl = new ThreadControl();
    490         Runnable shutdownTomcatThread = threadControl.new shutdownTomcatServer("stop-tomcat");
    491         new Thread(shutdownTomcatThread).start();
    492         threadControl.destroy();
    493         tomcat_server_up = false;
    494         JOptionPane.showMessageDialog((Component) null, "Tomcat server has been shutted down !");
    495         } else {
    496         JOptionPane.showMessageDialog((Component) null,"Tomcat server was not running!");
    497         }
    498         changeTomcatButtonPane2();
    499     }
    500     }
    501    
    502     private class RestartTomcatButtonListener
    503     implements ActionListener {
    504     public void actionPerformed(ActionEvent event) {
    505         //before we restart Tomcat server, we want to make sure the conf_pane settings are saved
    506         if (project_conf_changed) {
    507         saveProjectConf(GAI.build_properties_file);
    508         }
    509         /*boolean site_conf_changed = site_conf.confChanged();
    510         boolean interface_conf_changed=interface_conf.confChanged();
    511         if (site_conf_changed) {
    512         site_conf.saveFile(site_conf_file);
    513         }
    514         if (interface_conf_changed) {
    515         interface_conf.saveFile(interface_conf_file);
    516         }*/
    517         tomcat_server_up = checkTomcatServer();
    518         if (tomcat_server_up) {
    519         ThreadControl threadControl = new ThreadControl();
    520         Runnable restartTomcatThread = threadControl.new restartTomcatServer("restart-tomcat");
    521         new Thread(restartTomcatThread).start();
    522         threadControl.destroy();
    523         tomcat_server_up = true;
    524         JOptionPane.showMessageDialog((Component) null,"Tomcat server has been Restarted successfully!");
    525         } else {
    526         JOptionPane.showMessageDialog((Component) null,"Tomcat server was not running!");
    527         }
    528     }
    529     }
    530    
    531     private class StartupMysqlButtonListener
    532     implements ActionListener {
    533     public void actionPerformed(ActionEvent event) {
    534         //before we startup the MySQL server, we want to make sure the Conf_pane settings are saved
    535         saveProjectConf(GAI.build_properties_file);
    536         mysql_server_up = checkMysqlServer();
    537         if (!mysql_server_up) {
    538         ThreadControl threadControl = new ThreadControl();
    539         Runnable startupMysqlThread = threadControl.new startupMysqlServer("start-mysql");
    540         new Thread(startupMysqlThread).start();
    541         threadControl.destroy();
    542         mysql_server_up = true;
    543         JOptionPane.showMessageDialog((Component) null,"MYSQL server has been Startup successfully!"); 
    544         } else {
    545         JOptionPane.showMessageDialog((Component) null,"MYSQL server has been running");   
    546         }
    547         changeMysqlButtonPane1();
    548     }
    549     } 
    550    
    551     private class ShutdownMysqlButtonListener
    552     implements ActionListener {
    553     public void actionPerformed(ActionEvent event) {
    554         mysql_server_up = checkMysqlServer();
    555         if (mysql_server_up){
    556         ThreadControl threadControl = new ThreadControl();
    557         Runnable shutdownMysqlThread = threadControl.new shutdownMysqlServer("stop-mysql");
    558         new Thread(shutdownMysqlThread).start();
    559         threadControl.destroy();
    560         JOptionPane.showMessageDialog((Component) null,"MYSQL server has been Shutdown successfully !");
    561         mysql_server_up = false;
    562         } else {
    563         JOptionPane.showMessageDialog((Component) null,"MYSQL server was not running!");
    564         }
    565         changeMysqlButtonPane2();
    566     }
    567     }
    568    
    569     private class RestartMysqlButtonListener
    570     implements ActionListener {
    571     public void actionPerformed(ActionEvent event) {
    572         saveProjectConf(GAI.build_properties_file);
    573         mysql_server_up = checkMysqlServer();
    574         if (mysql_server_up) {
    575         ThreadControl threadControl = new ThreadControl();
    576         Runnable restartMysqlThread = threadControl.new restartMysqlServer("restart-mysql");
    577         new Thread(restartMysqlThread).start();
    578         threadControl.destroy();
    579         JOptionPane.showMessageDialog((Component) null,"MYSQL server has been Restarted successfully!"); 
    580         mysql_server_up = true;
    581         } else {
    582         JOptionPane.showMessageDialog((Component) null,"MYSQL server was not running!");
    583         }
    584     }
    585     }
    586 
    587     // Save the configuration file globally,when click File->Save or restart (or startup) Tomcat and MySQl server
    588     public void saveProjectConf(File file){
    589         String new_string;
    590     Enumeration keys = conf_table.keys();
    591     String key;
    592     String value;
    593     String filename = file.getPath();
    594     while (keys.hasMoreElements()) {
    595         key = (String) keys.nextElement();
    596         value = (String) conf_table.get(key);
    597         for (int j=0 ; j < conf_array.size(); j++){
    598         if (((String)conf_array.get(j)).startsWith(key.toLowerCase())){
    599             new_string = key+"="+value;
    600             conf_array.set(j, new_string.toLowerCase());
    601         }
    602         }
    603     }
    604 
    605     try {
    606         BufferedWriter conf_out = new BufferedWriter(new FileWriter(filename));
    607         for (int j=0 ; j < conf_array.size(); j++){
    608         conf_out.write(conf_array.get(j).toString());
    609         conf_out.newLine();
    610         }
    611         conf_out.close();
    612         getConfContent();
    613         project_conf_changed = false;
    614     } catch (Exception e) {
    615         e.printStackTrace();
    616     }
    617     }
    618 
    619     public boolean projectConfChanged() {
    620     return project_conf_changed;
    621     }
    622 
    623     public void getConfContent(){
    624     String filename = GAI.build_properties_file.getPath();
    625     if (!GAI.build_properties_file.exists()){
    626         JOptionPane.showMessageDialog((Component) null,"Build property file does not exist"); 
    627     } else {
    628         readProjectConf(filename);
    629     }
    630     }
    631    
    632     /* Read build.properties file
    633      * @param
    634      */
    635     public void readProjectConf (String filename) {
    636     String fileLine;
    637     /*inside the array will store, the conf_setting[i][0]:Comment,
    638      * conf_setting[i][1]:Para and conf_setting[i][2]:Value
    639      * conf_array[] store all the details from the build.properties*/
    640     conf_array = new ArrayList();
    641     conf_setting = new Object [rowLength][colLength];
    642     try {
    643         BufferedReader conf_in = new BufferedReader(new FileReader(filename));
    644         int i = 0;
    645         while ((fileLine = conf_in.readLine()) != null) {
    646         // This is an empty line
    647         if (fileLine.matches("^\\s*$")) {
    648             // Do Nothing
    649         } else if (fileLine.matches("##.+")){
    650             //This line shows the specific service for these conf setting
    651             conf_array.add(fileLine);
    652         } else  if (fileLine.matches("#.+")){
    653             //This line is Configuration Comment line
    654             conf_array.add(fileLine);
    655             conf_setting[i][0] = fileLine.substring(1); // use 1 to get rid of the # symbol.
    656         } else if (!fileLine.matches("#.+") && !fileLine.matches("^\\s*$") ){
    657             //This line is Setting line
    658             int end_index = fileLine.indexOf("=");
    659             conf_setting[i][1] = fileLine.substring(0,end_index).toUpperCase();
    660             conf_setting[i][2] = fileLine.substring(end_index+1);
    661             conf_table.put(conf_setting[i][1], conf_setting[i][2]);
    662             i++; //calculat the number of settings
    663             conf_array.add(fileLine);
    664         } else {
    665             // Wrong character in the line
    666         }
    667         }
    668         num_of_setting = i;
    669         for (int j=0; j<num_of_setting; j++){
    670         if (conf_setting[j][1].toString().matches("TOMCAT.SERVER")){
    671             tomcat_server = conf_setting[j][2].toString();
    672         }
    673         if (conf_setting[j][1].toString().matches("TOMCAT.PORT")){
    674             tomcat_port = conf_setting[j][2].toString();
    675         }
    676         if (conf_setting[j][1].toString().matches("MYSQL.ADMIN.USER")){
    677             mysql_adminuser = conf_setting[j][2].toString();
    678         }
    679         if (conf_setting[j][1].toString().matches("MYSQL.SERVER")){
    680             mysql_server = conf_setting[j][2].toString();
    681         }
    682         if (conf_setting[j][1].toString().matches("MYSQL.PORT")){
    683             mysql_port = conf_setting[j][2].toString();
    684         }   
    685         }
    686         conf_in.close();
    687     } catch (Exception e) {
    688         e.printStackTrace();
    689     }
    690     }
    691    
    692 
    693     public void clearTable (){
    694     for (int i=0; i< rowLength; i++){
    695         conf_display[i][0] = "";
    696         conf_display[i][1] = "";
    697         conf_display[i][2] = "";
    698     }
    699     }
    700 
    701     private boolean checkTomcatServer (){
    702     try {
    703         if (tomcat_server != "" && tomcat_port != ""){
    704         String http_string = "http://" + tomcat_server+":"+tomcat_port+"/";
    705         URL tomcatURL = new URL(http_string);
    706         HttpURLConnection tomcatConn = (HttpURLConnection) tomcatURL.openConnection();
    707         tomcatConn.connect();
    708         //necessary to get a Response, even if you don't care about contents
    709         InputStream connIn = tomcatConn.getInputStream();
    710         int pageStatus = tomcatConn.getResponseCode();
    711         if (pageStatus == HttpURLConnection.HTTP_NOT_FOUND) {//404 error
    712             //Tomcat is not running
    713             tomcat_server_up = false;
    714         } else {
    715             tomcat_server_up = true;
    716         } 
    717         } else {
    718         System.err.println("Either Tomcat server or Tomcat port was not set properly");
    719         }
    720     } catch (Exception ex) {
    721         tomcat_server_up = false;
    722         System.err.println(ex.getMessage());
    723     }
    724     return tomcat_server_up;
    725     }
    726    
    727     private boolean checkMysqlServer(){
    728     Connection conn = null;
    729     try {
    730         String mysql_userName ="gsdl3reader";
    731         String mysql_password = "";
    732         String mysql_url ="jdbc:mysql://"+mysql_server+":"+mysql_port+"/localsite_gs3mgdemo";
    733         //System.err.println("what is Mysql_URL:" + mysql_url);
    734         Class.forName("com.mysql.jdbc.Driver").newInstance();
    735         conn = DriverManager.getConnection(mysql_url, mysql_userName, mysql_password);
    736         if (conn == null) {
    737         mysql_server_up =false;
    738         } else {
    739         mysql_server_up = true;
    740         }
    741     } catch (Exception e) {
    742         mysql_server_up = false;
    743         System.err.println("Cannot connect to database server");
    744     }
    745     return mysql_server_up;
    746     }
    747    
    748     public class ConfSettingTableModel
    749     extends AbstractTableModel
    750     {
    751     String[] columnNames = {"Configuration Parameter",
    752     "Configuration Value"};
    753    
    754     public int getColumnCount(){
    755     return columnNames.length;
    756     }
    757    
    758     public int getRowCount() {
    759     return display_row_count;
    760     }
    761    
    762     public String getColumnName(int col){
    763        
    764         return columnNames[col];
    765     }
    766    
    767     public Object getValueAt(int row,int col){
    768         return conf_display[row][col+1];
    769     }
    770    
    771     public boolean isCellEditable(int row, int col){
    772         if (col==0){
    773         return false;
    774         } else if (conf_display[row][col].toString().matches("MYSQL.+")){
    775         mysql_server_up = checkMysqlServer();
    776         if (mysql_server_up) {
    777             return false;
    778         }
    779         } else if (conf_display[row][col].toString().matches("TOMCAT.+")){
    780         tomcat_server_up = checkTomcatServer();
    781         if (tomcat_server_up) {
    782            return false;
    783         }
    784         }
    785         return true;
    786     }
    787    
    788     public void setValueAt(Object value, int row, int col){
    789         if (!isCellEditable(row, col))
     80    protected JSplitPane main_conf_pane = null;
     81
     82    protected JPanel main_contentPane = null;
     83    public Hashtable conf_table;
     84
     85    /** The panel that contains a Conf_list */
     86    private JPanel confList_pane = null;
     87
     88    /** The panel that contains the conf content. */
     89    private JPanel confContent_pane = null;
     90    private JScrollPane conf_table_pane = null;
     91
     92    /** The List showing all the Configuration files concerned. */
     93    private JList conf_list = null;
     94    private JTree conf_tree = null;
     95
     96    /** The label at the top of the confList_pane. */
     97    private JLabel confList_label = null;
     98    /** The label shown at the top of the confContent Pane. */
     99    private JLabel confContent_label = null;
     100
     101    // The control buttons used to manipulate Configuration Pane
     102    protected JPanel inner_button_pane = null;
     103    protected JPanel inner_control_pane = null;
     104    protected JPanel tomcat_button_pane = null;
     105    protected JPanel mysql_button_pane = null;
     106    protected JPanel setting_shown_pane = null;
     107
     108    /** Buttons in inner button pane */
     109    private JButton startup_tomcat_button = null;
     110    private JButton shutdown_tomcat_button = null;
     111    private JButton restart_tomcat_button = null;
     112    private JButton startup_mysql_button = null;
     113    private JButton shutdown_mysql_button = null;
     114    private JButton restart_mysql_button = null;
     115
     116    private JButton save_button = null;
     117
     118    private JLabel conf_label = null;
     119    private JLabel conf_setting_label = null;
     120
     121    /* ConfPane empty AREA to show XML configuration file */
     122    //private JTextArea conf_xml_area = null;
     123
     124    //control tomcat and mysql server running status
     125    private String tomcat_server;
     126    private String tomcat_port;
     127    private String mysql_adminuser;
     128    private String mysql_server;
     129    private String mysql_port;
     130    private String conf_pane_name;
     131
     132    private boolean tomcat_server_up = false;
     133    private boolean mysql_server_up = false;
     134
     135    /** The scrollable area into which the configuration content is placed. */
     136    //private JScrollPane conf_xml_content = null;
     137
     138    public SiteConfSetting site_conf = null;
     139    public SiteConfSetting interface_conf = null;
     140
     141    /** The various sizes for the screen layout */
     142    static private Dimension MIN_SIZE = new Dimension(90, 90);
     143    static private Dimension LIST_SIZE = new Dimension(200, 450);
     144    static private Dimension CONTENT_SIZE = new Dimension(600, 450);
     145    static private Dimension TABLE_SIZE = new Dimension(500, 200);
     146    static private int MINIMUM_TABLE_HEADER_SIZE = 15;
     147
     148    private JTable conf_setting_table = null;
     149
     150    private int num_of_setting;
     151
     152    //The details display in the table
     153    int display_row_count = 5;
     154    int rowLength = 20;
     155    int colLength = 3;
     156    private Object[][] conf_display = new Object[rowLength][colLength];
     157    private Object[][] conf_setting;
     158
     159    //An array to store all the details in the build.properties file
     160    private ArrayList conf_array;
     161
     162    //Site configuration
     163    // TODO!! there are more than one site and interface - need to extend this
     164    public File site_conf_file = new File(GSFile.siteConfigFile(GSFile.siteHome(GAI.gsdl3_web_home, "localsite")));
     165    public File interface_conf_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GAI.gsdl3_web_home, "default")));
     166    public boolean project_conf_changed = false;
     167
     168    ConfSettingTableModel conf_table_model = null;
     169    DefaultMutableTreeNode top = new DefaultMutableTreeNode("Configuration Files");
     170
     171    //Constructor
     172    public ConfPane()
     173    {
     174        conf_table = new Hashtable();
     175        // create all the control button panes
     176        inner_control_pane = new JPanel();
     177        inner_button_pane = new JPanel();
     178        tomcat_button_pane = new JPanel();
     179        mysql_button_pane = new JPanel();
     180
     181        /*
     182         * the class for showing the site configurations including
     183         * siteConfig.xml and interfaceConfig.xml
     184         */
     185        site_conf = new SiteConfSetting("siteConfig", site_conf_file);
     186        interface_conf = new SiteConfSetting("interfaceConfig", interface_conf_file);
     187
     188        // Main Configuration Pane
     189        main_conf_pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     190        // Main pane for Configuration Content Pane
     191        main_contentPane = new JPanel();
     192
     193        //Create a tree for a list Configuration files we are interested
     194        //DefaultMutableTreeNode child1 = new DefaultMutableTreeNode();
     195        DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Project Configuration");
     196
     197        DefaultMutableTreeNode compile = new DefaultMutableTreeNode("Compile");
     198        DefaultMutableTreeNode tomcat = new DefaultMutableTreeNode("Tomcat");
     199        DefaultMutableTreeNode proxy = new DefaultMutableTreeNode("Proxy");
     200        DefaultMutableTreeNode mysql = new DefaultMutableTreeNode("MySQL");
     201        DefaultMutableTreeNode gsdl = new DefaultMutableTreeNode("GSDL");
     202        child1.add(compile);
     203        child1.add(tomcat);
     204        child1.add(proxy);
     205        child1.add(mysql);
     206        child1.add(gsdl);
     207
     208        DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Site Configuration");
     209        //DefaultMutableTreeNode child2 = new DefaultMutableTreeNode();
     210        DefaultMutableTreeNode siteConf = new DefaultMutableTreeNode("SiteConfig");
     211        DefaultMutableTreeNode interfaceConf = new DefaultMutableTreeNode("InterfaceConfig");
     212        child2.add(siteConf);
     213        child2.add(interfaceConf);
     214
     215        //DefaultMutableTreeNode child3 = new DefaultMutableTreeNode("Conf 3");
     216        top.add(child1);
     217        top.add(child2);
     218        //top.add(child3);
     219        conf_tree = new JTree(top);
     220        conf_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
     221        conf_tree.addTreeSelectionListener(new ConfTreeListener());
     222
     223        // inner button_pane Buttons
     224        StartupTomcatButtonListener stbl = new StartupTomcatButtonListener();
     225        ShutdownTomcatButtonListener stdbl = new ShutdownTomcatButtonListener();
     226        RestartTomcatButtonListener rtbl = new RestartTomcatButtonListener();
     227
     228        StartupMysqlButtonListener smbl = new StartupMysqlButtonListener();
     229        ShutdownMysqlButtonListener smdbl = new ShutdownMysqlButtonListener();
     230        RestartMysqlButtonListener rmbl = new RestartMysqlButtonListener();
     231
     232        ImageIcon startupTomcatButtonIcon = new ImageIcon(GAI.images_path + "redo.gif");
     233        ImageIcon shutdownTomcatButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
     234        ImageIcon restartTomcatButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
     235
     236        ImageIcon startupMysqlButtonIcon = new ImageIcon(GAI.images_path + "redo.gif");
     237        ImageIcon shutdownMysqlButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
     238        ImageIcon restartMysqlButtonIcon = new ImageIcon(GAI.images_path + "stop.gif");
     239        ImageIcon saveButtonIcon = new ImageIcon(GAI.images_path + "save.gif");
     240
     241        startup_tomcat_button = new JButton();
     242        startup_tomcat_button.addActionListener(stbl);
     243        startup_tomcat_button.setMnemonic(KeyEvent.VK_S);
     244        startup_tomcat_button.setEnabled(false);
     245        startup_tomcat_button.setText(GAI.dictionary.get("ConfPane.Tomcat_Startup"));
     246        startup_tomcat_button.setToolTipText(GAI.dictionary.get("ConfPane.Tomcat_Startup_Tooltip"));
     247
     248        shutdown_tomcat_button = new JButton();
     249        shutdown_tomcat_button.addActionListener(stdbl);
     250        shutdown_tomcat_button.setEnabled(false);
     251        shutdown_tomcat_button.setText(GAI.dictionary.get("ConfPane.Tomcat_Shutdown"));
     252        shutdown_tomcat_button.setToolTipText(GAI.dictionary.get("ConfPane.Tomcat_Shutdown_Tooltip"));
     253
     254        restart_tomcat_button = new JButton();
     255        restart_tomcat_button.addActionListener(rtbl);
     256        restart_tomcat_button.setEnabled(false);
     257        restart_tomcat_button.setText(GAI.dictionary.get("ConfPane.Tomcat_Restart"));
     258        restart_tomcat_button.setToolTipText(GAI.dictionary.get("ConfPane.Tomcat_Restart_Tooltip"));
     259
     260        startup_mysql_button = new JButton();
     261        startup_mysql_button.addActionListener(smbl);
     262        startup_mysql_button.setMnemonic(KeyEvent.VK_S);
     263        startup_mysql_button.setEnabled(false);
     264        startup_mysql_button.setText(GAI.dictionary.get("ConfPane.MySQL_Startup"));
     265        startup_mysql_button.setToolTipText(GAI.dictionary.get("ConfPane.MySQL_Startup_Tooltip"));
     266
     267        shutdown_mysql_button = new JButton();
     268        shutdown_mysql_button.addActionListener(smdbl);
     269        shutdown_mysql_button.setEnabled(false);
     270        shutdown_mysql_button.setText(GAI.dictionary.get("ConfPane.MySQL_Shutdown"));
     271        shutdown_mysql_button.setToolTipText(GAI.dictionary.get("ConfPane.MySQL_Shutdown_Tooltip"));
     272
     273        restart_mysql_button = new JButton();
     274        restart_mysql_button.addActionListener(rmbl);
     275        restart_mysql_button.setEnabled(false);
     276        restart_mysql_button.setText(GAI.dictionary.get("ConfPane.MySQL_Restart"));
     277        restart_mysql_button.setToolTipText(GAI.dictionary.get("ConfPane.MySQL_Restart_Tooltip"));
     278
     279        //tomcat control buttons
     280        stbl = null;
     281        stdbl = null;
     282        rtbl = null;
     283
     284        //mysql control button
     285        smbl = null;
     286        smdbl = null;
     287        rmbl = null;
     288
     289        //read in build properties
     290        getConfContent();
     291    }
     292
     293    /**
     294     * Any implementation of ActionListener requires this method so that when an
     295     * action is performed the appropriate effect can occur.
     296     */
     297    public void actionPerformed(ActionEvent event)
     298    {
     299    }
     300
     301    /** This method is called to actually layout the components. */
     302    public void display()
     303    {
     304        //Create Components.
     305        //KeyListenerImpl key_listener = new KeyListenerImpl();
     306        //MouseListenerImpl mouse_listener = new MouseListenerImpl();
     307        //this.addKeyListener(key_listener);
     308
     309        //confList_Pane
     310        confList_pane = new JPanel();
     311        confList_pane.setBorder(BorderFactory.createLoweredBevelBorder());
     312        confList_pane.setPreferredSize(LIST_SIZE);
     313        confList_pane.setSize(LIST_SIZE);
     314        confList_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
     315        confList_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
     316
     317        confList_label = new JLabel();
     318        confList_label.setOpaque(true);
     319        confList_label.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
     320        confList_label.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
     321        confList_label.setText(GAI.dictionary.get("ConfPane.Conf_List"));
     322
     323        // confContent_Pane
     324        confContent_pane = new JPanel();
     325        confContent_pane.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
     326        confContent_pane.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
     327        confContent_pane.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
     328
     329        confContent_label = new JLabel();
     330        confContent_label.setOpaque(true);
     331        confContent_label.setBackground(Configuration.getColor("coloring.workspace_selection_background"));
     332        confContent_label.setForeground(Configuration.getColor("coloring.workspace_selection_foreground"));
     333        confContent_label.setText(GAI.dictionary.get("ConfPane.Conf_Content"));
     334
     335        conf_table_model = new ConfSettingTableModel();
     336        conf_setting_table = new JTable(conf_table_model)
     337        {
     338            public String getToolTipText(MouseEvent e)
     339            {
     340                String tip = null;
     341                Point p = e.getPoint();
     342                int rowIndex = rowAtPoint(p);
     343                int colIndex = columnAtPoint(p);
     344                int realColumnIndex = convertColumnIndexToModel(colIndex);
     345                if (realColumnIndex == 0)
     346                {
     347                    tip = conf_display[rowIndex][realColumnIndex].toString();
     348                }
     349                else
     350                {
     351                    tip = super.getToolTipText(e);
     352                }
     353                return tip;
     354            }
     355
     356            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int colIndex)
     357            {
     358                Component c = super.prepareRenderer(renderer, rowIndex, colIndex);
     359                if (colIndex == 0)
     360                {
     361                    c.setBackground(Configuration.getColor("coloring.table_noneditable_background"));
     362                }
     363                else
     364                {
     365                    c.setBackground(Configuration.getColor("coloring.table_editable_background"));
     366                }
     367                return c;
     368            }
     369        };
     370
     371        //When the MySQL and TOMCAT servers are still running and detect double-clicking occuring (editing mode)
     372        conf_setting_table.addMouseListener(new MouseAdapter()
     373        {
     374            public void mouseClicked(MouseEvent e)
     375            {
     376                if (e.getClickCount() == 2)
     377                {
     378                    if (conf_pane_name.matches("MYSQL"))
     379                    {
     380                        mysql_server_up = false;
     381                        mysql_server_up = checkMysqlServer();
     382                        if (mysql_server_up)
     383                        {
     384                            JOptionPane.showMessageDialog((Component) null, "MySQL is running, shutdown the MySQL server before making any changes");
     385                        }
     386                    }
     387                    if (conf_pane_name.matches("TOMCAT"))
     388                    {
     389                        tomcat_server_up = false;
     390                        tomcat_server_up = checkTomcatServer();
     391                        if (tomcat_server_up)
     392                        {
     393                            JOptionPane.showMessageDialog((Component) null, "TOMCAT is running, shutdown the TOMCAT server before making any changes");
     394                        }
     395                    }
     396                }
     397            }
     398        });
     399        conf_setting_table.addKeyListener(new KeyAdapter()
     400        {
     401            public void keyPressed(KeyEvent ke)
     402            {
     403                if (ke.getKeyCode() == KeyEvent.VK_F2)
     404                {
     405                    if (conf_pane_name.matches("MYSQL"))
     406                    {
     407                        mysql_server_up = checkMysqlServer();
     408                        if (mysql_server_up)
     409                        {
     410                            JOptionPane.showMessageDialog((Component) null, "MySQL is running, shutdown the MySQL server before making any changes");
     411                        }
     412                    }
     413                    if (conf_pane_name.matches("TOMCAT"))
     414                    {
     415                        tomcat_server_up = checkTomcatServer();
     416                        if (tomcat_server_up)
     417                        {
     418                            JOptionPane.showMessageDialog((Component) null, "TOMCAT is running, shutdown the TOMCAT server before making any changes");
     419                        }
     420                    }
     421                }
     422            }
     423        });
     424
     425        //Set up tableHeader
     426        JTableHeader table_header = conf_setting_table.getTableHeader();
     427        Dimension table_header_preferred_size = table_header.getPreferredSize();
     428        if (table_header_preferred_size.height < MINIMUM_TABLE_HEADER_SIZE)
     429        {
     430            table_header_preferred_size.setSize(table_header_preferred_size.width, MINIMUM_TABLE_HEADER_SIZE);
     431            table_header.setPreferredSize(table_header_preferred_size);
     432        }
     433
     434        table_header.setFont(new Font("Arial", Font.BOLD, 13));
     435        conf_setting_table.setRowHeight(30);
     436        conf_table_pane = new JScrollPane(conf_setting_table);
     437        conf_table_pane.setVisible(false);
     438        conf_table_pane.getViewport().setBackground(Configuration.getColor("coloring.collection_tree_background"));
     439
     440        // Layout Components
     441        confList_pane.setLayout(new BorderLayout());
     442        JScrollPane conf_treeView = new JScrollPane(conf_tree);
     443        confList_pane.add(conf_treeView, BorderLayout.CENTER);
     444        confList_pane.add(confList_label, BorderLayout.NORTH);
     445        confContent_pane.setLayout(new BorderLayout());
     446        confContent_pane.add(conf_table_pane, BorderLayout.CENTER);
     447
     448        inner_button_pane.setLayout(new GridLayout(1, 2));
     449        inner_control_pane.setLayout(new BorderLayout());
     450        inner_control_pane.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
     451        inner_control_pane.setPreferredSize(new Dimension(50, 50));
     452        inner_control_pane.setSize(new Dimension(50, 50));
     453        inner_control_pane.add(inner_button_pane, BorderLayout.CENTER);
     454
     455        main_contentPane.setLayout(new BorderLayout());
     456        main_contentPane.add(confContent_label, BorderLayout.NORTH);
     457        main_contentPane.add(confContent_pane, BorderLayout.CENTER);
     458        main_contentPane.add(inner_control_pane, BorderLayout.SOUTH);
     459        main_conf_pane.add(confList_pane, JSplitPane.LEFT);
     460        main_conf_pane.add(main_contentPane, JSplitPane.RIGHT);
     461        main_conf_pane.setDividerLocation(LIST_SIZE.width - 10);
     462
     463        this.setLayout(new BorderLayout());
     464        this.add(main_conf_pane, BorderLayout.CENTER);
     465    }
     466
     467    public void save()
     468    {
     469        if (project_conf_changed)
     470        {
     471            saveProjectConf(GAI.build_properties_file);
     472        }
     473        if (site_conf.confChanged())
     474        {
     475            site_conf.saveFile(site_conf_file);
     476        }
     477        if (interface_conf.confChanged())
     478        {
     479            interface_conf.saveFile(interface_conf_file);
     480        }
     481
     482    }
     483
     484    public boolean configurationChanged()
     485    {
     486        return (project_conf_changed || site_conf.confChanged() || interface_conf.confChanged());
     487
     488    }
     489
     490    private class StartupTomcatButtonListener implements ActionListener
     491    {
     492        public void actionPerformed(ActionEvent event)
     493        {
     494            /*
     495             * before startup Tomcat server, we want to make sure project and
     496             * Site configuration files are saved
     497             */
     498            if (project_conf_changed)
     499            {
     500                saveProjectConf(GAI.build_properties_file);
     501            }
     502            /*
     503             * boolean site_conf_changed = site_conf.confChanged(); boolean
     504             * interface_conf_changed=interface_conf.confChanged(); if
     505             * (site_conf_changed) { site_conf.saveFile(site_conf_file); } if
     506             * (interface_conf_changed) {
     507             * interface_conf.saveFile(interface_conf_file); }
     508             */
     509            tomcat_server_up = checkTomcatServer();
     510            if (!tomcat_server_up)
     511            {
     512                ThreadControl threadControl = new ThreadControl();
     513                Runnable startupTomcatThread = threadControl.new startupTomcatServer("start-tomcat");
     514                new Thread(startupTomcatThread).start();
     515                threadControl.destroy();
     516                tomcat_server_up = true;
     517                JOptionPane.showMessageDialog((Component) null, "Tomcat server has been Startup successfully!");
     518            }
     519            else
     520            {
     521                JOptionPane.showMessageDialog((Component) null, "Tomcat server is running");
     522            }
     523            changeTomcatButtonPane1();
     524        }
     525    }
     526
     527    private class ShutdownTomcatButtonListener implements ActionListener
     528    {
     529        public void actionPerformed(ActionEvent event)
     530        {
     531            tomcat_server_up = checkTomcatServer();
     532            if (tomcat_server_up)
     533            {
     534                ThreadControl threadControl = new ThreadControl();
     535                Runnable shutdownTomcatThread = threadControl.new shutdownTomcatServer("stop-tomcat");
     536                new Thread(shutdownTomcatThread).start();
     537                threadControl.destroy();
     538                tomcat_server_up = false;
     539                JOptionPane.showMessageDialog((Component) null, "Tomcat server has been shutted down !");
     540            }
     541            else
     542            {
     543                JOptionPane.showMessageDialog((Component) null, "Tomcat server was not running!");
     544            }
     545            changeTomcatButtonPane2();
     546        }
     547    }
     548
     549    private class RestartTomcatButtonListener implements ActionListener
     550    {
     551        public void actionPerformed(ActionEvent event)
     552        {
     553            //before we restart Tomcat server, we want to make sure the conf_pane settings are saved
     554            if (project_conf_changed)
     555            {
     556                saveProjectConf(GAI.build_properties_file);
     557            }
     558            /*
     559             * boolean site_conf_changed = site_conf.confChanged(); boolean
     560             * interface_conf_changed=interface_conf.confChanged(); if
     561             * (site_conf_changed) { site_conf.saveFile(site_conf_file); } if
     562             * (interface_conf_changed) {
     563             * interface_conf.saveFile(interface_conf_file); }
     564             */
     565            tomcat_server_up = checkTomcatServer();
     566            if (tomcat_server_up)
     567            {
     568                ThreadControl threadControl = new ThreadControl();
     569                Runnable restartTomcatThread = threadControl.new restartTomcatServer("restart-tomcat");
     570                new Thread(restartTomcatThread).start();
     571                threadControl.destroy();
     572                tomcat_server_up = true;
     573                JOptionPane.showMessageDialog((Component) null, "Tomcat server has been Restarted successfully!");
     574            }
     575            else
     576            {
     577                JOptionPane.showMessageDialog((Component) null, "Tomcat server was not running!");
     578            }
     579        }
     580    }
     581
     582    private class StartupMysqlButtonListener implements ActionListener
     583    {
     584        public void actionPerformed(ActionEvent event)
     585        {
     586            //before we startup the MySQL server, we want to make sure the Conf_pane settings are saved
     587            saveProjectConf(GAI.build_properties_file);
     588            mysql_server_up = checkMysqlServer();
     589            if (!mysql_server_up)
     590            {
     591                ThreadControl threadControl = new ThreadControl();
     592                Runnable startupMysqlThread = threadControl.new startupMysqlServer("start-mysql");
     593                new Thread(startupMysqlThread).start();
     594                threadControl.destroy();
     595                mysql_server_up = true;
     596                JOptionPane.showMessageDialog((Component) null, "MYSQL server has been Startup successfully!");
     597            }
     598            else
     599            {
     600                JOptionPane.showMessageDialog((Component) null, "MYSQL server has been running");
     601            }
     602            changeMysqlButtonPane1();
     603        }
     604    }
     605
     606    private class ShutdownMysqlButtonListener implements ActionListener
     607    {
     608        public void actionPerformed(ActionEvent event)
     609        {
     610            mysql_server_up = checkMysqlServer();
     611            if (mysql_server_up)
     612            {
     613                ThreadControl threadControl = new ThreadControl();
     614                Runnable shutdownMysqlThread = threadControl.new shutdownMysqlServer("stop-mysql");
     615                new Thread(shutdownMysqlThread).start();
     616                threadControl.destroy();
     617                JOptionPane.showMessageDialog((Component) null, "MYSQL server has been Shutdown successfully !");
     618                mysql_server_up = false;
     619            }
     620            else
     621            {
     622                JOptionPane.showMessageDialog((Component) null, "MYSQL server was not running!");
     623            }
     624            changeMysqlButtonPane2();
     625        }
     626    }
     627
     628    private class RestartMysqlButtonListener implements ActionListener
     629    {
     630        public void actionPerformed(ActionEvent event)
     631        {
     632            saveProjectConf(GAI.build_properties_file);
     633            mysql_server_up = checkMysqlServer();
     634            if (mysql_server_up)
     635            {
     636                ThreadControl threadControl = new ThreadControl();
     637                Runnable restartMysqlThread = threadControl.new restartMysqlServer("restart-mysql");
     638                new Thread(restartMysqlThread).start();
     639                threadControl.destroy();
     640                JOptionPane.showMessageDialog((Component) null, "MYSQL server has been Restarted successfully!");
     641                mysql_server_up = true;
     642            }
     643            else
     644            {
     645                JOptionPane.showMessageDialog((Component) null, "MYSQL server was not running!");
     646            }
     647        }
     648    }
     649
     650    // Save the configuration file globally,when click File->Save or restart (or startup) Tomcat and MySQl server
     651    public void saveProjectConf(File file)
     652    {
     653        String new_string;
     654        Enumeration keys = conf_table.keys();
     655        String key;
     656        String value;
     657        String filename = file.getPath();
     658        while (keys.hasMoreElements())
     659        {
     660            key = (String) keys.nextElement();
     661            value = (String) conf_table.get(key);
     662            for (int j = 0; j < conf_array.size(); j++)
     663            {
     664                if (((String) conf_array.get(j)).startsWith(key.toLowerCase()))
     665                {
     666                    new_string = key + "=" + value;
     667                    conf_array.set(j, new_string.toLowerCase());
     668                }
     669            }
     670        }
     671
     672        try
     673        {
     674            BufferedWriter conf_out = new BufferedWriter(new FileWriter(filename));
     675            for (int j = 0; j < conf_array.size(); j++)
     676            {
     677                conf_out.write(conf_array.get(j).toString());
     678                conf_out.newLine();
     679            }
     680            conf_out.close();
     681            getConfContent();
     682            project_conf_changed = false;
     683        }
     684        catch (Exception e)
     685        {
     686            e.printStackTrace();
     687        }
     688    }
     689
     690    public boolean projectConfChanged()
     691    {
     692        return project_conf_changed;
     693    }
     694
     695    public void getConfContent()
     696    {
     697        String filename = GAI.build_properties_file.getPath();
     698        if (!GAI.build_properties_file.exists())
     699        {
     700            JOptionPane.showMessageDialog((Component) null, "Build property file does not exist");
     701        }
     702        else
     703        {
     704            readProjectConf(filename);
     705        }
     706    }
     707
     708    /*
     709     * Read build.properties file
     710     *
     711     * @param
     712     */
     713    public void readProjectConf(String filename)
     714    {
     715        String fileLine;
     716        /*
     717         * inside the array will store, the conf_setting[i][0]:Comment,
     718         * conf_setting[i][1]:Para and conf_setting[i][2]:Value conf_array[]
     719         * store all the details from the build.properties
     720         */
     721        conf_array = new ArrayList();
     722        conf_setting = new Object[rowLength][colLength];
     723        try
     724        {
     725            BufferedReader conf_in = new BufferedReader(new FileReader(filename));
     726            int i = 0;
     727            while ((fileLine = conf_in.readLine()) != null)
     728            {
     729                // This is an empty line
     730                if (fileLine.matches("^\\s*$"))
     731                {
     732                    // Do Nothing
     733                }
     734                else if (fileLine.matches("##.+"))
     735                {
     736                    //This line shows the specific service for these conf setting
     737                    conf_array.add(fileLine);
     738                }
     739                else if (fileLine.matches("#.+"))
     740                {
     741                    //This line is Configuration Comment line
     742                    conf_array.add(fileLine);
     743                    conf_setting[i][0] = fileLine.substring(1); // use 1 to get rid of the # symbol.
     744                }
     745                else if (!fileLine.matches("#.+") && !fileLine.matches("^\\s*$"))
     746                {
     747                    //This line is Setting line
     748                    int end_index = fileLine.indexOf("=");
     749                    conf_setting[i][1] = fileLine.substring(0, end_index).toUpperCase();
     750                    conf_setting[i][2] = fileLine.substring(end_index + 1);
     751                    conf_table.put(conf_setting[i][1], conf_setting[i][2]);
     752                    i++; //calculat the number of settings
     753                    conf_array.add(fileLine);
     754                }
     755                else
     756                {
     757                    // Wrong character in the line
     758                }
     759            }
     760            num_of_setting = i;
     761            for (int j = 0; j < num_of_setting; j++)
     762            {
     763                if (conf_setting[j][1].toString().matches("TOMCAT.SERVER"))
     764                {
     765                    tomcat_server = conf_setting[j][2].toString();
     766                }
     767                if (conf_setting[j][1].toString().matches("TOMCAT.PORT"))
     768                {
     769                    tomcat_port = conf_setting[j][2].toString();
     770                }
     771                if (conf_setting[j][1].toString().matches("MYSQL.ADMIN.USER"))
     772                {
     773                    mysql_adminuser = conf_setting[j][2].toString();
     774                }
     775                if (conf_setting[j][1].toString().matches("MYSQL.SERVER"))
     776                {
     777                    mysql_server = conf_setting[j][2].toString();
     778                }
     779                if (conf_setting[j][1].toString().matches("MYSQL.PORT"))
     780                {
     781                    mysql_port = conf_setting[j][2].toString();
     782                }
     783            }
     784            conf_in.close();
     785        }
     786        catch (Exception e)
     787        {
     788            e.printStackTrace();
     789        }
     790    }
     791
     792    public void clearTable()
     793    {
     794        for (int i = 0; i < rowLength; i++)
     795        {
     796            conf_display[i][0] = "";
     797            conf_display[i][1] = "";
     798            conf_display[i][2] = "";
     799        }
     800    }
     801
     802    private boolean checkTomcatServer()
     803    {
     804        try
     805        {
     806            if (tomcat_server != "" && tomcat_port != "")
     807            {
     808                String http_string = "http://" + tomcat_server + ":" + tomcat_port + "/";
     809                URL tomcatURL = new URL(http_string);
     810                HttpURLConnection tomcatConn = (HttpURLConnection) tomcatURL.openConnection();
     811                tomcatConn.connect();
     812                //necessary to get a Response, even if you don't care about contents
     813                InputStream connIn = tomcatConn.getInputStream();
     814                int pageStatus = tomcatConn.getResponseCode();
     815                if (pageStatus == HttpURLConnection.HTTP_NOT_FOUND)
     816                {//404 error
     817                    //Tomcat is not running
     818                    tomcat_server_up = false;
     819                }
     820                else
     821                {
     822                    tomcat_server_up = true;
     823                }
     824            }
     825            else
     826            {
     827                System.err.println("Either Tomcat server or Tomcat port was not set properly");
     828            }
     829        }
     830        catch (Exception ex)
     831        {
     832            tomcat_server_up = false;
     833            System.err.println(ex.getMessage());
     834        }
     835        return tomcat_server_up;
     836    }
     837
     838    private boolean checkMysqlServer()
     839    {
     840        Connection conn = null;
     841        try
     842        {
     843            String mysql_userName = "gsdl3reader";
     844            String mysql_password = "";
     845            String mysql_url = "jdbc:mysql://" + mysql_server + ":" + mysql_port + "/localsite_gs3mgdemo";
     846            //System.err.println("what is Mysql_URL:" + mysql_url);
     847            Class.forName("com.mysql.jdbc.Driver").newInstance();
     848            conn = DriverManager.getConnection(mysql_url, mysql_userName, mysql_password);
     849            if (conn == null)
     850            {
     851                mysql_server_up = false;
     852            }
     853            else
     854            {
     855                mysql_server_up = true;
     856            }
     857        }
     858        catch (Exception e)
     859        {
     860            mysql_server_up = false;
     861            System.err.println("Cannot connect to database server");
     862        }
     863        return mysql_server_up;
     864    }
     865
     866    public class ConfSettingTableModel extends AbstractTableModel
     867    {
     868        String[] columnNames = { "Configuration Parameter", "Configuration Value" };
     869
     870        public int getColumnCount()
     871        {
     872            return columnNames.length;
     873        }
     874
     875        public int getRowCount()
     876        {
     877            return display_row_count;
     878        }
     879
     880        public String getColumnName(int col)
     881        {
     882
     883            return columnNames[col];
     884        }
     885
     886        public Object getValueAt(int row, int col)
     887        {
     888            return conf_display[row][col + 1];
     889        }
     890
     891        public boolean isCellEditable(int row, int col)
     892        {
     893            if (col == 0)
     894            {
     895                return false;
     896            }
     897            else if (conf_display[row][col].toString().matches("MYSQL.+"))
     898            {
     899                mysql_server_up = checkMysqlServer();
     900                if (mysql_server_up)
     901                {
     902                    return false;
     903                }
     904            }
     905            else if (conf_display[row][col].toString().matches("TOMCAT.+"))
     906            {
     907                tomcat_server_up = checkTomcatServer();
     908                if (tomcat_server_up)
     909                {
     910                    return false;
     911                }
     912            }
     913            return true;
     914        }
     915
     916        public void setValueAt(Object value, int row, int col)
     917        {
     918            if (!isCellEditable(row, col))
     919                return;
     920            conf_display[row][col + 1] = value;
     921            project_conf_changed = true;
     922            //System.err.println("**ConfDisplay:" + conf_display[row][col].toString());
     923            conf_table.put(conf_display[row][col].toString(), value);
     924            fireTableCellUpdated(row, col + 1);
     925            updateUI();
     926        }
     927    }
     928
     929    public int showProjectConf(String conf_param)
     930    {
     931        conf_table_pane.setVisible(true);
     932        clearPrevConfPane();
     933        confContent_pane.add(conf_table_pane, BorderLayout.CENTER);
     934        confContent_pane.revalidate();
     935        clearTable();
     936        int j = 0;
     937        int row_count = 0;
     938        for (int i = 0; i < num_of_setting; i++)
     939        {
     940            if (conf_setting[i][1].toString().matches("^(" + conf_param + ").+"))
     941            {
     942                row_count = row_count + 1;
     943                conf_display[j][0] = conf_setting[i][0];
     944                conf_display[j][1] = conf_setting[i][1];
     945                conf_display[j][2] = conf_table.get(conf_setting[i][1]);
     946                j++;
     947            }
     948        }
     949        return row_count;
     950    }
     951
     952    public void displaySiteConf(SiteConfSetting site_conf_tmp)
     953    {
     954        clearPrevConfPane();
     955        confContent_pane.add(site_conf_tmp, BorderLayout.CENTER);
     956        try
     957        {
     958            site_conf_tmp.showText();
     959            site_conf_tmp.goTop();
     960            confContent_pane.revalidate();
     961        }
     962        catch (Exception e)
     963        {
     964            e.printStackTrace();
     965        }
     966    }
     967
     968    public void clearPrevConfPane()
     969    {
     970        confContent_pane.remove(conf_table_pane);
     971        confContent_pane.remove(site_conf);
     972        confContent_pane.remove(interface_conf);
     973    }
     974
     975    private class ConfTreeListener implements TreeSelectionListener
     976    {
     977        public void valueChanged(TreeSelectionEvent e)
     978        {
     979            String option = conf_tree.getLastSelectedPathComponent().toString();
     980            conf_table_pane.setVisible(true);
     981            if (option == "Compile")
     982            {
     983                conf_pane_name = "COMPILE";
     984                display_row_count = showProjectConf(conf_pane_name);
     985                inner_button_pane.removeAll();
     986                inner_button_pane.setLayout(new GridLayout(1, 3));
     987            }
     988            else if (option == "Tomcat")
     989            {
     990                conf_pane_name = "TOMCAT";
     991                display_row_count = showProjectConf(conf_pane_name);
     992                //Setup Tomcat button control pane
     993                inner_button_pane.removeAll();
     994                inner_button_pane.setLayout(new GridLayout(1, 3));
     995                if (checkTomcatServer())
     996                {
     997                    changeTomcatButtonPane1();
     998                }
     999                else
     1000                {
     1001                    changeTomcatButtonPane2();
     1002                }
     1003            }
     1004            else if (option == "Proxy")
     1005            {
     1006                conf_pane_name = "PROXY";
     1007                display_row_count = showProjectConf(conf_pane_name);
     1008                //Setup Proxy button control pane
     1009                inner_button_pane.removeAll();
     1010                inner_button_pane.setLayout(new GridLayout(1, 3));
     1011            }
     1012            else if (option == "MySQL")
     1013            {
     1014                conf_pane_name = "MYSQL";
     1015                display_row_count = showProjectConf(conf_pane_name);
     1016                // Setup MySQL button control pane
     1017                inner_button_pane.removeAll();
     1018                inner_button_pane.setLayout(new GridLayout(1, 3));
     1019                if (checkMysqlServer())
     1020                {
     1021                    changeMysqlButtonPane1();
     1022                }
     1023                else
     1024                {
     1025                    changeMysqlButtonPane2();
     1026                }
     1027            }
     1028            else if (option == "GSDL")
     1029            {
     1030                conf_pane_name = "GSDL";
     1031                display_row_count = showProjectConf(conf_pane_name);
     1032                inner_button_pane.removeAll();
     1033            }
     1034            else if (option == "SiteConfig")
     1035            {
     1036                conf_pane_name = "SiteConfig";
     1037                inner_button_pane.removeAll();
     1038                displaySiteConf(site_conf);
     1039            }
     1040            else if (option == "InterfaceConfig")
     1041            {
     1042                conf_pane_name = "InterfaceConfig";
     1043                inner_button_pane.removeAll();
     1044                displaySiteConf(interface_conf);
     1045            }
     1046            updateUI();
     1047        }
     1048    }
     1049
     1050    public void modeChanged(int mode)
     1051    {
    7901052        return;
    791         conf_display[row][col+1] = value;
    792         project_conf_changed = true;
    793         //System.err.println("**ConfDisplay:" + conf_display[row][col].toString());
    794         conf_table.put(conf_display[row][col].toString(), value);
    795         fireTableCellUpdated(row,col+1);
    796         updateUI();
    797     }
    798     }
    799 
    800     public int showProjectConf(String conf_param) {
    801     conf_table_pane.setVisible(true);
    802     clearPrevConfPane();
    803     confContent_pane.add(conf_table_pane, BorderLayout.CENTER);
    804     confContent_pane.revalidate(); 
    805     clearTable();
    806     int j=0;
    807     int row_count = 0;
    808     for (int i=0; i< num_of_setting; i++){
    809         if (conf_setting[i][1].toString().matches("^("+ conf_param +").+")) {
    810         row_count = row_count +1;
    811         conf_display[j][0] = conf_setting[i][0];
    812             conf_display[j][1] = conf_setting[i][1];
    813         conf_display[j][2] = conf_table.get(conf_setting[i][1]);
    814         j++;
    815         }
    816     }
    817     return row_count;
    818     }
    819      
    820     public void displaySiteConf(SiteConfSetting site_conf_tmp){
    821     clearPrevConfPane();
    822     confContent_pane.add(site_conf_tmp, BorderLayout.CENTER);
    823     try {
    824         site_conf_tmp.showText();
    825         site_conf_tmp.goTop();
    826         confContent_pane.revalidate();
    827     } catch (Exception e) {
    828         e.printStackTrace();
    829     }   
    830      }
    831    
    832     public void clearPrevConfPane() {
    833     confContent_pane.remove(conf_table_pane);
    834     confContent_pane.remove(site_conf);
    835     confContent_pane.remove(interface_conf);
    836     }
    837    
    838    
    839     private class ConfTreeListener implements TreeSelectionListener{
    840     public void valueChanged (TreeSelectionEvent e){
    841         String option = conf_tree.getLastSelectedPathComponent().toString();
    842         conf_table_pane.setVisible(true);
    843         if (option == "Compile"){
    844         conf_pane_name = "COMPILE";
    845         display_row_count = showProjectConf(conf_pane_name);
     1053    }
     1054
     1055    public void gainFocus()
     1056    {
     1057        return;
     1058    }
     1059
     1060    public void changeTomcatButtonPane1()
     1061    {
    8461062        inner_button_pane.removeAll();
    847         inner_button_pane.setLayout(new GridLayout(1,3));
    848         } else if (option == "Tomcat"){
    849         conf_pane_name ="TOMCAT";
    850         display_row_count = showProjectConf(conf_pane_name);
    851         //Setup Tomcat button control pane
     1063        inner_button_pane.setLayout(new GridLayout(1, 2));
     1064        inner_button_pane.add(restart_tomcat_button);
     1065        inner_button_pane.add(shutdown_tomcat_button);
     1066        restart_tomcat_button.setEnabled(true);
     1067        shutdown_tomcat_button.setEnabled(true);
     1068        updateUI();
     1069    }
     1070
     1071    public void changeTomcatButtonPane2()
     1072    {
    8521073        inner_button_pane.removeAll();
    853         inner_button_pane.setLayout(new GridLayout(1,3));
    854         if (checkTomcatServer()) {
    855             changeTomcatButtonPane1();
    856         } else {
    857             changeTomcatButtonPane2();
    858         }
    859         } else if (option =="Proxy"){
    860         conf_pane_name="PROXY";
    861         display_row_count = showProjectConf(conf_pane_name);
    862         //Setup Proxy button control pane
     1074        inner_button_pane.setLayout(new GridLayout(1, 2));
     1075        inner_button_pane.add(startup_tomcat_button);
     1076        inner_button_pane.add(shutdown_tomcat_button);
     1077        startup_tomcat_button.setEnabled(true);
     1078        shutdown_tomcat_button.setEnabled(false);
     1079        updateUI();
     1080    }
     1081
     1082    public void changeMysqlButtonPane1()
     1083    {
    8631084        inner_button_pane.removeAll();
    864         inner_button_pane.setLayout(new GridLayout(1,3));
    865         } else if (option == "MySQL"){
    866         conf_pane_name="MYSQL";
    867         display_row_count = showProjectConf(conf_pane_name);
    868         // Setup MySQL button control pane
     1085        inner_button_pane.setLayout(new GridLayout(1, 2));
     1086        inner_button_pane.add(restart_mysql_button);
     1087        inner_button_pane.add(shutdown_mysql_button);
     1088        restart_mysql_button.setEnabled(true);
     1089        shutdown_mysql_button.setEnabled(true);
     1090        updateUI();
     1091    }
     1092
     1093    public void changeMysqlButtonPane2()
     1094    {
    8691095        inner_button_pane.removeAll();
    870         inner_button_pane.setLayout(new GridLayout(1,3));
    871         if (checkMysqlServer()) {
    872             changeMysqlButtonPane1();
    873         } else {
    874             changeMysqlButtonPane2();
    875         }
    876         } else if (option == "GSDL"){
    877         conf_pane_name ="GSDL";
    878         display_row_count = showProjectConf(conf_pane_name);
    879         inner_button_pane.removeAll();
    880         } else if (option == "SiteConfig"){
    881         conf_pane_name = "SiteConfig";
    882         inner_button_pane.removeAll();
    883         displaySiteConf(site_conf);
    884         } else if (option == "InterfaceConfig") {
    885         conf_pane_name = "InterfaceConfig";
    886         inner_button_pane.removeAll();
    887         displaySiteConf(interface_conf);
    888         }
    889         updateUI();
    890     }
    891     }
    892 
    893     public void modeChanged (int mode){
    894     return;
    895     }
    896 
    897     public void gainFocus() {
    898     return;
    899     }
    900 
    901     public void changeTomcatButtonPane1 (){
    902     inner_button_pane.removeAll();
    903     inner_button_pane.setLayout(new GridLayout(1,2));
    904     inner_button_pane.add(restart_tomcat_button);
    905     inner_button_pane.add(shutdown_tomcat_button);
    906     restart_tomcat_button.setEnabled (true);
    907     shutdown_tomcat_button.setEnabled (true);
    908     updateUI();
    909     }
    910     public void changeTomcatButtonPane2 (){
    911     inner_button_pane.removeAll();
    912     inner_button_pane.setLayout(new GridLayout(1,2));
    913     inner_button_pane.add(startup_tomcat_button);
    914     inner_button_pane.add(shutdown_tomcat_button);
    915     startup_tomcat_button.setEnabled (true);
    916     shutdown_tomcat_button.setEnabled (false);
    917     updateUI();
    918     }   
    919     public void changeMysqlButtonPane1 (){
    920     inner_button_pane.removeAll();
    921     inner_button_pane.setLayout(new GridLayout(1,2));
    922     inner_button_pane.add(restart_mysql_button);
    923     inner_button_pane.add(shutdown_mysql_button);
    924     restart_mysql_button.setEnabled (true);
    925     shutdown_mysql_button.setEnabled (true);
    926     updateUI();
    927     }
    928     public void changeMysqlButtonPane2 (){
    929     inner_button_pane.removeAll();
    930     inner_button_pane.setLayout(new GridLayout(1,2));
    931     inner_button_pane.add(startup_mysql_button);
    932     inner_button_pane.add(shutdown_mysql_button);
    933     startup_mysql_button.setEnabled (true);
    934     shutdown_mysql_button.setEnabled (false);
    935     updateUI();
    936     }   
    937     public void afterDisplay(){
    938     return;
    939     }
    940 }
    941 
     1096        inner_button_pane.setLayout(new GridLayout(1, 2));
     1097        inner_button_pane.add(startup_mysql_button);
     1098        inner_button_pane.add(shutdown_mysql_button);
     1099        startup_mysql_button.setEnabled(true);
     1100        shutdown_mysql_button.setEnabled(false);
     1101        updateUI();
     1102    }
     1103
     1104    public void afterDisplay()
     1105    {
     1106        return;
     1107    }
     1108}
Note: See TracChangeset for help on using the changeset viewer.