Changeset 5375


Ignore:
Timestamp:
2003-08-29T16:45:53+12:00 (21 years ago)
Author:
jmt12
Message:

Fixed 203B160 & 203B161 - Needs an add all metadata and replace name in MGPP Indexes

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  
    189189    }
    190190
     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
    191200    /** Retrieve the sources of this index.
    192201     * @return the sources as an ArrayList
  • trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java

    r5342 r5375  
    899899    private GComboBox level_combobox;
    900900    private JButton add_index_button;
     901    private JButton add_all_button;
    901902    private JButton add_level_button;
    902903    private JButton move_index_down_button;
     
    904905    private JButton move_index_up_button;
    905906    private JButton move_level_up_button;
     907    private JButton replace_button;
    906908    private JButton remove_index_button;
    907909    private JButton remove_level_button;
     
    990992        add_index_button.setMnemonic(KeyEvent.VK_A);
    991993       
     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
    9921002        remove_index_button = new JButton("CDM.IndexManager.MGPP.Remove_Index");
    9931003        remove_index_button.setEnabled(false);
     
    9991009        EnableAddIndexListener index_eal = new EnableAddIndexListener();
    10001010        add_index_button.addActionListener(new AddIndexActionListener());
     1011        add_all_button.addActionListener(new AddAllActionListener());
    10011012        current_indexes_list.addListSelectionListener(new CurrentIndexesListSelectionListener());
    10021013        Gatherer.dictionary.register(add_index_button, null, false);
     1014        Gatherer.dictionary.register(add_all_button, null, false);
    10031015        Gatherer.dictionary.register(current_indexes_label, null, false);
    10041016        Gatherer.dictionary.register(index_label, null, false);
     
    10061018        Gatherer.dictionary.register(move_index_down_label, null, false);
    10071019        Gatherer.dictionary.register(move_index_up_label, null, false);
     1020        Gatherer.dictionary.register(replace_button, null, false);
    10081021        Gatherer.dictionary.register(remove_index_button, null, false);
    10091022        index_combobox.addActionListener(index_eal);
     
    10121025        move_index_down_button.addActionListener(new MoveIndexDownListener());
    10131026        move_index_up_button.addActionListener(new MoveIndexUpListener());
     1027        replace_button.addActionListener(new ReplaceIndexActionListener());
    10141028        remove_index_button.addActionListener(new RemoveIndexActionListener(index_eal));
    10151029        // Layout Indexes
     
    10361050
    10371051        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));
    10391053        index_button_panel.add(add_index_button);
     1054        index_button_panel.add(add_all_button);
     1055        index_button_panel.add(replace_button);
    10401056        index_button_panel.add(remove_index_button);
    10411057
     
    12191235    public void destroy() {
    12201236        Gatherer.dictionary.deregister(add_index_button);
     1237        Gatherer.dictionary.deregister(add_all_button);
    12211238        Gatherer.dictionary.deregister(current_indexes_label);
    12221239        Gatherer.dictionary.deregister(index_label);
     
    12241241        Gatherer.dictionary.deregister(move_index_down_label);
    12251242        Gatherer.dictionary.deregister(move_index_up_label);
     1243        Gatherer.dictionary.deregister(replace_button);
    12261244        Gatherer.dictionary.deregister(remove_index_button);
    12271245
     
    12591277        sources.add(source);
    12601278        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        }
    12661318        // Done. Disable add
    12671319        add_index_button.setEnabled(false);
     
    12961348        if(!event.getValueIsAdjusting()) {
    12971349            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            }
    12981359            if(index != null) {
    12991360            move_index_down_button.setEnabled((model.indexOf(index) < model.getSize() - 1));
     
    13721433            id = selected_object.toString();
    13731434            }
    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            }
    13751447        }
    13761448        else {
     
    14631535    }
    14641536
     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   
    14651565    private class RemoveIndexActionListener
    14661566        implements ActionListener {
Note: See TracChangeset for help on using the changeset viewer.