Ignore:
Timestamp:
2003-09-26T14:58:33+12:00 (21 years ago)
Author:
mdewsnip
Message:

Many more tooltips and improvements to the Dictionary. Still more to come.

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

Legend:

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

    r5347 r5536  
    1 package org.greenstone.gatherer.collection;
    21/**
    32 *#########################################################################
     
    3635 *########################################################################
    3736 */
     37package org.greenstone.gatherer.collection;
     38
    3839import java.awt.*;
    3940import java.awt.event.*;
     
    4142import javax.swing.*;
    4243import javax.swing.event.*;
     44import org.greenstone.gatherer.Dictionary;
    4345import org.greenstone.gatherer.Gatherer;
    4446import org.greenstone.gatherer.collection.Collection;
    45 import org.greenstone.gatherer.collection.CollectionManager;
    4647import org.greenstone.gatherer.gui.ModalDialog;
    4748import org.greenstone.gatherer.gui.SimpleMenuBar;
     
    5051import org.greenstone.gatherer.util.StaticStrings;
    5152import org.greenstone.gatherer.util.Utility;
     53
    5254/** This class provides the functionality to delete current collections from the GSDLHOME/collect/ directory. The user chooses the collection from a list, where each entry also displays details about itself, confirms the delete of a collection by checking a checkbox then presses the ok button to actually delete the collection.
    5355 * @author John Thompson, Greenstone Digital Library, University of Waikato
     
    6062    /** The model behind the list. */
    6163    private DefaultListModel list_model = null;
    62     /** A reference to ourself so any inner-classes get dispose of us. */
     64    /** A reference to ourself so any inner-classes can dispose of us. */
    6365    private DeleteCollectionPrompt prompt = null;
    6466    /** The close button, which exits the prompt without deleting anything. */
     
    8284    /** The size of the delete prompt screen. */
    8385    public static final Dimension SIZE = new Dimension(500, 500);
     86
    8487    /** Constructor.
    8588     * @see org.greenstone.gatherer.collection.DeleteCollectionPrompt.CloseButtonListener
     
    9093    public DeleteCollectionPrompt() {
    9194    super(Gatherer.g_man);
    92     this.close_button = new JButton(get("General.Close", null));
    93     this.confirmation = new JCheckBox(get("DeleteCollectionPrompt.Confirm_Delete", null));
    94     this.details = new JTextArea();
    95     this.details_label = new JLabel(get("DeleteCollectionPrompt.Collection_Details", null));
    96     this.list = new JList();
    97     this.list_label = new JLabel(get("DeleteCollectionPrompt.Collection_List", null));
    98     this.list_model = new DefaultListModel();
    99     this.ok_button = new JButton(get("General.OK", null));
    100     this.prompt = this;
    101     this.setModal(true);
    102     this.setSize(SIZE);
    103     this.setTitle(get("DeleteCollectionPrompt.Title", null));
    104     this.setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at
     95    close_button = new JButton();
     96    Dictionary.setText(close_button, "General.Close");
     97    confirmation = new JCheckBox();
     98    Dictionary.setText(confirmation, "DeleteCollectionPrompt.Confirm_Delete");
     99    details = new JTextArea();
     100    details.setFont(Gatherer.config.getFont("general.tooltip_font", false));
     101    Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection");
     102    details_label = new JLabel();
     103    Dictionary.setText(details_label, "DeleteCollectionPrompt.Collection_Details");
     104    list = new JList();
     105    list_label = new JLabel();
     106    Dictionary.setText(list_label, "DeleteCollectionPrompt.Collection_List");
     107    list_model = new DefaultListModel();
     108    ok_button = new JButton();
     109    Dictionary.setText(ok_button, "General.OK");
     110    prompt = this;
     111    setModal(true);
     112    setSize(SIZE);
     113    // setTitle();
     114    Dictionary.setText(this, "DeleteCollectionPrompt.Title");
     115
     116    setJMenuBar(new SimpleMenuBar("0")); // need to find an appropriate help page to open at
    105117    close_button.addActionListener(new CloseButtonListener());
    106118    confirmation.addActionListener(new ConfirmationCheckBoxListener());
    107119    confirmation.setEnabled(false);
    108120    confirmation.setSelected(false);
    109     details.setFont(Gatherer.config.getFont("general.tooltip_font", false));
    110     details.setText(get("DeleteCollectionPrompt.No_Collection", null));
    111121    list.addListSelectionListener(new CollectionListListener());
    112122    list.clearSelection();
     
    117127    scanForCollections();
    118128    }
     129
    119130    /** Destructor. */
    120131    public void destroy() {
     
    129140    prompt = null;
    130141    }
     142
    131143    /** This method causes the modal prompt to be displayed.
    132      * returns true if it has deleted the collection that is currently open*/
     144     * returns true if it has deleted the collection that is currently open */
    133145    public boolean display() {
    134146    // Central pane
     
    176188   
    177189    }
     190
    178191    /** Shows a delete complete prompt.
    179       * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted.
    180       * @see org.greenstone.gatherer.collection.Collection
    181       */
     192     * @param success A <strong>boolean</strong> indicating if the collection was successfully deleted.
     193     * @see org.greenstone.gatherer.collection.Collection
     194     */
    182195    public void resultPrompt(boolean success) {
    183196    args = new String[1];
    184197    args[0] = collection.getName();
    185     if(success) {
    186         JOptionPane.showMessageDialog(prompt,get("DeleteCollectionPrompt.Successful_Delete", args),get("DeleteCollectionPrompt.Successful_Title", null),JOptionPane.INFORMATION_MESSAGE);
     198    if (success) {
     199        JOptionPane.showMessageDialog(prompt,Dictionary.newget("DeleteCollectionPrompt.Successful_Delete", args),Dictionary.newget("DeleteCollectionPrompt.Successful_Title"),JOptionPane.INFORMATION_MESSAGE);
    187200    }
    188201    else {
    189         JOptionPane.showMessageDialog(prompt,get("DeleteCollectionPrompt.Failed_Delete", args),get("DeleteCollectionPrompt.Failed_Title", null),JOptionPane.WARNING_MESSAGE);
    190     }
    191     }
    192     /** Retrieves a phrase from the <strong>Dictionary</strong> in <strong>Gatherer</strong>.
    193       * @param key A <strong>String</strong> used to match against a specific phrase in the dictionary.
    194       * @see org.greenstone.gatherer.Dictionary
    195       * @see org.greenstone.gatherer.Gatherer
    196       */
    197     private String get(String key, String args[]) {
    198     if(key.indexOf(".") == -1) {
    199         key = "DeleteCollectionPrompt." + key;
    200     }
    201     return Gatherer.dictionary.get(key, args);
    202     }
     202        JOptionPane.showMessageDialog(prompt,Dictionary.newget("DeleteCollectionPrompt.Failed_Delete", args),Dictionary.newget("DeleteCollectionPrompt.Failed_Title"),JOptionPane.WARNING_MESSAGE);
     203    }
     204    }
     205
    203206
    204207    /** Method to scan the collect directory retrieving and reloading each collection it finds, while building the list of known collections.
    205       * @see org.greenstone.gatherer.Configuration
    206       * @see org.greenstone.gatherer.Gatherer
    207       * @see org.greenstone.gatherer.util.ArrayTools
    208       * @see org.greenstone.gatherer.util.Utility
    209       */
     208     * @see org.greenstone.gatherer.Configuration
     209     * @see org.greenstone.gatherer.Gatherer
     210     * @see org.greenstone.gatherer.util.ArrayTools
     211     * @see org.greenstone.gatherer.util.Utility
     212     */
    210213    private void scanForCollections() {
    211214    // Start at the collect dir.
     
    232235    // Otherwise the collect directory doesn't actually exist, so there ain't much we can do.
    233236    }
     237
    234238    /** A button listener implementation, which listens for actions on the close button and disposes of the dialog when detected. */
    235239    private class CloseButtonListener
     
    237241    /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
    238242     * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
    239             */
     243     */
    240244    public void actionPerformed(ActionEvent event) {
    241245        // Ask the collection manager to refresh the 'Greenstone Collections' folder
     
    245249    }
    246250    }
     251
    247252    /** This private class listens for selection events in from the list and then displays the appropriate details for that collection.
    248       */
     253     */
    249254    private class CollectionListListener
    250255    implements ListSelectionListener {
     
    264269        args[3] = collection.getMaintainer();
    265270        args[4] = collection.getDescription();
    266         details.setText(get("DeleteCollectionPrompt.Details", args));
     271        Dictionary.setText(details, "DeleteCollectionPrompt.Details", args);
    267272        details.setCaretPosition(0);
    268273        }
    269274        else {
    270275        confirmation.setEnabled(false);
    271         details.setText(get("DeleteCollectionPrompt.No_Collection", null));
    272         }
    273     }
    274     }
    275     /** A check box listener so we can tell if the users selected confirm. */
     276        Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection");
     277        }
     278    }
     279    }
     280
     281    /** A check box listener so we can tell if the user has confirmed the deletion */
    276282    private class ConfirmationCheckBoxListener
    277283    implements ActionListener {
    278284    /** Any implementation of ActionListener must include this method so we can be informed when the button is actioned.
    279285     * @param event An <strong>ActionEvent</strong> containing all the relevant information garnered from the event itself.
    280             */
     286     */
    281287    public void actionPerformed(ActionEvent event) {
    282         if(confirmation.isSelected()) {
    283         ok_button.setEnabled(true);
    284         }
    285         else {
    286         ok_button.setEnabled(false);
    287         }
     288        // OK button is only enabled if the confirmation check box is ticked
     289        ok_button.setEnabled(confirmation.isSelected());
    288290    }
    289291    }         
     292
    290293    /** The OK button listener implementation. */
    291294    private class OKButtonListener
     
    314317        resultPrompt(true);
    315318        list_model.removeElement(collection);
    316         details.setText(get("DeleteCollectionPrompt.No_Collection", null));
     319        Dictionary.setText(details, "DeleteCollectionPrompt.No_Collection");
    317320        confirmation.setEnabled(false);
    318321        confirmation.setSelected(false);
     
    355358        return config.getMaintainer();
    356359    }
     360
    357361    public String toString() {
    358         return config.getName();
    359        
     362        return config.getName();       
    360363    }
    361364    }
  • trunk/gli/src/org/greenstone/gatherer/collection/SaveCollectionBox.java

    r5355 r5536  
    9494    }
    9595    /** Displays the prompt by first building the controls, then waits for a user selection.
    96       * @param name The name of the current collection as a <strong>String</strong>.
    97       */
     96     * @param name The name of the current collection as a <strong>String</strong>.
     97     */
    9898    public int getUserOption(String name) {
    9999    JPanel content_pane = (JPanel) this.getContentPane();
     
    145145    }
    146146    /** 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       */
     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     */
    150150    private String get(String key) {
    151151    return get(key, null);
    152152    }
    153153    /** 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       */
     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     */
    158158    private String get(String key, String args[]) {
    159159    if(key.indexOf('.') == -1) {
     
    167167    /** Any extension of KeyAdapter can override this method so that we can be informed whenever a key is released (ie after a keyTyped event). In this case we map the key press to an appropriate click on one of the buttons (not necessarily the one the key release was detected on).
    168168     * @param event A <strong>KeyEvent</strong> containing details about the key release event.
    169             */
     169     */
    170170    public void keyReleased(KeyEvent event) {
    171171        if(event.getKeyCode() == KeyEvent.VK_Y) {
Note: See TracChangeset for help on using the changeset viewer.