Ignore:
Timestamp:
2003-11-30T21:43:23+13:00 (21 years ago)
Author:
jmt12
Message:

Here is the result of sixteen hours work over the weekend. I'm too tired to comment them all separately, but here are some of the highlights:
Rewrote how the 'base on collection' method actually retrieves and updates the collection configuration - ensuring the CDM.CollectionConfiguration class is used instead of the retarded Collection.CollectionConfiguration (which coincidently has had a name change to BasicCollectionConfiguration). Went through code search for places where the two versions had been confused. Rewrote large swathes of GDMDocument so as to differentiate between normal and extracted metadata - an attempt to prevent the snowballing extracted metadata problem. Fixed problem where GLI was correctly recieving the last few lines of an external process. The collection shortname is no longer visible, nor is the confusing double name for metadata elements. Also coloured folders in the trees are kaput. The users email is now saved as part of the GLI configuration and is used as appropriate to fill out collection fields. There are new options on the right click menus over trees to allow the expansion and collapsing of folders. 'Show Files' now shows all types (or at least 6 types) of image properly (arg, the plagues of copy and paste). 'Based On' collections are public, plugin list automatically moves to next entry if plugin removed (I guess we should do the same in every other screen?) and metadata arguments in plugins/classifiers are no longer editable. There are about a dozen other small things, but I can't remember them. Hope I remembered to set all of the files to UNIX line-endings.

Location:
trunk/gli/src/org/greenstone/gatherer/gui
Files:
11 edited

