Changeset 5375
- Timestamp:
- 2003-08-29T16:45:53+12:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Index.java
r5255 r5375 189 189 } 190 190 191 /** Tries to retrieve this indexes name according to the CollectionMetaManager. */ 192 public String getName() { 193 CollectionMeta metadatum = CollectionDesignManager.collectionmeta_manager.getMetadatum(StaticStrings.STOP_CHARACTER + getID(), false); 194 if(metadatum != null) { 195 return metadatum.getValue(CollectionMeta.TEXT); 196 } 197 return ""; 198 } 199 191 200 /** Retrieve the sources of this index. 192 201 * @return the sources as an ArrayList -
trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java
r5342 r5375 899 899 private GComboBox level_combobox; 900 900 private JButton add_index_button; 901 private JButton add_all_button; 901 902 private JButton add_level_button; 902 903 private JButton move_index_down_button; … … 904 905 private JButton move_index_up_button; 905 906 private JButton move_level_up_button; 907 private JButton replace_button; 906 908 private JButton remove_index_button; 907 909 private JButton remove_level_button; … … 990 992 add_index_button.setMnemonic(KeyEvent.VK_A); 991 993 994 add_all_button = new JButton("CDM.IndexManager.MGPP.Add_All_Metadata"); 995 add_all_button.setEnabled(true); 996 add_all_button.setMnemonic(KeyEvent.VK_L); 997 998 replace_button = new JButton("CDM.IndexManager.MGPP.Replace_Index"); 999 replace_button.setEnabled(false); 1000 replace_button.setMnemonic(KeyEvent.VK_C); 1001 992 1002 remove_index_button = new JButton("CDM.IndexManager.MGPP.Remove_Index"); 993 1003 remove_index_button.setEnabled(false); … … 999 1009 EnableAddIndexListener index_eal = new EnableAddIndexListener(); 1000 1010 add_index_button.addActionListener(new AddIndexActionListener()); 1011 add_all_button.addActionListener(new AddAllActionListener()); 1001 1012 current_indexes_list.addListSelectionListener(new CurrentIndexesListSelectionListener()); 1002 1013 Gatherer.dictionary.register(add_index_button, null, false); 1014 Gatherer.dictionary.register(add_all_button, null, false); 1003 1015 Gatherer.dictionary.register(current_indexes_label, null, false); 1004 1016 Gatherer.dictionary.register(index_label, null, false); … … 1006 1018 Gatherer.dictionary.register(move_index_down_label, null, false); 1007 1019 Gatherer.dictionary.register(move_index_up_label, null, false); 1020 Gatherer.dictionary.register(replace_button, null, false); 1008 1021 Gatherer.dictionary.register(remove_index_button, null, false); 1009 1022 index_combobox.addActionListener(index_eal); … … 1012 1025 move_index_down_button.addActionListener(new MoveIndexDownListener()); 1013 1026 move_index_up_button.addActionListener(new MoveIndexUpListener()); 1027 replace_button.addActionListener(new ReplaceIndexActionListener()); 1014 1028 remove_index_button.addActionListener(new RemoveIndexActionListener(index_eal)); 1015 1029 // Layout Indexes … … 1036 1050 1037 1051 index_button_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 1038 index_button_panel.setLayout(new GridLayout( 1,2,5,0));1052 index_button_panel.setLayout(new GridLayout(2,2,5,0)); 1039 1053 index_button_panel.add(add_index_button); 1054 index_button_panel.add(add_all_button); 1055 index_button_panel.add(replace_button); 1040 1056 index_button_panel.add(remove_index_button); 1041 1057 … … 1219 1235 public void destroy() { 1220 1236 Gatherer.dictionary.deregister(add_index_button); 1237 Gatherer.dictionary.deregister(add_all_button); 1221 1238 Gatherer.dictionary.deregister(current_indexes_label); 1222 1239 Gatherer.dictionary.deregister(index_label); … … 1224 1241 Gatherer.dictionary.deregister(move_index_down_label); 1225 1242 Gatherer.dictionary.deregister(move_index_up_label); 1243 Gatherer.dictionary.deregister(replace_button); 1226 1244 Gatherer.dictionary.deregister(remove_index_button); 1227 1245 … … 1259 1277 sources.add(source); 1260 1278 Index index = new Index(sources); 1261 // Create new metadatum 1262 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID()); 1263 metadatum.setValue(name); 1264 // Assign new index 1265 addIndex(index, metadatum); 1279 if(!model.contains(index)) { 1280 // Create new metadatum 1281 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID()); 1282 metadatum.setValue(name); 1283 // Assign new index 1284 addIndex(index, metadatum); 1285 } 1286 // Done. Disable add 1287 add_index_button.setEnabled(false); 1288 } 1289 } 1290 1291 private class AddAllActionListener 1292 implements ActionListener { 1293 1294 public void actionPerformed(ActionEvent event) { 1295 for(int i = 0; i < index_combobox.getItemCount(); i++) { 1296 Object source = index_combobox.getItemAt(i); 1297 // Create new index 1298 ArrayList sources = new ArrayList(); 1299 sources.add(source); 1300 Index index = new Index(sources); 1301 sources = null; 1302 if(!model.contains(index)) { 1303 // Determine the metadatum value 1304 String name = source.toString(); 1305 if(name.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE)) { 1306 name = name.substring(Utility.EXTRACTED_METADATA_NAMESPACE.length() + 1); 1307 } 1308 // Create new metadatum 1309 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID()); 1310 metadatum.setValue(name); 1311 name = null; 1312 // Assign new index 1313 addIndex(index, metadatum); 1314 } 1315 source = null; 1316 index = null; 1317 } 1266 1318 // Done. Disable add 1267 1319 add_index_button.setEnabled(false); … … 1296 1348 if(!event.getValueIsAdjusting()) { 1297 1349 Index index = (Index)current_indexes_list.getSelectedValue(); 1350 Object[] selected_objects = current_indexes_list.getSelectedValues(); 1351 if(selected_objects.length == 1) { 1352 String full_text = index.toString(); 1353 if(full_text.indexOf("\"") != -1) { 1354 index_name_field.setText(index.getName()); 1355 } 1356 ArrayList sources = index.getSources(); 1357 index_combobox.setSelectedItem(sources.get(0)); 1358 } 1298 1359 if(index != null) { 1299 1360 move_index_down_button.setEnabled((model.indexOf(index) < model.getSize() - 1)); … … 1372 1433 id = selected_object.toString(); 1373 1434 } 1374 add_index_button.setEnabled(getIndex(id) == null); 1435 if(id.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE)) { 1436 id = id.substring(Utility.EXTRACTED_METADATA_NAMESPACE.length() + 1); 1437 } 1438 Index index = getIndex(id); 1439 if(index == null) { 1440 add_index_button.setEnabled(true); 1441 replace_button.setEnabled(false); 1442 } 1443 else { 1444 add_index_button.setEnabled(false); 1445 replace_button.setEnabled(!name.equals(index.getName())); 1446 } 1375 1447 } 1376 1448 else { … … 1463 1535 } 1464 1536 1537 /** Replace really only replaces the string. */ 1538 private class ReplaceIndexActionListener 1539 implements ActionListener { 1540 1541 public void actionPerformed(ActionEvent event) { 1542 Object[] selected_objects = current_indexes_list.getSelectedValues(); 1543 if(selected_objects.length == 1) { 1544 Index index = (Index) selected_objects[0]; 1545 // Remove old name 1546 CollectionDesignManager.collectionmeta_manager.removeMetadata(CollectionConfiguration.STOP_CHARACTER + index.getID()); 1547 // Enter new name 1548 String name = index_name_field.getText(); 1549 // Create new metadatum 1550 CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + index.getID()); 1551 index = null; 1552 metadatum.setValue(name); 1553 name = null; 1554 // Assign new index 1555 CollectionDesignManager.collectionmeta_manager.addMetadatum(metadatum); 1556 metadatum = null; 1557 } 1558 current_indexes_list.setSelectedValue(selected_objects[0], true); 1559 // Done. Disable add 1560 add_index_button.setEnabled(false); 1561 replace_button.setEnabled(false); 1562 } 1563 } 1564 1465 1565 private class RemoveIndexActionListener 1466 1566 implements ActionListener {
Note:
See TracChangeset
for help on using the changeset viewer.