Changeset 6848


Ignore:
Timestamp:
2004-02-19T11:52:25+13:00 (20 years ago)
Author:
mdewsnip
Message:

Fix to a bug where files were incorrectly marked as having folder level metadata.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java

    r6847 r6848  
    222222        }
    223223    }
    224     else if(esrc == expand_for_extracted) {
     224    else if (esrc == expand_for_extracted) {
    225225        EditorDialog ed = new EditorDialog();
    226226        ed.setEditable(false);
     
    246246
    247247    public void run() {
    248         ///ystem.err.println("Add metadata - '" + value + "'");
     248        // System.err.println("Add metadata - '" + value + "'");
    249249        // Check the new metadata is valid
    250         if(records != null && element != null && value != null) {
     250        if (records != null && element != null && value != null) {
    251251        // Check the records, and if they are folders then display the warning.
    252252        Metadata added_metadata = null;
    253         if(!records[0].isLeaf()) {
     253        if (!records[0].isLeaf()) {
    254254            WarningDialog dialog = new WarningDialog("warning.DirectoryLevelMetadata", true);
    255             if(dialog.display() == JOptionPane.OK_OPTION) {
     255            if (dialog.display() == JOptionPane.OK_OPTION) {
    256256            added_metadata = Gatherer.c_man.getCollection().msm.addMetadata(System.currentTimeMillis(), records, element, value);
    257257            }
     
    285285        // you have valid values in all fields.
    286286        Gatherer.println("Replacing value:");
    287         if(selected_metadata != null && records != null && element != null && value != null) {
     287        if (selected_metadata != null && records != null && element != null && value != null) {
    288288        selected_metadata = Gatherer.c_man.getCollection().msm.updateMetadata(System.currentTimeMillis(), selected_metadata, records, value, MetaEditPrompt.CONFIRM, selected_metadata.isFileLevel());
    289289        }
     
    299299    public void run() {
    300300        Gatherer.println("Removing value:");
    301         if(selected_metadata != null && records != null) {
     301        if (selected_metadata != null && records != null) {
    302302        Gatherer.c_man.getCollection().msm.removeMetadata(System.currentTimeMillis(), selected_metadata, records);
    303303        }
     
    320320     */
    321321    public void collectionChanged(boolean ready) {
    322     if(ready) {
     322    if (ready) {
    323323        TreeModel collection_model = Gatherer.c_man.getRecordSet();
    324324        //String[] args = new String[1];
     
    333333        collection_tree.setForeground(Gatherer.config.getColor("coloring.collection_tree_foreground", false));
    334334        // Register our msm dependant components (or correctly their models) with msm.
    335         if(model != null) {
     335        if (model != null) {
    336336        // remove the listener first - in case its already present
    337337        Gatherer.c_man.getCollection().msm.removeMSMListener(model);
     
    377377    DragGroup group = new DragGroup();
    378378    TreeModel collection_model = Gatherer.c_man.getRecordSet();
    379     if(collection_model != null) {
     379    if (collection_model != null) {
    380380        collection_tree = new DragTree("MetaEdit", collection_model, null, false);
    381381    }
     
    408408
    409409    // Collection Pane
    410 
    411410    collection_pane.add(collection_label, BorderLayout.NORTH);
    412411    collection_pane.add(collection_scroll, BorderLayout.CENTER);
     
    485484    JTableHeader table_header = table.getTableHeader();
    486485    Dimension table_header_preferred_size = table_header.getPreferredSize();
    487     if(table_header_preferred_size.height < MINIMUM_TABLE_HEADER_SIZE) {
     486    if (table_header_preferred_size.height < MINIMUM_TABLE_HEADER_SIZE) {
    488487        table_header_preferred_size.setSize(table_header_preferred_size.width, MINIMUM_TABLE_HEADER_SIZE);
    489488        table_header.setPreferredSize(table_header_preferred_size);
     
    584583    // Use this opportunity to update the table model etc.
    585584    // Select the first file (if any)
    586     if(collection_tree != null && collection_tree.getRowCount() > 0) {
     585    if (collection_tree != null && collection_tree.getRowCount() > 0) {
    587586        collection_tree.setImmediate(true);
    588587        collection_tree.setSelectionRow(0);
     
    595594
    596595    // Update the menubars idea of whats been selected
    597     if(collection_tree != null) {
    598         if(collection_tree.isSelectionEmpty()) {
     596    if (collection_tree != null) {
     597        if (collection_tree.isSelectionEmpty()) {
    599598        Gatherer.g_man.menu_bar.setMetaAuditSuffix(null);
    600599        }
     
    644643    // Validate card_layout_2
    645644    // We only ever change tools if the metadata table has finished building or is empty.
    646     if(update_card) {
     645    if (update_card) {
    647646        if (selected_metadata == null && model.isBuildingComplete() && model.getRowCount() == 0) {
    648647        card_layout2.show(control_pane, TOOLS_OFF);
     
    721720        tree.setSelectedMetadataElement(selected_metadata.getElement());
    722721        GValueNode value_node = selected_metadata.getValueNode();
    723         if(value_node != null) {
     722        if (value_node != null) {
    724723            tree.setSelectedValue(value_node.getFullPath(true));
    725724        }
     
    757756    }
    758757
    759     if(collection_tree.getSelectionCount() > 0) {
     758    if (collection_tree.getSelectionCount() > 0) {
    760759        records = null;
    761760        TreePath paths[] = collection_tree.getSelectionPaths();
    762         for(int i = 0; i < paths.length; i++) {
     761        for (int i = 0; i < paths.length; i++) {
    763762        FileNode record = (FileNode) paths[i].getLastPathComponent();
    764763        records = ArrayTools.add(records, record);
     
    784783
    785784        // Remove old model from msm
    786         if(Gatherer.c_man.ready()) {
     785        if (Gatherer.c_man.ready()) {
    787786        Gatherer.c_man.getCollection().msm.removeMSMListener(model);
    788787        }
     
    792791    }
    793792
    794     if(table != null) {
     793    if (table != null) {
    795794        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    796795        Dimension table_size = table.getPreferredSize();
     
    960959     */
    961960    public void mouseClicked(MouseEvent event) {
    962         if(SwingUtilities.isRightMouseButton(event)) {
     961        if (SwingUtilities.isRightMouseButton(event)) {
    963962        new RightButtonMenu(event);
    964963        }
     
    986985        // Creation
    987986        // Any folder node gets a menu item allowing you to collapse or expand it depending on its current status
    988         if(!node.isLeaf()) {
     987        if (!node.isLeaf()) {
    989988                // Collapse
    990         if(collection_tree.isExpanded(path)) {
     989        if (collection_tree.isExpanded(path)) {
    991990            collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Collapse"), KeyEvent.VK_C);
    992991        }
     
    10151014    public void actionPerformed(ActionEvent event) {
    10161015        Object source = event.getSource();
    1017         if(source == show_metaaudit) {
     1016        if (source == show_metaaudit) {
    10181017        Gatherer.g_man.showMetaAuditBox();
    10191018        }
    1020         else if(source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) {
     1019        else if (source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) {
    10211020                // Collapse
    1022         if(collection_tree.isExpanded(path)) {
     1021        if (collection_tree.isExpanded(path)) {
    10231022            collection_tree.collapsePath(path);
    10241023        }
     
    10971096
    10981097        JPanel value_field_pane = new JPanel();
    1099         //TransformCharacterTextField value_init = new TransformCharacterTextField();
    1100         //value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);
    11011098        value = new JTextField();
    1102         //value_init = null;
    11031099        value.setBackground(Gatherer.config.getColor("coloring.editable_background", false));
    11041100        value.setForeground(Gatherer.config.getColor("coloring.editable_foreground", false));
     
    11841180
    11851181    public String getSelectedValue() {
    1186         //return /odec.transform(/odec.transformUnicode(value.getText()), /odec.TEXT_TO_GREENSTONE);
    11871182        String raw_value = value.getText();
    11881183        raw_value = Codec.transformUnicode(raw_value);
     
    12201215        // Load the model for the newly selected metadata element
    12211216        selected_metadata_element = element;
    1222         if(Gatherer.c_man != null && Gatherer.c_man.getCollection() != null && Gatherer.c_man.getCollection().msm != null && tree != null) {
     1217        if (Gatherer.c_man != null && Gatherer.c_man.getCollection() != null && Gatherer.c_man.getCollection().msm != null && tree != null) {
    12231218        vm = Gatherer.c_man.getCollection().msm.getValueTree(element);
    12241219        tree.setModel(vm);
  • trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java

    r6842 r6848  
    131131    /* Called to retrieve the Metadata record that matches a certain row. Usually caused by the user selectiong a row in the table. It synchronized so that the model doesn't up and change while we're trying to retrieve the indicated element. */
    132132    public synchronized Metadata getMetadataAtRow(int row) {
    133     if(0 <= row && row < current_metadata.size()) {
     133    if (row >= 0 && row < current_metadata.size()) {
    134134        return (Metadata) current_metadata.get(row);
    135135    }
     
    206206        ElementWrapper element = metadatum.getElement();
    207207        if(i < 0) {
    208               Gatherer.println("Could not find suitable row to select!");
    209               return;
    210         }
     208        Gatherer.println("Could not find suitable row to select!");
     209        return;
     210        }
    211211        Metadata newly_selected_metadatum = (Metadata) current_metadata.get(i);
    212212        if (!newly_selected_metadatum.getElement().equals(element)) {
    213             // Try one row previous
    214             i--;
    215             if(i < 0) {
    216                   Gatherer.println("Could not find suitable row to select!");
    217                   return;
    218              }
    219 
    220             newly_selected_metadatum = (Metadata) current_metadata.get(i);
    221             if (!newly_selected_metadatum.getElement().equals(element)) {
    222                 Gatherer.println("Could not find suitable row to select!");
    223                 return;
    224             }
     213        // Try one row previous
     214        i--;
     215        if(i < 0) {
     216            Gatherer.println("Could not find suitable row to select!");
     217            return;
     218        }
     219
     220        newly_selected_metadatum = (Metadata) current_metadata.get(i);
     221        if (!newly_selected_metadatum.getElement().equals(element)) {
     222            Gatherer.println("Could not find suitable row to select!");
     223            return;
     224        }
    225225        }
    226226
  • trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java

    r6827 r6848  
    338338                    }
    339339                    }
    340                     // check whether the metadata is null
     340
     341                    // Determine whether this metadata is file or folder level
    341342                    if (metadata != null) {
    342                     // We determine whether this metadata is file or folder level
    343                     if(filename != null) {
    344                         ///ystem.err.println("Filename    = " + filename);
    345                         ///ystem.err.println("filename_text = " + filename_text);
    346                         // If can only be file level if there is no folder path details in filename and if the filename matched the filename text node (it may have matched .* instead)!
    347                         if(filename.indexOf(File.separator) == -1 && filename.equals(filename_text)) {
    348                         metadata.setFileLevel(true);
    349                         ///ystem.err.println("File level!!!");
    350                         }
    351                         else {
    352                         metadata.setFileLevel(false);
    353                         ///ystem.err.println("Inherited!!!");
    354                         }
    355                     }
     343                    // The metadata is folder level if the file expression matches .*
     344                    if (filename_text != null && filename_text.equals(DIRECTORY_FILENAME)) {
     345                        metadata.setFileLevel(false);
     346                    }
     347                    // Otherwise it must be file level
    356348                    else {
    357                         ///ystem.err.println("Filename is null therefore this is file level metadata.");
    358349                        metadata.setFileLevel(true);
    359350                    }
     351
    360352                    metadata.setFile(file);
    361353                    // If mode is overwrite, then remove any previous values for this metadata element.
Note: See TracChangeset for help on using the changeset viewer.