Legend:

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

    r5854 r6051  
    6565 */
    6666public class CollectionPane
    67     extends JPanel
    68     implements ActionListener, FocusListener {
    69     /** The group encompassing all of the components available as drop targets for drag and drop actions. Required so that only one component renders the ghost and higlights itself as a target, which the other members are restored to their original, pristine, condition. */
    70     private DragGroup group                  =  null;
    71     /** The tree showing the files within the collection. */
    72     private DragTree collection_tree        =  null;
    73     /** The tree showing the available source workspace. */
    74     private WorkspaceTree workspace_tree    =  null;
    75     /** The threaded queue that handles the actually movement of files, so that the gui remains responsive. */
    76     private FileQueue file_queue          =  null;
    77     /** The filter currently applied to the collection tree. */
    78     private Filter collection_filter = null;
    79     /** The filter currently applied to the workspace tree. */
    80     private Filter workspace_filter = null;
    81     /** The collection model which is used to build, and hold the data of, the collection tree. */
    82     private TreeModel collection    = null;
    83     /** The GTree model used as the data source for the workspace tree. */
    84     private TreeModel workspace          =  null;
    85     /** The button used to cancel all pending file queue jobs. */
    86     private JButton stop_action           =  null;
    87     /** The button used to create a new folder in the collection tree. */
    88     private JButton new_folder            =  null;
    89     /** The label shown at the top of the collection tree. */
    90     private JLabel collection_label       =  null;
    91     /** The label shown in the status area explaining the file apon which action is taking place. */
    92     private JLabel filename_label        =  null;
    93     /** The label shown explaining the current state of the file queue thread. */
    94     private JLabel status_label           =  null;
    95     /** The label at the top of the workspace tree. */
    96     private JLabel workspace_label        =  null;
    97     /** The panel that contains the collection tree. */
    98     private JPanel collection_pane        =  null;
    99     /** The panel that contains the various controls including the status area. */
    100     private JPanel control_pane           =  null;
    101     /** The panel that contains the workspace tree. */
    102     private JPanel workspace_pane        =  null;
    103     /** The scrollable area into which the collection tree is placed. */
    104     private JScrollPane collection_scroll =  null;
    105     /** The scrollable area into which the workspace tree is placed. */
    106     private JScrollPane workspace_scroll  =  null;
    107     /** A split pane seperating the two trees, allowing for the screen real-estate for each to be changed. */
    108     private JSplitPane tree_pane          =  null;
    109     /** Text fragment arguments used to fill in phrases returned from the dictionary. */
    110     private String args[]                =  null;
    111     /** Ensures that expansion and selection events between collection trees based on the same model are synchronized. */
    112     private TreeSynchronizer collection_tree_sync = null;
    113     /** Ensures that expansion and selection events between workspace trees based on the same model are synchronized. */
    114     private TreeSynchronizer workspace_tree_sync = null;
    115     /** The button used to delete files, which also doubles as a drop target for files from the Trees. */
    116     private UndoManager bin_button            =  null;
    117     /** The default size of a label in the interface. */
    118     static final private Dimension LABEL_SIZE = new Dimension(100,30);
    119     /** The default size of a special mapping dialog. */
    120     static final Dimension DIALOG_SIZE = new Dimension(400, 120);
    121     /** The minimum size a gui component can become. */
    122     static private Dimension MIN_SIZE    = new Dimension( 90,  90);
    123     /** The default size of the status area. */
    124     static private Dimension STATUS_SIZE = new Dimension(450, 120);
    125     /** The initial size of the trees. */
    126     static private Dimension TREE_SIZE   = new Dimension(400, 430);
    127 
    128     /* Constructor.
    129     * @param tree_sync Ensures that expansion events between like trees are synchronized.
    130     * @see org.greenstone.gatherer.file.FileManager
    131     * @see org.greenstone.gatherer.file.FileQueue
    132     */
    133     public CollectionPane(TreeSynchronizer workspace_tree_sync, TreeSynchronizer collection_tree_sync) {
     67    extends JPanel
     68    implements ActionListener, FocusListener {
     69    /** The group encompassing all of the components available as drop targets for drag and drop actions. Required so that only one component renders the ghost and higlights itself as a target, which the other members are restored to their original, pristine, condition. */
     70    private DragGroup group               =  null;
     71    /** The tree showing the files within the collection. */
     72    private DragTree collection_tree        =  null;
     73    /** The tree showing the available source workspace. */
     74    private WorkspaceTree workspace_tree    =  null;
     75    /** The threaded queue that handles the actually movement of files, so that the gui remains responsive. */
     76    private FileQueue file_queue          =  null;
     77    /** The filter currently applied to the collection tree. */
     78    private Filter collection_filter = null;
     79    /** The filter currently applied to the workspace tree. */
     80    private Filter workspace_filter = null;
     81    /** The collection model which is used to build, and hold the data of, the collection tree. */
     82    private TreeModel collection    = null;
     83    /** The GTree model used as the data source for the workspace tree. */
     84    private TreeModel workspace       =  null;
     85    /** The button used to cancel all pending file queue jobs. */
     86    private JButton stop_action        =  null;
     87    /** The button used to create a new folder in the collection tree. */
     88    private JButton new_folder          =  null;
     89    /** The label shown at the top of the collection tree. */
     90    private JLabel collection_label    =  null;
     91    /** The label shown in the status area explaining the file apon which action is taking place. */
     92    private JLabel filename_label        =  null;
     93    /** The label shown explaining the current state of the file queue thread. */
     94    private JLabel status_label        =  null;
     95    /** The label at the top of the workspace tree. */
     96    private JLabel workspace_label      =  null;
     97    /** The panel that contains the collection tree. */
     98    private JPanel collection_pane      =  null;
     99    /** The panel that contains the various controls including the status area. */
     100    private JPanel control_pane        =  null;
     101    /** The panel that contains the workspace tree. */
     102    private JPanel workspace_pane        =  null;
     103    /** The scrollable area into which the collection tree is placed. */
     104    private JScrollPane collection_scroll =  null;
     105    /** The scrollable area into which the workspace tree is placed. */
     106    private JScrollPane workspace_scroll  =  null;
     107    /** A split pane seperating the two trees, allowing for the screen real-estate for each to be changed. */
     108    private JSplitPane tree_pane          =  null;
     109    /** Text fragment arguments used to fill in phrases returned from the dictionary. */
     110    private String args[]                =  null;
     111    /** Ensures that expansion and selection events between collection trees based on the same model are synchronized. */
     112    private TreeSynchronizer collection_tree_sync = null;
     113    /** Ensures that expansion and selection events between workspace trees based on the same model are synchronized. */
     114    private TreeSynchronizer workspace_tree_sync = null;
     115    /** The button used to delete files, which also doubles as a drop target for files from the Trees. */
     116    private UndoManager bin_button          =  null;
     117    /** The default size of a label in the interface. */
     118    static final private Dimension LABEL_SIZE = new Dimension(100,30);
     119    /** The default size of a special mapping dialog. */
     120    static final Dimension DIALOG_SIZE = new Dimension(400, 120);
     121    /** The minimum size a gui component can become. */
     122    static private Dimension MIN_SIZE   = new Dimension( 90,  90);
     123    /** The default size of the status area. */
     124    static private Dimension STATUS_SIZE = new Dimension(450, 120);
     125    /** The initial size of the trees. */
     126    static private Dimension TREE_SIZE   = new Dimension(400, 430);
     127
     128    /* Constructor.
     129    * @param tree_sync Ensures that expansion events between like trees are synchronized.
     130    * @see org.greenstone.gatherer.file.FileManager
     131    * @see org.greenstone.gatherer.file.FileQueue
     132    */
     133    public CollectionPane(TreeSynchronizer workspace_tree_sync, TreeSynchronizer collection_tree_sync) {
    134134    this.group = new DragGroup();
    135135    this.file_queue = Gatherer.f_man.getQueue();
     
    149149    new_folder.setPreferredSize(MIN_SIZE);
    150150    Dictionary.registerTooltip(new_folder, "Collection.New_Folder_Tooltip");
    151     }
    152 
    153     /** Any implementation of ActionListener requires this method so that when an action is performed the appropriate effect can occur. In this case there are three valid possibilities. If the action occured on the recycle bin, then delete the current selection from the collection tree. If the action instead occured on the new folder button, then create a new folder under the current (single) selection in the collection tree. And finally if the cancel button was pressed, cancel the current, and remaining, jobs on the file queue. */
    154     public void actionPerformed(ActionEvent event) {
     151    }
     152
     153    /** Any implementation of ActionListener requires this method so that when an action is performed the appropriate effect can occur. In this case there are three valid possibilities. If the action occured on the recycle bin, then delete the current selection from the collection tree. If the action instead occured on the new folder button, then create a new folder under the current (single) selection in the collection tree. And finally if the cancel button was pressed, cancel the current, and remaining, jobs on the file queue. */
     154    public void actionPerformed(ActionEvent event) {
    155155    // If a user has clicked on the bin button directly remove whatever
    156156    // files are selected in the active tree.
    157157    if(event.getSource() == bin_button) {
    158         if(!bin_button.ignore()) {
     158        if(!bin_button.ignore()) {
    159159        // Find the active tree (you've made selections in).
    160160        DragTree tree = (DragTree) group.getActive();
     
    164164        TreePath paths[] = tree.getSelectionPaths();
    165165        if(paths != null) {
    166             FileNode[] source_nodes = new FileNode[paths.length];
    167             for(int i = 0; i < paths.length; i++) {
     166            FileNode[] source_nodes = new FileNode[paths.length];
     167            for(int i = 0; i < paths.length; i++) {
    168168            source_nodes[i] = (FileNode)(paths[i].getLastPathComponent());
    169             }
    170             Gatherer.f_man.action(tree, source_nodes, bin_button, null);
    171         }
    172         }
     169            }
     170            Gatherer.f_man.action(tree, source_nodes, bin_button, null);
     171        }
     172        }
    173173    }
    174174    // If a user has clicked on new_folder create a new folder under
    175175    // whatever node is selected.
    176176    else if(event.getSource() == new_folder && collection_tree != null) {
    177         int count = collection_tree.getSelectionCount();
    178         boolean error = false;
    179         if(count == 1) {
     177        int count = collection_tree.getSelectionCount();
     178        boolean error = false;
     179        if(count == 1) {
    180180        TreePath path = collection_tree.getSelectionPath();
    181181        FileNode node = (FileNode) path.getLastPathComponent();
    182182        if(node.getAllowsChildren()) {
    183             Gatherer.f_man.newFolder(collection_tree, node);
     183            Gatherer.f_man.newFolder(collection_tree, node);
    184184        }
    185185        else {
    186             // try the parent
    187             FileNode parent = (FileNode)node.getParent();
    188             if (parent!=null && parent.getAllowsChildren()) {
     186            // try the parent
     187            FileNode parent = (FileNode)node.getParent();
     188            if (parent!=null && parent.getAllowsChildren()) {
    189189            Gatherer.f_man.newFolder(collection_tree, parent);
    190             } else {
     190            } else {
    191191            error = true;
    192             }
    193         }
    194         }
    195         else {
     192            }
     193        }
     194        }
     195        else {
    196196        error = true;
    197         }
    198         if(error) {
     197        }
     198        if(error) {
    199199        // instead of an error, we now create a new folder at the root
    200200        FileNode node = (FileNode) collection_tree.getModel().getRoot();
    201201        Gatherer.f_man.newFolder(collection_tree, node);
    202202        //JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.No_Parent_For_New_Folder"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    203         }
     203        }
    204204    }
    205205    else if(event.getSource() == stop_action) {
    206         file_queue.cancelAction();
    207     }
    208     }
    209     /** 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.
    210     * @param ready <i>true</i> if a collection is loaded and ready to be modified, <i>false</i> otherwise.
    211     * @see org.greenstone.gatherer.Configuration
    212     * @see org.greenstone.gatherer.Gatherer
    213     * @see org.greenstone.gatherer.collection.CollectionManager
    214     * @see org.greenstone.gatherer.gui.Coloring
    215     * @see org.greenstone.gatherer.gui.Filter
    216     * @see org.greenstone.gatherer.util.TreeSynchronizer
    217     */
    218     public void collectionChanged(boolean ready) {
     206        file_queue.cancelAction();
     207    }
     208    }
     209    /** 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.
     210    * @param ready <i>true</i> if a collection is loaded and ready to be modified, <i>false</i> otherwise.
     211    * @see org.greenstone.gatherer.Configuration
     212    * @see org.greenstone.gatherer.Gatherer
     213    * @see org.greenstone.gatherer.collection.CollectionManager
     214    * @see org.greenstone.gatherer.gui.Coloring
     215    * @see org.greenstone.gatherer.gui.Filter
     216    * @see org.greenstone.gatherer.util.TreeSynchronizer
     217    */
     218    public void collectionChanged(boolean ready) {
    219219    // Try to retrieve the collections record set.
    220220    collection = Gatherer.c_man.getRecordSet();
    221221    if(collection != null) {
    222         args = new String[1];
    223         args[0] = Gatherer.c_man.getCollection().getName();
    224         Dictionary.registerText(collection_label, "Collection.Collection", args);
    225         collection_tree.setModel(collection);
    226         collection_tree.repaint();
    227         collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
     222        //args = new String[1];
     223        //args[0] = Gatherer.c_man.getCollection().getName();
     224        Dictionary.registerText(collection_label, "Collection.Collection");
     225        collection_tree.setModel(collection);
     226        collection_tree.repaint();
     227        collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
    228228    }
    229229    else {
    230         String args[] = new String[1];
    231         args[0] = Dictionary.get("Collection.No_Collection");
    232         Dictionary.registerText(collection_label, "Collection.Collection", args);
    233         args = null;
    234         collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error")));
    235         collection_filter.setBackground(Color.lightGray);
     230        String args[] = new String[1];
     231        args[0] = Dictionary.get("Collection.No_Collection");
     232        Dictionary.registerText(collection_label, "Collection.Collection", args);
     233        args = null;
     234        collection_tree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("Error")));
     235        collection_filter.setBackground(Color.lightGray);
    236236    }
    237237    collection_tree.setEnabled(ready);
     
    251251    stop_action.setEnabled(ready);
    252252    new_folder.setEnabled(ready);
    253     }
    254 
    255     /** Generates the pane on controls used to 'collect' files into the collection. Resposible for creating, connecting and laying out these controls. */
    256     public void display() {
     253    }
     254
     255    /** Generates the pane on controls used to 'collect' files into the collection. Resposible for creating, connecting and laying out these controls. */
     256    public void display() {
    257257    // Create Components.
    258258    KeyListenerImpl key_listener = new KeyListenerImpl();
     
    306306    collection_pane.setSize(TREE_SIZE);
    307307
    308     args = new String[1];
    309     args[0] = Dictionary.get("Collection.No_Collection");
     308    //args = new String[1];
     309    //args[0] = Dictionary.get("Collection.No_Collection");
    310310    collection_label = new JLabel();
    311311    collection_label.setOpaque(true);
    312     Dictionary.registerText(collection_label, "Collection.Collection", args);
     312    Dictionary.registerText(collection_label, "Collection.No_Collection");
    313313
    314314    collection = Gatherer.c_man.getRecordSet();
    315315    if(collection != null) {
    316         collection_tree = new DragTree(Utility.COLLECTION_TREE, collection, null, true);
    317         collection_tree.setEnabled(true);
     316        collection_tree = new DragTree(Utility.COLLECTION_TREE, collection, null, true);
     317        collection_tree.setEnabled(true);
    318318    }
    319319    else {
    320         collection_tree = new DragTree(Utility.COLLECTION_TREE, null, true);
    321         collection_tree.setEnabled(false);
     320        collection_tree = new DragTree(Utility.COLLECTION_TREE, null, true);
     321        collection_tree.setEnabled(false);
    322322    }
    323323    group.add(collection_tree);
     
    340340    collection_filter = Gatherer.g_man.getFilter(collection_tree);
    341341    if(collection != null) {
    342         collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
     342        collection_filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
    343343    }
    344344    else {
    345         collection_filter.setBackground(Color.lightGray);
     345        collection_filter.setBackground(Color.lightGray);
    346346    }
    347347    // Change the default colours of this filters combobox.
     
    427427    this.add(tree_pane, BorderLayout.CENTER);
    428428    this.add(control_pane, BorderLayout.SOUTH);
    429     }
    430     /** This method ensures that a certain tree path is visible and selected within the collection tree, expanding nodes if necessary. If the method is successful the bounds of the new selection are returned. */
    431     public Rectangle expandPath(TreePath path) {
     429    }
     430    /** This method ensures that a certain tree path is visible and selected within the collection tree, expanding nodes if necessary. If the method is successful the bounds of the new selection are returned. */
     431    public Rectangle expandPath(TreePath path) {
    432432    collection_tree.setImmediate(true);
    433433    collection_tree.scrollPathToVisible(path);
     
    435435    collection_tree.setImmediate(false);
    436436    return collection_tree.getRowBounds(collection_tree.getRowForPath(path));
    437     }
    438     /** Called whenever this pane gains focus, this method ensures that the various tree renderers are correctly colouring the tree (as these settings sometimes get lost).
    439     * @param event A <strong>FocusEvent</strong> containing details about the focus action performed.
    440     */
    441     public void focusGained(FocusEvent event) {
     437    }
     438    /** Called whenever this pane gains focus, this method ensures that the various tree renderers are correctly colouring the tree (as these settings sometimes get lost).
     439    * @param event A <strong>FocusEvent</strong> containing details about the focus action performed.
     440    */
     441    public void focusGained(FocusEvent event) {
    442442    DefaultTreeCellRenderer def = new DefaultTreeCellRenderer();
    443443    DefaultTreeCellRenderer w = (DefaultTreeCellRenderer)workspace_tree.getCellRenderer();
    444444    DefaultTreeCellRenderer c = (DefaultTreeCellRenderer)collection_tree.getCellRenderer();
    445445    if(event.getSource() == workspace_tree) {
    446         w.setBackgroundSelectionColor(def.getBackgroundSelectionColor());
    447         c.setBackgroundSelectionColor(Color.lightGray);
     446        w.setBackgroundSelectionColor(def.getBackgroundSelectionColor());
     447        c.setBackgroundSelectionColor(Color.lightGray);
    448448    }
    449449    else if(event.getSource() == collection_tree) {
    450         c.setBackgroundSelectionColor(def.getBackgroundSelectionColor());
    451         w.setBackgroundSelectionColor(Color.lightGray);
     450        c.setBackgroundSelectionColor(def.getBackgroundSelectionColor());
     451        w.setBackgroundSelectionColor(Color.lightGray);
    452452    }
    453453    repaint();
    454     }
    455     /** Implementation side-effect, not used in any way.
    456     * @param event A <strong>FocusEvent</strong> containing details about the focus action performed.
    457     */
    458     public void focusLost(FocusEvent event) {
    459     }
    460 
    461     /** Called to inform this control panel that it has just gained focus as an effect of the user clicking on its tab.
    462     * @see org.greenstone.gatherer.tree.GTree
    463     */
    464     public void gainFocus() {
     454    }
     455    /** Implementation side-effect, not used in any way.
     456    * @param event A <strong>FocusEvent</strong> containing details about the focus action performed.
     457    */
     458    public void focusLost(FocusEvent event) {
     459    }
     460
     461    /** Called to inform this control panel that it has just gained focus as an effect of the user clicking on its tab.
     462    * @see org.greenstone.gatherer.tree.GTree
     463    */
     464    public void gainFocus() {
    465465    // Update the menubar's idea of whats been selected
    466466    if (collection_tree != null) {
    467         if (collection_tree.isSelectionEmpty()) {
     467        if (collection_tree.isSelectionEmpty()) {
    468468        Gatherer.g_man.menu_bar.setMetaAuditSuffix(null);
    469         }
    470         else {
     469        }
     470        else {
    471471        Gatherer.g_man.menu_bar.setMetaAuditSuffix(collection_tree.getSelectionDetails());
    472         }
     472        }
    473473    }
    474474    // Update the meta-audit view to show the current selection, if any.
    475475    Gatherer.g_man.meta_audit.setRecords(getSelected());
    476     }
    477 
    478     /** Retrieve a list of the currently selected file records in the active tree. */
    479     public FileNode[] getSelected() {
     476    }
     477
     478    /** Retrieve a list of the currently selected file records in the active tree. */
     479    public FileNode[] getSelected() {
    480480    TreePath paths[] = collection_tree.getSelectionPaths();
    481481    FileNode records[] = null;
    482482    if(paths != null) {
    483         records = new FileNode[paths.length];
    484         for(int i = 0; i < records.length; i++) {
     483        records = new FileNode[paths.length];
     484        for(int i = 0; i < records.length; i++) {
    485485        records[i] = (FileNode) paths[i].getLastPathComponent();
    486         }
     486        }
    487487    }
    488488    return records;
    489     }
    490 
    491     public String getSelectionDetails() {
     489    }
     490
     491    public String getSelectionDetails() {
    492492    return collection_tree.getSelectionDetails();
    493     }
    494 
    495 
    496     public void refreshCollectionTree(int refresh_reason)
    497     {
     493    }
     494
     495
     496    public void refreshCollectionTree(int refresh_reason)
     497    {
    498498    collection_tree.refresh(null);
    499     }
    500 
    501 
    502     public void refreshWorkspaceTree(int refresh_reason)
    503     {
     499    }
     500
     501
     502    public void refreshWorkspaceTree(int refresh_reason)
     503    {
    504504    workspace_tree.refresh(refresh_reason);
    505     }
    506 
    507 
    508     /** Used to set the enabled state, and hence the colouring, of the two tree labels.
    509     * @param label The <strong>JLabel</strong> to be affected.
    510     * @param state <i>true</i> for enabled, i.e. when a collection is ready, <i>false</i> otherwise.
    511     * @param foreground The <strong>Color</strong> to make the foreground text of the label when enabled.
    512     * @param background The <strong>Color</strong> to make the background of the label when enabled.
    513     */
    514     private void setEnabled(JLabel label, boolean state, Color foreground, Color background) {
     505    }
     506
     507
     508    /** Used to set the enabled state, and hence the colouring, of the two tree labels.
     509    * @param label The <strong>JLabel</strong> to be affected.
     510    * @param state <i>true</i> for enabled, i.e. when a collection is ready, <i>false</i> otherwise.
     511    * @param foreground The <strong>Color</strong> to make the foreground text of the label when enabled.
     512    * @param background The <strong>Color</strong> to make the background of the label when enabled.
     513    */
     514    private void setEnabled(JLabel label, boolean state, Color foreground, Color background) {
    515515    ///ystem.err.println("Setting the label color to state " + state);
    516516    if(state) {
    517         label.setBackground(background);
    518         label.setForeground(foreground);
     517        label.setBackground(background);
     518        label.setForeground(foreground);
    519519    }
    520520    else {
    521         label.setBackground(Color.lightGray);
    522         label.setForeground(Color.black);
     521        label.setBackground(Color.lightGray);
     522        label.setForeground(Color.black);
    523523    }
    524524    label.repaint();
    525525    ///ystem.err.println("Color is now " + label.getBackground());
    526     }
    527 
    528     /** When a user right-clicks within the trees on the collection pane view they are presented with a small popup menu of context based options. This class provides such functionality.
    529      */
    530     private class GPopupMenu
    531     extends JPopupMenu
    532     implements ActionListener {
    533     /** The tree over which the right click action occured. */
    534     private DragTree tree = null;
    535     /** The file record over which the right click action occured, if any. */
    536     private FileNode node = null;
    537     /** A menu item enabled if a delete action is appropriate in the menus current context. */
    538     private JMenuItem delete = null;
    539     /** A menu item enabled if a special directory mapping is appropriate in the menus current context. */
    540     private JMenuItem map = null;
    541     /** A menu item enabled if a new folder action is appropriate in the menus current context. */
    542     private JMenuItem new_folder = null;
    543     /** A menu item enabled if a show meta-audit dialog action is appropriate in the menus current context. */
    544     private JMenuItem show_metaaudit = null;
    545     /** A menu item allowing a user to unmap a special directory, if and only if a special directory is selected. */
    546     private JMenuItem unmap = null;
    547     /** Constructor. */
    548     public GPopupMenu(DragTree tree, MouseEvent event) {
    549         super();
    550         this.tree = tree;
    551         TreePath path = tree.getClosestPathForLocation(event.getX(), event.getY());
    552         if(path != null) {
    553         node = (FileNode)path.getLastPathComponent();
    554         // Set Options based on selection and tree
    555         if(tree.getSelectionCount() != 0 && tree == collection_tree) {
    556             String[] args = new String[1];
    557             args[0] = collection_tree.getSelectionDetails();
    558             show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V);
    559             show_metaaudit.addActionListener(this);
    560             add(show_metaaudit);
    561         }
    562         if(tree == collection_tree && node != null && node.getFile() != null && node.getFile().isDirectory() && !node.isReadOnly()) {
    563             new_folder = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Folder"), KeyEvent.VK_N);
    564             new_folder.addActionListener(this);
    565             add(new_folder);
    566             add(new JSeparator());
    567         }
    568         if(tree == collection_tree && tree.getSelectionCount() != 0 && node != null && !node.isReadOnly()) {
    569             delete = new JMenuItem(Dictionary.get("CollectionPopupMenu.Delete"), KeyEvent.VK_D);
    570             delete.addActionListener(this);
    571             add(delete);
    572         }
    573         if(tree == workspace_tree && node != null && !node.isLeaf()) {
    574             String node_name = node.toString();
    575             FileNode root = (FileNode) tree.getModel().getRoot();
    576             if(!node_name.equals(Dictionary.get("Tree.World")) && !node_name.equals(Dictionary.get("Tree.Root")) && !node_name.equals(Dictionary.get("Tree.Public")) && !node_name.equals(Dictionary.get("Tree.Private"))) {
    577             // You can unmap 1st level nodes.
    578             if(root.getIndex(node) != -1) {
    579                 unmap = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_U);
    580                 unmap.addActionListener(this);
    581                 add(unmap);
     526    }
     527
     528        /** When a user right-clicks within the trees on the collection pane view they are presented with a small popup menu of context based options. This class provides such functionality.
     529         */
     530        private class GPopupMenu
     531            extends JPopupMenu
     532            implements ActionListener {
     533
     534            /** The tree over which the right click action occured. */
     535            private DragTree tree = null;
     536            /** The file record over which the right click action occured, if any. */
     537            private FileNode node = null;
     538            private JMenuItem collapse_expand_folder_menuitem;
     539            /** A menu item enabled if a delete action is appropriate in the menus current context. */
     540            private JMenuItem delete = null;
     541            /** A menu item enabled if a special directory mapping is appropriate in the menus current context. */
     542            private JMenuItem map = null;
     543            /** A menu item enabled if a new folder action is appropriate in the menus current context. */
     544            private JMenuItem new_folder = null;
     545            /** A menu item enabled if a show meta-audit dialog action is appropriate in the menus current context. */
     546            private JMenuItem show_metaaudit = null;
     547            /** A menu item allowing a user to unmap a special directory, if and only if a special directory is selected. */
     548            private JMenuItem unmap = null;
     549            private TreePath path = null;
     550            /** Constructor. */
     551            public GPopupMenu(DragTree tree, MouseEvent event) {
     552                super();
     553                this.tree = tree;
     554                this.path = tree.getClosestPathForLocation(event.getX(), event.getY());
     555                if(path != null) {
     556                node = (FileNode)path.getLastPathComponent();
     557                    // Any folder node gets a menu item allowing you to collapse or expand it depending on its current status
     558                    if(!node.isLeaf()) {
     559                        // Collapse
     560                        if(tree.isExpanded(path)) {
     561                            collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Collapse"), KeyEvent.VK_C);
     562                        }
     563                        // Expand
     564                        else {
     565                            collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Expand"), KeyEvent.VK_O);
     566                        }
     567                        collapse_expand_folder_menuitem.addActionListener(this);
     568                        add(collapse_expand_folder_menuitem);
     569                    }
     570                    // Set Options based on selection and tree
     571                    if(tree.getSelectionCount() != 0 && tree == collection_tree) {
     572                        String[] args = new String[1];
     573                        args[0] = collection_tree.getSelectionDetails();
     574                        show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V);
     575                        show_metaaudit.addActionListener(this);
     576                        add(show_metaaudit);
     577                    }
     578                    if(tree == collection_tree && node != null && node.getFile() != null && node.getFile().isDirectory() && !node.isReadOnly()) {
     579                        new_folder = new JMenuItem(Dictionary.get("CollectionPopupMenu.New_Folder"), KeyEvent.VK_N);
     580                        new_folder.addActionListener(this);
     581                        add(new_folder);
     582                        add(new JSeparator());
     583                    }
     584                    if(tree == collection_tree && tree.getSelectionCount() != 0 && node != null && !node.isReadOnly()) {
     585                        delete = new JMenuItem(Dictionary.get("CollectionPopupMenu.Delete"), KeyEvent.VK_D);
     586                        delete.addActionListener(this);
     587                        add(delete);
     588                    }
     589                    if(tree == workspace_tree && node != null && !node.isLeaf()) {
     590                        String node_name = node.toString();
     591                        FileNode root = (FileNode) tree.getModel().getRoot();
     592                        if(!node_name.equals(Dictionary.get("Tree.World")) && !node_name.equals(Dictionary.get("Tree.Root")) && !node_name.equals(Dictionary.get("Tree.Public")) && !node_name.equals(Dictionary.get("Tree.Private"))) {
     593                            // You can unmap 1st level nodes.
     594                            if(root.getIndex(node) != -1) {
     595                                unmap = new JMenuItem(Dictionary.get("MappingPrompt.Unmap"), KeyEvent.VK_U);
     596                                unmap.addActionListener(this);
     597                                add(unmap);
     598                            }
     599                            // Or map any other level directories.
     600                            else {
     601                                map = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_M);
     602                                map.addActionListener(this);
     603                                add(map);
     604                            }
     605                        }
     606                    }
     607                    show(tree, event.getX(), event.getY());
     608                }
    582609            }
    583             // Or map any other level directories.
    584             else {
    585                 map = new JMenuItem(Dictionary.get("MappingPrompt.Map"), KeyEvent.VK_M);
    586                 map.addActionListener(this);
    587                 add(map);
     610
     611            /** Called whenever one of the menu items is actioned apon, this method then causes the appropriate effect. */
     612            public void actionPerformed(ActionEvent event) {
     613                Object source = event.getSource();
     614                if(source == delete) {
     615                    // Retrieve the selection. Of course this gets a bit tricky as the user may have right clicked over a node not in the current selection, in which case we remove only that node.
     616                    TreePath[] selection_paths = tree.getSelectionPaths();
     617                    if(selection_paths != null) {
     618                        FileNode[] source_nodes = new FileNode[selection_paths.length];
     619                        boolean found = false;
     620                        for(int i = 0; i < selection_paths.length; i++) {
     621                            source_nodes[i] = (FileNode) selection_paths[i].getLastPathComponent();
     622                            if(node != null) {
     623                                found = found || source_nodes[i].equals(node);
     624                            }
     625                        }
     626                        if(node != null && !found) {
     627                            source_nodes = null;
     628                            source_nodes = new FileNode[1];
     629                            source_nodes[0] = node;
     630                        }
     631                        // Fire a delete action
     632                        Gatherer.f_man.action(tree, source_nodes, bin_button, null);
     633                        source_nodes = null;
     634                    }
     635                    selection_paths = null;
     636                }
     637                else if(source == map && node != null) {
     638                    MappingPrompt mp = new MappingPrompt(node.getFile());
     639                    mp.destroy();
     640                    mp = null;
     641                }
     642                else if(source == new_folder && node != null) {
     643                    Gatherer.f_man.newFolder(tree, node);
     644                }
     645                else if(source == show_metaaudit) {
     646                    Gatherer.g_man.showMetaAuditBox();
     647                }
     648                else if(source == unmap && node != null) {
     649                    Gatherer.c_man.removeDirectoryMapping(node);
     650                }
     651                else if(source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) {
     652                    // Collapse
     653                    if(tree.isExpanded(path)) {
     654                        tree.collapsePath(path);
     655                    }
     656                    // Expand
     657                    else {
     658                        tree.expandPath(path);
     659                    }
     660                }
    588661            }
    589             }
    590         }
    591         show(tree, event.getX(), event.getY());
    592         }
    593     }
    594     /** Called whenever one of the menu items is actioned apon, this method then causes the appropriate effect. */
    595     public void actionPerformed(ActionEvent event) {
    596         if(event.getSource() == delete) {
    597         // Retrieve the selection. Of course this gets a bit tricky as the user may have right clicked over a node not in the current selection, in which case we remove only that node.
    598         TreePath[] selection_paths = tree.getSelectionPaths();
    599         if(selection_paths != null) {
    600             FileNode[] source_nodes = new FileNode[selection_paths.length];
    601             boolean found = false;
    602             for(int i = 0; i < selection_paths.length; i++) {
    603             source_nodes[i] = (FileNode) selection_paths[i].getLastPathComponent();
    604             if(node != null) {
    605                 found = found || source_nodes[i].equals(node);
    606             }
    607             }
    608             if(node != null && !found) {
    609             source_nodes = null;
    610             source_nodes = new FileNode[1];
    611             source_nodes[0] = node;
    612             }
    613             // Fire a delete action
    614             Gatherer.f_man.action(tree, source_nodes, bin_button, null);
    615             source_nodes = null;
    616         }
    617         selection_paths = null;
    618         }
    619         else if(event.getSource() == map && node != null) {
    620         MappingPrompt mp = new MappingPrompt(node.getFile());
    621         mp.destroy();
    622         mp = null;
    623         }
    624         else if(event.getSource() == new_folder && node != null) {
    625         Gatherer.f_man.newFolder(tree, node);
    626         }
    627         else if(event.getSource() == show_metaaudit) {
    628         Gatherer.g_man.showMetaAuditBox();
    629         }
    630         else if(event.getSource() == unmap && node != null) {
    631         Gatherer.c_man.removeDirectoryMapping(node);
    632         }
    633     }
    634     }
    635 
    636     /** This class listens for certain key presses, such as [Enter] or [Delete], and responds appropriately. */
    637     private class KeyListenerImpl
     662        }
     663
     664    /** This class listens for certain key presses, such as [Enter] or [Delete], and responds appropriately. */
     665    private class KeyListenerImpl
    638666    extends KeyAdapter {
    639667    /** Called whenever a key that was pressed is released, it is this action that will cause the desired effects (this allows for the key event itself to be processed prior to this listener dealing with it). */
    640668    public void keyReleased(KeyEvent event) {
    641669                ///ystem.err.println("Key Release detected. " + event.getKeyCode());
    642         if(event.getKeyCode() == KeyEvent.VK_DELETE) {
     670        if(event.getKeyCode() == KeyEvent.VK_DELETE) {
    643671        // Get the selected files from the tree and removal them using the default dnd removal method.
    644672        // Find the active tree (you've made selections in).
     
    649677        TreePath paths[] = tree.getSelectionPaths();
    650678        if(paths != null) {
    651             FileNode[] source_nodes = new FileNode[paths.length];
    652             for(int i = 0; i < source_nodes.length; i++) {
     679            FileNode[] source_nodes = new FileNode[paths.length];
     680            for(int i = 0; i < source_nodes.length; i++) {
    653681            source_nodes[i] = (FileNode) paths[i].getLastPathComponent();
    654             }
    655             Gatherer.f_man.action(tree, source_nodes, bin_button, null);
    656             source_nodes = null;
    657         }
    658         }
    659         else if(event.getKeyCode() == KeyEvent.VK_ENTER) {
     682            }
     683            Gatherer.f_man.action(tree, source_nodes, bin_button, null);
     684            source_nodes = null;
     685        }
     686        }
     687        else if(event.getKeyCode() == KeyEvent.VK_ENTER) {
    660688        // Get the first selected file.
    661689        DragTree tree = (DragTree)event.getSource();
    662690        TreePath path = tree.getSelectionPath();
    663691        if(path != null) {
    664             File file = ((FileNode)path.getLastPathComponent()).getFile();
    665             if(file != null && file.isFile()) {
     692            File file = ((FileNode)path.getLastPathComponent()).getFile();
     693            if(file != null && file.isFile()) {
    666694            Gatherer.self.spawnApplication(file);
    667             }
    668             else {
    669             if(!tree.isExpanded(path)) {
    670                 tree.expandPath(path);
    671695            }
    672696            else {
    673                 tree.collapsePath(path);
     697            if(!tree.isExpanded(path)) {
     698                tree.expandPath(path);
    674699            }
    675             }
    676         }
    677         }
    678     }
    679     }
    680 
    681     /** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name. */
    682     private class MappingPrompt
     700            else {
     701                tree.collapsePath(path);
     702            }
     703            }
     704        }
     705        }
     706    }
     707    }
     708
     709    /** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name. */
     710    private class MappingPrompt
    683711    extends JDialog
    684712    implements ActionListener, KeyListener {
     
    688716    private JTextField name_field = null;
    689717    public MappingPrompt(File file) {
    690         super(Gatherer.g_man);
    691         setModal(true);
    692         setSize(DIALOG_SIZE);
    693         Dictionary.setText(this, "MappingPrompt.Title");
    694 
    695         // Creation
    696         JPanel content_pane = (JPanel) getContentPane();
    697         JPanel center_pane = new JPanel();
    698         JPanel file_pane = new JPanel();
    699         JLabel file_label = new JLabel();
    700         file_label.setPreferredSize(LABEL_SIZE);
    701         Dictionary.setText(file_label, "MappingPrompt.File");
    702         JLabel file_field = new JLabel(file.getAbsolutePath());
    703         JPanel name_pane = new JPanel();
    704         JLabel name_label = new JLabel();
    705         name_label.setPreferredSize(LABEL_SIZE);
    706         Dictionary.setText(name_label, "MappingPrompt.Name");
    707         name_field = new JTextField(file.getName());
    708         JPanel button_pane = new JPanel();
    709         ok_button = new JButton();
    710         ok_button.setEnabled(name_field.getText().length() > 0);
    711         Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
    712         cancel_button = new JButton();
    713         Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip");
    714 
    715         // Connection
    716         cancel_button.addActionListener(this);
    717         ok_button.addActionListener(this);
    718         name_field.addKeyListener(this);
    719         // Layout
    720         file_pane.setLayout(new BorderLayout());
    721         file_pane.add(file_label, BorderLayout.WEST);
    722         file_pane.add(file_field, BorderLayout.CENTER);
    723 
    724         name_pane.setLayout(new BorderLayout());
    725         name_pane.add(name_label, BorderLayout.WEST);
    726         name_pane.add(name_field, BorderLayout.CENTER);
    727 
    728         center_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
    729         center_pane.setLayout(new GridLayout(2,1,5,5));
    730         center_pane.add(file_pane);
    731         center_pane.add(name_pane);
    732 
    733         button_pane.setLayout(new GridLayout(1,2,5,5));
    734         button_pane.add(ok_button);
    735         button_pane.add(cancel_button);
    736 
    737         content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    738         content_pane.setLayout(new BorderLayout());
    739         content_pane.add(center_pane, BorderLayout.CENTER);
    740         content_pane.add(button_pane, BorderLayout.SOUTH);
    741         // Display
    742         Dimension screen_size = Gatherer.config.screen_size;
    743         setLocation((screen_size.width - DIALOG_SIZE.width) / 2, (screen_size.height - DIALOG_SIZE.height) / 2);
    744         show();
    745         // If not cancelled create mapping.
    746         if(!cancelled) {
     718        super(Gatherer.g_man);
     719        setModal(true);
     720        setSize(DIALOG_SIZE);
     721        Dictionary.setText(this, "MappingPrompt.Title");
     722
     723        // Creation
     724        JPanel content_pane = (JPanel) getContentPane();
     725        JPanel center_pane = new JPanel();
     726        JPanel file_pane = new JPanel();
     727        JLabel file_label = new JLabel();
     728        file_label.setPreferredSize(LABEL_SIZE);
     729        Dictionary.setText(file_label, "MappingPrompt.File");
     730        JLabel file_field = new JLabel(file.getAbsolutePath());
     731        JPanel name_pane = new JPanel();
     732        JLabel name_label = new JLabel();
     733        name_label.setPreferredSize(LABEL_SIZE);
     734        Dictionary.setText(name_label, "MappingPrompt.Name");
     735        name_field = new JTextField(file.getName());
     736        JPanel button_pane = new JPanel();
     737        ok_button = new JButton();
     738        ok_button.setEnabled(name_field.getText().length() > 0);
     739        Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
     740        cancel_button = new JButton();
     741        Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip");
     742
     743        // Connection
     744        cancel_button.addActionListener(this);
     745        ok_button.addActionListener(this);
     746        name_field.addKeyListener(this);
     747        // Layout
     748        file_pane.setLayout(new BorderLayout());
     749        file_pane.add(file_label, BorderLayout.WEST);
     750        file_pane.add(file_field, BorderLayout.CENTER);
     751
     752        name_pane.setLayout(new BorderLayout());
     753        name_pane.add(name_label, BorderLayout.WEST);
     754        name_pane.add(name_field, BorderLayout.CENTER);
     755
     756        center_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     757        center_pane.setLayout(new GridLayout(2,1,5,5));
     758        center_pane.add(file_pane);
     759        center_pane.add(name_pane);
     760
     761        button_pane.setLayout(new GridLayout(1,2,5,5));
     762        button_pane.add(ok_button);
     763        button_pane.add(cancel_button);
     764
     765        content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     766        content_pane.setLayout(new BorderLayout());
     767        content_pane.add(center_pane, BorderLayout.CENTER);
     768        content_pane.add(button_pane, BorderLayout.SOUTH);
     769        // Display
     770        Dimension screen_size = Gatherer.config.screen_size;
     771        setLocation((screen_size.width - DIALOG_SIZE.width) / 2, (screen_size.height - DIALOG_SIZE.height) / 2);
     772        show();
     773        // If not cancelled create mapping.
     774        if(!cancelled) {
    747775        Gatherer.c_man.addDirectoryMapping(name_field.getText(), file);
    748         }
     776        }
    749777    }
    750778    public void actionPerformed(ActionEvent event) {
    751         if(event.getSource() == cancel_button) {
     779        if(event.getSource() == cancel_button) {
    752780        cancelled = true;
    753         }
    754         dispose();
     781        }
     782        dispose();
    755783    }
    756784    public void destroy() {
    757         cancel_button = null;
    758         ok_button = null;
    759         name_field = null;
     785        cancel_button = null;
     786        ok_button = null;
     787        name_field = null;
    760788    }
    761789    public void keyPressed(KeyEvent event) {
    762790    }
    763791    public void keyReleased(KeyEvent event) {
    764         ok_button.setEnabled(name_field.getText().length() > 0);
     792        ok_button.setEnabled(name_field.getText().length() > 0);
    765793
    766794    }
    767795    public void keyTyped(KeyEvent event) {
    768796    }
    769     }
    770     /** This class listens for mouse clicks and responds right mouse button clicks (popup menu). */
    771     private class MouseListenerImpl
     797    }
     798    /** This class listens for mouse clicks and responds right mouse button clicks (popup menu). */
     799    private class MouseListenerImpl
    772800    extends MouseAdapter {
    773801    /** Any subclass of MouseAdapter can override this method to respond to mouse click events. In this case we want to open a pop-up menu if we detect a right mouse click over one of our registered components, and start an external application if someone double clicks on a certain file record. */
    774802    public void mouseClicked(MouseEvent event) {
    775         if(SwingUtilities.isRightMouseButton(event)) {
     803        if(SwingUtilities.isRightMouseButton(event)) {
    776804        new GPopupMenu((DragTree)event.getSource(), event);
    777         }
    778     }
    779     }
     805        }
     806    }
     807    }
    780808}
  • trunk/gli/src/org/greenstone/gatherer/gui/Filter.java

    r5772 r6051  
    7474    static final private Dimension SIZE = new Dimension(100,25);
    7575    /** Preprogrammed default filters. */
    76     static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.\\.gif$)|(^.\\.bmp$)|(^.\\.tif$)"};
     76    static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tif$)"};
    7777
    7878    /** Constructor.
     
    129129    }
    130130
    131     /** Used to restore the filter state to enabled, the normal state during collection editing. 
     131    /** Used to restore the filter state to enabled, the normal state during collection editing.
    132132     * @param state The new state for the filter. <i>true</i> for enabled, <i>false</i> otherwise.
    133133     */
     
    282282    }
    283283    /** An object that holds a filter entry. This is string used for the filter pattern and, if not custom built, its name. */
    284     private class Entry 
     284    private class Entry
    285285    implements Comparable {
    286286    /** The compiled pattern created from a regular expression. */
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6040 r6051  
    202202    }
    203203    else if(esrc == menu_bar.file_options) {
     204         // Just incase the user has edited the GeneralSettings of a collection without losing focus afterwards. Well I'm forever losing foc... ooh shiney.
     205         config_pane.loseFocus();
     206         // And spawn a new preferences.
    204207        new Preferences();
    205208    }
     
    459462
    460463        preview_pane = new PreviewPane();
    461         preview_pane.display(); 
    462         if(Gatherer.config.get("workflow.preview", true)) {         
     464        preview_pane.display();
     465        if(Gatherer.config.get("workflow.preview", true)) {
    463466        tab_pane.addTab("GUI.Preview", Utility.getImage("final.gif"), preview_pane);
    464467        tab_pane.setEnabledAt(tab_pane.indexOfComponent(preview_pane), false);
  • trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java

    r6027 r6051  
    234234      this.element = element;
    235235      // Transform the raw text to be GREENSTONE and DOM compatible - as that will be its next destination immediately after being added to the value model
    236       this.value = Codec.transform(value, Codec.ENCODE_PATH); 
     236      this.value = Codec.transform(value, Codec.ENCODE_PATH);
    237237      this.value = Codec.transform(this.value, Codec.REMOVE_SQUARE_BRACKET);
    238238      this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);
     
    335335    if(ready) {
    336336        TreeModel collection_model = Gatherer.c_man.getRecordSet();
    337         String[] args = new String[1];
    338         args[0] = Gatherer.c_man.getCollection().getName();
    339         Dictionary.registerText(collection_label, "Collection.Collection", args);
     337        //String[] args = new String[1];
     338        //args[0] = Gatherer.c_man.getCollection().getName();
     339        Dictionary.registerText(collection_label, "Collection.Collection");
    340340        // Update label coloring.
    341341        collection_label.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
     
    389389    ///atherer.println("\tCreating collection_label");
    390390    collection_label = new JLabel();
    391     Dictionary.registerText(collection_label, "Collection.Collection");
     391    Dictionary.registerText(collection_label, "Collection.No_Collection");
    392392    collection_label.setOpaque(true);
    393393
     
    972972
    973973
    974     /** Provides a popup menu to display when a right mouse button click is detected over the collection tree. */
    975     private class RightButtonMenu
    976     extends JPopupMenu
    977     implements ActionListener {
    978     /** Constructor.
    979      * @param event The <strong>MouseEvent</strong> that triggered the creation of this menu. Used to determine where the menu will be located.
    980      */
    981     private RightButtonMenu(MouseEvent event) {
    982         super();
    983         // Creation
    984         String[] args = new String[1];
    985         args[0] = collection_tree.getSelectionDetails();
    986         JMenuItem show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V);
    987         show_metaaudit.addActionListener(this);
    988         add(show_metaaudit);
    989         // Display
    990         show(collection_tree, event.getX(), event.getY());
    991         show_metaaudit = null;
    992     }
    993 
    994     /** Called whenever a user clicks on the single menu item, view all assigned metadata.
    995      * @param event An <strong>ActionEvent</strong> containing further information about the action.
    996      * @see org.greenstone.gatherer.Gatherer
    997      * @see org.greenstone.gatherer.gui.GUIManager
    998      */
    999     public void actionPerformed(ActionEvent event) {
    1000         Gatherer.g_man.showMetaAuditBox();
    1001     }
    1002     }
     974    /** Provides a popup menu to display when a right mouse button click is detected over the collection tree. */
     975    private class RightButtonMenu
     976        extends JPopupMenu
     977        implements ActionListener {
     978
     979        private FileNode node;
     980        private JMenuItem collapse_expand_folder_menuitem;
     981        private JMenuItem show_metaaudit;
     982        private TreePath path;
     983
     984        /** Constructor.
     985         * @param event The <strong>MouseEvent</strong> that triggered the creation of this menu. Used to determine where the menu will be located.
     986         */
     987        private RightButtonMenu(MouseEvent event) {
     988            super();
     989            this.path = collection_tree.getClosestPathForLocation(event.getX(), event.getY());
     990            this.node = (FileNode)path.getLastPathComponent();
     991           // Creation
     992            // Any folder node gets a menu item allowing you to collapse or expand it depending on its current status
     993            if(!node.isLeaf()) {
     994                // Collapse
     995                if(collection_tree.isExpanded(path)) {
     996                    collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Collapse"), KeyEvent.VK_C);
     997                }
     998                // Expand
     999                else {
     1000                    collapse_expand_folder_menuitem = new JMenuItem(Dictionary.get("Menu.Expand"), KeyEvent.VK_O);
     1001                }
     1002                collapse_expand_folder_menuitem.addActionListener(this);
     1003                add(collapse_expand_folder_menuitem);
     1004            }
     1005            String[] args = new String[1];
     1006            args[0] = collection_tree.getSelectionDetails();
     1007            show_metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", args), KeyEvent.VK_V);
     1008            show_metaaudit.addActionListener(this);
     1009            add(show_metaaudit);
     1010            // Display
     1011            show(collection_tree, event.getX(), event.getY());
     1012            show_metaaudit = null;
     1013        }
     1014
     1015        /** Called whenever a user clicks on the single menu item, view all assigned metadata.
     1016         * @param event An <strong>ActionEvent</strong> containing further information about the action.
     1017         * @see org.greenstone.gatherer.Gatherer
     1018         * @see org.greenstone.gatherer.gui.GUIManager
     1019         */
     1020        public void actionPerformed(ActionEvent event) {
     1021            Object source = event.getSource();
     1022            if(source == show_metaaudit) {
     1023                Gatherer.g_man.showMetaAuditBox();
     1024            }
     1025            else if(source == collapse_expand_folder_menuitem && path != null && node != null && !node.isLeaf()) {
     1026                // Collapse
     1027                if(collection_tree.isExpanded(path)) {
     1028                    collection_tree.collapsePath(path);
     1029                }
     1030                // Expand
     1031                else {
     1032                    collection_tree.expandPath(path);
     1033                }
     1034            }
     1035        }
     1036    }
    10031037
    10041038
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r6041 r6051  
     1/**
     2 *#########################################################################
     3 *
     4 * A component of the Gatherer application, part of the Greenstone digital
     5 * library suite from the New Zealand Digital Library Project at the
     6 * University of Waikato, New Zealand.
     7 *
     8 * Author: John Thompson, Greenstone Digital Library, University of Waikato
     9 *
     10 * Copyright (C) 1999 New Zealand Digital Library Project
     11 *
     12 * This program is free software; you can redistribute it and/or modify
     13 * it under the terms of the GNU General Public License as published by
     14 * the Free Software Foundation; either version 2 of the License, or
     15 * (at your option) any later version.
     16 *
     17 * This program is distributed in the hope that it will be useful,
     18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 * GNU General Public License for more details.
     21 *
     22 * You should have received a copy of the GNU General Public License
     23 * along with this program; if not, write to the Free Software
     24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     25 *########################################################################
     26 */
    127package org.greenstone.gatherer.gui;
    228
     
    1036import org.greenstone.gatherer.Dictionary;
    1137import org.greenstone.gatherer.Gatherer;
    12 import org.greenstone.gatherer.collection.CollectionConfiguration;
     38import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
    1339import org.greenstone.gatherer.util.Utility;
    1440import org.greenstone.gatherer.gui.SimpleMenuBar;
     
    6086        File metadata_directory = new File(possible_collections[i], Utility.META_DIR);
    6187        if(collect_cfg_file.exists()) {
    62         CollectionConfiguration collect_cfg = new CollectionConfiguration(collect_cfg_file);
     88        BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(collect_cfg_file);
    6389        String collection_name = collect_cfg.getName();
    6490        // Even if there is no metadata directory we add it if its one of the 'big five + 1' that we know how to handle.
     
    74100        // Else not a collection at all. Someones pulling a fast one.
    75101    }
    76    
     102
    77103    // Sort the result.
    78104    Collections.sort(base_collection_model);
     
    135161    cancel_button.setMnemonic(KeyEvent.VK_C);
    136162    Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip");
    137    
     163
    138164    //ColorListener email_color_listener = new ColorListener(address, host); No more email
    139165
     
    203229    center_pane.setLayout(new BorderLayout());
    204230    center_pane.add(description_pane, BorderLayout.CENTER);
    205          
     231
    206232    bottom_pane.setLayout(new BorderLayout());
    207233    bottom_pane.add(base_collection_pane, BorderLayout.CENTER);
     
    245271     * @return the filename as a String
    246272     */
    247     public String getName() {
    248     // Retrieve the first 8 non-whitespace characters of title_final.
    249     StringBuffer name_buffer = new StringBuffer("");
    250     int i = 0;
    251     while(i < title_final.length() && name_buffer.length() < 8) {
    252         char c = title_final.charAt(i);
    253         if(!Character.isWhitespace(c)) {
    254         name_buffer.append(Character.toLowerCase(c));
    255         }
    256         i++;
    257     }
    258     // We need to ensure the filename is unique
    259     int counter = 0;
    260     while(filenameClashes(name_buffer.toString())) {
    261         counter++;
    262         String suffix = String.valueOf(counter);
    263         name_buffer.replace(name_buffer.length() - suffix.length(), name_buffer.length(), suffix);
    264     }
    265     // All done
    266     return name_buffer.toString();
    267     }
     273    public String getName() {
     274        // Retrieve the first 8 non-whitespace characters of title_final.
     275        StringBuffer name_buffer = new StringBuffer("");
     276        int i = 0;
     277        while(i < title_final.length() && name_buffer.length() < 8) {
     278            char c = title_final.charAt(i);
     279            if(!Character.isWhitespace(c)) {
     280                name_buffer.append(Character.toLowerCase(c));
     281            }
     282            i++;
     283        }
     284        // We need to ensure the filename is unique
     285        int counter = 0;
     286        StringBuffer new_name_buffer = new StringBuffer(name_buffer.toString());
     287        while(filenameClashes(new_name_buffer.toString())) {
     288            new_name_buffer = new StringBuffer(name_buffer.toString());
     289            counter++;
     290            String suffix = String.valueOf(counter);
     291            // If we have to truncate the namestring so as to fit the suffix
     292            if(suffix.length() + new_name_buffer.length() > 8) {
     293                new_name_buffer.replace(new_name_buffer.length() - suffix.length(), new_name_buffer.length(), suffix);
     294            }
     295            // Or just append it if that isn't necessary
     296            else {
     297                new_name_buffer.append(suffix);
     298            }
     299
     300        }
     301        // All done
     302        return new_name_buffer.toString();
     303    }
    268304
    269305    private boolean filenameClashes(String filename) {
     
    283319
    284320
    285     private class BrowseListener 
     321    private class BrowseListener
    286322    implements ActionListener {
    287323    public void actionPerformed(ActionEvent event) {
     
    298334        if(file != null) {
    299335        file = file.getParentFile();
    300         CollectionConfiguration collect_cfg = new CollectionConfiguration(new File(file, Utility.META_DIR));
     336        BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(new File(file, Utility.META_DIR));
    301337        Item item = new Item(file, collect_cfg.getName());
    302338        base_collection.addItem(item);
    303339        base_collection.setSelectedItem(item);
    304         }           
     340        }
    305341    }
    306342    }
     
    336372    }
    337373
    338     private class CreateListener
    339     implements ActionListener {
     374    private class CreateListener
     375        implements ActionListener {
     376
    340377    public void actionPerformed(ActionEvent event) {
    341         // Validate.
    342         title_final = title.getText();
    343         if(title_final.length() == 0) {
    344         JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("NewCollectionPrompt.Title_Error"), Dictionary.get("NewCollectionPrompt.Error"), JOptionPane.ERROR_MESSAGE);
    345         title.setForeground(Gatherer.config.getColor("coloring.error_foreground", false));
    346         title.setBackground(Gatherer.config.getColor("coloring.error_background", false));
    347         return;
    348         }
    349         // We must ensure that the collection title is unique. This is a pain in the nether regions as we are forced to load the collect.cfg of each other collection in turn looking for a conflicting title
    350         else {
    351 
    352 
    353         }
     378        // Validate.
     379        title_final = title.getText();
     380        if(title_final.length() == 0) {
     381            JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("NewCollectionPrompt.Title_Error"), Dictionary.get("NewCollectionPrompt.Error"), JOptionPane.ERROR_MESSAGE);
     382            title.setForeground(Gatherer.config.getColor("coloring.error_foreground", false));
     383            title.setBackground(Gatherer.config.getColor("coloring.error_background", false));
     384            return;
     385        }
     386        // We must ensure that the collection title is unique. This is a pain in the nether regions as we are forced to load the collect.cfg of each other collection in turn looking for a conflicting title
     387        else {
     388            File collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
     389            File children[] = collection_directory.listFiles();
     390            for(int i = 0; children != null && i < children.length; i++) {
     391                if(children[i].isDirectory()) {
     392                    BasicCollectionConfiguration other_collection = new BasicCollectionConfiguration(new File(children[i], Utility.CONFIG_DIR));
     393                    if(other_collection.getName().equalsIgnoreCase(title_final)) {
     394                        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("NewCollectionPrompt.Title_Clash"), Dictionary.get("NewCollectionPrompt.Error"), JOptionPane.ERROR_MESSAGE);
     395                        title.setForeground(Gatherer.config.getColor("coloring.error_foreground", false));
     396                        title.setBackground(Gatherer.config.getColor("coloring.error_background", false));
     397                        return;
     398                    }
     399                    other_collection = null;
     400                }
     401            }
     402        }
     403
    354404        /* Suppress filename
    355405        name_final = file.getText();
     
    382432        host.setForeground(Gatherer.config.getColor("coloring.error_foreground", false));
    383433        host.setBackground(Gatherer.config.getColor("coloring.error_background", false));
    384         return; 
     434        return;
    385435        }
    386436        */
     
    412462    }
    413463
    414     private class Item 
     464    private class Item
    415465    implements Comparable {
    416466    private File file;
     
    435485
    436486    /*
    437     private class RestrictedTextField 
     487    private class RestrictedTextField
    438488    extends JTextField {
    439489    public RestrictedTextField(RestrictedTextDocument document, String value, int cols) {
     
    445495    }
    446496
    447     private class RestrictedTextDocument 
     497    private class RestrictedTextDocument
    448498    extends PlainDocument {
    449499    private char block[];
     
    468518        }
    469519    }
    470     public void insertString(int offs, String str, AttributeSet a) 
     520    public void insertString(int offs, String str, AttributeSet a)
    471521        throws BadLocationException {
    472522        // Remove any blocked characters.
     
    505555        updateFilename();
    506556    }
    507          
     557
    508558    ** Gives notification that a portion of the document has been removed. *
    509559    public void removeUpdate(DocumentEvent e) {
  • trunk/gli/src/org/greenstone/gatherer/gui/OpenCollectionDialog.java

    r5593 r6051  
    4848import org.greenstone.gatherer.Dictionary;
    4949import org.greenstone.gatherer.Gatherer;
    50 import org.greenstone.gatherer.collection.CollectionConfiguration;
     50import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
    5151import org.greenstone.gatherer.collection.CollectionManager;
     52import org.greenstone.gatherer.util.StaticStrings;
    5253import org.greenstone.gatherer.util.Utility;
    5354
    54 public class OpenCollectionDialog 
     55public class OpenCollectionDialog
    5556    extends JFileChooser {
    5657    static final private ImageIcon LOCKED_COLLECTION_ICON = Utility.getImage("lcolicn.gif");
    5758    static final private ImageIcon NORMAL_COLLECTION_ICON = Utility.getImage("ncolicn.gif");
    58     /** The name of the mouse listener that initiates editing on a double click. */ 
     59    /** The name of the mouse listener that initiates editing on a double click. */
    5960    static final private String SINGLE_CLICK_LISTENER = "SingleClickListener";
    6061
     
    8182    }
    8283
    83     public void destroy() { 
     84    public void destroy() {
    8485    }
    8586
     
    104105     */
    105106    static public void disableRename(Component c) {
    106     if (c instanceof JList){             
     107    if (c instanceof JList){
    107108        EventListener[] listeners=c.getListeners(MouseListener.class);
    108109        for(int i=0; listeners != null && i < listeners.length; i++) {
     
    122123        }
    123124    }
    124     } 
     125    }
    125126
    126127
    127128    /* The DescriptionPreview accessory is adapted from the ImagePreview.java (an example used by FileChooserDemo2.java). */
    128     private class DescriptionPreview 
     129    private class DescriptionPreview
    129130    extends JPanel
    130131    implements PropertyChangeListener {
     
    153154        if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) {
    154155        file = null;
    155         update = true;           
     156        update = true;
    156157        }
    157158        // If a file became selected, find out which one.
     
    170171            File config_file = new File(file.getParentFile(), Utility.CONFIG_DIR);
    171172            if(config_file.exists()) {
    172             CollectionConfiguration collect_cfg = new CollectionConfiguration(config_file);
     173            BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(config_file);
     174            text.setText(StaticStrings.SPEECH_CHARACTER + collect_cfg.getName() + StaticStrings.SPEECH_CHARACTER + StaticStrings.NEW_LINE_CHAR);
    173175            text.setText(collect_cfg.getDescription());
    174176            text.setCaretPosition(0);
     
    180182
    181183    /** ImageFilter.java is a 1.4 example used by FileChooserDemo2.java. */
    182     private class GathererFilter 
     184    private class GathererFilter
    183185    extends FileFilter {
    184186
     
    196198    private class GathererFileSystemView
    197199    extends FileSystemView {
    198          
     200
    199201    private FileSystemView default_system_view = FileSystemView.getFileSystemView();
    200    
     202
    201203    /** Creates a new folder with a default folder name. */
    202     public File createNewFolder(File containingDir) 
     204    public File createNewFolder(File containingDir)
    203205        throws IOException {
    204206        return default_system_view.createNewFolder(containingDir);
    205     }         
     207    }
    206208
    207209    /** Gets the list of shown (i.e. */
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r5847 r6051  
    1313import org.greenstone.gatherer.checklist.CheckList;
    1414import org.greenstone.gatherer.checklist.Entry;
     15import org.greenstone.gatherer.gui.EmailField;
    1516import org.greenstone.gatherer.gui.ModalDialog;
    1617import org.greenstone.gatherer.gui.SimpleMenuBar;
     
    2425
    2526    private CheckList warning_preferences_check_list;
     27    private EmailField email_field;
    2628    private JButton apply_button;
    2729    private JButton cancel_button;
     
    3941    private JCheckBox workflow_preview;
    4042    private JComboBox language_combobox;
     43    private JLabel email_label;
    4144    private JLabel language_label;
    4245    private JLabel library_path_label;
     
    5154    private Preferences self;
    5255
    53     static final Dimension LABEL_SIZE = new Dimension(150, 25);
     56    static final Dimension LABEL_SIZE = new Dimension(175, 25);
    5457    static final Dimension ROW_SIZE = new Dimension(640, 25);
    5558    static final Dimension SIZE = new Dimension(640, 345);
     
    136139    proxy_host_label = new JLabel();
    137140    proxy_host_label.setPreferredSize(LABEL_SIZE);
    138     Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host"); 
     141    Dictionary.registerText(proxy_host_label, "Preferences.Connection.Proxy_Host");
    139142    proxy_host_field = new JTextField(Gatherer.config.getString("general.proxy_host", true));
    140143    proxy_host_field.setEnabled(currently_enabled);
     
    227230    classes_folder = null;
    228231
     232    // Users email
     233    JPanel email_pane = new JPanel();
     234    email_label = new JLabel();
     235    email_label.setPreferredSize(LABEL_SIZE);
     236    Dictionary.registerText(email_label, "Preferences.General.Email");
     237    email_field = new EmailField(Gatherer.config.getColor("coloring.error_background", false));
     238    email_field.setText(Gatherer.config.getEmail());
     239    Dictionary.registerTooltip(email_field, "Preferences.General.Email_Tooltip");
     240
    229241    // Extracted metadata
    230242    view_extracted_metadata_checkbox = new JCheckBox();
     
    255267
    256268    // Layout
     269    email_pane.setLayout(new BorderLayout());
     270    email_pane.add(email_label, BorderLayout.WEST);
     271    email_pane.add(email_field, BorderLayout.CENTER);
     272
    257273    language_pane.setLayout(new BorderLayout());
    258274    language_pane.add(language_label, BorderLayout.WEST);
     
    261277    general_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    262278    general_pane.setLayout(new GridLayout(5,1,0,5));
     279    general_pane.add(email_pane);
     280    general_pane.add(language_pane);
    263281    general_pane.add(view_extracted_metadata_checkbox);
    264282    general_pane.add(show_file_size_checkbox);
    265     general_pane.add(language_pane);
    266283
    267284    return general_pane;
     
    399416
    400417    public void dispose() {
    401     // Dispose
    402     super.dispose();
     418        // Where's my code for unregistering all of the components?!?
     419
     420        // Dispose
     421        super.dispose();
    403422    }
    404423
     
    428447
    429448        // General preferences
     449        Gatherer.config.setEmail(email_field.getText());
     450
    430451        Gatherer.config.set("general.show_file_size", Configuration.COLLECTION_SPECIFIC, show_file_size_checkbox.isSelected());
    431452        Gatherer.g_man.refreshTrees(DragTree.TREE_DISPLAY_CHANGED);
     
    472493    }
    473494
    474     private class DictionaryEntry 
     495    private class DictionaryEntry
    475496    implements Comparable {
    476497    private Locale locale;
     
    526547        workflow_design.setSelected(element.getEnabled("design"));
    527548        workflow_export.setSelected(element.getEnabled("export"));
    528         workflow_preview.setSelected(element.getEnabled("preview"));           
     549        workflow_preview.setSelected(element.getEnabled("preview"));
    529550        }
    530551    }
     
    570591    public String toString() {
    571592        if(text == null) {
    572         text = element.getFirstChild().getNodeValue(); 
     593        text = element.getFirstChild().getNodeValue();
    573594        }
    574595        return text;
  • trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java

    r5815 r6051  
    4949
    5050public class PreviewPane
    51     extends JPanel {
    52 
    53     private CalHTMLPane view   = null;
    54     private int back_count    = 0;
    55     private int forward_count  = 0;
    56     private JButton back       = null;
    57     private JButton forward    = null;
    58     private JButton home       = null;
    59     private JButton reload = null;
    60     private JLabel status      = null;
    61     private Observer observer = null;
    62     private URL homepage = null;
    63 
    64     static final public String BLANK_PAGE = "<html><head><title>No Page</title></head><body></body></html>";
    65 
    66     public PreviewPane() {
     51    extends JPanel {
     52
     53    private CalHTMLPane view   = null;
     54    private int back_count  = 0;
     55    private int forward_count  = 0;
     56    private JButton back       = null;
     57    private JButton forward = null;
     58    private JButton home       = null;
     59    private JButton reload = null;
     60    private JLabel status     = null;
     61    private Observer observer = null;
     62    private URL homepage = null;
     63
     64    static final public String BLANK_PAGE = "<html><head><title>No Page</title></head><body></body></html>";
     65
     66    public PreviewPane() {
    6767    super();
    6868
     
    9595
    9696    status = new JLabel();
    97     Dictionary.registerText(status, "Browser.Ready"); 
    98     }
    99 
    100     public void collectionChanged(boolean ready) {
     97    Dictionary.registerText(status, "Browser.Ready");
     98    }
     99
     100    public void collectionChanged(boolean ready) {
    101101    // If we were showing a page, but that page is no longer available, then return to a blank page
    102102    if(!ready && homepage != null) {
    103         homepage = null;
    104         view.showHTMLDocument(BLANK_PAGE);
     103        homepage = null;
     104        view.showHTMLDocument(BLANK_PAGE);
    105105    }
    106106    if (ready && Gatherer.config.exec_address != null) {
    107         // reload the home page for the current collection
    108         try {
     107        // reload the home page for the current collection
     108        try {
    109109        // Now load the collection
    110         Collection this_coll = Gatherer.c_man.getCollection();
     110        Collection this_collection = Gatherer.c_man.getCollection();
     111        String search_types = this_collection.cdm.searchtype_manager.getSearchTypes();
    111112        String extra_args = "";
    112         String build_type = this_coll.getCollectionType();
    113         if (build_type.equals("mgpp")) {
    114             // we need some more args on the url
    115             String search_types = this_coll.getSearchTypes();
    116             if (search_types.equals("")) {
    117             extra_args = "&ct=1&qt=0&qto=3";
    118             } else if (search_types.equals("plain")) {
    119             extra_args = "&ct=1&qt=0&qto=1";
    120             } else if (search_types.equals("form")) {
    121             extra_args = "&ct=1&qt=1&qto=2";
    122             } else if (search_types.equals("plain,form")) {
    123             extra_args = "&ct=1&qt=0&qto=3";
    124             } else if (search_types.equals("form,plain")) {
    125             extra_args = "&ct=1&qt=1&qto=3";
    126             }
    127         }
    128        
    129         homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + this_coll.getName()+extra_args);
     113        if (search_types.length() > 0) {
     114            // we need some more args on the url
     115            if (search_types.equals("")) {
     116                extra_args = "&ct=1&qt=0&qto=3";
     117            } else if (search_types.equals("plain")) {
     118                extra_args = "&ct=1&qt=0&qto=1";
     119            } else if (search_types.equals("form")) {
     120                extra_args = "&ct=1&qt=1&qto=2";
     121            } else if (search_types.equals("plain,form")) {
     122                extra_args = "&ct=1&qt=0&qto=3";
     123            } else if (search_types.equals("form,plain")) {
     124                extra_args = "&ct=1&qt=1&qto=3";
     125            }
     126        }
     127
     128        homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + this_collection.getName() + extra_args);
    130129        String[] args = new String[1];
    131130        args[0] = homepage.toString();
    132131        Dictionary.registerText(status, "Browser.Loading", args);
    133132        view.showHTMLDocument(homepage, null, true);
    134         }
    135         catch (MalformedURLException exception) {
     133        }
     134        catch (MalformedURLException exception) {
    136135        Gatherer.printStackTrace(exception);
    137         }
    138     }
    139     }
    140 
    141     public void display() {
     136        }
     137    }
     138    }
     139
     140    public void display() {
    142141    JPanel control_pane = new JPanel();
    143142    control_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     
    157156    add(a_panel, BorderLayout.CENTER);
    158157    add(status, BorderLayout.SOUTH);
    159     }
    160 
    161     /** This method is called when the user selects the 'Preview' tab from the views bar. Can be used to display a particular page or perform some other relevant tests (ensure internet connection to specified server maybe?)
    162     */
    163     public void gainFocus() {
     158    }
     159
     160    /** This method is called when the user selects the 'Preview' tab from the views bar. Can be used to display a particular page or perform some other relevant tests (ensure internet connection to specified server maybe?)
     161    */
     162    public void gainFocus() {
    164163    if(Gatherer.c_man.ready() && Gatherer.c_man.built()) {
    165         if(homepage == null && Gatherer.config.exec_address != null) {
     164        if(homepage == null && Gatherer.config.exec_address != null) {
    166165        try {
    167             // Now load the collection
    168             homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName());
    169             String[] args = new String[1];
    170             args[0] = homepage.toString();
    171             Dictionary.registerText(status, "Browser.Loading", args);
    172             view.showHTMLDocument(homepage);
     166            // Now load the collection
     167            homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName());
     168            String[] args = new String[1];
     169            args[0] = homepage.toString();
     170            Dictionary.registerText(status, "Browser.Loading", args);
     171            view.showHTMLDocument(homepage);
    173172        }
    174173        catch (MalformedURLException exception) {
    175             Gatherer.printStackTrace(exception);
    176         }
    177         }
     174            Gatherer.printStackTrace(exception);
     175        }
     176        }
    178177    }
    179178    validate();
    180     }
    181 
    182     public void configServer(String command) {
     179    }
     180
     181    public void configServer(String command) {
    183182    try {
    184         String url = Gatherer.config.exec_address.toString() + command;
    185         ///ystem.err.println("Action: " + url);
    186         view.setLoadSynchronously(true);
    187         view.showHTMLDocument(new URL(url));
    188         view.setLoadSynchronously(false);
    189         ///ystem.err.println("Complete.");
    190         url = null;
     183        String url = Gatherer.config.exec_address.toString() + command;
     184        ///ystem.err.println("Action: " + url);
     185        view.setLoadSynchronously(true);
     186        view.showHTMLDocument(new URL(url));
     187        view.setLoadSynchronously(false);
     188        ///ystem.err.println("Complete.");
     189        url = null;
    191190    }
    192191    catch(Exception error) {
    193         ///ystem.err.println("Bad URL.");
    194     }
    195     }
    196 
    197     public void validate() {
     192        ///ystem.err.println("Bad URL.");
     193    }
     194    }
     195
     196    public void validate() {
    198197    back.setEnabled(back_count > 0);
    199198    home.setEnabled(homepage != null);
    200199    forward.setEnabled(forward_count > 0);
    201200    reload.setEnabled(homepage != null);
    202     }
    203 
    204     private class BackListener
     201    }
     202
     203    private class BackListener
    205204    implements ActionListener {
    206205    public void actionPerformed(ActionEvent event) {
    207         view.goBack();
    208         back_count--;
    209         forward_count++;
    210         validate();
    211     }
    212     }
    213 
    214     private class ForwardListener
     206        view.goBack();
     207        back_count--;
     208        forward_count++;
     209        validate();
     210    }
     211    }
     212
     213    private class ForwardListener
    215214    implements ActionListener {
    216215    public void actionPerformed(ActionEvent event) {
    217         view.goForward();
    218         back_count++;
    219         forward_count--;
    220         validate();
    221     }
    222     }
    223 
    224     private class HomeListener
     216        view.goForward();
     217        back_count++;
     218        forward_count--;
     219        validate();
     220    }
     221    }
     222
     223    private class HomeListener
    225224    implements ActionListener {
    226225    public void actionPerformed(ActionEvent event) {
    227         view.showHTMLDocument(homepage);
    228         back_count++;
    229         forward_count = 0;
    230         validate();
    231     }
    232     }
    233 
    234     private class ReloadListener
     226        view.showHTMLDocument(homepage);
     227        back_count++;
     228        forward_count = 0;
     229        validate();
     230    }
     231    }
     232
     233    private class ReloadListener
    235234    implements ActionListener {
    236235    public void actionPerformed(ActionEvent event) {
    237         view.reloadDocument();
    238     }
    239     }
    240 
    241     private class Observer
     236        view.reloadDocument();
     237    }
     238    }
     239
     240    private class Observer
    242241    extends DefaultCalHTMLObserver {
    243242    public int state = CalCons.DOC_LOADED;
    244243    public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) {
    245         back_count++;
    246         forward_count = 0;
    247         validate();
     244        back_count++;
     245        forward_count = 0;
     246        validate();
    248247    }
    249248
    250249    public void linkFocusUpdate(CalHTMLPane pane, URL url) {
    251         String[] args = new String[1];
    252         args[0] = url.toString();
    253         Dictionary.registerText(status, "Browser.Follow", args);
     250        String[] args = new String[1];
     251        args[0] = url.toString();
     252        Dictionary.registerText(status, "Browser.Follow", args);
    254253    }
    255254
    256255    public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) {
    257         this.state = state;
    258         String[] args = new String[1];
    259         args[0] = url.toString();
    260 
    261         switch(state) {
     256        this.state = state;
     257        String[] args = new String[1];
     258        args[0] = url.toString();
     259
     260        switch(state) {
    262261        // The Pane is attempting to connect to the given URL to receive data.
    263         case CalCons.PRE_CONNECT:
     262        case CalCons.PRE_CONNECT:
    264263        ///ystem.err.println("Preconnect: " + state + " - " + message);
    265264        break;
    266265        // The Pane was unable to connect to the given URL or was unable to parse the content. Most likely this will be due to an incorrectly specified URL. The message argument may contain further details of the reason for failure.
    267         case CalCons.PARSE_FAILED:
     266        case CalCons.PARSE_FAILED:
    268267        ///ystem.err.println("Parse Failed: " + state + " - " + message);
    269268        Dictionary.registerText(status, "Browser.CannotConnect", args);
    270269        break;
    271270        // The Pane has established a connection to the given URL and is receiving any content.
    272         case CalCons.CONNECTED:
     271        case CalCons.CONNECTED:
    273272        ///ystem.err.println("Connected: " + state + " - " + message);
    274273        Dictionary.registerText(status, "Browser.Loading", args);
    275274        break;
    276275        // The size of the content at the given URL is known and is contained in the value argument.
    277         case CalCons.DOC_LENGTH:
     276        case CalCons.DOC_LENGTH:
    278277        ///ystem.err.println("Doc Length: " + state + " - " + message);
    279278        break;
    280279        // The title of the document for the given URL is known and is contained in the message argument. Only the title of a document in the Pane's top level frame will be sent to this method. If the document has no name, the message will be null, unless the document is a Frameset document in which case the message "Frameset" will be sent.
    281         case CalCons.TITLE:
     280        case CalCons.TITLE:
    282281        ///ystem.err.println("Title: " + state + " - " + message);
    283282        break;
    284283        // An exception has been thrown during parsing of the data from the URL. This will most likely be an IOException such as a server time-out.
    285         case CalCons.PARSE_FAILED_POST_CONNECT:
     284        case CalCons.PARSE_FAILED_POST_CONNECT:
    286285        ///ystem.err.println("Parse Failed Post Connect: " + state + " - " + message);
    287286        Dictionary.registerText(status, "Browser.TimedOut", args);
    288287        break;
    289288        // The document has been parsed but formatting cannot be completed because the document contains images of unspecified size. The parsing thread is waiting for image updates to give it the information it needs to format and display the document.
    290         case CalCons.WAITING_FOR_IMAGES:
     289        case CalCons.WAITING_FOR_IMAGES:
    291290        ///ystem.err.println("Waiting For Images: " + state + " - " + message + " - " + url.toString());
    292291        break;
    293292        // All text and image data has been received, parsed and the document structure determined.
    294         case CalCons.DOC_LOADED:
     293        case CalCons.DOC_LOADED:
    295294        ///ystem.err.println("Doc Loaded: " + state + " - " + message);
    296295        Dictionary.registerText(status, "Browser.Ready");
    297296        break;
    298         }
    299     }
    300     }
     297        }
     298    }
     299    }
    301300}
  • trunk/gli/src/org/greenstone/gatherer/gui/SimpleOpenCollectionDialog.java

    r5939 r6051  
    3535import org.greenstone.gatherer.Dictionary;
    3636import org.greenstone.gatherer.Gatherer;
    37 import org.greenstone.gatherer.collection.CollectionConfiguration;
     37import org.greenstone.gatherer.collection.BasicCollectionConfiguration;
    3838import org.greenstone.gatherer.gui.ModalDialog;
    3939import org.greenstone.gatherer.util.StaticStrings;
     
    7171
    7272    JPanel center_pane = new JPanel();
    73    
     73
    7474    JPanel collection_list_pane = new JPanel();
    7575    JLabel collection_list_label = new JLabel();
     
    155155    private class AdvancedListener
    156156    implements ActionListener {
    157    
     157
    158158    public void actionPerformed(ActionEvent event) {
    159159        result = BROWSE_OPTION;
     
    164164    private class CancelListener
    165165    implements ActionListener {
    166    
     166
    167167    public void actionPerformed(ActionEvent event) {
    168168        result = CANCEL_OPTION;
    169169        SimpleOpenCollectionDialog.this.dispose();
    170170    }
    171     }   
     171    }
    172172
    173173    private class CollectionListSelectionListener
     
    192192        }
    193193        else {
    194         CollectionConfiguration collection_configuration = (CollectionConfiguration) collection_list.getSelectedValue();
     194        BasicCollectionConfiguration collection_configuration = (BasicCollectionConfiguration) collection_list.getSelectedValue();
    195195        description_textarea.setText(collection_configuration.getDescription());
    196196        description_textarea.setCaretPosition(0);
     
    214214        String collection_foldername = collection_folder.getName();
    215215        if(!collection_folder.isFile() && !collection_foldername.equals(StaticStrings.MODEL_COLLECTION_NAME)) {
    216            CollectionConfiguration collection_configuration = new CollectionConfiguration(new File(collection_folder, Utility.CONFIG_DIR));
     216           BasicCollectionConfiguration collection_configuration = new BasicCollectionConfiguration(new File(collection_folder, Utility.CONFIG_DIR));
    217217           if(!collection_configuration.getName().equals(StaticStrings.ERROR_STR)) {
    218218              data.add(collection_configuration);
     
    247247    private class OpenListener
    248248    implements ActionListener {
    249    
     249
    250250    public void actionPerformed(ActionEvent event) {
    251251        result = OK_OPTION;
    252         CollectionConfiguration collection_configuration = (CollectionConfiguration) collection_list.getSelectedValue();
     252        BasicCollectionConfiguration collection_configuration = (BasicCollectionConfiguration) collection_list.getSelectedValue();
    253253        File collect_cfg_file = collection_configuration.getFile();
    254254        File etc_folder = collect_cfg_file.getParentFile();
     
    261261        SimpleOpenCollectionDialog.this.dispose();
    262262    }
    263     } 
     263    }
    264264}
  • trunk/gli/src/org/greenstone/gatherer/gui/table/GTableModel.java

    r6028 r6051  
    5050 * @version 2.3b
    5151 */
    52 public class GTableModel 
    53     extends AbstractTableModel 
     52public class GTableModel
     53    extends AbstractTableModel
    5454    implements MSMListener {
    5555
     
    7070    // Register this model with the msm manager.
    7171    if (Gatherer.c_man.ready()) {
    72         Gatherer.c_man.getCollection().msm.addMSMListener(this); 
     72        Gatherer.c_man.getCollection().msm.addMSMListener(this);
    7373    }
    7474    }
     
    200200        // Ensure the position is within the current metadata
    201201        if (i >= current_metadata.size()) {
    202         i = current_metadata.size() - 1;
     202            i = current_metadata.size() - 1;
    203203        }
    204204
    205205        // Select the same row as before, except if it would select a different element
    206206        ElementWrapper element = metadatum.getElement();
     207        if(i < 0) {
     208              Gatherer.println("Could not find suitable row to select!");
     209              return;
     210         }
    207211        Metadata newly_selected_metadatum = (Metadata) current_metadata.get(i);
    208212        if (!newly_selected_metadatum.getElement().equals(element)) {
    209         // Try one row previous
    210         i--;
    211         newly_selected_metadatum = (Metadata) current_metadata.get(i);
    212         if (!newly_selected_metadatum.getElement().equals(element)) {
    213             Gatherer.println("Could not find suitable row to select!");
    214             return;
    215         }
     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            }
    216225        }
    217226
     
    298307    /** Determine if the given metadata is common to all selected file nodes given the context of the current view. */
    299308   public boolean isCommon(Metadata entry) {
    300       return (entry.getCount() == file_nodes.length);
     309      return (entry.getCount() >= file_nodes.length);
    301310   }
    302    
     311
    303312    /** Determine if the given metadata is common to all selected file nodes given the context of the current view. */
    304313    public boolean isCommon(int row) {
     
    352361                showInheritedMetadataWarning();
    353362                }
    354                
     363
    355364                // If the piece of metadata is in the list, increment its count
    356365                int index = current_metadata.indexOf(metadatum);
     
    364373                index = add(current_metadata, metadatum);
    365374                fireTableRowsInserted(index, index);
    366                
     375
    367376                // Remember we have seen this element
    368377                if (known_elements.contains(element) == false) {
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTreeCellRenderer.java

    r5915 r6051  
    4646import org.greenstone.gatherer.util.Utility;
    4747
    48 public class DragTreeCellRenderer 
     48public class DragTreeCellRenderer
    4949    extends DefaultTreeCellRenderer {
    50      
     50
    5151    private boolean in_focus = false;
    5252    private Color selection_background;
    5353    private Color selection_foreground;
    54      
    55     static final private ImageIcon GREY_FOLDER = Utility.getImage("greyfolder.gif", true);
    56     static final private ImageIcon GREEN_FILE = Utility.getImage("greenfile.gif", true);
    57     static final private ImageIcon GREEN_FOLDER = Utility.getImage("greenfolder.gif", true);
     54
     55    //static final private ImageIcon GREY_FOLDER = Utility.getImage("greyfolder.gif", true);
     56    //static final private ImageIcon GREEN_FILE = Utility.getImage("greenfile.gif", true);
     57    //static final private ImageIcon GREEN_FOLDER = Utility.getImage("greenfolder.gif", true);
    5858
    5959    public DragTreeCellRenderer() {
     
    7474    if(value instanceof FileNode) {
    7575        FileNode node = (FileNode) value;
    76        
     76
    7777        String new_value = null;
    7878        if(Gatherer.config.get("general.show_file_size", Configuration.COLLECTION_SPECIFIC) && node.getFile() != null && !node.getAllowsChildren()) {
     
    8585        tree_cell = (JLabel) super.getTreeCellRendererComponent(tree, new_value, sel, expanded, leaf, row, hasFocus);
    8686
     87        /*
    8788        if(node.getFile() == null || node.isFileSystemRoot()) {
    88         ((JLabel)tree_cell).setIcon(GREY_FOLDER);
     89            ((JLabel)tree_cell).setIcon(GREY_FOLDER);
    8990        }
    9091        else if(node.isInCurrentCollection()) {
    91         if(!node.getFile().isFile()) {
     92            if(!node.getFile().isFile()) {
    9293            ((JLabel)tree_cell).setIcon(GREEN_FOLDER);
    93         }
    94         else {
     94            }
     95            else {
    9596            ((JLabel)tree_cell).setIcon(GREEN_FILE);
    96         }
     97            }
    9798        }
     99        */
    98100    }
    99101    else {
     
    102104    return tree_cell;
    103105    }
    104          
     106
    105107    public void loseFocus() {
    106108    setBackgroundSelectionColor(Color.lightGray);
Note: See TracChangeset for help on using the changeset viewer.