Changeset 8813


Ignore:
Timestamp:
2004-12-15T13:41:43+13:00 (19 years ago)
Author:
mdewsnip
Message:

Fixed up a few more refreshing problems.

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

Legend:

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

    r8811 r8813  
    9595    static public ActionRecorderDialog feedback_dialog = null;
    9696
     97    // Refresh reasons
     98    static public final int COLLECTION_OPENED   = 0;
     99    static public final int COLLECTION_CLOSED   = 1;
     100    static public final int COLLECTION_REBUILT  = 2;
     101    static public final int PREFERENCES_CHANGED = 3;
     102
    97103
    98104    /** Magic to allow Enter to fire the default button. */
     
    326332
    327333
    328 
    329334    public void run(Dimension size, Splash splash, GUIManager g_man)
    330335    {
     
    448453    }
    449454
     455
     456    static public void refresh(int refresh_reason)
     457    {
     458    if (g_man != null) {
     459        g_man.refresh(refresh_reason, c_man.ready());
     460    }
     461
     462    // Now is a good time to force a garbage collect
     463    System.gc();
     464    }
     465
     466
    450467    // used to send reload coll messages to the tomcat server
    451468    static public void configGS3Server(String site, String command) {
     
    471488    }
    472489
    473     /** Retrieve the metadata directory, as required by any MSMCaller implementation.
    474      * @return The currently active collection metadata directory as a <strong>String</strong>.
    475      * @see org.greenstone.gatherer.collection.CollectionManager
    476      */
    477     public String getCollectionMetadata() {
    478     if (c_man != null && c_man.ready()) {
    479         return c_man.getCollectionMetadata();
    480     }
    481     return "";
    482     }
    483490
    484491    /** Used to 'spawn' a new child application when a file is double clicked.
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r8783 r8813  
    101101    static final public String LOCK_FILE = "gli.lck";
    102102
    103     static public final int COLLECTION_OPENED  = 10;
    104     static public final int COLLECTION_CLOSED  = 11;
    105     static public final int COLLECTION_REBUILT = 12;
    106 
    107103    /** Used to indicate the source of the message is the file collection methods. */
    108104    static final public int COLLECT   = 3;
     
    226222    // workspace_model = null;
    227223    Configuration.setCollectionConfiguration(null);
     224    Gatherer.refresh(Gatherer.COLLECTION_CLOSED);
    228225    if (Gatherer.g_man != null) {
    229         Gatherer.g_man.updateUI();
    230         Gatherer.g_man.refresh(COLLECTION_CLOSED, false);
     226        Gatherer.g_man.updateUI();  // !!! Necessary?
    231227    }
    232228    }
     
    482478        Gatherer.g_man.refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED);
    483479
    484         Gatherer.g_man.refresh(COLLECTION_OPENED, ready());
     480        Gatherer.refresh(Gatherer.COLLECTION_OPENED);
    485481    }
    486482    }
     
    959955
    960956        // We're done. Let everyone know.
    961         if (Gatherer.g_man != null) {
    962         Gatherer.g_man.refresh(COLLECTION_OPENED, ready());
    963         }
     957        Gatherer.refresh(Gatherer.COLLECTION_OPENED);
    964958        result = true;
    965959    }
     
    11331127
    11341128        // Fire a collection changed first to update the preview etc buttons
    1135         Gatherer.g_man.refresh(COLLECTION_REBUILT, ready());
     1129        Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
    11361130
    11371131        // Now display a message dialog saying its all built
     
    11441138        else {
    11451139        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
    1146         Gatherer.g_man.refresh(COLLECTION_REBUILT, ready());
     1140        Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
    11471141        }
    11481142    }
     
    11531147        } else {
    11541148        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
    1155         Gatherer.g_man.refresh(COLLECTION_REBUILT, ready());
     1149        Gatherer.refresh(Gatherer.COLLECTION_REBUILT);
    11561150        }
    11571151       
  • trunk/gli/src/org/greenstone/gatherer/gui/EnrichPane.java

    r8802 r8813  
    100100
    101101    /** Used to dynamically filter the collection tree at user request. Note that this is synchronized with the collection tree filter in the Gather view. */
    102     private Filter filter = null;
     102    private Filter collection_filter = null;
    103103    /** The currently reported selection. */
    104104    private CollectionTreeNode[] file_nodes = null;
     
    125125    private DragTree collection_tree;
    126126    /** Provide synchronization between the collection trees in this view and the collection pane view. */
    127     private TreeSynchronizer tree_sync = null;
     127    private TreeSynchronizer collection_tree_sync = null;
    128128    private boolean metadata_edit_event = false;
    129129
     
    132132     * @param tree_sync The <strong>TreeSynchronizer</strong> to be used on the collection tree
    133133     */
    134     public EnrichPane(TreeSynchronizer tree_sync)
     134    public EnrichPane(TreeSynchronizer collection_tree_sync)
    135135    {
    136     this.tree_sync = tree_sync;
     136    this.collection_tree_sync = collection_tree_sync;
    137137
    138138    add = new GLIButton();
     
    267267    collection_tree.addTreeSelectionListener(this);
    268268    collection_tree.addTreeExpansionListener(Gatherer.g_man.foa_listener);
    269     collection_tree.setLargeModel(true);
     269    collection_tree.setBackgroundNonSelectionColor(Configuration.getColor("coloring.collection_tree_background", false));
     270    collection_tree.setTextNonSelectionColor(Configuration.getColor("coloring.collection_tree_foreground", false));
     271    collection_tree.setBackgroundSelectionColor(Configuration.getColor("coloring.collection_selection_background", false));
     272    collection_tree.setTextSelectionColor(Configuration.getColor("coloring.collection_selection_foreground", false));
    270273    collection_tree.setRootVisible(false);
    271274
     
    274277    JScrollPane collection_scroll = new JScrollPane(collection_tree);
    275278
    276     filter = Gatherer.g_man.getFilter(collection_tree);
    277     filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
    278     filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE);
    279     Dictionary.registerTooltip(filter.getComboBox(), "Collection.Filter_Tooltip");
     279    collection_filter = Gatherer.g_man.getFilter(collection_tree);
     280    collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
     281    collection_filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE);
     282    Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip");
    280283
    281284    // Layout
     
    287290    collection_pane.add(collection_label, BorderLayout.NORTH);
    288291    collection_pane.add(collection_scroll, BorderLayout.CENTER);
    289     collection_pane.add(filter, BorderLayout.SOUTH);
     292    collection_pane.add(collection_filter, BorderLayout.SOUTH);
    290293
    291294    JSplitPane main_split_pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
     
    438441    public void modeChanged(int mode)
    439442    {
    440     filter.setEditable(mode > Configuration.LIBRARIAN_MODE);
     443    collection_filter.setEditable(mode > Configuration.LIBRARIAN_MODE);
    441444    }
    442445
    443446
    444     public void refresh(int refresh_reason, boolean ready)
     447    /** Refresh this pane, depending on what has just happened (refresh_reason). */
     448    public void refresh(int refresh_reason, boolean collection_loaded)
    445449    {
    446     if (ready) {
    447         // Update label
     450    if (collection_loaded) {
     451        // Update collection label
    448452        Dictionary.registerText(collection_label, "Collection.Collection");
    449453        collection_label.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
    450454        collection_label.setForeground(Configuration.getColor("coloring.collection_heading_foreground", false));
    451455
    452         // Update tree
    453         collection_tree.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
    454         collection_tree.setForeground(Configuration.getColor("coloring.collection_tree_foreground", false));
    455         if (refresh_reason != CollectionManager.COLLECTION_REBUILT) {
     456        // Update collection tree
     457        if (refresh_reason == Gatherer.COLLECTION_OPENED) {
    456458        collection_tree.setModel(Gatherer.c_man.getRecordSet());
    457459        }
     460
     461        // Update collection filter
     462        collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
    458463    }
    459464    else {
    460         // Update label
     465        // Update collection label
    461466        Dictionary.registerText(collection_label, "Collection.No_Collection");
    462467        collection_label.setBackground(Color.lightGray);
    463468        collection_label.setForeground(Color.black);
    464469
    465         // Update tree
    466         collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode(Dictionary.get("Collection.No_Collection"))));
    467     }
    468 
    469     filter.setEnabled(ready);
    470     // Ensure that this collection tree view is synchronized with any others.
    471     tree_sync.add(collection_tree);
     470        // Update collection tree
     471        collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error")));
     472
     473        // Update collection filter
     474        collection_filter.setBackground(Color.lightGray);
     475    }
     476
     477    // Enable or disable the controls
     478    collection_tree.setEnabled(collection_loaded);
     479    collection_filter.setEnabled(collection_loaded);
     480
     481    // Ensure that this collection tree view is synchronized with all others
     482    collection_tree_sync.add(collection_tree);
     483
     484    // Force the metadata table to be rebuilt (for switching extracted metadata on or off)
     485    if (refresh_reason == Gatherer.PREFERENCES_CHANGED) {
     486        valueChanged(null);
     487    }
    472488    }
    473489
  • trunk/gli/src/org/greenstone/gatherer/gui/Filter.java

    r7233 r8813  
    132132    public void setEnabled(boolean state) {
    133133    ignore = true;
    134     combobox.setEditable(state);
    135134    combobox.setEnabled(state);
    136135    ignore = false;
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r8783 r8813  
    103103    /** Ensures that expansion events between like collection trees are synchronized. */
    104104    private TreeSynchronizer collection_tree_sync = null;
    105     /** Ensures that expansion events between like workspace trees are synchronized. */
    106     private TreeSynchronizer workspace_tree_sync = null;
    107 
    108     static public final int GUI_REFRESHED = 0;
    109     static public final int PREFERENCES_CHANGED = 1;
    110105
    111106
     
    120115    this.collection_tree_sync = new TreeSynchronizer();
    121116    this.meta_audit = new MetaAuditFrame(collection_tree_sync, null);
    122     this.workspace_tree_sync = new TreeSynchronizer();
    123117   
    124118    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
     
    342336        }
    343337
    344         gather_pane = new GatherPane(workspace_tree_sync, collection_tree_sync);
     338        gather_pane = new GatherPane(collection_tree_sync);
    345339        gather_pane.display();
    346340        if(Configuration.get("workflow.gather", true)) {
     
    494488
    495489
    496     public void refresh(int refresh_reason, boolean ready)
     490    public void refresh(int refresh_reason, boolean collection_loaded)
    497491    {
     492    // Set the collection information in the title bar
     493    if (collection_loaded) {
     494        Collection collection = Gatherer.c_man.getCollection();
     495        setTitle(collection.getTitle(), collection.getName());
     496    }
     497    else {
     498        setTitle(null, null);
     499    }
     500
    498501    // Update the menu bar
    499     menu_bar.refresh(refresh_reason, ready);
     502    menu_bar.refresh(refresh_reason, collection_loaded);
    500503
    501504    // Update the loaded panes
    502505    if (mirror_pane != null) {
    503         mirror_pane.refresh(refresh_reason, ready);
     506        mirror_pane.refresh(refresh_reason, collection_loaded);
    504507    }
    505508    if (gather_pane != null) {
    506         gather_pane.refresh(refresh_reason, ready);
     509        gather_pane.refresh(refresh_reason, collection_loaded);
    507510    }
    508511    if (enrich_pane != null) {
    509         enrich_pane.refresh(refresh_reason, ready);
     512        enrich_pane.refresh(refresh_reason, collection_loaded);
    510513    }
    511514    if (design_pane != null) {
    512         design_pane.refresh(refresh_reason, ready);
     515        design_pane.refresh(refresh_reason, collection_loaded);
    513516    }
    514517    if (create_pane != null) {
    515         create_pane.refresh(refresh_reason, ready);
    516     }
    517 
    518     if (refresh_reason == PREFERENCES_CHANGED) {
    519         // Force both workspace and collection trees to redraw
    520         Gatherer.g_man.refreshWorkspaceTree(DragTree.TREE_DISPLAY_CHANGED);
    521         Gatherer.g_man.refreshCollectionTree(DragTree.TREE_DISPLAY_CHANGED);
    522     }
    523 
     518        create_pane.refresh(refresh_reason, collection_loaded);
     519    }
     520
     521    // Now enable tabs as necessary. Do this on event queue to prevent crazy NPEs
    524522    if (!locked) {
    525         // Now enable tabs as necessary. Do this on event queue to prevent crazy NPEs
    526         if(tab_updater == null) {
    527         tab_updater = new TabUpdater(tab_pane, ready);
     523        if (tab_updater == null) {
     524        tab_updater = new TabUpdater(tab_pane, collection_loaded);
    528525        }
    529526        else {
    530         tab_updater.setReady(ready);
     527        tab_updater.setReady(collection_loaded);
    531528        }
    532529        SwingUtilities.invokeLater(tab_updater);
    533530    }
    534 
    535     // Set the title
    536     String collection_title = null;
    537     String collection_name = null;
    538     if (ready) {
    539         Collection collection = Gatherer.c_man.getCollection();
    540         collection_title = collection.getTitle();
    541         collection_name = collection.getName();
    542         collection = null;
    543     }
    544     setTitle(collection_title, collection_name);
    545     collection_title = null;
    546     collection_name = null;
    547 
    548     // Now is a good time to force a garbage collect
    549     System.gc();
    550531    }
    551532
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r8788 r8813  
    130130     * @see org.greenstone.gatherer.file.FileQueue
    131131     */
    132     public GatherPane(TreeSynchronizer workspace_tree_sync, TreeSynchronizer collection_tree_sync) {
     132    public GatherPane(TreeSynchronizer collection_tree_sync) {
    133133    this.group = new DragGroup();
    134134    this.file_queue = Gatherer.f_man.getQueue();
    135135    this.collection_tree_sync = collection_tree_sync;
    136    
     136
    137137    // Create components.
    138138    stop_action = new GLIButton();
     
    284284
    285285    collection_filter = Gatherer.g_man.getFilter(collection_tree);
    286     if (collection != null) {
    287         collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
    288     }
    289     else {
    290         collection_filter.setBackground(Color.lightGray);
    291     }
    292     // Add a tool tip
     286    collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
     287    collection_filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE);
    293288    Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip");
    294289
     
    419414
    420415
    421     /** Called whenever a significant change occurs in the current collections state, such as a new collection being loaded or the current one being closed. Several actions must occur in the GUI to indicate this change to the user, such as en/disabling the collection tree.
    422      * @param ready <i>true</i> if a collection is loaded and ready to be modified, <i>false</i> otherwise.
    423      * @see org.greenstone.gatherer.Configuration
    424      * @see org.greenstone.gatherer.Gatherer
    425      * @see org.greenstone.gatherer.collection.CollectionManager
    426      * @see org.greenstone.gatherer.gui.Coloring
    427      * @see org.greenstone.gatherer.gui.Filter
    428      * @see org.greenstone.gatherer.util.TreeSynchronizer
    429      */
    430     public void refresh(int refresh_reason, boolean ready)
     416    /** Refresh this pane, depending on what has just happened (refresh_reason). */
     417    public void refresh(int refresh_reason, boolean collection_loaded)
    431418    {
    432     if (ready) {
    433         // Update label
     419    if (collection_loaded) {
     420        // Update collection label
    434421        Dictionary.registerText(collection_label, "Collection.Collection");
    435 
    436         // Update tree
    437         if (refresh_reason != CollectionManager.COLLECTION_REBUILT) {
     422        collection_label.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
     423        collection_label.setForeground(Configuration.getColor("coloring.collection_heading_foreground", false));
     424
     425        // Update collection tree
     426        if (refresh_reason == Gatherer.COLLECTION_OPENED) {
    438427        collection_tree.setModel(Gatherer.c_man.getRecordSet());
    439         collection_tree.repaint();
    440         }
    441 
    442         // Update filter
     428        }
     429
     430        // Update collection filter
    443431        collection_filter.setBackground(Configuration.getColor("coloring.collection_heading_background", false));
    444432    }
    445433    else {
    446         // Update label
    447         String args[] = new String[1];
     434        // Update collection label
     435        String[] args = new String[1];
    448436        args[0] = Dictionary.get("Collection.No_Collection");
    449437        Dictionary.registerText(collection_label, "Collection.Collection", args);
    450         args = null;
    451 
    452         // Update tree
     438        collection_label.setBackground(Color.lightGray);
     439        collection_label.setForeground(Color.black);
     440
     441        // Update collection tree
    453442        collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error")));
    454443
    455         // Update filter
     444        // Update collection filter
    456445        collection_filter.setBackground(Color.lightGray);
    457446    }
    458     collection_tree.setEnabled(ready);
    459     collection_filter.setEnabled(ready);
    460     collection_filter.setEditable(Configuration.getMode() > Configuration.LIBRARIAN_MODE);
    461     Dictionary.registerTooltip(collection_filter.getComboBox(), "Collection.Filter_Tooltip");
    462 
    463     // Change the label at the top of collection tree.
    464     setEnabled(collection_label, ready, Configuration.getColor("coloring.collection_heading_foreground", false), Configuration.getColor("coloring.collection_heading_background", false));
    465     // Ensure that this tree view of the collection record set is synchronized with any others.
     447
     448    // Enable or disable the controls
     449    workspace_tree.setEnabled(true);
     450    collection_tree.setEnabled(collection_loaded);
     451    collection_filter.setEnabled(collection_loaded);
     452    bin_button.setEnabled(collection_loaded);
     453    new_folder.setEnabled(collection_loaded);
     454
     455    // Ensure that this collection tree view is synchronized with all others
    466456    collection_tree_sync.add(collection_tree);
    467 
    468     // Refresh the collection tree (the workspace tree stays the same)
    469     refreshCollectionTree(DragTree.LOADED_COLLECTION_CHANGED);
    470 
    471     // Enable or disable the control buttons
    472     bin_button.setEnabled(ready);
    473     new_folder.setEnabled(ready);
    474457    }
    475458
     
    484467    }
    485468   
    486    
    487     /** Used to set the enabled state, and hence the colouring, of the two tree labels.
    488      * @param label The <strong>JLabel</strong> to be affected.
    489      * @param state <i>true</i> for enabled, i.e. when a collection is ready, <i>false</i> otherwise.
    490      * @param foreground The <strong>Color</strong> to make the foreground text of the label when enabled.
    491      * @param background The <strong>Color</strong> to make the background of the label when enabled.
    492      */
    493     private void setEnabled(JLabel label, boolean state, Color foreground, Color background) {
    494     ///ystem.err.println("Setting the label color to state " + state);
    495     if(state) {
    496         label.setBackground(background);
    497         label.setForeground(foreground);
    498     }
    499     else {
    500         label.setBackground(Color.lightGray);
    501         label.setForeground(Color.black);
    502     }
    503     label.repaint();
    504     ///ystem.err.println("Color is now " + label.getBackground());
    505     }
    506 
    507469
    508470    /** When a user right-clicks within the workspace and collection trees they are presented with a small popup menu of context based options. This class provides such functionality.
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r8688 r8813  
    711711
    712712        // Refresh the GLI to account for the configuration changes
    713         Gatherer.g_man.refresh(GUIManager.PREFERENCES_CHANGED, Gatherer.c_man.ready());
     713        Gatherer.refresh(Gatherer.PREFERENCES_CHANGED);
    714714
    715715        // Hide dialog
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r8784 r8813  
    508508    public void setEnabled(boolean state) {
    509509    super.setEnabled(state);
    510     clearSelection();
     510
    511511    // Change some colors
    512512    if(state) {
Note: See TracChangeset for help on using the changeset viewer.