Changeset 4410


Ignore:
Timestamp:
2003-05-30T10:38:01+12:00 (21 years ago)
Author:
kjdon
Message:

made the MEtaEditPane an MSMListener, so that it will update itself when a metadata set is added or removed

File:
1 edited

Legend:

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

    r4367 r4410  
    5858import org.greenstone.gatherer.msm.Metadata;
    5959import org.greenstone.gatherer.msm.MSMEvent;
     60import org.greenstone.gatherer.msm.MSMListener;
    6061import org.greenstone.gatherer.util.ArrayTools;
    6162import org.greenstone.gatherer.util.DragGroup;
     
    7374public class MetaEditPane
    7475    extends JPanel
    75     implements ActionListener, ListSelectionListener, TreeModelListener, TreeSelectionListener {
     76    implements ActionListener, ListSelectionListener, TreeModelListener, TreeSelectionListener, MSMListener {
    7677    /** <i>true</i> if the selection has changed since the last time it was asked for, <i>false</i> otherwise. */
    7778    public boolean has_changed = false;
     
    282283        collection_tree.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
    283284        collection_tree.setForeground(Gatherer.config.getColor("coloring.collection_tree_foreground", false));
    284                 // Register our msm dependant components (or correctly their models) with msm.
     285        // Register our msm dependant components (or correctly their models) with msm.
    285286        if(model != null) {
     287        // remove the listener first - in case its already present
     288        Gatherer.c_man.getCollection().msm.removeMSMListener(model);
    286289        Gatherer.c_man.getCollection().msm.addMSMListener(model);
    287290        }
     291        // register the pane itself as an MSMListener, so if we add a new metadata set, it will immediately show up. - remove itself first just in case
     292        Gatherer.c_man.getCollection().msm.removeMSMListener(this);
     293        Gatherer.c_man.getCollection().msm.addMSMListener(this);
     294
    288295        tree.setElementModel(Gatherer.c_man.getCollection().msm.getElementModel());
     296       
    289297    }
    290298    else {
     
    562570    this.add(external_split, BorderLayout.CENTER);
    563571    }
     572
     573    /** Method that is called whenever an element within a set is changed or modified. - needed for MSMListener
     574     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     575     */
     576    public void elementChanged(MSMEvent event) {}
     577
    564578    /** Ensures a certain tree path is expanded, visible and selected within the collection tree.
    565579    * @param path The <strong>TreePath</strong> to make visible.
     
    604618    public Metadata getSelectedMetadata() {
    605619    return selected_metadata;
     620    }
     621
     622    /** Called whenever the metadata value changes in some way, such as the addition of a new value. - needed for MSMListener
     623     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     624     */
     625    public void metadataChanged(MSMEvent event) {}
     626
     627    /** Method that is called whenever the metadata set collection changes in some way, such as the addition of a new set or the merging of two sets. - needed for MSMListener
     628     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     629     */
     630    public void setChanged(MSMEvent event){
     631    // call the collection tree value changed - we need to do the same stuff here
     632    valueChanged((TreeSelectionEvent) null);
     633
    606634    }
    607635
     
    717745    }
    718746    }
     747
     748    /** Called whenever the value tree of an metadata element changes in some way, such as the addition of a new value. - needed for MSMListener
     749     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     750     */
     751    public void valueChanged(MSMEvent event) {}
    719752
    720753    /** This method is called whenever the selection within the collection
     
    9771010    }
    9781011    }
     1012
    9791013}
Note: See TracChangeset for help on using the changeset viewer.