Changeset 8600


Ignore:
Timestamp:
2004-11-18T16:29:37+13:00 (19 years ago)
Author:
mdewsnip
Message:

The first smidgeon of the "plugin suggestion" code.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r8249 r8600  
    4141import org.greenstone.gatherer.Dictionary;
    4242import org.greenstone.gatherer.Gatherer;
     43import org.greenstone.gatherer.collection.CollectionContentsChangedListener;
    4344import org.greenstone.gatherer.gui.GComboBox;
    4445import org.greenstone.gatherer.gui.GLIButton;
     
    5152/** This class is for maintaining a list of known plug-ins, and importing new plugins using the parser. */
    5253public class PlugInManager
    53     extends DOMProxyListModel {
     54    extends DOMProxyListModel
     55    implements CollectionContentsChangedListener
     56{
    5457    /** The library 'reserve' of base plugins. */
    5558    private ArrayList library = null;
     
    7275    // Create the separator, cause we can reuse it.
    7376    separator = getSeparator();
     77
     78    // Listen for CollectionContentsChanged events, so we can give plugin hints when new files are added
     79    Gatherer.c_man.addCollectionContentsChangedListener(this);
    7480    }
    7581
     
    104110    return true;
    105111    }
     112
     113
    106114    /** Destructor. */
    107115    public void destroy() {
     
    113121    library = null;
    114122    }
     123
     124
     125    public void fileAddedToCollection(File file)
     126    {
     127    System.err.println("New file added to collection: " + file);
     128
     129    // First check the plugins already assigned in the collection
     130    for (int i = 0; i < super.getSize(); i++) {
     131        PlugIn assigned_plugin = (PlugIn) getElementAt(i);
     132        if (assigned_plugin.isSeparator() == false) {
     133        System.err.println("Assigned plugin: " + assigned_plugin);
     134        }
     135    }
     136
     137    // System.err.println("Number of plugins assigned in the collection: " + super.getSize());
     138    System.err.println("Number of plugins loaded: " + library.size());
     139    }
     140
    115141
    116142    /** Method to retrieve the control for this manager.
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r8597 r8600  
    8989    /** Are we currently in the process of importing? */
    9090    private boolean importing = false;
     91    /** The objects listening for CollectionContentsChanged events. */
     92    private ArrayList collection_contents_changed_listeners = new ArrayList();
    9193    /** The collection this manager is managing! */
    9294    static private Collection collection = null;
     
    118120    this.importing = false;
    119121    this.collection = null;
     122    }
     123
     124
     125    public void addCollectionContentsChangedListener(CollectionContentsChangedListener listener)
     126    {
     127    collection_contents_changed_listeners.add(listener);
    120128    }
    121129
     
    517525    catch (Exception error) {
    518526        DebugStream.printStackTrace(error);
     527    }
     528    }
     529
     530
     531    public void fireFileAddedToCollection(File file)
     532    {
     533    // Send the event off to all the CollectionContentsChangedListeners
     534    for (int i = 0; i < collection_contents_changed_listeners.size(); i++) {
     535        ((CollectionContentsChangedListener) collection_contents_changed_listeners.get(i)).fileAddedToCollection(file);
    519536    }
    520537    }
  • trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r8599 r8600  
    161161    public LongProgressBar getProgressBar() {
    162162    return progress;
    163     }
    164     /** Prevent the progress bar updating momentarily, while its size is re-adjusted. */
    165     public void pause() {
    166     progress.setIndeterminate(true);
    167163    }
    168164
     
    353349                    DebugStream.printStackTrace(exception);
    354350                    }
    355                  // If not cancelled
    356                     if(!cancel_action) {
    357                     // Step one is to create a dummy FileNode. Its important it has the correct structure so getPath works.
    358                     FileNode new_record = new FileNode(target_file);
    359                     SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, new_record);
    360                     new_node = new_record;
    361                     new_record = null;
     351                    // If not cancelled
     352                    if (!cancel_action) {
     353                    // Create a dummy FileNode with the correct structure (so getPath works)
     354                    new_node = new FileNode(target_file);
     355                    SynchronizedTreeModelTools.insertNodeInto(target_model, destination_node, new_node);
    362356                    }
    363357                }
     
    403397                    source_model.refresh(new TreePath(((FileNode)origin_node.getParent()).getPath()));
    404398                }
    405                
    406                 // We can't have been cancelled, and we must have created a new FileNode during the above phase, before we can handle metadata.
     399
     400                // If we haven't been cancelled and we created a new FileNode during the above phase, now is the time to deal with metadata
    407401                if (!cancel_action && new_node != null) {
    408                     /* Time to handle any existing metadata. */
    409                     // If the directory came from inside our collection...
     402                    // If the file came from inside our collection...
    410403                    if (job.source.toString().equals("Collection")) {
    411                     // System.err.println("Move within collection...");
    412 
    413404                    // Get the non-folder level metadata assigned to the origin node...
    414405                    ArrayList assigned_metadata = MetadataXMLFileManager.getMetadataAssignedDirectlyToFile(source_file);
     
    426417                        MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(i);
    427418                        MetadataXMLFileManager.addMetadata(new_node, metadata_value);
    428                     }   
     419                    }
     420                    }
     421
     422                    if (job.type == FileJob.COPY) {
     423                    Gatherer.c_man.fireFileAddedToCollection(new_node.getFile());
    429424                    }
    430425                }
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r8595 r8600  
    478478    collection_tree.refresh(null);
    479479    }
    480    
     480
    481481
    482482    public void refreshWorkspaceTree(int refresh_reason) {
Note: See TracChangeset for help on using the changeset viewer.