Changeset 8793 for trunk/gli/src/org/greenstone/gatherer/gems
- Timestamp:
- 2004-12-14T10:44:40+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/gems
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r8627 r8793 57 57 import org.greenstone.gatherer.Dictionary; 58 58 import org.greenstone.gatherer.GetOpt; 59 import org.greenstone.gatherer.cdm.*; 59 60 import org.greenstone.gatherer.gui.GComboBox; 60 61 import org.greenstone.gatherer.gui.GLIButton; 62 import org.greenstone.gatherer.gui.HelpFrame; 61 63 import org.greenstone.gatherer.gui.ModalDialog; 62 64 import org.greenstone.gatherer.gui.NonWhitespaceField; 63 65 import org.greenstone.gatherer.gui.TransformCharacterTextField; 64 import org.greenstone.gatherer.gui.HelpFrame;65 import org.greenstone.gatherer.cdm.*;66 66 import org.greenstone.gatherer.util.Codec; 67 67 import org.greenstone.gatherer.util.Utility; … … 84 84 static final private Dimension ADD_FILE_SIZE = new Dimension(400,125); 85 85 static final private Dimension ADD_SET_SIZE = new Dimension(400,150); 86 static final private Dimension OPEN_SETS_SIZE = new Dimension(400,135); 86 87 static final private Dimension ADD_OR_EDIT_ATTRIBUTE_SIZE = new Dimension(600,325); 87 88 static final private Dimension ADD_OR_EDIT_VALUE_SIZE = new Dimension(600,440); 89 88 90 static final private Dimension COMPONENT_SIZE = new Dimension(300,30); 89 91 static final private Dimension SIZE = new Dimension(800,480); … … 115 117 /** A reference to ourselves so our inner classes can dispose of us. */ 116 118 private GEMS self = null; 119 private String gsdl_path = null; 117 120 private int current_attribute = -1; 118 121 private int current_attribute_type = -1; … … 189 192 // Load configuration file 190 193 try { 194 191 195 config = new Configuration(go.gsdl_path, null, null); 196 197 192 198 } 193 199 catch (Exception exception) { … … 195 201 } 196 202 GEMS GEMS; 197 GEMS = new GEMS( );203 GEMS = new GEMS(go.gsdl_path); 198 204 } 199 205 … … 203 209 * @param action a systematic action that should be performed 204 210 */ 205 public GEMS( )211 public GEMS(String gsdl_path) 206 212 { 207 213 this.dialog_options = new String[2]; 208 214 this.screen_size = config.screen_size; 209 215 this.self = this; 210 216 this.gsdl_path = gsdl_path; 217 211 218 // Initialise some common images 212 219 Utility.initImages(this); … … 731 738 // File -> Open 732 739 if (event_source == file_open) { 733 JFileChooser metadata_set_file_chooser = new JFileChooser(new File(Utility.METADATA_DIR)); 734 metadata_set_file_chooser.setFileFilter(new MetadataSetFileFilter()); 735 if (metadata_set_file_chooser.showDialog(this, Dictionary.get("General.Open")) == JFileChooser.APPROVE_OPTION) { 736 MetadataSet metadata_set = msm.loadMetadataSet(metadata_set_file_chooser.getSelectedFile());737 // Update tree 738 //only update tree if the metadata_set return is not null(it will be null if set is already739 //opened-Attila - oct 19 0 4740 if(metadata_set != null) {741 model.add(null, metadata_set, GEMSNode.SET);742 }743 } 740 741 //we first launch the dialog to determine where the jfilechooser should be opened 742 //ie: for collection specific sets - attila dec10-04 743 String set_directory = Utility.METADATA_DIR; 744 745 SetSelectionDialog m = new SetSelectionDialog(); 746 m.show(); 747 748 //once we have clicked 'ok' on the jdialog above, then we should have 749 //the directory pointer in string set_directory...and pass it to the jfilechoose constru 750 744 751 745 752 return; … … 858 865 859 866 867 private class ActionTask 868 extends Thread { 869 private int action; 870 public ActionTask(int action) { 871 this.action = action; 872 } 873 public void run() { 874 boolean complete = false; 875 while(!complete) { 876 if(self.isVisible()) { 877 switch(action) { 878 case ADD_SET: 879 add_set_action_listener.actionPerformed(new ActionEvent(this, 0, "Blarg!")); 880 break; 881 case REMOVE_SET: 882 if(!mds_tree.isSelectionEmpty()) { 883 remove_set_action_listener.actionPerformed(new ActionEvent(this, 0, "Blarg!")); 884 } 885 break; 886 } 887 complete = true; 888 } 889 else { 890 try { 891 synchronized(this) { 892 wait(100); 893 } 894 } 895 catch(Exception exception) { 896 } 897 } 898 } 899 } 900 } 860 901 //callback method 861 902 protected void processWindowEvent(WindowEvent evt){ … … 1107 1148 language_box.addItem(languagecodes.get(p).toString()); 1108 1149 } 1109 1150 1151 String code = Configuration.getLanguage(); 1152 language_box.setSelectedItem(code); 1153 //System.out.println(code); 1110 1154 } 1111 1155 /** Any implementation of ActionListener must include this method so that we can be informed when an action as occured on our registered component, allowing us to add a new attribute to the selected set or element. … … 1122 1166 //allow user to choose language when they create attr 1123 1167 1168 1169 1124 1170 1125 1171 if(source == popupListener.menuAddAttributeAttribute) { … … 2066 2112 } 2067 2113 } 2114 //// 2115 private class SetSelectionDialog 2116 extends ModalDialog 2117 implements ActionListener { 2118 private JButton cancel_button = null; 2119 private JButton ok_button = null; 2120 //private JTextField name_field = null; 2121 //private JTextField namespace_field = null; 2122 private JComboBox existingSetJComboBox = new JComboBox(); 2123 2124 public SetSelectionDialog() { 2125 super(self); 2126 setModal(true); 2127 setSize(OPEN_SETS_SIZE); 2128 Dictionary.setText(this, "Open Sets"); 2129 2130 // Creation 2131 JPanel content_pane = (JPanel) getContentPane(); 2132 content_pane.setBackground(config.getColor("coloring.collection_heading_background", false)); 2133 JPanel center_pane = new JPanel(); 2134 center_pane.setOpaque(false); 2135 2136 2137 JPanel boxes_pane = new JPanel(); 2138 2139 JPanel button_pane = new JPanel(); 2140 button_pane.setOpaque(false); 2141 2142 ok_button = new GLIButton(); 2143 ok_button.setMnemonic(KeyEvent.VK_O); 2144 Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip"); 2145 cancel_button = new GLIButton(); 2146 cancel_button.setMnemonic(KeyEvent.VK_C); 2147 Dictionary.setBoth(cancel_button, "General.Cancel", "General.Pure_Cancel_Tooltip"); 2148 TextFieldEnabler ok_button_enabler = new TextFieldEnabler(ok_button); 2149 2150 // Connection 2151 cancel_button.addActionListener(this); 2152 ok_button.addActionListener(this); 2153 // ok_button_enabler.add(name_field); 2154 // ok_button_enabler.add(namespace_field); 2155 2156 // Layout 2068 2157 2158 // label_pane.add 2159 // boxes_pane.setLayout(new GridLayout(2,1,0,5)); 2160 boxes_pane.setLayout(new GridLayout(4,1)); 2161 // boxes_pane.add(name_field); 2162 // boxes_pane.add(namespace_field); 2163 2164 JLabel inheritJLabel = new JLabel(); 2165 Dictionary.setText(inheritJLabel, "GEMS.inheritMetadataSet"); 2166 2167 //label_pane.add(inheritJLabel); 2168 2169 2170 //add inherit metadata set functionality 2171 // String[] s = msm.getSets().toArray(); 2172 2173 //JComboBox existingSetJComboBox = new JComboBox(new String(msm.getSetsForInherit().toArray())); 2174 2175 int getSetsLen = msm.getSets().toArray().length; 2176 Vector theSets = msm.getSets(); 2177 // System.out.println(Configuration.gsdl_path); 2178 File[] col_dir = new File(Configuration.gsdl_path + "/collect").listFiles(); 2179 2180 existingSetJComboBox.addItem("Default Metadata Sets #% " + Configuration.gsdl_path + "gli/metadata"); 2181 2182 for(int k = 0; k < col_dir.length; k++){ 2183 //MetadataSet ms = (MetadataSet)theSets.elementAt(k); 2184 2185 if(col_dir[k].isDirectory() && col_dir[k].getName().compareTo("CVS") != 0) { 2186 2187 File metadir = new File(col_dir[k].toString() + "/metadata"); 2188 if(metadir.exists()) 2189 existingSetJComboBox.addItem(new String(col_dir[k].getName() + " Collection Sets #% " + col_dir[k].toString() + "/metadata")); 2190 2191 } 2192 2193 // existingSetJComboBox.addItem(new String(ms.getName() + " #% " + ms.getFile().toString())); 2194 2195 } 2196 //add sets to existingSetJComboBox 2197 2198 existingSetJComboBox.setSelectedIndex(0); 2199 //String tempstr = new String(); 2200 JLabel dummyl = new JLabel(); 2201 Dictionary.setText(dummyl, "GEMS.Add_Set.No_Inherit"); 2202 2203 2204 2205 //existingSetJComboBox.addItem("Do not inherit"); 2206 // existingSetJComboBox.setSelectedIndex(getSetsLen); 2207 boxes_pane.add(new JLabel("Select which group of metadata sets you wish to edit:\n\n\n\n")); 2208 boxes_pane.add(new JLabel("\n")); 2209 boxes_pane.add(existingSetJComboBox); 2210 boxes_pane.add(new JLabel("\n")); 2211 // center_pane.setLayout(new BorderLayout(5,0)); 2212 // center_pane.add(label_pane, BorderLayout.WEST); 2213 // center_pane.add(boxes_pane, BorderLayout.CENTER); 2214 2215 // button_pane.setLayout(new GridLayout(1,3,0,5)); 2216 button_pane.setLayout(new GridLayout(1,3,0,5)); 2217 button_pane.add(ok_button); 2218 button_pane.add(cancel_button); 2219 2220 2221 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 2222 content_pane.setLayout(new BorderLayout()); 2223 content_pane.add(boxes_pane, BorderLayout.CENTER); 2224 content_pane.add(button_pane, BorderLayout.SOUTH); 2225 2226 setLocation((config.screen_size.width - ADD_SET_SIZE.width) / 2, (config.screen_size.height - ADD_SET_SIZE.height) / 2); 2227 } 2228 /** Any implementation of ActionListener must include this method so that we can be informed when an action as occured on our registered component, allowing us to 2229 * @param event An <strong>ActionEvent</strong> containing information about the event. 2230 */ 2231 2232 public void actionPerformed(ActionEvent event) { 2233 Object source = event.getSource(); 2234 2235 2236 // if(a_set_exists_with_this_namespace(namespace_field.getText()) == false){ 2237 if(source == ok_button) { 2238 //this code below handles whether we inherit from an existing set or not 2239 2240 // String namespace_str = namespace_field.getText(); 2241 //String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 2242 String loc = (String) existingSetJComboBox.getSelectedItem(); 2243 2244 String [] whereto = loc.split("#%"); 2245 String set_directory = whereto[1].trim(); 2246 2247 //load the jfilechooser: 2248 2249 JFileChooser metadata_set_file_chooser = new JFileChooser(new File(set_directory)); 2250 metadata_set_file_chooser.setFileFilter(new MetadataSetFileFilter()); 2251 if (metadata_set_file_chooser.showDialog(this, Dictionary.get("General.Open")) == JFileChooser.APPROVE_OPTION) { 2252 MetadataSet metadata_set = msm.loadMetadataSet(metadata_set_file_chooser.getSelectedFile()); 2253 // Update tree 2254 //only update tree if the metadata_set return is not null(it will be null if set is already 2255 //opened-Attila - oct 19 0 4 2256 if(metadata_set != null) { 2257 model.add(null, metadata_set, GEMSNode.SET); 2258 } 2259 } 2260 2261 2262 setVisible(false); 2263 } 2264 else if(source == cancel_button) { 2265 setVisible(false); 2266 } 2267 else { 2268 //name_field.setText(""); 2269 setVisible(true); 2270 } 2271 } 2272 2273 public void dispose() { 2274 cancel_button = null; 2275 ok_button = null; 2276 super.dispose(); 2277 } 2278 } 2279 2280 //// 2069 2281 private class AddOrEditValueActionListener 2070 2282 extends ModalDialog … … 2768 2980 menuAddSet = new JMenuItem(); 2769 2981 //Dictionary.setText(menuAddSet,"GEMS.Popup.menuAddSet"); 2770 Dictionary.setText(menuAddSet,"GEMS.Add_Set_Tooltip");2982 //Dictionary.setText(menuAddSet,"GEMS.Add_Set_Tooltip"); 2771 2983 2772 2984 menuRenameSet = new JMenuItem(); -
trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
r8782 r8793 47 47 import org.greenstone.gatherer.util.Utility; 48 48 import org.greenstone.gatherer.collection.CollectionManager; 49 import org.greenstone.gatherer.file.*; 49 50 import org.greenstone.gatherer.util.XMLTools; 50 51 import org.apache.xerces.parsers.*; … … 518 519 //File value_file = new File(file, value_element.getName() + ".mdv"); 519 520 ///ystem.err.println("Saving value file: " + value_file.toString()); 520 // XMLTools.export(value_tree.getDocument(), value_file);521 //Utility.export(value_tree.getDocument(), value_file); 521 522 // If this is a hierarchy element, write hierarchy file. 522 523 //if(value_element.getNamespace().equals(MetadataSetManager.HIDDEN) || value_tree.isHierarchy()) {
Note:
See TracChangeset
for help on using the changeset viewer.