Ignore:
Timestamp:
2003-10-03T14:07:35+12:00 (21 years ago)
Author:
mdewsnip
Message:

Many more small improvements and tooltips added. Still more to come!

Location:
trunk/gli/src/org/greenstone/gatherer/collection
Files:
5 edited

Legend:

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

    r5527 r5564  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.io.*;
    3940import java.lang.Class;
     
    4243import javax.swing.event.*;
    4344import javax.swing.tree.*;
     45import org.greenstone.gatherer.Dictionary;
    4446import org.greenstone.gatherer.Gatherer;
    4547import org.greenstone.gatherer.Message;
     
    6971import org.greenstone.gatherer.util.Codec;
    7072import org.greenstone.gatherer.util.GSDLSiteConfig;
    71 import org.greenstone.gatherer.util.MetadataXML;
    7273import org.greenstone.gatherer.util.StaticStrings;
    7374import org.greenstone.gatherer.util.SynchronizedTreeModelTools;
     
    120121    }
    121122    /** Add a special directory mapping.
    122       * @param name The name for this directory mapping as a <strong>String</strong>.
    123       * @param file The directory this mapping maps to as a <strong>File</strong>.
    124       */
     123     * @param name The name for this directory mapping as a <strong>String</strong>.
     124     * @param file The directory this mapping maps to as a <strong>File</strong>.
     125     */
    125126    public void addDirectoryMapping(String name, File file) {
    126127    if(ready()) {
    127                 // Update the information stored in the collection
     128        // Update the information stored in the collection
    128129        collection.addDirectoryMapping(name, file);
    129                 // Now update the tree
     130        // Now update the tree
    130131        FileSystemModel model = (FileSystemModel) Gatherer.g_man.collection_pane.getWorkspaceTree().getModel();
    131132        FileNode parent = (FileNode) model.getRoot();
     
    135136    }
    136137    /** This method calls the builcol.pl scripts via a GShell so as to not lock up the processor.
    137       * @see org.greenstone.gatherer.Configuration
    138       * @see org.greenstone.gatherer.Gatherer
    139       * @see org.greenstone.gatherer.Message
    140       * @see org.greenstone.gatherer.collection.Collection
    141       * @see org.greenstone.gatherer.gui.BuildOptions
    142       * @see org.greenstone.gatherer.shell.GShell
    143       * @see org.greenstone.gatherer.shell.GShellListener
    144       * @see org.greenstone.gatherer.shell.GShellProgressMonitor
    145       * @see org.greenstone.gatherer.util.Utility
    146       */
     138     * @see org.greenstone.gatherer.Configuration
     139     * @see org.greenstone.gatherer.Gatherer
     140     * @see org.greenstone.gatherer.Message
     141     * @see org.greenstone.gatherer.collection.Collection
     142     * @see org.greenstone.gatherer.gui.BuildOptions
     143     * @see org.greenstone.gatherer.shell.GShell
     144     * @see org.greenstone.gatherer.shell.GShellListener
     145     * @see org.greenstone.gatherer.shell.GShellProgressMonitor
     146     * @see org.greenstone.gatherer.util.Utility
     147     */
    147148    public void buildCollection() {
    148149    Gatherer.println("CollectionManager.buildCollection()");
     
    222223    try {
    223224        // Create a progress monitor.
    224         ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, get("CollectionManager.Creating_New"), "mkcol.pl", 0, 7);
     225        ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, Dictionary.newget("CollectionManager.Creating_New"), "mkcol.pl", 0, 7);
    225226        // Create the new collection.
    226227        makeCollection(description, email, name, title);
     
    234235        gcache_dir.mkdirs();
    235236        if(progress != null) {
    236         progress.setNote(get("CollectionManager.Gcache_Created"));
     237        progress.setNote(Dictionary.newget("CollectionManager.Gcache_Created"));
    237238        }
    238239
     
    242243        log_dir.mkdirs();
    243244        if(progress != null) {
    244         progress.setNote(get("CollectionManager.Log_Created"));
     245        progress.setNote(Dictionary.newget("CollectionManager.Log_Created"));
    245246        }
    246247
     
    395396        String args[] = new String[1];
    396397        args[0] = name;
    397         progress.setNote(get("CollectionManager.Session_Ready", args));
     398        progress.setNote(Dictionary.newget("CollectionManager.Session_Ready", args));
    398399        progress.close();
    399400    }
     
    436437
    437438    /** Method that is called whenever an element within a set is changed or modified. We want to mark the collection so that it needs saving again.
    438       * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
    439       * @see org.greenstone.gatherer.collection.Collection
    440       */
     439     * @param event A <strong>MSMEvent</strong> containing details of the event that caused this message to be fired.
     440     * @see org.greenstone.gatherer.collection.Collection
     441     */
    441442    public void elementChanged(MSMEvent event) {
    442443    // This means the state of the collections has changed, so we should set saved to false.
     
    444445    }
    445446    /** Used to retrieve the build options associated with the currently loaded collection. If none yet exist, default ones are created.
    446       * @return A <strong>BuildOptions</strong> object containing the build options for the current collection.
    447       * @see org.greenstone.gatherer.collection.Collection
    448       */
     447     * @return A <strong>BuildOptions</strong> object containing the build options for the current collection.
     448     * @see org.greenstone.gatherer.collection.Collection
     449     */
    449450    public BuildOptions getBuildOptions() {
    450451    return collection.build_options;
     
    452453
    453454    /** Retrieve the current collection.
    454       * @return The <strong>Collection</strong> itself.
    455       */
     455     * @return The <strong>Collection</strong> itself.
     456     */
    456457    public Collection getCollection() {
    457458    return collection;
     
    578579        return collection.getTitle();
    579580    }
    580     return get("Collection.No_Collection");
     581    return Dictionary.newget("Collection.No_Collection");
    581582    }
    582583
     
    610611    // Create and add Greenstone collections node.
    611612    // Starting at the collection directory of gsdl...
    612     FileNode world_root = new FileNode(get("Tree.World"));
     613    FileNode world_root = new FileNode(Dictionary.newget("Tree.World"));
    613614    world_root.unmap();
    614615    workspace_root.insert(world_root);
     
    619620    if(roots != null) {
    620621        FileNode file_root;
    621         String name = get("Tree.Root");
     622        String name = Dictionary.newget("Tree.Root");
    622623        if(roots.length == 1) {
    623624        file_root = new FileNode(roots[0], name);
     
    644645    if(home_folder_str != null && home_folder_str.length() > 0) {
    645646        File home_folder = new File(home_folder_str);
    646         FileNode home_folder_node = new FileNode(home_folder, get("Tree.Home", home_folder.getName()));
     647        String[] args = new String[1];
     648        args[0] = home_folder.getName();
     649        FileNode home_folder_node = new FileNode(home_folder, Dictionary.newget("Tree.Home", args));
    647650        workspace_root.insert(home_folder_node);
    648651    }
     
    651654    if(Gatherer.config.get("workflow.mirror", false)) {
    652655        // Add Public workspace
    653         FileNode public_root = new FileNode(new File(Utility.CACHE_DIR), get("Tree.Public"));
     656        FileNode public_root = new FileNode(new File(Utility.CACHE_DIR), Dictionary.newget("Tree.Public"));
    654657        workspace_root.insert(public_root);
    655658        // Add Private workspace if a collection has been loaded.
    656659        if(ready()) {
    657         FileNode private_root = new FileNode(new File(getCollectionCache()), get("Tree.Private"));
     660        FileNode private_root = new FileNode(new File(getCollectionCache()), Dictionary.newget("Tree.Private"));
    658661        workspace_root.insert(private_root);
    659662        }
     
    753756        File metadata_directory = new File(collection_directory, Utility.META_DIR);
    754757        if(!metadata_directory.exists()) {
    755             JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Old_Collection", args2), get("General.Warning"), JOptionPane.INFORMATION_MESSAGE);
     758            JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Old_Collection", args2), Dictionary.newget("General.Warning"), JOptionPane.INFORMATION_MESSAGE);
    756759        }
    757760        // Normal GLI collection
     
    783786                collection.gdm = new GDMManager();
    784787                // Tell everyone that it worked.
    785                 Gatherer.println(get("CollectionManager.Loading_Successful", name));
     788                String[] args = new String[1];
     789                args[0] = name;
     790                Gatherer.println(Dictionary.newget("CollectionManager.Loading_Successful", args));
    786791                // Now we need to hook up classes that depend on messages from the metadata set manager to keep their content fresh.
    787792                collection.msm.addMSMListener(this);
     
    796801                // There is obviously no existing collection present.
    797802                Gatherer.printStackTrace(error);
    798                 JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Cannot_Open", args2), get("General.Error"), JOptionPane.ERROR_MESSAGE);
     803                JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Cannot_Open", args2), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE);
    799804            }
    800805            }
     
    803808        }
    804809        else {
    805         JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.File_Not_Found", args2), get("General.Error"), JOptionPane.ERROR_MESSAGE);
     810        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.File_Not_Found", args2), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE);
    806811        }
    807812        collection_directory = null;
    808813    }
    809814    else {
    810         JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Not_Col_File", args2), get("General.Error"), JOptionPane.ERROR_MESSAGE);
     815        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Not_Col_File", args2), Dictionary.newget("General.Error"), JOptionPane.ERROR_MESSAGE);
    811816        Gatherer.println("Not a Gatherer Collection.");
    812817    }
     
    929934        workspace_model = null;
    930935        Gatherer.g_man.collectionChanged(ready());
    931         JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Preview_Ready"), get("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE);
     936        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Preview_Ready"), Dictionary.newget("CollectionManager.Preview_Ready_Title"), JOptionPane.INFORMATION_MESSAGE);
    932937    }
    933938    else if(event.getStatus() == GShell.ERROR) {
    934         JOptionPane.showMessageDialog(Gatherer.g_man, get("CollectionManager.Preview_Ready_Failed"), get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
     939        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.newget("CollectionManager.Preview_Ready_Failed"), Dictionary.newget("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
    935940        Gatherer.g_man.collectionChanged(ready());
    936941    }
     
    977982    FileNode greenstone_collections_node = null;
    978983    int root_child_count = root.getChildCount();
    979     String greenstone_collections_str = get("Tree.World");
     984    String greenstone_collections_str = Dictionary.newget("Tree.World");
    980985    for(int i = 0; greenstone_collections_node == null && i < root_child_count; i++) {
    981986        TreeNode child = root.getChildAt(i);
     
    10971102        model.removeNodeFromParent(old);
    10981103                // Create and insert new.
    1099         FileNode private_workspace = new FileNode(new File(getCollectionCache()), get("Tree.Private"));
     1104        FileNode private_workspace = new FileNode(new File(getCollectionCache()), Dictionary.newget("Tree.Private"));
    11001105        model.insertNodeInto(private_workspace, root, 2);
    11011106    }
     
    11081113    collection.setSaved(false);
    11091114    }
    1110     /** Used to retrive a value from the dictionary based on the key.
    1111       * @param key A <strong>String</strong> indicating what value to retrieve.
    1112       * @return A <strong>String</strong> representing the value.
    1113       */
    1114     private String get(String key) {
    1115     return get(key, (String[])null);
    1116     }
    1117 
    1118     /** Used to retrive a value from the dictionary based on the key. */
    1119     private String get(String key, String arg) {
    1120     String[] args = new String[1];
    1121     args[0] = arg;
    1122     return get(key, args);
    1123     }
    1124 
    1125     /** Used to retrive a value from the dictionary based on the key, and an array of arguments.
    1126       * @param key A <strong>String</strong> indicating what value to retrieve.
    1127       * @param args A <strong>String[]</strong> of arguments to be inserted into the phrase.
    1128       * @return A <strong>String</strong> representing the value.
    1129       */
    1130     private String get(String key, String args[]) {
    1131     if(key.indexOf('.') == -1) {
    1132         key = "CollectionManager." + key;
    1133     }
    1134     return Gatherer.dictionary.get(key, args);
    1135     }
     1115
    11361116    /** Install collection by moving its files from building to index after a successful build.
    1137       * @see org.greenstone.gatherer.Gatherer
    1138       * @see org.greenstone.gatherer.util.Utility
    1139       */
     1117     * @see org.greenstone.gatherer.Gatherer
     1118     * @see org.greenstone.gatherer.util.Utility
     1119     */
    11401120    private void installCollection() {
    11411121    Gatherer.println("Build complete. Moving files.");
    11421122
    1143 
    11441123    try {
    1145                 // We have to ensure that the local library
     1124        // We have to ensure that the local library
    11461125        if(Gatherer.config.exec_file != null) {
    11471126        ///ystem.err.println("Local Library Found!");
     
    11611140
    11621141        // Special case for build mode "all": replace index dir with building dir
    1163         if (build_mode == null || build_mode.equals(get("CreatePane.Mode_All"))) {
     1142        if (build_mode == null || build_mode.equals(Dictionary.newget("CreatePane.Mode_All"))) {
    11641143        // Remove the old index directory
    11651144        if (index_dir.exists()) {
     
    12091188    }
    12101189    }
     1190
    12111191    /** Creates and dispatches a message given the initial details.
    1212       * @param level An <i>int</i> indicating the message level for this message.
    1213       * @param message A <strong>String</strong> which contains the payload of this message.
    1214       * @see org.greenstone.gatherer.Log
    1215       * @see org.greenstone.gatherer.Message
    1216       */
     1192     * @param level An <i>int</i> indicating the message level for this message.
     1193     * @param message A <strong>String</strong> which contains the payload of this message.
     1194     * @see org.greenstone.gatherer.Log
     1195     * @see org.greenstone.gatherer.Message
     1196     */
    12171197    private void message(int level, String message) {
    12181198    Message msg = new Message(Message.COLLECT, level, message);
  • trunk/gli/src/org/greenstone/gatherer/collection/Job.java

    r5335 r5564  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.awt.event.*;
    3940import java.io.*;
     
    4142import java.util.*;
    4243import javax.swing.tree.*;
     44import org.greenstone.gatherer.Dictionary;
    4345import org.greenstone.gatherer.Gatherer;
    4446import org.greenstone.gatherer.WGet;
     
    218220        int count = 0;
    219221        while(count < 3 && (user_pass = (String) Gatherer.authentications.get(address)) == null) {
    220         Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Gatherer.dictionary.get("WGet.Prompt"), "HTTP");
     222        Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.newget("WGet.Prompt"), "HTTP");
    221223        count++;
    222224        }
  • trunk/gli/src/org/greenstone/gatherer/collection/LoadCollectionBox.java

    r4675 r5564  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.awt.event.*;
    3940import java.io.*;
    4041import javax.swing.*;
    4142import javax.swing.filechooser.*;
     43import org.greenstone.gatherer.Dictionary;
    4244import org.greenstone.gatherer.Gatherer;
    4345import org.greenstone.gatherer.util.Utility;
    4446import org.outerj.pollo.util.*;
     47
    4548/**
    4649 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    5659    String defaultPath = Utility.getCollectionDir(Gatherer.config.gsdl_path);
    5760    chooser = new JFileChooser(new File(defaultPath));
    58     chooser.setDialogTitle(Gatherer.dictionary.get("SaveCollectionBox.Title"));
    59     ExtensionFileFilter filter1 = new ExtensionFileFilter(".col", Gatherer.dictionary.get("General.File_Description"));
     61    chooser.setDialogTitle(Dictionary.newget("SaveCollectionBox.Title"));
     62    ExtensionFileFilter filter1 = new ExtensionFileFilter(".col", Dictionary.newget("General.File_Description"));
    6063    chooser.setFileFilter(filter1);
    6164    chooser.setAcceptAllFileFilterUsed(false);
  • trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionBox.java

    r5536 r5564  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.awt.*;
    3940import java.awt.event.*;
    4041import javax.swing.*;
     42import org.greenstone.gatherer.Dictionary;
    4143import org.greenstone.gatherer.Gatherer;
     44
    4245/** Provides a prompt allowing the user some choice in whether a collection saves. */
    4346public class SaveCollectionBox
     
    6770    // Dialog setup
    6871    this.setModal(true);
    69     this.setTitle(get("SaveCollectionBox.Title"));
     72    this.setTitle(Dictionary.newget("SaveCollectionBox.Title"));
    7073    this.setSize(360,100);
    7174    }
     
    103106    String args[] = new String[1];
    104107    args[0] = name;
    105     JLabel save_label = new JLabel(get("SaveCollectionBox.Label", args));
     108    JLabel save_label = new JLabel();
     109    Dictionary.setText(save_label, "SaveCollectionBox.Label", args);
    106110    content_pane.add(save_label);
    107111    JPanel button_pane = new JPanel(new GridLayout(1,3));
    108112    content_pane.add(button_pane);
    109113    // We add both mnemonics and key listener so that the 'y' of yes is underlined, but pressing just [Y] (rather than [CTL]-[Y]) performs a systematic click.
    110     yes = new JButton(get("General.Yes"));
     114    yes = new JButton();
    111115    yes.addActionListener(this);
    112116    KeyListenerImpl key_listener = new KeyListenerImpl();
    113117    yes.addKeyListener(key_listener);
    114118    yes.setMnemonic(KeyEvent.VK_Y);
     119    Dictionary.setBoth(yes, "General.Yes", "General.Yes_Tooltip");
    115120    button_pane.add(yes);
    116     no = new JButton(get("General.No"));
     121    no = new JButton();
    117122    no.addActionListener(this);
    118123    no.addKeyListener(key_listener);
    119124    no.setMnemonic(KeyEvent.VK_N);
     125    Dictionary.setBoth(no, "General.No", "General.No_Tooltip");
    120126    button_pane.add(no);
    121     cancel = new JButton(get("General.Cancel"));
     127    cancel = new JButton();
    122128    cancel.addActionListener(this);
    123129    cancel.addKeyListener(key_listener);
    124130    cancel.setMnemonic(KeyEvent.VK_C);
     131    Dictionary.setBoth(cancel, "General.Cancel", "General.Cancel_Tooltip");
    125132    button_pane.add(cancel);
    126133    // Center on screen.
     
    144151    return result;
    145152    }
    146     /** Method to retrieve a phrase from the dictionary based of a key.
    147      * @param key A <strong>String</strong> used to find the correct phrase.
    148      * @return A <strong>String</strong> containing the correct phrase with the correct formatting.
    149      */
    150     private String get(String key) {
    151     return get(key, null);
    152     }
    153     /** Method to retrieve a phrase from the dictionary based of a key and including arguments.
    154      * @param key A <strong>String</strong> used to find the correct phrase.
    155      * @param args A <strong>String[]</strong> of arguments used in formatting and filling out the phrase.
    156      * @return A <strong>String</strong> containing the correct phrase with the correct formatting.
    157      */
    158     private String get(String key, String args[]) {
    159     if(key.indexOf('.') == -1) {
    160         key = "SaveCollectionBox." + key;
    161     }
    162     return Gatherer.dictionary.get(key, args);
    163     }
     153
    164154    /** Listens for key presses when the focus is on one of the buttons. Note that the key pressed needn't be the one associated with the button in focus. */
    165155    private class KeyListenerImpl
  • trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionTask.java

    r4675 r5564  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.io.*;
    3940import java.util.*;
    4041import javax.swing.*;
    4142import org.greenstone.gatherer.Gatherer;
    42 import org.greenstone.gatherer.Message;
    4343import org.greenstone.gatherer.collection.Collection;
    44 import org.greenstone.gatherer.gui.GUIManager;
    45 import org.greenstone.gatherer.undo.UndoManager;
    4644import org.greenstone.gatherer.util.Utility;
     45
    4746/** The actually saving of a collection must run in a thread other than the AWTEvent thread, or else the save progress box will never get updated. To that end this class provides a threaded save method, which saves the various parts of the collection to the appropriate disk location.
    4847 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    111110    // Create progress monitor box. It will display itself as necessary.
    112111    // WARNING: ProgressMonitors seem to be extremely dodgy, and are not recommended!
    113     // ProgressMonitor spd = new ProgressMonitor(Gatherer.g_man, Gatherer.dictionary.get("SaveProgressDialog.Title", collection.getName()), null, 0, 100);
     112    // ProgressMonitor spd = new ProgressMonitor(Gatherer.g_man, Dictionary.newget("SaveProgressDialog.Title", collection.getName()), null, 0, 100);
    114113    // spd.setMillisToDecideToPopup(100);
    115114    // spd.setMillisToPopup(100);
Note: See TracChangeset for help on using the changeset viewer.