- Timestamp:
- 2013-07-30T12:07:00+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/admin/gui/ConfPane.java
r25635 r27941 38 38 package org.greenstone.admin.gui; 39 39 40 import java.awt.*; 41 import java.awt.event.*; 42 import java.io.*; 43 import java.util.List; 40 import java.awt.BorderLayout; 41 import java.awt.Component; 42 import java.awt.Dimension; 43 import java.awt.Font; 44 import java.awt.GridLayout; 45 import java.awt.Point; 46 import java.awt.event.ActionEvent; 47 import java.awt.event.ActionListener; 48 import java.awt.event.KeyAdapter; 49 import java.awt.event.KeyEvent; 50 import java.awt.event.MouseAdapter; 51 import java.awt.event.MouseEvent; 52 import java.io.BufferedReader; 53 import java.io.BufferedWriter; 54 import java.io.File; 55 import java.io.FileReader; 56 import java.io.FileWriter; 57 import java.io.InputStream; 58 import java.net.HttpURLConnection; 59 import java.net.URL; 60 import java.sql.Connection; 61 import java.sql.DriverManager; 44 62 import java.util.ArrayList; 63 import java.util.Enumeration; 64 import java.util.HashMap; 45 65 import java.util.Hashtable; 46 import java.util.Enumeration; 47 import java.lang.Object; 48 import javax.swing.*; 49 import javax.swing.event.*; 50 import javax.swing.tree.*; 51 import javax.swing.table.*; 52 import java.awt.event.MouseEvent; 53 import java.net.*; 54 import java.sql.*; 66 67 import javax.swing.BorderFactory; 68 import javax.swing.ImageIcon; 69 import javax.swing.JButton; 70 import javax.swing.JLabel; 71 import javax.swing.JList; 72 import javax.swing.JOptionPane; 73 import javax.swing.JPanel; 74 import javax.swing.JScrollPane; 75 import javax.swing.JSplitPane; 76 import javax.swing.JTable; 77 import javax.swing.JTree; 78 import javax.swing.event.TreeSelectionEvent; 79 import javax.swing.event.TreeSelectionListener; 80 import javax.swing.table.AbstractTableModel; 81 import javax.swing.table.JTableHeader; 82 import javax.swing.table.TableCellRenderer; 83 import javax.swing.tree.DefaultMutableTreeNode; 84 import javax.swing.tree.TreeSelectionModel; 55 85 56 86 import org.greenstone.admin.GAI; 57 import org.greenstone.admin.GAIManager; 58 import org.greenstone.admin.gui.ThreadControl; 59 //import org.greenstone.admin.gui.ConfSettingTableModel; 60 import org.greenstone.admin.gui.SiteConfSetting; 61 import org.greenstone.admin.gui.ParsingProgress; 62 87 import org.greenstone.gsdl3.util.GSFile; 63 88 import org.greenstone.util.Configuration; 64 import org.greenstone.gsdl3.util.GSFile;65 89 66 90 /** … … 148 172 private JTable conf_setting_table = null; 149 173 150 private int num_of_setting;151 152 174 //The details display in the table 153 175 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; 176 //int rowLength = 20; 177 //int colLength = 3; 178 //private Object[][] conf_display = new Object[rowLength][colLength]; 179 //private Object[][] conf_setting; 180 181 private final String ONE = "1"; 182 private final String TWO = "2"; 183 private final String THREE = "3"; 184 185 private ArrayList<ArrayList<Object>> conf_display = new ArrayList<ArrayList<Object>>(); 186 private ArrayList<HashMap<String, Object>> conf_setting = new ArrayList<HashMap<String, Object>>(); 158 187 159 188 //An array to store all the details in the build.properties file … … 345 374 if (realColumnIndex == 0) 346 375 { 347 tip = conf_display [rowIndex][realColumnIndex].toString();376 tip = conf_display.get(rowIndex).get(realColumnIndex).toString(); 348 377 } 349 378 else … … 713 742 public void readProjectConf(String filename) 714 743 { 744 System.err.println("FILENAME = " + filename); 715 745 String fileLine; 716 746 /* … … 720 750 */ 721 751 conf_array = new ArrayList<String>(); 722 conf_setting = new Object[rowLength][colLength]; 752 conf_setting.clear(); 753 723 754 try 724 755 { 725 756 BufferedReader conf_in = new BufferedReader(new FileReader(filename)); 726 int i = 0;727 757 while ((fileLine = conf_in.readLine()) != null) 728 758 { 759 HashMap<String, Object> map = new HashMap<String, Object>(); 729 760 // This is an empty line 730 761 if (fileLine.matches("^\\s*$")) … … 741 772 //This line is Configuration Comment line 742 773 conf_array.add(fileLine); 743 conf_setting[i][0] = fileLine.substring(1); // use 1 to get rid of the # symbol. 774 map.put(ONE, fileLine.substring(1)); 775 conf_setting.add(map); 744 776 } 745 777 else if (!fileLine.matches("#.+") && !fileLine.matches("^\\s*$")) … … 747 779 //This line is Setting line 748 780 int end_index = fileLine.indexOf("="); 749 if (end_index != -1)781 if (end_index != -1) 750 782 { 751 conf_setting[i][1] = fileLine.substring(0, end_index).toUpperCase();752 conf_setting[i][2] = fileLine.substring(end_index + 1);753 conf_table.put( conf_setting[i][1], conf_setting[i][2]);754 i++; //calculat the number of settings 783 map.put(TWO, fileLine.substring(0, end_index).toUpperCase()); 784 map.put(THREE, fileLine.substring(end_index + 1)); 785 conf_table.put(map.get(TWO), map.get(THREE)); 786 755 787 conf_array.add(fileLine); 788 789 if (map.get(TWO).toString().matches("TOMCAT.SERVER")) 790 { 791 tomcat_server = map.get(THREE).toString(); 792 } 793 if (map.get(TWO).toString().matches("TOMCAT.PORT")) 794 { 795 tomcat_port = map.get(THREE).toString(); 796 } 797 if (map.get(TWO).toString().matches("MYSQL.ADMIN.USER")) 798 { 799 mysql_adminuser = map.get(THREE).toString(); 800 } 801 if (map.get(TWO).toString().matches("MYSQL.SERVER")) 802 { 803 mysql_server = map.get(THREE).toString(); 804 } 805 if (map.get(TWO).toString().matches("MYSQL.PORT")) 806 { 807 mysql_port = map.get(THREE).toString(); 808 } 809 810 conf_setting.add(map); 756 811 } 757 812 } … … 761 816 } 762 817 } 763 num_of_setting = i; 764 for (int j = 0; j < num_of_setting; j++) 765 { 766 if (conf_setting[j][1].toString().matches("TOMCAT.SERVER")) 767 { 768 tomcat_server = conf_setting[j][2].toString(); 769 } 770 if (conf_setting[j][1].toString().matches("TOMCAT.PORT")) 771 { 772 tomcat_port = conf_setting[j][2].toString(); 773 } 774 if (conf_setting[j][1].toString().matches("MYSQL.ADMIN.USER")) 775 { 776 mysql_adminuser = conf_setting[j][2].toString(); 777 } 778 if (conf_setting[j][1].toString().matches("MYSQL.SERVER")) 779 { 780 mysql_server = conf_setting[j][2].toString(); 781 } 782 if (conf_setting[j][1].toString().matches("MYSQL.PORT")) 783 { 784 mysql_port = conf_setting[j][2].toString(); 785 } 786 } 818 787 819 conf_in.close(); 788 820 } … … 795 827 public void clearTable() 796 828 { 797 for (int i = 0; i < rowLength; i++) 798 { 799 conf_display[i][0] = ""; 800 conf_display[i][1] = ""; 801 conf_display[i][2] = ""; 802 } 829 conf_display.clear(); 803 830 } 804 831 … … 889 916 public Object getValueAt(int row, int col) 890 917 { 891 return conf_display[row][col + 1]; 918 try 919 { 920 return conf_display.get(row).get(col + 1); 921 } 922 catch (Exception ex) 923 { 924 return ""; 925 } 892 926 } 893 927 … … 898 932 return false; 899 933 } 900 else if (conf_display [row][col].toString().matches("MYSQL.+"))934 else if (conf_display.get(row).get(col).toString().matches("MYSQL.+")) 901 935 { 902 936 mysql_server_up = checkMysqlServer(); … … 906 940 } 907 941 } 908 else if (conf_display [row][col].toString().matches("TOMCAT.+"))942 else if (conf_display.get(row).get(col).toString().matches("TOMCAT.+")) 909 943 { 910 944 tomcat_server_up = checkTomcatServer(); … … 921 955 if (!isCellEditable(row, col)) 922 956 return; 923 conf_display[row][col + 1] = value; 957 if (conf_display.get(row) == null) 958 { 959 ArrayList<Object> list = new ArrayList<Object>(); 960 list.add(col + 1, value); 961 conf_display.add(row, list); 962 } 963 else 964 { 965 conf_display.get(row).add(col + 1, value); 966 } 924 967 project_conf_changed = true; 925 968 //System.err.println("**ConfDisplay:" + conf_display[row][col].toString()); 926 conf_table.put(conf_display [row][col].toString(), value);969 conf_table.put(conf_display.get(row).get(col).toString(), value); 927 970 fireTableCellUpdated(row, col + 1); 928 971 updateUI(); … … 937 980 confContent_pane.revalidate(); 938 981 clearTable(); 939 int j = 0; 982 940 983 int row_count = 0; 941 for (int i = 0; i < num_of_setting; i++)942 { 943 if (conf_setting [i][1].toString().matches("^(" + conf_param + ").+"))984 for (int i = 0; i < conf_setting.size(); i++) 985 { 986 if (conf_setting.get(i).get(TWO) != null && conf_setting.get(i).get(TWO).toString().matches("^(" + conf_param + ").+")) 944 987 { 945 988 row_count = row_count + 1; 946 conf_display[j][0] = conf_setting[i][0]; 947 conf_display[j][1] = conf_setting[i][1]; 948 conf_display[j][2] = conf_table.get(conf_setting[i][1]); 949 j++; 989 990 ArrayList<Object> list = new ArrayList<Object>(); 991 list.add(conf_setting.get(i).get(ONE)); 992 list.add(conf_setting.get(i).get(TWO)); 993 list.add(conf_table.get(conf_setting.get(i).get(TWO))); 994 conf_display.add(list); 950 995 } 951 996 }
Note:
See TracChangeset
for help on using the changeset viewer.