Changeset 6389


Ignore:
Timestamp:
2004-01-09T15:08:11+13:00 (20 years ago)
Author:
jmt12
Message:

Introduced the idea of detail modes - these have an effect on several parts of the gui, such as disabling or hiding all regular expression based controls, simplifying the output from perl scripts and (having been given yet another new last minute feature to implement) displays a completely different create pane. Mode is stored in the config.xml and is changable via the Preferences controls

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

Legend:

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

    r6319 r6389  
    5858    static final public boolean COLLECTION_SPECIFIC = true;
    5959    static final public boolean GENERAL_SETTING = true;
     60
     61    static final public int ASSISTANT_MODE = 1;
     62    static final public int LIBRARIAN_MODE = 2;
     63    static final public int SYSTEMS_MODE   = 3;
     64    static final public int EXPERT_MODE    = 4;
    6065
    6166    /** The string identifying an argument's name attribute. */
     
    456461    }
    457462
     463    /** Because modes will soon be an integral part of GLI, they get their own easy to remember methods such as this one to get the mode.
     464     * @return an int representing the mode
     465     */
     466    public int getMode() {
     467    return getInt("general.mode", GENERAL_SETTING);
     468    }
     469
     470    /** Return the current mode as a string for use in title bar etc
     471     * @return the mode as a String
     472     */
     473    public String getModeAsString() {
     474    String result;
     475    switch(getInt("general.mode", GENERAL_SETTING)) {
     476    case ASSISTANT_MODE:
     477        result = Dictionary.get("Preferences.Mode.Assistant");
     478        break;
     479    case SYSTEMS_MODE:
     480        result = Dictionary.get("Preferences.Mode.Systems");
     481        break;
     482    case EXPERT_MODE:
     483        result = Dictionary.get("Preferences.Mode.Expert");
     484        break;
     485    default:
     486        result = Dictionary.get("Preferences.Mode.Librarian");
     487    }
     488    return result;
     489    }
     490
    458491    /** Retrieve the value of the named property, and noting whether we consult the general or collection specific configuration. */
    459492    public String getString(String property, boolean general) {
     
    671704    country = null;
    672705    setString(property, general, text.toString());
     706    }
     707
     708    /** Because modes will soon be an integral part of GLI, they get their own easy to remember methods such as this one to set the mode.
     709     * @param value the new value for mode
     710     */
     711    public void setMode(int value) {
     712    setInt("general.mode", GENERAL_SETTING, value);
    673713    }
    674714
  • trunk/gli/src/org/greenstone/gatherer/cdm/Argument.java

    r6087 r6389  
    22 *#########################################################################
    33 *
    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.
     4 * A component of the Greenstone Librarian Interface (GLI) application,
     5 * part of the Greenstone digital library software suite from the New
     6 * Zealand Digital Library Project at the University of Waikato,
     7 * New Zealand.
    78 *
    8  * Author: John Thompson, Greenstone Digital Library, University of Waikato
     9 * Author: John Thompson
     10 *         Greenstone Project, New Zealand Digital Library
     11 *         University of Waikato
     12 *         http://www.nzdl.org
    913 *
    10  * Copyright (C) 1999 New Zealand Digital Library Project
     14 * Copyright (C) 2004 New Zealand Digital Library, University of Waikato
    1115 *
    1216 * This program is free software; you can redistribute it and/or modify
     
    2529 *########################################################################
    2630 */
     31
    2732package org.greenstone.gatherer.cdm;
    2833
    2934import java.io.*;
    3035import java.util.*;
     36import org.greenstone.gatherer.Configuration;
    3137import org.greenstone.gatherer.Gatherer;
    3238import org.greenstone.gatherer.cdm.CollectionConfiguration;
     
    4147
    4248/** This class contains all the details about a single argument that can be passed to this plugin, including option lists if the parameters are restricted.
    43  * @author John Thompson, Greenstone Digital Library, University of Waikato
    44  * @version 2.3
     49 * @author John Thompson, Greenstone Project, New Zealand Digital Library, University of Waikato
     50 * @version 2.41 final
    4551 */
    4652public class Argument
    4753    implements Comparable, Serializable {
    48     /** An element of the argument type enumeration. */
     54    /** An element of the argument type enumeration specifying a combobox control. */
    4955    static final public byte ENUM = 0;
    50     /** An element of the argument type enumeration. */
     56    /** An element of the argument type enumeration specifying a checkbox control. */
    5157    static final public byte FLAG = 1;
    52     /** An element of the argument type enumeration. */
     58    /** An element of the argument type enumeration specifying a tree control. */
    5359    static final public byte HIERARCHY = 2;
    54     /** An element of the argument type enumeration. */
     60    /** An element of the argument type enumeration specifying a spinner control. */
    5561    static final public byte INTEGER = 3;
    56     /** An element of the argument type enumeration. */
     62    /** An element of the argument type enumeration specifying a language combobox control. */
    5763    static final public byte LANGUAGE = 4;
    58     /** An element of the argument type enumeration. */
     64    /** An element of the argument type enumeration specifying a list control. */
    5965    static final public byte METADATA = 5;
    60     /** An element of the argument type enumeration. */
     66    /** An element of the argument type enumeration specifying a metadata combobox control. */
    6167    static final public byte METADATUM = 6;
    62     /** An element of the argument type enumeration. */
     68    /** An element of the argument type enumeration specifying a text field. */
    6369    static final public byte STRING = 7;
     70    /** An element of the argument type enumeration specifying a regular expression text field. */
     71    static final public byte REGEXP = 8;
     72    /** true if this argument should actually be hidden within the GLI. This is iportant for arguments such as import dir or other location critical arguments. */
     73    private boolean hidden_gli = false;
    6474    /** <i>true</i> if this argument is required for the applicable script to work properly, <i>false</i> otherwise. */
    6575    private boolean required = false;
    66     /** The type of this argument. Initially an int, but bytes are cheaper. */
     76    /** The type of this argument. Used to be an int, but bytes are cheaper. */
    6777    private byte type = STRING;
    68    
    6978    /** The maximum value an integer based control can have. */
    7079    private int maximum = Integer.MAX_VALUE;
    7180    /** The minimum value an integer based control can have. */
    7281    private int minimum = Integer.MIN_VALUE;
    73 
     82    /** Every argument has a detail mode level at which it becomes available to the user to edit.
     83     * @see org.greenstone.gatherer.Configuration
     84     */
     85    private int mode_level = Configuration.LIBRARIAN_MODE;
     86    /** The DOM element this argument is built around, if any. */
    7487    private Element element;
    7588    /** If the argument is of type ENUM then this map holds all the various options. Each entry is an &lt;option value&gt; -&gt; &lt;description&gt; mapping. */
     
    88101    }
    89102
     103    /** Another constructor but this one is a little more interesting as it takes a DOM element.
     104     * @param element the Element this argument is based around
     105     */
    90106    public Argument(Element element) {
    91107    this.element = element;
     
    93109
    94110    /** Method to add an element to the option list.
    95      * @param name The name value of the option as a <strong>String</strong>.
    96      * @param desc The description of this options as a <strong>String</strong>.
     111     * @param name the name value of the option as a String
     112     * @param desc the description of this options as a String
    97113     */
    98114    public void addOption(String name, String desc) {
     
    109125
    110126    /** Method to compare two arguments for ordering.
    111      * @param object The argument we are comparing to, as an <strong>Object</strong>.
    112      * @return An <i>int</i> specifying the argument order, using values as set out in String.
    113      * @see java.lang.String#compareTo
     127     * @param object the argument we are comparing to, as an Object
     128     * @return an int specifying the argument order, using values as set out in String
    114129     * @see org.greenstone.gatherer.cdm.Argument
    115130     */
     
    123138    }
    124139
     140    /** Create a copy of this argument.
     141     * @return a newly created Argument with the same details as this one
     142     */
    125143    public Argument copy() {
    126144    Argument copy = new Argument();
     
    136154
    137155    /** Method to determine if two arguments are equal.
    138      * @param object The argument to test against, as an <strong>Object</strong>.
    139      * @return <i>true</i> if the arguments names match, <i>false</i> otherwise.
     156     * @param object the argument to test against, as an Object
     157     * @return true if the arguments names match, false otherwise
    140158     */
    141159    public boolean equals(Object object) {
     
    144162
    145163    /** Method to retrieve the value of default_value.
    146      * @return A <strong>String</strong> containing the default value.
     164     * @return a String containing the default value
    147165     */
    148166    public String getDefaultValue() {
     
    151169
    152170    /** Method to retrieve this arguments description.
    153      * @return A <strong>String</strong> containing the description.
     171     * @return a String containing the description
    154172     */
    155173    public String getDescription() {
     
    158176
    159177    /** Method to retrieve the description of a certain list option value.
    160      * @param key The <strong>String</strong> whose description we are searching for.
    161      * @return The description of the desired key as a <strong>String</strong> which may be empty if no such key exists.
     178     * @param key the String whose description we are searching for
     179     * @return the description of the desired key as a String which may be empty if no such key exists
    162180     */
    163181    public String getDescription(String key) {
     
    168186    }
    169187
     188    /** Retrieve the upper bound of a range based argument.
     189     * @return the maximum as an int
     190     */
    170191    public int getMaximum() {
    171192    return maximum;
    172193    }
    173194
     195    /** Retrieve the lower bound of a range based argument.
     196     * @return the minimum as an int
     197     */
    174198    public int getMinimum() {
    175199    return minimum;
    176200    }
    177201
    178     /** Method to retrieve the option list for this argument.
    179      * @return A <strong>HashMap</strong> containing &lt;option value&gt; -&gt; &lt;description&gt; entries.
    180      */
    181     public HashMap getOptions() {
    182     return list;
     202    /** Retrieves the mode level at which this argument should become available. Any higher levels should also see this argument.
     203     * @return the mode level as an int
     204     */
     205    public int getModeLevel() {
     206    return mode_level;
    183207    }
    184208
    185209    /** Method to retrieve the value of name.
    186      * @return A <strong>String</strong> containing the argument name.
     210     * @return a String containing the argument name
     211     * @see org.greenstone.gatherer.util.StaticStrings#NAME_ATTRIBUTE
    187212     */
    188213    public String getName() {
     
    193218    }
    194219
     220    /** Method to retrieve the option list for this argument.
     221     * @return a HashMap containing &lt;option value&gt; -&gt; &lt;description&gt; entries
     222     */
     223    public HashMap getOptions() {
     224    return list;
     225    }
     226
    195227    /** Retrieve the name of the owner of this argument.
    196      * @return The owners name as a <strong>String</strong>.
     228     * @return the owners name as a String
    197229     */
    198230    public String getOwner() {
     
    201233   
    202234    /** Method to determine the type of this argument.
    203      * @return An <i>byte</i> specifying the type.
     235     * @return a byte specifying the type
    204236     */
    205237    public byte getType() {
     
    208240
    209241    /** Method to retrieve the value of value.
    210      * @return The value of value as a <strong>String</strong>.
     242     * @return the value of value as a String
     243     * @see org.greenstone.gatherer.Gatherer#c_man
     244     * @see org.greenstone.gatherer.collection.Collection#msm
     245     * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
     246     * @see org.greenstone.gatherer.msm.ElementWrapper
     247     * @see org.greenstone.gatherer.msm.MetadataSetManager#getElement(String)
     248     * @see org.greenstone.gatherer.msm.MSMUtils#getValue(Element)
    211249     */
    212250    public String getValue() {
     
    227265
    228266    /** Retrieve the vector of values.
    229      * @return An <strong>ArrayList</strong> of values.
     267     * @return an ArrayList of values
     268     * @see org.greenstone.gatherer.Gatherer#c_man
     269     * @see org.greenstone.gatherer.collection.Collection#msm
     270     * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
     271     * @see org.greenstone.gatherer.msm.ElementWrapper
     272     * @see org.greenstone.gatherer.msm.MetadataSetManager#getElement(String)
     273     * @see org.greenstone.gatherer.msm.MSMUtils#getValue(Element)
    230274     */
    231275    public ArrayList getValues() {
     
    250294
    251295    /** Method to determine if this argument has been assigned.
    252      * @return <i>true</i> if it has, <i>false</i> otherwise.
     296     * @return true if it has, false otherwise
     297     * @see org.greenstone.gatherer.util.StaticStrings#ASSIGNED_ATTRIBUTE
     298     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
    253299     */
    254300    public boolean isAssigned() {
     
    256302    }
    257303
     304    /** Determine if this is a custom argument ie one that has been parsed from the config file but doesn't have a matching entry in the argument library.
     305     * @return true if this argument is a custom, false otherwise
     306     * @see org.greenstone.gatherer.util.StaticStrings#CUSTOM_ATTRIBUTE
     307     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
     308     */
    258309    public boolean isCustomArgument() {
    259310    return (element != null && element.getAttribute(StaticStrings.CUSTOM_ATTRIBUTE).equals(StaticStrings.TRUE_STR));
    260311    }
    261312
     313    /** Determine if this argument is hidden in GLI
     314     * @return true if the argument is hidden, false otherwise
     315     */
     316    public boolean isHiddenGLI() {
     317    return hidden_gli;
     318    }
     319
    262320    /** Method to determine of this argument is required for the associated script to work.
    263      * @return <i>true</i> if this argument is required, <i>false</i> otherwise.
     321     * @return true if this argument is required, false otherwise
    264322     */
    265323    public boolean isRequired() {
     
    269327    /** Method to allow for the activation of arguments that might never have their setValue() method called.
    270328     * @param assigned the desired state as a boolean
     329     * @see org.greenstone.gatherer.util.StaticStrings#ASSIGNED_ATTRIBUTE
     330     * @see org.greenstone.gatherer.util.StaticStrings#FALSE_STR
     331     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
    271332     */
    272333    public void setAssigned(boolean assigned) {
     
    276337    }
    277338
     339    /** Set the custom argument flag.
     340     * @param custom true to make this argument custom, false otherwise
     341     * @see org.greenstone.gatherer.util.StaticStrings#CUSTOM_ATTRIBUTE
     342     * @see org.greenstone.gatherer.util.StaticStrings#FALSE_STR
     343     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
     344     */
    278345    public void setCustomArgument(boolean custom) {
    279346    if(element != null) {
     
    290357
    291358    /** Set the value of desc.
    292      * @param description The new value of desc as a <strong>String</strong>.
     359     * @param description the new value of desc as a String
    293360     */
    294361    public void setDescription(String description) {
     
    296363    }
    297364
     365    /** Set the element this argument should be based upon.
     366     * @param element the Element
     367     */
    298368    public void setElement(Element element) {
    299369    this.element = element;
    300370    }
    301371
     372    /** Mark this argument as being hidden in GLI. */
     373    public void setHiddenGLI() {
     374    hidden_gli = true;
     375    }
     376
     377    /** Set the upper bound for a range type argument.
     378     * @param maximum the maximum as an int
     379     */
    302380    public void setMaximum(int maximum) {
    303381    this.maximum = maximum;
    304382    }
    305383
     384    /** Set the lower bound for a range type argument.
     385     * @param minimum the minimum as an int
     386     */
    306387    public void setMinimum(int minimum) {
    307388    this.minimum = minimum;
    308389    }
    309390
     391    /** Set the detail mode level where this argument will become available.
     392     * @param mode_level the mode level as an int
     393     */
     394    public void setModeLevel(int mode_level) {
     395    this.mode_level = mode_level;
     396    }
     397
    310398    /** Set the value of name.
    311      * @param name The new value of name as a <strong>String</strong>.
     399     * @param name the new value of name as a String
    312400     */
    313401    public void setName(String name) {
     
    316404
    317405    /** Sets the value of the options list.
    318      * @param list The new options list as a <strong>HashMap</strong>.
     406     * @param list the new options list as a HashMap
    319407     */
    320408    public void setOptions(HashMap list) {
     
    323411
    324412    /** Set the owner of this argument.
    325      * @param owner The name of the owner of this argument as a <strong>String</strong>.
     413     * @param owner the name of the owner of this argument as a String
    326414     */
    327415    public void setOwner(String owner) {
     
    330418
    331419    /** Set the value of required.
    332      * @param required The new value of required as a <i>boolean</i>.
     420     * @param required the new value of required as a boolean
    333421     */
    334422    public void setRequired(boolean required) {
     
    337425
    338426    /** Set the value of type.
    339      * @param type The new value of type as an <i>byte</i>.
     427     * @param type the new value of type as an byte
    340428     */
    341429    public void setType(byte type) {
     
    344432
    345433    /** Set the value of type, by matching a type to the given string.
    346      * @param new_type A <strong>String</strong> which contains the name of a certain argument type.
     434     * @param new_type a String which contains the name of a certain argument type
     435     * @see org.greenstone.gatherer.util.StaticStrings#ENUM_STR
     436     * @see org.greenstone.gatherer.util.StaticStrings#FLAG_STR
     437     * @see org.greenstone.gatherer.util.StaticStrings#HIERARCHY_STR
     438     * @see org.greenstone.gatherer.util.StaticStrings#INT_STR
     439     * @see org.greenstone.gatherer.util.StaticStrings#LANGUAGE_STR
     440     * @see org.greenstone.gatherer.util.StaticStrings#METADATA_TYPE_STR
     441     * @see org.greenstone.gatherer.util.StaticStrings#METADATUM_TYPE_STR
     442     * @see org.greenstone.gatherer.util.StaticStrings#REGEXP_STR
    347443     */
    348444    public void setType(String new_type) {
     
    369465        this.type = METADATUM;
    370466    }
     467    else if(new_type.equalsIgnoreCase(StaticStrings.REGEXP_STR)) {
     468        this.type = REGEXP;
     469    }
    371470    else {
    372471        this.type = STRING;
    373472    }
    374    
    375     }
     473    }
     474
    376475    /** Method to set the value of this argument.
    377      * @param value
    378      * @see org.greenstone.gatherer.Gatherer
    379      * @see org.greenstone.gatherer.msm.MSMUtils
     476     * @param value the new value for the argument
     477     * @see org.greenstone.gatherer.Gatherer#println
     478     * @see org.greenstone.gatherer.msm.MSMUtils#setValue
    380479     */
    381480    public void setValue(String value) {
     
    390489    /** Set the values vector to the given values. Currently I just assign the new values, whereas I may later want to implement a deep clone.
    391490     * @param values an ArrayList of values
    392      * @see org.greenstone.gatherer.Gatherer
    393      * @see org.greenstone.gatherer.msm.MSMUtils   
     491     * @see org.greenstone.gatherer.Gatherer#println
     492     * @see org.greenstone.gatherer.msm.MSMUtils#setValue   
    394493     */
    395494    public void setValues(ArrayList values) {
     
    411510    /** Method for translating the data of this class into a string.
    412511     * @return a String containing a fragment of the total arguments string
    413      * @see org.greenstone.gatherer.Gatherer
    414      * @see org.greenstone.gatherer.collection.Collection
    415      * @see org.greenstone.gatherer.collection.CollectionManager
    416      * @see org.greenstone.gatherer.msm.MetadataSetManager
    417      * @see org.greenstone.gatherer.msm.MSMUtils
    418      * @see org.greenstone.gatherer.util.StaticStrings
     512     * @see org.greenstone.gatherer.Gatherer#c_man
     513     * @see org.greenstone.gatherer.collection.Collection#msm
     514     * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
     515     * @see org.greenstone.gatherer.msm.MetadataSetManager#getElement(String)
     516     * @see org.greenstone.gatherer.msm.MSMUtils#getValue
     517     * @see org.greenstone.gatherer.util.StaticStrings#COMMA_CHARACTER
     518     * @see org.greenstone.gatherer.util.StaticStrings#NAME_ATTRIBUTE
     519     * @see org.greenstone.gatherer.util.StaticStrings#SPACE_CHARACTER
     520     * @see org.greenstone.gatherer.util.StaticStrings#SPEECH_CHARACTER
    419521     */
    420522    public String toString() {
  • trunk/gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java

    r6324 r6389  
    3131import java.util.*;
    3232import javax.swing.*;
     33import org.greenstone.gatherer.Configuration;
    3334import org.greenstone.gatherer.Dictionary;
    3435import org.greenstone.gatherer.Gatherer;
     
    237238    ArrayList arguments = data.getArguments(true, false);
    238239    int total_height = 250;
     240    int mode = Gatherer.config.getMode();
    239241    for(int i = 0; i < arguments.size(); i++) {
    240242        Argument argument = (Argument) arguments.get(i);
    241         ArgumentControl argument_control = new ArgumentControl(argument);
    242         total_height = total_height - argument_control.getPreferredSize().height;
    243         central_pane.add(argument_control);
     243        if(mode > Configuration.LIBRARIAN_MODE || !(argument.getType() == Argument.REGEXP)) {
     244        ArgumentControl argument_control = new ArgumentControl(argument);
     245        total_height = total_height - argument_control.getPreferredSize().height;
     246        central_pane.add(argument_control);
     247        }
    244248    }
    245249    if(total_height > 0) {
     
    376380        value = spinner;
    377381        break;
     382        case Argument.REGEXP:
    378383        case Argument.STRING:
    379384        // Use a standard text field
  • trunk/gli/src/org/greenstone/gatherer/cdm/ClassifierManager.java

    r6318 r6389  
    548548    private JButton configure = null;
    549549
    550     private JButton move_bottom_button;
     550    //private JButton move_bottom_button;
    551551
    552552    private JButton move_down_button;
    553553
    554     private JButton move_top_button;
     554    //private JButton move_top_button;
    555555
    556556    private JButton move_up_button;
     
    565565
    566566    /** Constructor.
    567      * @see org.greenstone.gatherer.cdm.ClassifierManager.Control.AddListener
    568      * @see org.greenstone.gatherer.cdm.ClassifierManager.Control.ConfigureListener
    569      * @see org.greenstone.gatherer.cdm.ClassifierManager.Control.RemoveListener
     567     * @see org.greenstone.gatherer.cdm.ClassifierManager.ClassifierControl.AddListener
     568     * @see org.greenstone.gatherer.cdm.ClassifierManager.ClassifierControl.ConfigureListener
     569     * @see org.greenstone.gatherer.cdm.ClassifierManager.ClassifierControl.RemoveListener
    570570     */
    571571    public ClassifierControl() {
     
    625625        JPanel move_button_pane = new JPanel();
    626626
    627         move_top_button = new DoubleImageButton("", Utility.getImage("arrow-top.gif"), Utility.getImage("arrow-top-disabled.gif"));
    628         move_top_button.setEnabled(false);
    629         move_top_button.setMnemonic(KeyEvent.VK_T);
     627        //move_top_button = new DoubleImageButton("", Utility.getImage("arrow-top.gif"), Utility.getImage("arrow-top-disabled.gif"));
     628        //move_top_button.setEnabled(false);
     629        //move_top_button.setMnemonic(KeyEvent.VK_T);
    630630        // move_top_button.setDisplayedMnemonicIndex(8);  // !! English-centric hack
    631         move_top_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
    632         Dictionary.registerBoth(move_top_button, "CDM.Move.Move_Top", "CDM.Move.Move_Top_Tooltip");
     631        //move_top_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
     632        //Dictionary.registerBoth(move_top_button, "CDM.Move.Move_Top", "CDM.Move.Move_Top_Tooltip");
    633633
    634634        move_up_button = new DoubleImageButton("", Utility.getImage("arrow-up.gif"), Utility.getImage("arrow-up-disabled.gif"));
     
    644644        Dictionary.registerBoth(move_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
    645645
    646         move_bottom_button = new DoubleImageButton("", Utility.getImage("arrow-bottom.gif"), Utility.getImage("arrow-bottom-disabled.gif"));
    647         move_bottom_button.setEnabled(false);
    648         move_bottom_button.setMnemonic(KeyEvent.VK_B);
    649         move_bottom_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
    650         Dictionary.registerBoth(move_bottom_button, "CDM.Move.Move_Bottom", "CDM.Move.Move_Bottom_Tooltip");
     646        //move_bottom_button = new DoubleImageButton("", Utility.getImage("arrow-bottom.gif"), Utility.getImage("arrow-bottom-disabled.gif"));
     647        //move_bottom_button.setEnabled(false);
     648        //move_bottom_button.setMnemonic(KeyEvent.VK_B);
     649        //move_bottom_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
     650        //Dictionary.registerBoth(move_bottom_button, "CDM.Move.Move_Bottom", "CDM.Move.Move_Bottom_Tooltip");
    651651
    652652        // Listeners
     
    660660
    661661        MoveListener ml = new MoveListener();
    662         move_bottom_button.addActionListener(ml);
     662        //move_bottom_button.addActionListener(ml);
    663663        move_down_button.addActionListener(ml);
    664         move_top_button.addActionListener(ml);
     664        //move_top_button.addActionListener(ml);
    665665        move_up_button.addActionListener(ml);
    666666
     
    675675
    676676        move_button_pane.setLayout(new GridLayout(4,1));
    677         move_button_pane.add(move_top_button);
    678677        move_button_pane.add(move_up_button);
     678        move_button_pane.add(new JPanel());
     679        move_button_pane.add(new JPanel());
    679680        move_button_pane.add(move_down_button);
    680         move_button_pane.add(move_bottom_button);
    681681
    682682        classifier_list_label.setBorder(BorderFactory.createEmptyBorder(0,2,0,2));
     
    858858        if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one)
    859859            if (classifier_list.isSelectionEmpty()) {
    860             move_top_button.setEnabled(false);
     860            //move_top_button.setEnabled(false);
    861861            move_up_button.setEnabled(false);
    862862            move_down_button.setEnabled(false);
    863             move_bottom_button.setEnabled(false);
     863            //move_bottom_button.setEnabled(false);
    864864            configure.setEnabled(false);
    865865            remove.setEnabled(false);
    866866            }
    867867            else {
    868             move_top_button.setEnabled(true);
     868            //move_top_button.setEnabled(true);
    869869            move_up_button.setEnabled(true);
    870870            move_down_button.setEnabled(true);
    871             move_bottom_button.setEnabled(true);
     871            //move_bottom_button.setEnabled(true);
    872872            configure.setEnabled(true);
    873873            remove.setEnabled(true);
     
    888888            if(object instanceof Classifier) {
    889889            Classifier classifier = (Classifier) object;
    890             if(event.getSource() == move_top_button) {
    891                 moveClassifier(classifier, true, true);
    892             }
    893             else if(event.getSource() == move_up_button) {
     890            //if(event.getSource() == move_top_button) {
     891            //    moveClassifier(classifier, true, true);
     892            //}
     893            //else
     894            if(event.getSource() == move_up_button) {
    894895                moveClassifier(classifier, true, false);
    895896            }
     
    897898                moveClassifier(classifier, false, false);
    898899            }
    899             else {
    900                 moveClassifier(classifier, false, true);
    901             }
     900            //else {
     901            //    moveClassifier(classifier, false, true);
     902            //}
    902903            classifier_list.setSelectedValue(classifier, true);
    903904            }
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r6051 r6389  
    9191        collect_config.display();
    9292    }
     93    loadDesignDetails();
     94    Gatherer.println("CollectionDesignModule loaded.");
     95    }
     96
     97    /** Reloads the various managers to ensure they have built themselves from the latest details available in the collection configuration class
     98     * @see org.greenstone.gatherer.cdm.ClassifierManager
     99     * @see org.greenstone.gatherer.cdm.CollectionMetaManager
     100     * @see org.greenstone.gatherer.cdm.FormatManager
     101     * @see org.greenstone.gatherer.cdm.GeneralManager
     102     * @see org.greenstone.gatherer.cdm.IndexManager
     103     * @see org.greenstone.gatherer.cdm.LanguageManager
     104     * @see org.greenstone.gatherer.cdm.MetadataSetView
     105     * @see org.greenstone.gatherer.cdm.PlugInManager
     106     * @see org.greenstone.gatherer.cdm.SearchTypeManager
     107     * @see org.greenstone.gatherer.cdm.SubcollectionIndexManager
     108     * @see org.greenstone.gatherer.cdm.SubcollectionManager
     109     * @see org.greenstone.gatherer.cdm.SuperCollectionManager
     110     * @see org.greenstone.gatherer.cdm.TranslationView
     111     */
     112    public void loadDesignDetails() {
    93113    // Create the command information managers, registering the config file with each as necessary
    94114    language_manager = new LanguageManager(collect_config.getLanguages());
     
    113133    translation_view = new TranslationView();
    114134    format_manager = new FormatManager(); // Parse formats at the very end, given that they depend upon several other managers to appear properly.
    115     Gatherer.println("CollectionDesignModule loaded.");
    116     }
     135    }
     136
    117137    /** This method deconstructs each of the managers, causing them to dispose of their controls.
    118138     */
     
    157177    }
    158178
    159     /** Retrieve the name of the collection configuration file which is being used as the source of the information in this object.
    160      * @return The files absolute path as a <strong>String</strong>.
    161      */
    162     /* private String getFilename() {
    163     return collect_config.getFile().getAbsolutePath();
    164     } */
     179    /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
     180     * @param mode the new mode as an int
     181     */
     182    public void modeChanged(int mode) {
     183    plugin_manager.modeChanged(mode);
     184    subcollection_manager.modeChanged(mode);
     185    }
    165186
    166187    /** The cdm is considered to be ready if the collect.cfg file was found and parsed and the collection title is not error.
     
    177198     * @see org.greenstone.gatherer.cdm.IndexManager
    178199     * @see org.greenstone.gatherer.cdm.LanguageManager
    179      * @see org.greenstone.gatherer.cdm.MetadataSetManager
     200     * @see org.greenstone.gatherer.cdm.MetadataSetView
    180201     * @see org.greenstone.gatherer.cdm.PlugInManager
    181202     * @see org.greenstone.gatherer.cdm.SubcollectionManager
    182      * @see org.greenstone.gatherer.util.EmailAddress
    183203     */
    184204   public void save() {
     
    218238    /** Method used during a global search and replace to highlight the appropriate record within the Collection Design Managers version of the Metadata Set Manager (view only).
    219239     * @param element The name of the desired element as a <strong>String</strong>.
    220      * @see org.greenstone.gatherer.cdm.GUI
    221      * @see org.greenstone.gatherer.cdm.MetadataSetManager
     240     * @see org.greenstone.gatherer.cdm.GeneralManager
     241     * @see org.greenstone.gatherer.cdm.MetadataSetView
    222242     */
    223243    public Rectangle setSelectedElement(String element) {
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMeta.java

    r5930 r6389  
    112112
    113113    /** Method to retrieve the value of language.
    114      * @return The value of language as a <strong>String</strong>.
     114     * @return the value of language as a <strong>String</strong>.
    115115     */
    116116    public String getLanguage() {
     
    120120
    121121    /** Method to retrieve the value of name.
    122      * @return
     122     * @return the name attribute of the collection meta as a String
    123123     */
    124124    public String getName() {
  • trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r6323 r6389  
    105105    view = null;
    106106    }
     107
     108    /** Called whenever the detail mode changes to ensure the contents tree is at an appropriate level (ie with Partitions disabled in lower levels)
     109     * Written 1543-07-01-2004, and made obsolete by a new list of requirements 1611-07-01-2004. *sigh*
     110     * @param mode the mode level as an int
     111     */
     112    /* public void modeChanged(int mode) {
     113    tree.resetModel(mode);
     114    } */
    107115
    108116    /** Force the display to show a certain pane of controls.
     
    519527    public DesignTree() {
    520528        super();
     529        resetModel(Gatherer.config.getMode());
     530        expandRow(0);
     531        setRootVisible(false);
     532        setSelectionRow(0);
     533    }
     534
     535    /** Reset the model used by the design page contents tree. This is necessary to hide the partitions entry when in lower detail modes
     536     * @param mode the current detail mode as an int
     537     */
     538    public void resetModel(int mode) {
    521539        root = new DesignNode("CDM.GUI.Root");
    522         this.setModel(new DefaultTreeModel(root));
    523540        // Now add the design categories.
    524541        for(int i = 0; i < CONTENTS.length; i++) {
    525542        root.add(new DesignNode(CONTENTS[i]));
    526543        }
    527         expandRow(0);
    528         setRootVisible(false);
    529         setSelectionRow(0);
     544        this.setModel(new DefaultTreeModel(root));
     545        updateUI();
    530546    }
    531547    /** Set the current view to the one specified.
     
    570586     * @see org.greenstone.gatherer.cdm.FormatManager
    571587     * @see org.greenstone.gatherer.cdm.LanguageManager
    572      * @see org.greenstone.gatherer.cdm.MetadataSetManager
     588     * @see org.greenstone.gatherer.cdm.MetadataSetView
    573589     * @see org.greenstone.gatherer.cdm.SubcollectionManager
     590     * @see org.greenstone.gatherer.cdm.TranslationView
    574591     * @see org.greenstone.gatherer.cdm.PlugInManager
    575592     */
  • trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java

    r6318 r6389  
    510510     * @see org.greenstone.gatherer.Configuration
    511511     * @see org.greenstone.gatherer.Gatherer
    512      * @see org.greenstone.gatherer.cdm.IndexManager.Control.AddListener
    513      * @see org.greenstone.gatherer.cdm.IndexManager.Control.ClearDefaultListener
    514      * @see org.greenstone.gatherer.cdm.IndexManager.Control.NameListener
    515      * @see org.greenstone.gatherer.cdm.IndexManager.Control.RemoveListener
    516      * @see org.greenstone.gatherer.cdm.IndexManager.Control.SetDefaultListener
     512     * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.AddListener
     513     * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.NameListener
     514     * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.RemoveListener
     515     * @see org.greenstone.gatherer.cdm.IndexManager.IndexControl.SetDefaultListener
    517516     * @see org.greenstone.gatherer.collection.CollectionManager
    518517     * @see org.greenstone.gatherer.gui.Coloring
  • trunk/gli/src/org/greenstone/gatherer/cdm/LanguageManager.java

    r6318 r6389  
    248248    private JTextField default_language_field = null;
    249249    /** Constructor.
    250      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.AddListener
    251      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.ClearDefaultListener
    252      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.ListListener
    253      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.RemoveListener
    254      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.SelectorListener
    255      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.SetDefaultListener
    256      * @see org.greenstone.gatherer.cdm.LanguageManager.Control.TranslateListener
     250     * @see org.greenstone.gatherer.cdm.LanguageManager.LanguageControl.AddListener
     251     * @see org.greenstone.gatherer.cdm.LanguageManager.LanguageControl.ClearDefaultListener
     252     * @see org.greenstone.gatherer.cdm.LanguageManager.LanguageControl.ListListener
     253     * @see org.greenstone.gatherer.cdm.LanguageManager.LanguageControl.RemoveListener
     254     * @see org.greenstone.gatherer.cdm.LanguageManager.LanguageControl.SelectorListener
     255     * @see org.greenstone.gatherer.cdm.LanguageManager.LanguageControl.SetDefaultListener
    257256     */
    258257    public LanguageControl() {
  • trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java

    r6051 r6389  
    2828
    2929import java.awt.*;
     30import java.awt.event.*;
    3031import java.util.*;
    3132import javax.swing.*;
     
    3637import org.greenstone.gatherer.cdm.Control;
    3738import org.greenstone.gatherer.cdm.ElementWrapper;
     39import org.greenstone.gatherer.gui.GLIButton;
     40import org.greenstone.gatherer.mem.MetadataEditorManager;
    3841import org.greenstone.gatherer.msm.MetadataSet;
    3942import org.greenstone.gatherer.msm.MSMEvent;
     
    8083    /** Called when an element is changed within a set in the MSM, prompting us to refresh our list of elements being shown.
    8184     * @param event A <strong>MSMEvent</strong> which encapsulates relevant data about the change.
    82      * @see org.greenstone.gatherer.cdm.MetadataSetManager.Control
     85     * @see org.greenstone.gatherer.cdm.MetadataSetView.MetadataSetControl
    8386     */
    8487    public void elementChanged(MSMEvent event) {
     
    115118     * @param element The elements fully qualified name as a <strong>String</strong>.
    116119     * @return The bounds of the selection as a <strong>Rectangle</strong>.
    117      * @see org.greenstone.gatherer.cdm.MetadataSetManager.Control
     120     * @see org.greenstone.gatherer.cdm.MetadataSetView.MetadataSetControl
    118121     */
    119122    public Rectangle setSelectedElement(String element) {
     
    123126    /** Prints out the contents of this manager, as they would appear in the collection configuration file.
    124127     * @return A <strong>String</strong> containing a block of commands.
    125      * @see org.greenstone.gatherer.cdm.MetadataSetManager.SetWrapper
     128     * @see org.greenstone.gatherer.cdm.MetadataSetView.SetWrapper
    126129     */
    127130    public String toString() {
     
    143146    /** Retrieves the current list of loaded metadata sets, and builds a list model around them.
    144147     * @see org.greenstone.gatherer.Gatherer
    145      * @see org.greenstone.gatherer.cdm.MetadataSetManager.SetWrapper
     148     * @see org.greenstone.gatherer.cdm.MetadataSetView.SetWrapper
    146149     * @see org.greenstone.gatherer.collection.CollectionManager
    147150     * @see org.greenstone.gatherer.msm.MetadataSet
     
    160163    extends JPanel
    161164    implements Control {
     165    /** Listens for clicks upon the configure button, or double clicks from the metadata set list. */
     166    private ConfigureActionListener configure_action_listener;
     167    /** Opens the MEM and systematically performs as if the add set button were clicked. */
     168    private JButton add_button;
     169    /** Opens the MEM with the appropriate set open for editing. */
     170    private JButton configure_button;
     171    /** Opens the MEM and systematically performs as if the remove set button were clicked. */
     172    private JButton remove_button;
    162173    /** The label denoting the element list. */
    163174    private JLabel element_label = null;
     
    186197     * @see org.greenstone.gatherer.Coloring;
    187198     * @see org.greenstone.gatherer.Dictionary
    188      * @see org.greenstone.gatherer.cdm.MetadataSetManager.ListListener
     199     * @see org.greenstone.gatherer.cdm.MetadataSetView.ListListener
    189200     * @see org.greenstone.gatherer.msm.MetadataSetManager
    190201     */
     
    213224        set_list = new JList(model);
    214225        set_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     226        if(model.size() > 0) {
     227        set_list.setSelectedIndex(0);
     228        }
     229
    215230        set_pane = new JPanel();
    216231        title = new JLabel();
     
    219234        Dictionary.registerText(title, "CDM.MetadataSetManager.Title");
    220235
     236        JPanel button_pane = new JPanel();
     237        add_button = new GLIButton();
     238        add_button.setEnabled(true);
     239        add_button.setMnemonic(KeyEvent.VK_A);
     240        Dictionary.registerBoth(add_button, "CDM.MetadataSetManager.Add", "CDM.MetadataSetManager.Add_Tooltip");
     241        configure_button = new GLIButton();
     242        configure_button.setEnabled(false);
     243        configure_button.setMnemonic(KeyEvent.VK_C);
     244        Dictionary.registerBoth(configure_button, "CDM.MetadataSetManager.Configure", "CDM.MetadataSetManager.Configure_Tooltip");
     245        remove_button = new GLIButton();
     246        remove_button.setEnabled(false);
     247        remove_button.setMnemonic(KeyEvent.VK_R);
     248        Dictionary.registerBoth(remove_button, "CDM.MetadataSetManager.Remove", "CDM.MetadataSetManager.Remove_Tooltip");
     249        configure_action_listener = new ConfigureActionListener();
     250
    221251        // Add listeners
     252        add_button.addActionListener(new AddButtonListener());
     253        configure_button.addActionListener(configure_action_listener);
     254        remove_button.addActionListener(new RemoveButtonListener());
    222255        set_list.addListSelectionListener(new ListListener());
    223 
     256        set_list.addMouseListener(configure_action_listener);
    224257        // Layout
    225258        instructions.setBorder(BorderFactory.createEmptyBorder(2,5,2,5));
     
    240273        central_pane.add(set_pane);
    241274        central_pane.add(element_pane);
     275       
     276        button_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
     277        button_pane.setLayout(new GridLayout(1,3,0,0));
     278        button_pane.add(add_button);
     279        button_pane.add(configure_button);
     280        button_pane.add(remove_button);
    242281
    243282        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     
    245284        add(header_pane, BorderLayout.NORTH);
    246285        add(central_pane, BorderLayout.CENTER);
     286        add(button_pane, BorderLayout.SOUTH);
    247287    }
    248288    /** Destructor. */
     
    256296     * @param element The elements fully qualified name as a <strong>String</strong>.
    257297     * @return The bounds of the selection as a <strong>Rectangle</strong>.
    258      * @see org.greenstone.gatherer.cdm.MetadataSetManager.Control
    259      * @see org.greenstone.gatherer.cdm.MetadataSetManager.Control.ElementWrapper
     298     * @see org.greenstone.gatherer.cdm.MetadataSetView.MetadataSetControl
     299     * @see org.greenstone.gatherer.msm.ElementWrapper
    260300     */
    261301    public Rectangle setSelectedElement(String element) {
     
    293333
    294334    public void loseFocus() {
     335    }
     336
     337    /** Listens for clicks on the add button, and actions them accordingly by opening the MEM and clicking add set. */
     338    private class AddButtonListener
     339        implements ActionListener {
     340        /** Called when the add button is clicked.
     341         * @param event an ActionEvent containing information about the mouse click
     342         * @see org.greenstone.gatherer.Gatherer
     343         * @see org.greenstone.gatherer.collection.Collection
     344         * @see org.greenstone.gatherer.collection.CollectionManager
     345         * @see org.greenstone.gatherer.mem.MetadataEditorManager
     346         * @see org.greenstone.gatherer.msm.MetadataSetManager
     347         */
     348        public void actionPerformed(ActionEvent event) {
     349        Gatherer.c_man.getCollection().msm.editMDS(null, MetadataEditorManager.ADD_SET);
     350        }
     351    }
     352
     353    /** Listens for clicks on the configure button or double clicks upon the metadata set list and chains to the MEM as appropriate. */
     354    private class ConfigureActionListener
     355        extends MouseAdapter
     356        implements ActionListener {
     357        /** Called when the configure button is clicked.
     358         * @param event an ActionEvent containing information about the mouse click
     359         */
     360        public void actionPerformed(ActionEvent event) {
     361        configureSet();
     362        }
     363
     364        /** Called whenever the mouse is clicked over a registered component, we use this to chain through to the configure prompt.
     365         * @param event a MouseEvent containing information about the mouse click
     366        */
     367        public void mouseClicked(MouseEvent event) {
     368        if(event.getClickCount() == 2 ) {
     369            configureSet();
     370        }
     371        }
     372        /** If some set is selected, then open the metadata set manager with the current set selected and expanded
     373         * @see org.greenstone.gatherer.Gatherer
     374         * @see org.greenstone.gatherer.collection.Collection
     375         * @see org.greenstone.gatherer.collection.CollectionManager
     376         * @see org.greenstone.gatherer.cdm.MetadataSetView.SetWrapper
     377         * @see org.greenstone.gatherer.mem.MetadataEditorManager
     378         * @see org.greenstone.gatherer.msm.MetadataSet
     379         * @see org.greenstone.gatherer.msm.MetadataSetManager
     380         */
     381        private void configureSet() {
     382        if(!set_list.isSelectionEmpty()) {
     383            MetadataSet set = ((SetWrapper)set_list.getSelectedValue()).getSet();
     384            Gatherer.c_man.getCollection().msm.editMDS(set, MetadataEditorManager.NORMAL);
     385        }
     386        else {
     387            configure_button.setEnabled(false);
     388        }
     389        }
    295390    }
    296391
     
    307402            Collections.sort(element_model);
    308403            element_list.setListData(element_model);
    309         }
    310         }
    311     }
     404            configure_button.setEnabled(true);
     405            remove_button.setEnabled(true);
     406        }
     407        else {
     408            configure_button.setEnabled(false);
     409            remove_button.setEnabled(false);
     410        }
     411        }
     412    }
     413
     414    /** Listens for clicks on the remove button, and actions them accordingly by opening the MEM and clicking remove set. */
     415    private class RemoveButtonListener
     416        implements ActionListener {
     417        /** Called when the remove button is clicked.
     418         * @param event an ActionEvent containing information about the mouse click
     419         * @see org.greenstone.gatherer.Gatherer
     420         * @see org.greenstone.gatherer.collection.Collection
     421         * @see org.greenstone.gatherer.collection.CollectionManager
     422         * @see org.greenstone.gatherer.cdm.MetadataSetView.SetWrapper
     423         * @see org.greenstone.gatherer.mem.MetadataEditorManager
     424         * @see org.greenstone.gatherer.msm.MetadataSet
     425         * @see org.greenstone.gatherer.msm.MetadataSetManager
     426         */
     427        public void actionPerformed(ActionEvent event) {
     428        if(!set_list.isSelectionEmpty()) {
     429            MetadataSet set = ((SetWrapper)set_list.getSelectedValue()).getSet();
     430            Gatherer.c_man.getCollection().msm.editMDS(set, MetadataEditorManager.REMOVE_SET);
     431        }
     432        else {
     433            remove_button.setEnabled(false);
     434        }
     435        }
     436    }   
    312437    }
    313438
  • trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java

    r6318 r6389  
    3636import javax.swing.plaf.basic.*;
    3737import org.apache.xerces.parsers.*;
     38import org.greenstone.gatherer.Configuration;
    3839import org.greenstone.gatherer.Dictionary;
    3940import org.greenstone.gatherer.Gatherer;
     
    5758    /** The library 'reserve' of base plugins. */
    5859    private ArrayList library = null;
     60    /** When asking how many rows are in the model, and if this variables value is true, then this modifier alters the number returned. This funtionality is used to hide the last three rows of the list in low detail modes. */
     61    private boolean modify_row_count = false;
    5962    /** The controls for editing the contents of this manager. */
    6063    private Control controls = null;
     
    6871    public PlugInManager() {
    6972    super(CollectionDesignManager.collect_config.getDocumentElement(), CollectionConfiguration.PLUGIN_ELEMENT, new PlugIn());
    70     Gatherer.println("PlugInManager: " + getSize() + " plugins parsed.");
     73    Gatherer.println("PlugInManager: " + super.getSize() + " plugins parsed.");
    7174    model = this;
    7275    // Reload/Create the library
     
    136139    }
    137140
     141    /** Overrides getSize in DOMProxyListModel to take into account the row count modifier used to hide the last three rows in lower detail modes
     142     * @return an int indicating the number of rows in the model, or more correctly the desired number of rows to display
     143     */
     144    public int getSize() {
     145    int result = super.getSize();
     146    if(modify_row_count) {
     147        result = result - 3;
     148    }
     149    return result;
     150    }
     151
     152    /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
     153     * @param mode the new mode as an int
     154     */
     155    public void modeChanged(int mode) {
     156    if(controls != null) {
     157        ((PlugInControl)controls).modeChanged(mode);
     158    }
     159    }   
     160
    138161    /** Method to move a plugin in the list order.
    139162     * @param plugin the PlugIn you want to move.
     
    143166    public void movePlugIn(PlugIn plugin, boolean direction, boolean all) {
    144167    // Can't ever move RecPlug or ArcPlug.
    145     if(getSize() < 3) {
     168    if(super.getSize() < 3) {
    146169        //Gatherer.println("Not enough plugins to allow moving.");
    147170        return;
     
    215238    public void placeSeparator() {
    216239    ///ystem.err.println("Placing separator.");
    217     int separator_index = getSize();
     240    int separator_index = super.getSize();
    218241    if(separator_index > 0) {
    219242        boolean found_fixed = false;
     
    269292    }
    270293
     294    /** Inform the model to hide/show the last three lines on the list.
     295     * @param modify_row_count true to hide the last three lines, false otherwise
     296     */
     297    public void setHideLines(boolean modify_row_count) {
     298    this.modify_row_count = modify_row_count;
     299    int original_size = super.getSize();
     300    if(modify_row_count) {
     301        fireIntervalRemoved(this, original_size - 4, original_size - 1);
     302    }
     303    else {
     304        fireIntervalAdded(this, original_size - 4, original_size - 1);
     305    }
     306    }
     307
    271308    /** Determine the current separator index. */
    272309    private int findSeparatorIndex() {
    273     int separator_index = getSize() - 1;
     310    int separator_index = super.getSize() - 1;
    274311    while(separator_index >= 0) {
    275312        PlugIn search = (PlugIn) getElementAt(separator_index);
     
    448485        }
    449486        else if(node_name.equalsIgnoreCase(CollectionConfiguration.ABSTRACT_ELEMENT)) {
    450             System.err.println("Is " + plugin.getName() + " abstract? " + MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR));
    451487        plugin.setIsAbstract(MSMUtils.getValue(node).equalsIgnoreCase(CollectionConfiguration.YES_STR));
    452488        }
     
    553589    private JButton configure = null;
    554590    /** Buttom to move an assinged plugin as low in the order as possible. */
    555     private JButton move_bottom_button = null;
     591    //private JButton move_bottom_button = null;
    556592    /** Button to move an assigned plugin one position lower in the order. */
    557593    private JButton move_down_button = null;
    558594    /** Button to move an assigned plugin as high in the order as possible. */
    559     private JButton move_top_button = null;
     595    //private JButton move_top_button = null;
    560596    /** Button to move an assigned plugin one position higher in the order. */
    561597    private JButton move_up_button = null;
     
    613649        Dictionary.registerText(instructions, "CDM.PlugInManager.Instructions");
    614650
    615         move_top_button = new DoubleImageButton("", Utility.getImage("arrow-top.gif"), Utility.getImage("arrow-top-disabled.gif"));
    616         move_top_button.setEnabled(false);
    617         move_top_button.setMnemonic(KeyEvent.VK_T);
    618         // move_top_button.setDisplayedMnemonicIndex(8);  // !! English-centric hack
    619         move_top_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
    620         Dictionary.registerBoth(move_top_button, "CDM.Move.Move_Top", "CDM.Move.Move_Top_Tooltip");
     651        //move_top_button = new DoubleImageButton("", Utility.getImage("arrow-top.gif"), Utility.getImage("arrow-top-disabled.gif"));
     652        //move_top_button.setEnabled(false);
     653        //move_top_button.setMnemonic(KeyEvent.VK_T);
     654        //move_top_button.setDisplayedMnemonicIndex(8);  // !! English-centric hack
     655        //move_top_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
     656        //Dictionary.registerBoth(move_top_button, "CDM.Move.Move_Top", "CDM.Move.Move_Top_Tooltip");
    621657
    622658        move_up_button = new DoubleImageButton("", Utility.getImage("arrow-up.gif"), Utility.getImage("arrow-up-disabled.gif"));
     
    632668        Dictionary.registerBoth(move_down_button, "CDM.Move.Move_Down", "CDM.Move.Move_Down_Tooltip");
    633669
    634         move_bottom_button = new DoubleImageButton("", Utility.getImage("arrow-bottom.gif"), Utility.getImage("arrow-bottom-disabled.gif"));
    635         move_bottom_button.setEnabled(false);
    636         move_bottom_button.setMnemonic(KeyEvent.VK_B);
    637         move_bottom_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
    638         Dictionary.registerBoth(move_bottom_button, "CDM.Move.Move_Bottom", "CDM.Move.Move_Bottom_Tooltip");
     670        //move_bottom_button = new DoubleImageButton("", Utility.getImage("arrow-bottom.gif"), Utility.getImage("arrow-bottom-disabled.gif"));
     671        //move_bottom_button.setEnabled(false);
     672        //move_bottom_button.setMnemonic(KeyEvent.VK_B);
     673        //move_bottom_button.setPreferredSize(Utility.DOUBLE_IMAGE_BUTTON_SIZE);
     674        //Dictionary.registerBoth(move_bottom_button, "CDM.Move.Move_Bottom", "CDM.Move.Move_Bottom_Tooltip");
    639675
    640676        movement_pane = new JPanel();
    641677
    642         PlugInComboboxListener picl = new PlugInComboboxListener();
     678        PlugInComboboxListener picl = new PlugInComboboxListener();
    643679        plugin = new GComboBox(getAvailable());
    644680        plugin.setBackgroundNonSelectionColor(Gatherer.config.getColor("coloring.editable_background", false));
     
    647683        plugin.setTextNonSelectionColor(Gatherer.config.getColor("coloring.workspace_tree_foreground", false));
    648684        plugin.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false));
    649         picl.itemStateChanged(new ItemEvent(plugin, 0, null, ItemEvent.SELECTED));
     685        picl.itemStateChanged(new ItemEvent(plugin, 0, null, ItemEvent.SELECTED));
    650686
    651687        plugin_label = new JLabel();
     
    677713        configure.addActionListener(new ConfigureListener());
    678714        MoveListener ml = new MoveListener();
    679         move_bottom_button.addActionListener(ml);
     715        //move_bottom_button.addActionListener(ml);
    680716        move_down_button.addActionListener(ml);
    681         move_top_button.addActionListener(ml);
     717        //move_top_button.addActionListener(ml);
    682718        move_up_button.addActionListener(ml);
    683         plugin.addItemListener(picl);
     719        plugin.addItemListener(picl);
    684720        remove.addActionListener(new RemoveListener());
    685721        plugin_list.addMouseListener(new ClickListener());
    686722        plugin_list.addListSelectionListener(new ListListener());
    687         picl = null;
     723        picl = null;
    688724
    689725        // Layout
     
    700736        movement_pane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0));
    701737        movement_pane.setLayout(new GridLayout(4,1));
    702         movement_pane.add(move_top_button);
    703738        movement_pane.add(move_up_button);
     739        movement_pane.add(new JPanel());
     740        movement_pane.add(new JPanel());
    704741        movement_pane.add(move_down_button);
    705         movement_pane.add(move_bottom_button);
    706742
    707743        plugin_list_pane.setLayout(new BorderLayout());
    708744        plugin_list_pane.add(plugin_list_label, BorderLayout.NORTH);
    709745        plugin_list_pane.add(new JScrollPane(plugin_list), BorderLayout.CENTER);
    710         plugin_list_pane.add(movement_pane, BorderLayout.EAST);
     746        modeChanged(Gatherer.config.getMode()); // Whether the movement buttons are visible is mode dependant
    711747
    712748        plugin_label.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     
    760796
    761797    public void loseFocus() {
     798    }
     799
     800    /** The current detail mode controls two aspects of plugin manager: whether the movement buttons are visible and whether the fixed position plugins Arc and RecPlug are in the list
     801     * @param mode the current mode as an int, which can be matched against static ints in the Configuration class
     802     */
     803    public void modeChanged(int mode) {
     804        // First of all we clear the current selection, as there can be some serious problems if the user selects the plugins we're hiding, or had the last plugin selected before we unhid the last three
     805        plugin_list.clearSelection();
     806        // The first change is dependant on whether the user is systems mode or higher
     807        if(mode >= Configuration.SYSTEMS_MODE) {
     808        // Show movement buttons
     809        plugin_list_pane.add(movement_pane, BorderLayout.EAST);
     810        // Do we show Arc and RecPlugs or hide them and the separator line
     811        setHideLines(!(mode >= Configuration.EXPERT_MODE));
     812        }
     813        // Otherwise hide the movement buttons and fixed plugins
     814        else {
     815        plugin_list_pane.remove(movement_pane);
     816        setHideLines(true);
     817        }
     818        plugin_list_pane.updateUI();
    762819    }
    763820
     
    864921        if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one (the second one)
    865922            if (plugin_list.isSelectionEmpty()) {
    866             move_top_button.setEnabled(false);
     923            //move_top_button.setEnabled(false);
    867924            move_up_button.setEnabled(false);
    868925            move_down_button.setEnabled(false);
    869             move_bottom_button.setEnabled(false);
     926            //move_bottom_button.setEnabled(false);
    870927            configure.setEnabled(false);
    871928            remove.setEnabled(false);
     
    874931            PlugIn selected_plugin = (PlugIn) plugin_list.getSelectedValue();
    875932            if(selected_plugin.isSeparator()) {
    876                 move_top_button.setEnabled(false);
     933                //move_top_button.setEnabled(false);
    877934                move_up_button.setEnabled(false);
    878935                move_down_button.setEnabled(false);
    879                 move_bottom_button.setEnabled(false);
     936                //move_bottom_button.setEnabled(false);
    880937                configure.setEnabled(false);
    881938                remove.setEnabled(false);
     
    886943                // Some buttons are only available for plugins other than ArcPlug and RecPlug
    887944                if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR)) {
    888                 move_top_button.setEnabled(false);
     945                //move_top_button.setEnabled(false);
    889946                move_up_button.setEnabled(false);
    890947                move_down_button.setEnabled(false);
    891                 move_bottom_button.setEnabled(false);
     948                //move_bottom_button.setEnabled(false);
    892949                remove.setEnabled(false);
    893950                }
     
    896953                PlugIn first_plugin = (PlugIn) getElementAt(0);
    897954                if(!first_plugin.equals(selected_plugin)) {
    898                     move_top_button.setEnabled(true);
     955                    //move_top_button.setEnabled(true);
    899956                    move_up_button.setEnabled(true);
    900957                }
    901958                else {
    902                     move_top_button.setEnabled(false);
     959                    //move_top_button.setEnabled(false);
    903960                    move_up_button.setEnabled(false);
    904961                }
     
    908965                if(selected_index != separator_index - 1) {
    909966                    move_down_button.setEnabled(true);
    910                     move_bottom_button.setEnabled(true);
     967                    //move_bottom_button.setEnabled(true);
    911968                }
    912969                else {
    913970                    move_down_button.setEnabled(false);
    914                     move_bottom_button.setEnabled(false);
     971                    //move_bottom_button.setEnabled(false);
    915972                }
    916973                remove.setEnabled(true);
     
    9621019            if (object instanceof PlugIn) {
    9631020            PlugIn plugin = (PlugIn) object;
    964             if (event.getSource() == move_top_button) {
    965                 movePlugIn(plugin, true, true);
    966             }
    967             else if (event.getSource() == move_up_button) {
     1021            //if (event.getSource() == move_top_button) {
     1022            //    movePlugIn(plugin, true, true);
     1023            //}
     1024            //else
     1025            if (event.getSource() == move_up_button) {
    9681026                movePlugIn(plugin, true, false);
    9691027            }
     
    9711029                movePlugIn(plugin, false, false);
    9721030            }
    973             else if (event.getSource() == move_bottom_button) {
    974                 movePlugIn(plugin, false, true);
    975             }
     1031            //else if (event.getSource() == move_bottom_button) {
     1032            //    movePlugIn(plugin, false, true);
     1033            //}
    9761034            plugin_list.setSelectedValue(plugin, true);
    9771035            }
  • trunk/gli/src/org/greenstone/gatherer/cdm/SubcollectionIndexManager.java

    r6318 r6389  
    341341        /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we want to check if they have a series of subcollections selected, and if so build an new subindex based apon them.
    342342         * @param event An <strong>ActionEvent</strong> containing information about the event.
    343          * @see org.greenstone.gatherer.cdm.SubIndex
     343         * @see org.greenstone.gatherer.cdm.SubcollectionIndex
    344344         */
    345345        public void actionPerformed(ActionEvent event) {
     
    374374        /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we want to check if they have a subindex selected, and if so remove it.
    375375         * @param event An <strong>ActionEvent</strong> containing information about the event.
    376          * @see org.greenstone.gatherer.cdm.SubIndex
     376         * @see org.greenstone.gatherer.cdm.SubcollectionIndex
    377377         */
    378378        public void actionPerformed(ActionEvent event) {
     
    387387        /** Any implementation of ActionListener must include this method so we can be informed when an action has been performed on one of our target controls. In this case we want to check if they have a subindex selected, and if so set it as default.
    388388         * @param event An <strong>ActionEvent</strong> containing information about the event.
    389          * @see org.greenstone.gatherer.cdm.DefaultSubIndex
    390          * @see org.greenstone.gatherer.cdm.SubIndex
     389         * @see org.greenstone.gatherer.cdm.SubcollectionIndex
    391390         */
    392391        public void actionPerformed(ActionEvent event) {
  • trunk/gli/src/org/greenstone/gatherer/cdm/SubcollectionManager.java

    r6318 r6389  
    3636import javax.swing.*;
    3737import javax.swing.event.*;
     38import org.greenstone.gatherer.Configuration;
    3839import org.greenstone.gatherer.Dictionary;
    3940import org.greenstone.gatherer.Gatherer;
     
    5960    extends DOMProxyListModel {
    6061
     62    static final private String DISABLED_CONTROLS = "Disabled";
     63    static final private String ENABLED_CONTROLS  = "Normal";
    6164    static final private String CLASS_DICTIONARY_NAME = "CDM.SubcollectionManager.";
    6265
     
    137140    } */
    138141
     142    /** Called when the detail mode has changed which in turn may cause several design elements to be available/hidden
     143     * @param mode the new mode as an int
     144     */
     145    public void modeChanged(int mode) {
     146    if(controls != null) {
     147        ((SubcollectionControl)controls).modeChanged(mode);
     148    }
     149    }   
     150
    139151    /** Method to remove the given subcollection.
    140152     * @param subcollection the Subcollection you want to remove
     
    162174    implements Control {
    163175
     176    private CardLayout card_layout;
    164177    private JButton add_button;
    165178    private JButton remove_button;
     
    167180    private JComboBox source_combobox;
    168181    private JList subcollection_list;
     182    private JPanel border_pane;
    169183    private JTabbedPane tabbed_pane;
    170184    private JTextArea instructions_area;
     
    178192    public SubcollectionControl() {
    179193        // Create
    180         JPanel border_pane = new JPanel();
    181194        JPanel header_pane = new JPanel();
    182195        instructions_area = new JTextArea();
     
    186199        instructions_area.setWrapStyleWord(true);
    187200        Dictionary.registerText(instructions_area, "CDM.SubcollectionManager.Instructions");
     201
     202        border_pane = new JPanel();
     203        card_layout = new CardLayout();
    188204
    189205        tabbed_pane = new JTabbedPane();
     
    202218        Dictionary.registerBoth(remove_button, "CDM.SubcollectionManager.Remove", "CDM.SubcollectionManager.Remove_Tooltip");
    203219        update_button = new GLIButton();
    204         update_button.setMnemonic(KeyEvent.VK_U);
     220        update_button.setMnemonic(KeyEvent.VK_C);
    205221        update_button.setEnabled(false);
    206222        Dictionary.registerBoth(update_button, "CDM.SubcollectionManager.Replace", "CDM.SubcollectionManager.Replace_Tooltip");
     
    256272        Dictionary.registerText(subcollection_list_label, "CDM.SubcollectionManager.Assigned");
    257273
     274        // Create a message pane which explains why these controls are not currently active
     275        JPanel message_pane = new JPanel();
     276        String args[] = new String[3];
     277        args[0] = Gatherer.config.getModeAsString();
     278        args[1] = Dictionary.get("Preferences.Mode.Systems");
     279        args[2] = Dictionary.get("Preferences.Mode.Expert");
     280        JTextArea message_textarea = new JTextArea();
     281        Dictionary.registerText(message_textarea, "CDM.SubcollectionManager.Partitions_Disabled", args);
     282        message_textarea.setEditable(false);
     283        message_textarea.setHighlighter(null); // Prevent highlighting
     284        message_textarea.setLineWrap(true);
     285        message_textarea.setOpaque(false); // Make it transparent
     286        message_textarea.setWrapStyleWord(true);
     287
    258288        // Add listeners
    259289        SubCollectionChangeListener cl = new SubCollectionChangeListener();
     
    316346        tabbed_pane.addTab(Dictionary.get("CDM.SubcollectionManager.Language_Controls"), (JPanel) CollectionDesignManager.language_manager.getControls());
    317347
     348        message_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
     349        message_pane.setLayout(new GridLayout(3,1,0,0));
     350        message_pane.add(new JPanel());
     351        message_pane.add(message_textarea);
     352        message_pane.add(new JPanel());
     353
    318354        border_pane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5));
    319         border_pane.setLayout(new BorderLayout());
    320         border_pane.add(tabbed_pane, BorderLayout.CENTER);
     355        border_pane.setLayout(card_layout);
     356        if(Gatherer.config.getMode() > Configuration.LIBRARIAN_MODE) {
     357        border_pane.add(tabbed_pane, ENABLED_CONTROLS);
     358        border_pane.add(message_pane, DISABLED_CONTROLS);
     359        }
     360        else {
     361        border_pane.add(message_pane, DISABLED_CONTROLS);
     362        border_pane.add(tabbed_pane, ENABLED_CONTROLS);
     363        }
    321364
    322365        setLayout(new BorderLayout());
     
    338381
    339382    public void loseFocus() {
     383    }
     384   
     385    /** Called when the detail mode has changed which in turn controls if any of the partition controls are visible, or if they are instead replaced with a message explaining why they are not.
     386     * @param mode the new mode as an int
     387     */
     388    public void modeChanged(int mode) {
     389        if(mode > Configuration.LIBRARIAN_MODE) {
     390        card_layout.show(border_pane, ENABLED_CONTROLS);
     391        }
     392        else {
     393        card_layout.show(border_pane, DISABLED_CONTROLS);
     394        }
    340395    }
    341396
  • trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r6318 r6389  
    4444import javax.swing.text.*;
    4545import javax.swing.tree.*;
     46import org.greenstone.gatherer.Configuration;
    4647import org.greenstone.gatherer.Dictionary;
    4748import org.greenstone.gatherer.Gatherer;
     
    9192    extends JPanel
    9293    implements GShellListener {
     94
     95    static private Dimension ARGUMENT_SIZE = new Dimension(800,90);
     96    /** The size of the buttons at the bottom of the screen. */
     97    static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);
     98    /** The size of the labels on the progress pane. */
     99    static private Dimension LABEL_SIZE = new Dimension(140, 25);
     100    /** The threshold for when the simple view is replaced by the complex one. */
     101    static private final int THRESHOLD = Configuration.EXPERT_MODE;
     102    /** An identifier for the control panel within the card layout. */
     103    static private String CONTROL  = "Control";
     104    /** An identifier for the progress panel within the card layout. */
     105    static private String PROGRESS = "Progress";
     106    /** An identifier for the simple panel within the card layout. */
     107    static private String SIMPLE   = "Simple";
     108
    93109    /** Determines the current view that should be shown for this pane. */
    94110    public boolean processing = false;
     
    120136    /** The label alongside the import progress bar gets some special treatment so... */
    121137    private JLabel progress_import_label = null;
     138    /** A panel containing the two progress bars. */
     139    private JPanel bar_area;
     140    /** The panel on which buttons are rendered on higher detail modes. */
     141    private JPanel button_pane;
    122142    /** The pane which contains the controls for configuration. */
    123143    private JPanel control_pane = null;
     
    126146    /** The pane which contains the progress information. */
    127147    private JPanel progress_pane = null;
    128     /** the pane on the right-hand side - shows the requested options view */
     148    /** The pane on the right-hand side - shows the requested options view */
    129149    private JPanel right = null;
     150    /** The simple panel on which all of the available arguments are rendered. */
     151    private JPanel sargument_configuration_panel;
     152    /** The panel on which buttons are rendered on lower details modes. */
     153    private JPanel sbutton_panel;
     154    /** A simplified version for lower detail modes containing both the control and progress panes smooshed together. */
     155    private JPanel simple_panel;
     156    /** The inner panel of the simple pane which is global so that the bar_area can be added and removed from it. */
     157    private JPanel sinner_panel;
     158    /** The outer panel of the simple pane which is global so that the arguments pane can be added and removed from it. */
     159    private JPanel souter_panel;
     160    /** The scrolling pane for the log. */
     161    private JScrollPane log_scroll;
     162    /** The scrolling pane the simple arguments are rendered within. */
     163    private JScrollPane sargument_configuration_scroll;
    130164    /** the scrolling pane the righthand side is inside - only used for import and build options. the log and log list are not inside a scrollpane */
    131165    private JScrollPane scroll_pane;
     
    138172    /** The homepage address of the current collection */
    139173    private String homepage = null;
    140     /** The size of the buttons at the bottom of the screen. */
    141     static private Dimension BUTTON_SIZE = new Dimension (256, 50);//(386, 50);
    142     /** The size of the labels on the progress pane. */
    143     static private Dimension LABEL_SIZE = new Dimension(140, 25);
    144     /** An identifier for the control panel within the card layout. */
    145     static private String CONTROL = "Control";
    146     /** An identifier for the progress panel within the card layout. */
    147     static private String PROGRESS      = "Progress";
     174
    148175
    149176    /** The constructor creates important helper classes, and initializes all the components.
     
    162189    Collection collection = Gatherer.c_man.getCollection();
    163190    log_textarea = new JTextArea();
     191    log_scroll = new JScrollPane(log_textarea);
    164192
    165193    // Create components
     
    168196    control_pane = new JPanel();
    169197    tree = new OptionTree();
     198    button_pane = new JPanel();
    170199
    171200    // Progress Pane
    172     progress_pane = new JPanel();
     201    progress_pane = new JPanel(); // One owner of the bar component
     202    bar_area = new JPanel(); // This component will be shared about
    173203
    174204    progress_copy_label = new JLabel();
     
    202232    Dictionary.registerText(progress_build_label, "CreatePane.Build_Progress");
    203233
    204     build_monitor = new GBuildProgressMonitor((GImportProgressMonitor)import_monitor); //GBasicProgressMonitor();
     234    build_monitor = new GBuildProgressMonitor(); //GBasicProgressMonitor();
    205235    Gatherer.c_man.registerBuildMonitor(build_monitor);
     236
     237    // And the simple panel
     238    simple_panel = new JPanel();
     239    sbutton_panel = new JPanel();
     240    sinner_panel = new JPanel();
    206241
    207242    // Buttons
     
    240275    }
    241276    Collection current_collection = Gatherer.c_man.getCollection();
    242     if (current_collection != previous_collection) {
     277    if (current_collection != previous_collection && !Gatherer.c_man.isImporting()) {
    243278        this.options_pane = new OptionsPane(current_collection.build_options);
    244279        previous_collection = current_collection;
     280    }
     281    // If we are in simple mode, we have to rebuild the simple arguments list
     282    if(Gatherer.config.getMode() < THRESHOLD) {
     283        souter_panel.remove(sargument_configuration_scroll);
     284        souter_panel.remove(sinner_panel);
     285        sargument_configuration_panel = options_pane.buildImport(null);
     286        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     287        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     288        sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     289        souter_panel.add(sargument_configuration_scroll);
     290        souter_panel.add(sinner_panel);
    245291    }
    246292    tree.valueChanged(null);
     
    253299    }
    254300    }
     301
     302    public void destroy() {
     303    if(document != null) {
     304        document.destroy();
     305    }
     306    }
    255307   
    256308    /** This method is called to actually layout the components.
     
    260312    public void display() {
    261313
     314    int current_mode = Gatherer.config.getMode();
     315
    262316    // Build control_pane
    263317    JPanel left = new JPanel();
     
    276330    options_area.add(right, BorderLayout.CENTER);
    277331
     332    button_pane = new JPanel();
     333    button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
     334    button_pane.setLayout(new GridLayout(1,2));
     335    if(current_mode >= THRESHOLD) {
     336        button_pane.add(build_button);
     337        button_pane.add(cancel_button);
     338        button_pane.add(preview_button);
     339    }
     340
    278341    control_pane.setLayout(new BorderLayout());
    279342    control_pane.add(options_area, BorderLayout.CENTER);
     343    control_pane.add(button_pane, BorderLayout.SOUTH);
    280344
    281345    // Build progress_pane
     
    295359    build_pane.add(build_monitor.getProgress(), BorderLayout.CENTER);
    296360
    297     JPanel bar_area = new JPanel();
    298361    bar_area.setBorder(BorderFactory.createEmptyBorder(10,10,5,10));
    299362
     
    304367    progress_pane.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    305368    progress_pane.setLayout(new BorderLayout());
    306     progress_pane.add(bar_area, BorderLayout.NORTH);
    307     progress_pane.add(new JScrollPane(log_textarea), BorderLayout.CENTER);
     369    if(current_mode >= THRESHOLD) {
     370        progress_pane.add(bar_area, BorderLayout.NORTH);
     371        progress_pane.add(log_scroll, BorderLayout.CENTER);
     372    }
     373
     374    // Simple panel
     375    sbutton_panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,0));
     376    sbutton_panel.setLayout(new GridLayout(3,1));
     377    if(current_mode < THRESHOLD) {
     378        sbutton_panel.add(build_button);
     379        sbutton_panel.add(cancel_button);
     380        sbutton_panel.add(preview_button);
     381    }
     382
     383    sinner_panel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));
     384    sinner_panel.setLayout(new BorderLayout());
     385    if(current_mode < THRESHOLD) {
     386        sinner_panel.add(bar_area, BorderLayout.CENTER);
     387    }
     388    sinner_panel.add(sbutton_panel, BorderLayout.EAST);
     389   
     390    if(options_pane != null) {
     391        sargument_configuration_panel = options_pane.buildImport(null);
     392        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     393    }
     394    else {
     395        sargument_configuration_panel = new JPanel();
     396    }
     397    sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     398    sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     399    souter_panel = new JPanel();
     400    souter_panel.setSize(new Dimension(400,800));
     401    souter_panel.setLayout(new GridLayout(2,1));
     402    souter_panel.add(sargument_configuration_scroll);
     403    souter_panel.add(sinner_panel);
     404
     405    simple_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     406    simple_panel.setLayout(new BorderLayout());
     407    simple_panel.add(souter_panel, BorderLayout.NORTH);
     408    if(current_mode < THRESHOLD) {
     409        simple_panel.add(log_scroll, BorderLayout.CENTER);
     410    }
    308411
    309412    // Main pane
    310413    main_pane = new JPanel(card_layout);
     414    if(current_mode < THRESHOLD) { // Simple mode - add first
     415        main_pane.add(simple_panel, SIMPLE);
     416    }
    311417    main_pane.add(control_pane, CONTROL);
    312418    main_pane.add(progress_pane, PROGRESS);
    313 
    314     // Buttons
    315     JPanel button_pane = new JPanel();
    316     button_pane.setBorder(BorderFactory.createEmptyBorder(5,10,10,10));
    317     button_pane.setLayout(new GridLayout(1,2));
    318     button_pane.add(build_button);
    319     button_pane.add(cancel_button);
    320     button_pane.add(preview_button);
     419    if(current_mode >= THRESHOLD) { // Expert mode - add last
     420        main_pane.add(simple_panel, SIMPLE);
     421    }
    321422
    322423    this.setLayout(new BorderLayout());
    323424    this.add(main_pane, BorderLayout.CENTER);
    324     this.add(button_pane, BorderLayout.SOUTH);
    325425    }
    326426
     
    331431     */
    332432    public void gainFocus() {
    333     if(!processing) {
     433    if(Gatherer.config.getMode() < THRESHOLD) {
     434        card_layout.show(main_pane, SIMPLE);
     435    }
     436    else if(!processing) {
    334437        card_layout.show(main_pane, CONTROL);
     438    }
     439    else {
     440        card_layout.show(main_pane, PROGRESS);
    335441    }
    336442    // Refresh the set of controls.
     
    339445    tree.setSelectionPath(path);
    340446    }
    341 
    342     /** Method to acquire the progress monitor associated with builds.
    343      * @return The build <strong>GShellProgressMonitor</strong>.
    344      */
    345     /* private GShellProgressMonitor getBuildProgress() {
    346     return build_monitor;
    347     } */
    348 
    349     /** Method to acquire the progress monitor associated with copying.
    350      * @return The copying <strong>GShellProgressMonitor</strong>.
    351      */
    352     /* private GShellProgressMonitor getCopyProgress() {
    353     return copy_monitor;
    354     } */
    355 
    356     /** Method to acquire the progress monitor associated with import.
    357      * @return The import <strong>GShellProgressMonitor</strong>.
    358      */
    359     /* private GShellProgressMonitor getImportProgress() {
    360     return import_monitor;
    361     } */
    362447
    363448    /** We are informed when this view pane loses focus so we can update build options. */
     
    376461    document.appendLine(event.getMessage());
    377462    log_textarea.setCaretPosition(document.getLengthToNearestLine());
     463    }
     464
     465    /** Called when the detail mode has changed which in turn may cause several import/build configuration arguments to be available/hidden
     466     * @param mode the new mode as an int
     467     */
     468    public void modeChanged(int mode) {
     469    // If we are below the complexity threshold ensure the simple controls are being shown
     470    if(Gatherer.config.getMode() < THRESHOLD) {
     471        // Update the arguments
     472        souter_panel.remove(sargument_configuration_scroll);
     473        souter_panel.remove(sinner_panel);
     474        if(options_pane != null) {
     475        sargument_configuration_panel = options_pane.buildImport(null);
     476        sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel);
     477        }
     478        else {
     479        sargument_configuration_panel = new JPanel();
     480        }
     481        sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel);
     482        sargument_configuration_scroll.setPreferredSize(ARGUMENT_SIZE);
     483        souter_panel.add(sargument_configuration_scroll);
     484        souter_panel.add(sinner_panel);
     485        // Remove the shared components from the expert panels
     486        button_pane.remove(build_button);
     487        button_pane.remove(cancel_button);
     488        button_pane.remove(preview_button);
     489        progress_pane.remove(bar_area);
     490        progress_pane.remove(log_scroll);
     491        // And add to simple one
     492        sbutton_panel.add(build_button);
     493        sbutton_panel.add(cancel_button);
     494        sbutton_panel.add(preview_button);
     495        sinner_panel.add(bar_area, BorderLayout.CENTER);
     496        simple_panel.add(log_scroll, BorderLayout.CENTER);
     497        // And bring the card to the front
     498        card_layout.show(main_pane, SIMPLE);
     499    }
     500    // And if we are above the threshold change to the complex controls
     501    else {
     502        // Remove the shared components from the simple panel
     503        sbutton_panel.remove(build_button);
     504        sbutton_panel.remove(cancel_button);
     505        sbutton_panel.remove(preview_button);
     506        sinner_panel.remove(bar_area);
     507        simple_panel.remove(log_scroll);
     508        // And add then to the expert ones
     509        button_pane.add(build_button);
     510        button_pane.add(cancel_button);
     511        button_pane.add(preview_button);
     512        progress_pane.add(bar_area, BorderLayout.NORTH);
     513        progress_pane.add(log_scroll, BorderLayout.CENTER);
     514        // And bring the appropriate card to the front
     515        if(!processing) {
     516        card_layout.show(main_pane, CONTROL);
     517        }
     518        else {
     519        card_layout.show(main_pane, PROGRESS);
     520        }
     521    }
     522    tree.valueChanged(null); // Ensure tree argument panels are rebuilt
    378523    }
    379524
     
    397542        document.setSpecialCharacter(OptionsPane.SUCCESSFUL);
    398543        options_pane.resetFileEntry();
    399         card_layout.show(main_pane, CONTROL);
     544        build_monitor.reset();
     545        import_monitor.reset();
     546        if(Gatherer.config.getMode() >= THRESHOLD) {
     547            card_layout.show(main_pane, CONTROL);
     548        }
    400549        }
    401550        // Otherwise its completed import but still got build to go
     
    414563        }
    415564        options_pane.resetFileEntry();
    416         card_layout.show(main_pane, CONTROL);
     565        if(Gatherer.config.getMode() >= THRESHOLD) {
     566        card_layout.show(main_pane, CONTROL);
     567        }
    417568    }
    418569    }
     
    457608        // First we force the build options to be updated if we haven't already.
    458609        tree.valueChanged(null);
     610       
     611        // Remember that for lower thresholds the above doesn't work, so try this instead
     612        if(Gatherer.config.getMode() < THRESHOLD) {
     613        options_pane.update(sargument_configuration_panel);
     614        }
     615
    459616        // Now go about building.
    460617        build_button.setEnabled(false);
    461618        cancel_button.setEnabled(true);
    462619        preview_button.setEnabled(false);
    463         // Create a new log document and assign it to the two textareas
    464620        document = options_pane.createNewLogDocument();
    465621        log_textarea.setDocument(document);
     
    467623        // Change the view.
    468624        processing = true;
    469         card_layout.show(main_pane, PROGRESS);
     625        if(Gatherer.config.getMode() >= THRESHOLD) {
     626        card_layout.show(main_pane, PROGRESS);
     627        }
    470628        // Reset the stop flag in all the process monitors, just incase.
    471629        ((GBuildProgressMonitor)build_monitor).reset();
     
    496654        processing = false;
    497655        document.setSpecialCharacter(OptionsPane.CANCELLED);
    498         card_layout.show(main_pane, CONTROL);
     656        if(Gatherer.config.getMode() >= THRESHOLD) {
     657        card_layout.show(main_pane, CONTROL);
     658        }
    499659        // Set the stop flag in all the process monitor.
    500660        build_monitor.setStop(true);
     661        build_monitor.reset();
    501662        copy_monitor.setStop(true);
    502663        import_monitor.setStop(true);
     664        import_monitor.reset();
    503665        // Set removeold automatically.
    504666        Gatherer.c_man.getCollection().build_options.setImportValue("removeold", true, null);
     
    591753        }
    592754        if(node != null && node.equals(building)) {
    593         previous_pane = options_pane.buildBuild();
     755        previous_pane = options_pane.buildBuild(null);
    594756        scroll_pane = new JScrollPane(previous_pane);
    595757        right.add(scroll_pane, BorderLayout.CENTER);
     
    597759        }
    598760        else if(node != null && node.equals(importing)) {
    599         previous_pane = options_pane.buildImport();
     761        previous_pane = options_pane.buildImport(null);
    600762        scroll_pane = new JScrollPane(previous_pane);
    601763        right.add(scroll_pane, BorderLayout.CENTER);
  • trunk/gli/src/org/greenstone/gatherer/gui/Filter.java

    r6051 r6389  
    7272    private DragTree tree = null;
    7373    /** The default size for the label. */
    74     static final private Dimension SIZE = new Dimension(100,25);
     74    static final private Dimension SIZE = new Dimension(100,30);
    7575    /** Preprogrammed default filters. */
    7676    static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tif$)"};
     
    9797    this.tree = tree;
    9898    // Create components.
    99     combobox = new GComboBox();
     99    combobox = new GComboBox(true);
    100100    combobox.add(new Entry());
    101101    for(int i = 0; i < DEFAULTS.length; i++) {
     
    108108        }
    109109    }
    110     combobox.setEditable(true);
    111110    label = new JLabel();
    112111    label.setPreferredSize(SIZE);
     
    153152    combobox.setSelectedItem(selection);
    154153    ignore = false;
     154    }
     155
     156    /** Sets whether this combobox is editable or not
     157     * @param value true to make the control editable, false otherwise
     158     */
     159    public void setEditable(boolean value) {
     160    combobox.setEditable(value);       
    155161    }
    156162
  • trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java

    r6321 r6389  
    4545/**
    4646 * @author John Thompson, Greenstone Digital Library, University of Waikato
    47  * @version
     47 * @version 2.3
    4848 */
    4949public class GComboBox
     
    175175    super.setEditable(editable);
    176176    this.editable = editable;
    177     setEditor(new Editor());
    178     setRenderer(new Renderer());
     177    if(editable) {
     178        this.setBackground(editable_background);
     179        this.setForeground(editable_foreground);
     180    }
     181    else {
     182        this.setBackground(background);
     183        this.setForeground(foreground);
     184    }
     185    setEditor(new Editor());
     186    setRenderer(new Renderer());
     187    updateUI();
    179188    }
    180189
     
    201210    ComboBoxModel old_model = (ComboBoxModel) getModel();
    202211    setModel(model);
     212    setOpaque(true);
    203213    // Restore any data given into our model
    204214    for(int i = 0; i < old_model.getSize(); i++) {
     
    226236    setBorder(BorderFactory.createLoweredBevelBorder());
    227237    setEditor(new Editor());
    228     setOpaque(true);
    229238    setRenderer(new Renderer());
    230239    }
     
    234243    implements ComboBoxEditor {
    235244    public Editor() {
    236         setBackground(editable_background);
    237         setForeground(editable_foreground);
    238245        setOpaque(true);
    239246        if(editable) {
    240         setSelectionColor(selection_background);
    241         setSelectedTextColor(selection_foreground);
    242         }
     247        setBackground(editable_background);
     248        setForeground(editable_foreground);
     249        }
     250        else {
     251        setBackground(background);
     252        setForeground(foreground);
     253        }
     254        setSelectionColor(selection_background);
     255        setSelectedTextColor(selection_foreground);
    243256    }
    244257
     
    301314    public Renderer() {
    302315        super("");
    303         this.setBackground(background);
    304         this.setForeground(foreground);
    305316        this.setOpaque(true);
    306317    }
     
    312323        this.setText("");
    313324        }
    314         if(editable) {
     325        if(isSelected) {
     326        this.setBackground(selection_background);
     327        this.setForeground(selection_foreground);
     328        }
     329        else if(editable) {
    315330        this.setBackground(editable_background);
    316331        this.setForeground(editable_foreground);
  • trunk/gli/src/org/greenstone/gatherer/gui/GConfigPane.java

    r5658 r6389  
    104104      }
    105105   }
     106
     107    /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching)
     108     * @param mode the mode level as an int
     109     */
     110    public void modeChanged(int mode) {
     111    cdm.modeChanged(mode);
     112    }
    106113   
    107114   public Rectangle setSelectedElement(ElementWrapper element) {
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6220 r6389  
    7474import org.greenstone.gatherer.gui.tree.WorkspaceTree;
    7575import org.greenstone.gatherer.help.HelpFrame;
     76import org.greenstone.gatherer.mem.MetadataEditorManager;
    7677import org.greenstone.gatherer.msm.ElementWrapper;
    7778import org.greenstone.gatherer.msm.Metadata;
     
    392393    }
    393394
     395    public void destroy() {
     396    // Destroying create pane ensures the latest log has been closed
     397    if(create_pane != null) {
     398        create_pane.destroy();
     399    }
     400    }
     401
    394402    /** Enabled events on the window to be trapped, creates all the visual components, then builds the tab and other layouts.
    395403     */
     
    511519    }
    512520    else {
    513         if(help != null) {
     521        // Deal to help
     522        if(help != null) {
    514523            help.destroy();
    515524            help = null;
    516         }
     525        }
    517526        Gatherer.self.exit();
    518527    }
     
    547556        int config_pos = tab_pane.indexOfComponent(config_pane);
    548557        tab_pane.setEnabledAt(config_pos, !lock);
     558    }
     559    }
     560
     561    public void modeChanged(int mode) {
     562    // Set the title
     563    String collection_title = null;
     564    String collection_name = null;
     565    if (Gatherer.c_man.ready()) {
     566        Collection collection = Gatherer.c_man.getCollection();
     567        collection_title = collection.getTitle();
     568        collection_name = collection.getName();
     569        collection = null;
     570    }
     571    setTitle(collection_title, collection_name);
     572    collection_title = null;
     573    collection_name = null;
     574    // Now pass on the message to anyone who cares
     575    if(collection_pane != null) {
     576        collection_pane.modeChanged(mode);
     577    }
     578    if(config_pane != null) {
     579        config_pane.modeChanged(mode);
     580    }
     581    if(create_pane != null) {
     582        create_pane.modeChanged(mode);
     583    }
     584    if(metaedit_pane != null) {
     585        metaedit_pane.modeChanged(mode);
    549586    }
    550587    }
     
    615652    // Finally display the collection name in the title bar.
    616653    StringBuffer title_buffer = new StringBuffer(Utility.PROGRAM_NAME);
    617     title_buffer.append(StaticStrings.COLON_CHARACTER);
    618654    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     655    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     656    // Describe the current user mode
     657    title_buffer.append(StaticStrings.MODE_STR);
     658    title_buffer.append(Gatherer.config.getModeAsString());
     659    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     660    title_buffer.append(StaticStrings.SPACE_CHARACTER);
     661    // Now for the current collection
     662    title_buffer.append(StaticStrings.COLLECTION_STR);
    619663    if (title != null && name != null) {
    620664        title_buffer.append(title);
     
    635679    public void showEditMetadataBox() {
    636680    if(Gatherer.c_man.getCollection() != null) {
    637         Gatherer.c_man.getCollection().msm.editMDS();
     681        Gatherer.c_man.getCollection().msm.editMDS(null, MetadataEditorManager.NORMAL);
    638682    }
    639683    }
     
    9641008        }
    9651009        if(config_pos != -1) {
    966         tab_pane.setEnabledAt(config_pos, ready && Gatherer.config.get("workflow.design", false));
     1010        tab_pane.setEnabledAt(config_pos, ready && Gatherer.config.get("workflow.design", false) && Gatherer.config.getMode() > Configuration.ASSISTANT_MODE);
    9671011        }
    9681012        if(export_pos != -1) {
     
    9941038    }
    9951039}
     1040
     1041
  • trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java

    r6318 r6389  
    4646import javax.swing.table.*;
    4747import javax.swing.tree.*;
     48import org.greenstone.gatherer.Configuration;
    4849import org.greenstone.gatherer.Dictionary;
    4950import org.greenstone.gatherer.Gatherer;
     
    140141     * @param tree_sync The <strong>TreeSynchronizer</strong> to be used on the collection tree
    141142     * @see org.greenstone.gatherer.Configuration
    142      * @see org.greenstone.gatherer.gui.table.GTable
    143      * @see org.greenstone.gatherer.valuetree.GValueTree
     143     * @see org.greenstone.gatherer.gui.MetaEditPane.GValueTree
    144144     */
    145145    public MetaEditPane(TreeSynchronizer tree_sync)
     
    190190     * @param event An <strong>ActionEvent</strong> containing information about the event.
    191191     * @see org.greenstone.gatherer.collection.CollectionManager
     192     * @see org.greenstone.gatherer.gui.MetaEditPane.GValueTree
    192193     * @see org.greenstone.gatherer.gui.table.GTableModel
    193194     * @see org.greenstone.gatherer.msm.ElementWrapper
    194195     * @see org.greenstone.gatherer.msm.MetadataSetManager
    195196     * @see org.greenstone.gatherer.msm.MSMEvent
    196      * @see org.greenstone.gatherer.valuetree.GValueTree
    197197     */
    198198    public void actionPerformed(ActionEvent event) {
     
    317317     * @param ready <i>true</i> if there is a collection currently ready to be editing, <i>false</i> otherwise.
    318318     * @see org.greenstone.gatherer.collection.CollectionManager
    319      * @see org.greenstone.gatherer.collection.CollectionModel
    320      * @see org.greenstone.gatherer.tree.GTree
    321319     * @see org.greenstone.gatherer.util.TreeSynchronizer
    322320     */
     
    358356     * @see org.greenstone.gatherer.Gatherer
    359357     * @see org.greenstone.gatherer.collection.CollectionManager
    360      * @see org.greenstone.gatherer.collection.CollectionModel
    361358     * @see org.greenstone.gatherer.file.FileOpenActionListener
    362359     * @see org.greenstone.gatherer.gui.Filter
    363360     * @see org.greenstone.gatherer.gui.GComboBox
    364361     * @see org.greenstone.gatherer.gui.table.GTableModel
    365      * @see org.greenstone.gatherer.tree.GTree
    366      * @see org.greenstone.gatherer.tree.GTreeModel
    367      * @see org.greenstone.gatherer.valuetree.GValueTree
    368362     */
    369363    public void display() {
     
    403397    filter = Gatherer.g_man.getFilter(collection_tree);
    404398    filter.setBackground(Gatherer.config.getColor("coloring.collection_heading_background", false));
    405     // Change the default colours of this filters combobox.
    406     GComboBox fcb = filter.getComboBox();
    407     fcb.setBackgroundNonSelectionColor(Color.white);
    408     fcb.setTextNonSelectionColor(Gatherer.config.getColor("coloring.collection_tree_foreground", false));
    409     fcb.setBackgroundSelectionColor(Gatherer.config.getColor("coloring.collection_selection_background", false));
    410     fcb.setTextSelectionColor(Gatherer.config.getColor("coloring.collection_selection_foreground", false));
    411     Dictionary.registerTooltip(fcb, "Collection.Filter_Tooltip");
    412     fcb = null;
     399    filter.setEditable(Gatherer.config.getMode() > Configuration.LIBRARIAN_MODE);
     400    Dictionary.registerTooltip(filter.getComboBox(), "Collection.Filter_Tooltip");
    413401
    414402    // Connection
     
    584572    /** Ensures a certain tree path is expanded, visible and selected within the collection tree.
    585573     * @param path The <strong>TreePath</strong> to make visible.
    586      * @see org.greenstone.gatherer.tree.GTree
     574     * @see org.greenstone.gatherer.gui.tree.DragTree
    587575     */
    588576    private void expandPath(TreePath path) {
     
    591579    }
    592580    /** Called to inform this control panel that it has just gained focus as an effect of the user clicking on its tab.
    593      * @see org.greenstone.gatherer.tree.GTree
     581     * @see org.greenstone.gatherer.gui.tree.DragTree
    594582     */
    595583    public void gainFocus() {
     
    630618     */
    631619    public void metadataChanged(MSMEvent event) {}
     620
     621    /** Called whenever the detail mode changes to ensure the filters are at an appropriate level (ie only editable by those that understand regular expression matching)
     622     * @param mode the mode level as an int
     623     */
     624    public void modeChanged(int mode) {
     625    filter.setEditable(mode > Configuration.LIBRARIAN_MODE);
     626    }
    632627
    633628    public void refreshTrees() {
     
    717712     * @param event The <strong>ListSelectionEvent</strong> which contains all the information about the event that has been fired.
    718713     * @see org.greenstone.gatherer.gui.table.GTableModel
    719      * @see org.greenstone.gatherer.valuetree.GValueTree
     714     * @see org.greenstone.gatherer.gui.MetaEditPane.GValueTree
    720715     */
    721716    public void valueChanged(ListSelectionEvent event) {
     
    750745     * @param event A <strong>TreeSelectionEvent</strong> containing information about the event.
    751746     * @see org.greenstone.gatherer.Gatherer
    752      * @see org.greenstone.gatherer.collection.FileNode
     747     * @see org.greenstone.gatherer.file.FileNode
    753748     * @see org.greenstone.gatherer.gui.GUIManager
    754749     * @see org.greenstone.gatherer.gui.MenuBar
    755750     * @see org.greenstone.gatherer.gui.table.GTableModel
    756751     * @see org.greenstone.gatherer.msm.MetadataSetManager
    757      * @see org.greenstone.gatherer.tree.GTree
     752     * @see org.greenstone.gatherer.gui.tree.DragTree
    758753     * @see org.greenstone.gatherer.util.ArrayTools
    759754     */
  • trunk/gli/src/org/greenstone/gatherer/gui/OptionsPane.java

    r6321 r6389  
    4444import javax.swing.event.*;
    4545import javax.swing.text.*;
     46import org.greenstone.gatherer.Configuration;
    4647import org.greenstone.gatherer.Dictionary;
    4748import org.greenstone.gatherer.Gatherer;
     
    6970    static final public char UNKNOWN = 'x';
    7071
     72    static private int BUILD = 0;
     73    static private int IMPORT = 1;
     74    static private int MINIMUM_ROWS = 11;
     75    static private Dimension LABEL_SIZE = new Dimension(180, 25);
     76    static private Dimension ROW_SIZE = new Dimension(610, 30);
     77    static private Dimension SPINNER_SIZE = new Dimension(100, 25);
     78    static private String DESCRIPTION_SEP = " + ";
     79
    7180    /** All process messages are written to this log text area. */
    7281    public JTextArea log_textarea = null;
     
    8594    private Vector writing_documents;
    8695
    87     static private int BUILD = 0;
    88     static private int IMPORT = 1;
    89     static private Dimension LABEL_SIZE = new Dimension(180, 25);
    90     static private Dimension ROW_SIZE = new Dimension(610, 25);
    91     static private Dimension SPINNER_SIZE = new Dimension(100, 25);
    92     static private String DESCRIPTION_SEP = " + ";
    93 
    9496
    9597    /** The default constructor creates the few session length options, but either retrieves the rest from the current collection, or creates a default set of options. */
     
    105107
    106108    /** This method creates the panel with all the build only options on it.
    107      * @return A <strong>JPanel</strong> which can be used to display all the build only options.
     109     * @param pane a JPanel which already has previous arguments available on it, to allow for lower moes to concatenate all of the arguments together
     110     * @return a JPanel which can be used to display all the build only options
     111     * @see org.greenstone.gatherer.Configuration#EXPERT_MODE
     112     * @see org.greenstone.gatherer.Configuration#getColor
     113     * @see org.greenstone.gatherer.Configuration#getMode
     114     * @see org.greenstone.gatherer.Gatherer#config
     115     * @see org.greenstone.gatherer.cdm.Argument
     116     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildArgument
     117     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildArgumentCount
     118     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValue
     119     * @see org.greenstone.gatherer.collection.BuildOptions#getBuildValueEnabled
     120     * @see org.greenstone.gatherer.gui.OptionsPane#ArgumentControl
    108121     */
    109     public JPanel buildBuild() {
    110     current_controls.clear();
    111     JPanel pane = new JPanel();
    112     pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
    113     pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    114     int build_argument_count = build_options.getBuildArgumentCount();
    115     pane.setLayout(new GridLayout(build_argument_count, 1, 5, 5));
    116     for(int i = 0; i < build_argument_count; i++) {
     122    public JPanel buildBuild(JPanel pane) {
     123    // Reset the arguments
     124    if(pane == null) {
     125        current_controls.clear();
     126    }
     127    ArrayList build_arguments = new ArrayList();
     128    int current_mode = Gatherer.config.getMode();
     129    int total_build_argument_count = build_options.getBuildArgumentCount();       
     130    for(int i = 0; i < total_build_argument_count; i++) {
    117131        // Retrieve the argument so we know how to format the control.
    118132        Argument argument = build_options.getBuildArgument(i);
    119         // Now attempt to retrieve any existing value for this argument.
    120         boolean enabled = build_options.getBuildValueEnabled(argument.getName());
    121         String value = build_options.getBuildValue(argument.getName());
    122         ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value);
    123         pane.add(argument_control);
    124         current_controls.add(argument_control);
     133        if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) {
     134        // Now attempt to retrieve any existing value for this argument.
     135        boolean enabled = build_options.getBuildValueEnabled(argument.getName());
     136        String value = build_options.getBuildValue(argument.getName());
     137        ArgumentControl argument_control = new ArgumentControl(BUILD, argument, enabled, value);
     138        build_arguments.add(argument_control);
     139        }
     140    }
     141    current_controls.addAll(build_arguments);
     142    // Now that we know how many arguments there are we can build the pane to view them on. Modes lower than EXPERT can provide a previous pane on which to add the arguments.
     143    if(pane == null || current_mode >= Configuration.EXPERT_MODE) {
     144        pane = new JPanel();
     145        pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     146        pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
     147        int argument_count = build_arguments.size();
     148        // If in any of the higher detail modes, and assuming we don't want super phat argument controls, we better ensure there is a minimum number or lines in the grid layout
     149        if(current_mode >= Configuration.EXPERT_MODE) {
     150        if(argument_count < MINIMUM_ROWS) {
     151            argument_count = MINIMUM_ROWS;
     152        }
     153        pane.setLayout(new GridLayout(argument_count, 1, 5, 5));
     154        }
     155        // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway
     156        else {
     157        pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
     158        }
     159    }
     160    for(int j = 0; j < build_arguments.size(); j++) {
     161        pane.add((JComponent)build_arguments.get(j));
    125162    }
    126163    pane.addMouseListener(this);
     164    build_arguments = null;
    127165    return pane;
    128166    }
     167
    129168    /** This method creates the panel with all the import only options on it.
    130      * @return A <strong>JPanel</strong> which can be used to display all the import only options.
     169     * @param pane a JPanel which already has previous arguments available on it, to allow for lower moes to concatenate all of the arguments together
     170     * @return a JPanel which can be used to display all the build only options
     171     * @see org.greenstone.gatherer.Configuration#EXPERT_MODE
     172     * @see org.greenstone.gatherer.Configuration#getColor
     173     * @see org.greenstone.gatherer.Configuration#getMode
     174     * @see org.greenstone.gatherer.Gatherer#config
     175     * @see org.greenstone.gatherer.cdm.Argument
     176     * @see org.greenstone.gatherer.collection.BuildOptions#getImportArgument
     177     * @see org.greenstone.gatherer.collection.BuildOptions#getImportArgumentCount
     178     * @see org.greenstone.gatherer.collection.BuildOptions#getImportValue
     179     * @see org.greenstone.gatherer.collection.BuildOptions#getImportValueEnabled
     180     * @see org.greenstone.gatherer.gui.OptionsPane#ArgumentControl
    131181     */
    132     public JPanel buildImport() {
    133     current_controls.clear();
    134     JPanel pane = new JPanel();
    135     pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
    136     pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    137     int import_argument_count = build_options.getImportArgumentCount();
    138     pane.setLayout(new GridLayout(import_argument_count, 1, 5, 5));
    139     for(int i = 0; i < import_argument_count; i++) {
     182    public JPanel buildImport(JPanel pane) {
     183    // Reset the arguments
     184    if(pane == null) {
     185        current_controls.clear();
     186    }
     187    ArrayList import_arguments = new ArrayList();
     188    int current_mode = Gatherer.config.getMode();
     189    int total_import_argument_count = build_options.getImportArgumentCount();       
     190    for(int i = 0; i < total_import_argument_count; i++) {
    140191        // Retrieve the argument so we know how to format the control.
    141192        Argument argument = build_options.getImportArgument(i);
    142         // Now attempt to retrieve any existing value for this argument.
    143         boolean enabled = build_options.getImportValueEnabled(argument.getName());
    144         String value = build_options.getImportValue(argument.getName());
    145         ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value);
    146         pane.add(argument_control);
    147         current_controls.add(argument_control);
     193        if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) {
     194        // Now attempt to retrieve any existing value for this argument.
     195        boolean enabled = build_options.getImportValueEnabled(argument.getName());
     196        String value = build_options.getImportValue(argument.getName());
     197        ArgumentControl argument_control = new ArgumentControl(IMPORT, argument, enabled, value);
     198        import_arguments.add(argument_control);
     199        }
     200    }
     201    current_controls.addAll(import_arguments);
     202    // Now that we know how many arguments there are we can build the pane to view them on. Modes lower than EXPERT can provide a previous pane on which to add the arguments.
     203    if(pane == null || current_mode >= Configuration.EXPERT_MODE) {
     204        pane = new JPanel();
     205        pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     206        pane.setBackground(Gatherer.config.getColor("coloring.collection_tree_background", false));
     207        int argument_count = import_arguments.size();
     208        // If in any of the higher detail modes, and assuming we don't want super phat argument controls, we better ensure there is a minimum number or lines in the grid layout
     209        if(current_mode >= Configuration.EXPERT_MODE) {
     210        if(argument_count < MINIMUM_ROWS) {
     211            argument_count = MINIMUM_ROWS;
     212        }
     213        pane.setLayout(new GridLayout(argument_count, 1, 5, 5));
     214        }
     215        // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway
     216        else {
     217        pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
     218        }
     219    }
     220    for(int j = 0; j < import_arguments.size(); j++) {
     221        pane.add((JComponent)import_arguments.get(j));
    148222    }
    149223    pane.addMouseListener(this);
     224    import_arguments = null;
    150225    return pane;
    151226    }
     227
    152228    /** This method is used to build a panel based on the message log, which is nothing like any of the other panels.
    153229     * @return A <strong>JPanel</strong> containing a scrollable text area which represents the shell process message log.
     
    322398        setLayout(new BorderLayout());
    323399        setPreferredSize(ROW_SIZE);
     400        setMaximumSize(ROW_SIZE);
    324401
    325402        // Try to determine what the value_controls value should be.
     
    425502        value_control = textfield;
    426503        break;
     504        case Argument.METADATUM:
     505        GComboBox gcombobox = new GComboBox(Gatherer.c_man.getCollection().msm.getAssignedElements(), false);
     506        gcombobox.setEnabled(enable);
     507        // Now ensure we have the existing value or default value selected if either exist.
     508        if(value != null) {
     509            boolean found = selectValue(gcombobox, value);
     510            // Its possible that this is a custom value and so doesn't exist in the combobox. If so add it and then select it
     511            if(!found) {
     512            gcombobox.addItem(value);
     513            gcombobox.setSelectedItem(value);
     514            }
     515        }
     516        add(gcombobox, BorderLayout.CENTER);
     517        value_control = gcombobox;
     518        break;
    427519        }
    428520
     
    454546    }
    455547
     548    /** Method to ensure that a certain value is selected, if it exists within that combobox to begin with.
     549     * @param combobox the JComboBox whose selection we are trying to preset
     550     * @param target The desired value of the selection as a String
     551     * @return true if the item was found and selected, false otherwise
     552     */
     553    public boolean selectValue(JComboBox combobox, String target) {
     554        for(int i = 0; i < combobox.getItemCount(); i++) {
     555        if(combobox.getItemAt(i).toString().equals(target)) {
     556            combobox.setSelectedIndex(i);
     557            return true;
     558        }
     559        }
     560        return false;
     561    }
     562
    456563    /** Update the values stored in the collection so as to rememebr the current state of this argument. */
    457564    public void update() {
     
    472579        }
    473580        else if(value_control instanceof JComboBox) {
    474         value = (String) ((JComboBox)value_control).getSelectedItem();
    475         }
    476                 // If this argument was a flag, but is now disabled, remove from the build options altogether
     581        value = (((JComboBox)value_control).getSelectedItem()).toString();
     582        }
     583        // If this argument was a flag, but is now disabled, remove from the build options altogether
    477584        if(!enable && value == null) {
    478585        if(type == BUILD) {
     
    483590        }
    484591        }
    485                 // Otherwise update the argument value
     592        // Otherwise update the argument value
    486593        else {
    487594        if(type == BUILD) {
     
    638745    public void valueChanged(ListSelectionEvent e) {
    639746        if (!e.getValueIsAdjusting()) { // we get two events for one change in list selection - use the false one ( the second one)
     747        ///ystem.err.println("Log change detected.");
    640748        JList source  = (JList)e.getSource();
    641749        file_entry = (FileEntry) source.getSelectedValue();
    642750        // First we determine if the old log has been completely written to file
    643751        Document document = log_textarea.getDocument();
    644         if(document instanceof AppendLineOnlyFileDocument) {
    645             AppendLineOnlyFileDocument append_line_only_file_document = (AppendLineOnlyFileDocument) document;
     752        ///ystem.err.println(" * current document: " + document);
     753        ///ystem.err.println(" * new document:     " + file_entry.getDocument());
     754        // If we are dealing with the same document don't do anything.
     755        if(document != file_entry.getDocument()) {
     756            if(document instanceof AppendLineOnlyFileDocument) {
     757            AppendLineOnlyFileDocument append_line_only_file_document = (AppendLineOnlyFileDocument) document;
    646758            if(append_line_only_file_document.isStillWriting()) {
     759                ///ystem.err.println("Current log is still active... finishing.");
    647760                writing_documents.add(append_line_only_file_document); // We have to maintain a reference until they are all done.
    648761                append_line_only_file_document.setOwner(OptionsPane.this);
    649762                append_line_only_file_document.setExit();
    650763            }
    651         }
    652         // Load the new log
    653         log_textarea.setDocument(file_entry.getDocument());
     764            else {
     765                ///ystem.err.println("Current log is complete. Nothing to do.");
     766            }
     767            }
     768            // Load the new log
     769            log_textarea.setDocument(file_entry.getDocument());
     770        }
    654771        }
    655772    }
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r6319 r6389  
    7676    private JLabel recursion_depth_label;
    7777    private JLabel title_label;
     78    private JRadioButton assistant_mode_radio_button;
     79    private JRadioButton expert_mode_radio_button;
     80    private JRadioButton librarian_mode_radio_button;
     81    private JRadioButton systems_mode_radio_button;
     82    private JSpinner proxy_port_field;
     83    private JSpinner recursion_depth_spinner;
    7884    private JTabbedPane tab_pane;
     85    private JTextArea mode_description_textarea;
    7986    private JTextField library_path_field;
    8087    private JTextField proxy_host_field;
    81     private JSpinner proxy_port_field;
    82     private JSpinner recursion_depth_spinner;
    8388    private Preferences self;
    8489
    85     static final Dimension LABEL_SIZE = new Dimension(175, 25);
     90    static final Dimension LABEL_SIZE = new Dimension(240, 25);
    8691    static final Dimension ROW_SIZE = new Dimension(640, 25);
    8792    static final Dimension SIZE = new Dimension(640, 345);
     
    101106    JPanel general_preferences = createGeneralPreferences();
    102107    tab_pane.add("Preferences.General", general_preferences);
     108    tab_pane.add("Preferences.Mode", createModePreferences());
    103109    tab_pane.add("Preferences.Workflow", createWorkflowPreferences());
    104110    tab_pane.add("Preferences.Connection", createConnectionPreferences());
     
    330336    }
    331337
     338    /** Generate the controls for altering the detail mode.
     339     * @return a JPanel of controls
     340     */
     341    private JPanel createModePreferences() {
     342    // Create Controls
     343    JPanel mode_panel = new JPanel();
     344    JPanel button_panel = new JPanel();
     345    ButtonGroup mode_button_group = new ButtonGroup();
     346    assistant_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Assistant"));
     347    assistant_mode_radio_button.setOpaque(false);
     348    mode_button_group.add(assistant_mode_radio_button);
     349    expert_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Expert"));
     350    expert_mode_radio_button.setOpaque(false);
     351    mode_button_group.add(expert_mode_radio_button);
     352    librarian_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Librarian"));
     353    librarian_mode_radio_button.setOpaque(false);
     354    mode_button_group.add(librarian_mode_radio_button);
     355    systems_mode_radio_button = new JRadioButton(Dictionary.get("Preferences.Mode.Systems"));
     356    systems_mode_radio_button.setOpaque(false);
     357    mode_button_group.add(systems_mode_radio_button);
     358    mode_description_textarea = new JTextArea();
     359    mode_description_textarea.setEditable(false);
     360    mode_description_textarea.setLineWrap(true);
     361    mode_description_textarea.setWrapStyleWord(true);
     362    // Determine which value is already selected
     363    switch(Gatherer.config.getMode()) {
     364    case Configuration.ASSISTANT_MODE:
     365        assistant_mode_radio_button.setSelected(true);
     366        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
     367        break;
     368    case Configuration.SYSTEMS_MODE:
     369        systems_mode_radio_button.setSelected(true);
     370        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Systems_Description"));
     371        break;
     372    case Configuration.EXPERT_MODE:
     373        expert_mode_radio_button.setSelected(true);
     374        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
     375        break;
     376    default:
     377        librarian_mode_radio_button.setSelected(true);
     378        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
     379    }
     380    // Connection - when a radio button is selected we have to change the description
     381    ModeRadioButtonListener listener = new ModeRadioButtonListener();
     382    assistant_mode_radio_button.addActionListener(listener);
     383    expert_mode_radio_button.addActionListener(listener);
     384    librarian_mode_radio_button.addActionListener(listener);
     385    systems_mode_radio_button.addActionListener(listener);
     386    listener = null;
     387    // Layout
     388    button_panel.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
     389    button_panel.setLayout(new GridLayout(4,1,2,2));
     390    button_panel.add(assistant_mode_radio_button);
     391    button_panel.add(librarian_mode_radio_button);
     392    button_panel.add(systems_mode_radio_button);
     393    button_panel.add(expert_mode_radio_button);
     394
     395    mode_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     396    mode_panel.setLayout(new BorderLayout());
     397    mode_panel.add(button_panel, BorderLayout.NORTH);
     398    mode_panel.add(new JScrollPane(mode_description_textarea), BorderLayout.CENTER);
     399
     400    return mode_panel;
     401    }
     402
    332403    /** The warning preferences are controlled through a checklist. */
    333404    private JPanel createWarningPreferences() {
     
    504575        Gatherer.config.setInt("general.max_folder_depth", Configuration.COLLECTION_SPECIFIC, ((Integer)recursion_depth_spinner.getValue()).intValue());
    505576
     577        // Mode preferences
     578        int current_mode = Gatherer.config.getMode();
     579        int new_mode;
     580        if(assistant_mode_radio_button.isSelected()) {
     581        new_mode = Configuration.ASSISTANT_MODE;
     582        }
     583        else if(systems_mode_radio_button.isSelected()) {
     584        new_mode = Configuration.SYSTEMS_MODE;
     585        }
     586        else if(expert_mode_radio_button.isSelected()) {
     587        new_mode = Configuration.EXPERT_MODE;
     588        }
     589        else  {
     590        new_mode = Configuration.LIBRARIAN_MODE;
     591        }
     592        // If there has been a change in modes, update the config, and also inform the persistant gui views that have a need to know
     593        if(new_mode != current_mode) {
     594        Gatherer.config.setMode(new_mode);
     595        Gatherer.c_man.getCollection().cdm.modeChanged(new_mode);
     596        Gatherer.g_man.modeChanged(new_mode);
     597        }
    506598        // Warning preferences
    507599        for(int i = 0; i < warning_preferences_check_list.getEntryCount(); i++) {
     
    522614        Gatherer.g_man.workflowUpdate("Gather", workflow_gather.isSelected());
    523615        Gatherer.g_man.workflowUpdate("Enrich", workflow_enrich.isSelected());
    524         Gatherer.g_man.workflowUpdate("Design", workflow_design.isSelected());
     616        Gatherer.g_man.workflowUpdate("Design", (workflow_design.isSelected() && Gatherer.config.getMode() > Configuration.ASSISTANT_MODE));
    525617        Gatherer.g_man.workflowUpdate("Export", workflow_export.isSelected());
    526618        Gatherer.g_man.workflowUpdate("Create", workflow_create.isSelected());
     
    568660        return locale.getDisplayName();
    569661        }
     662    }
     663    }
     664
     665    /** This listener updates the mode description depending on what mode is selected. */
     666    private class ModeRadioButtonListener
     667    implements ActionListener {
     668    public void actionPerformed(ActionEvent event) {
     669        Object source = event.getSource();
     670        if(source == assistant_mode_radio_button) {
     671        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Assistant_Description"));
     672        }
     673        else if(source == expert_mode_radio_button) {
     674        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Expert_Description"));
     675        }
     676        else if(source == systems_mode_radio_button) {
     677        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Systems_Description"));
     678        }
     679        else {
     680        mode_description_textarea.setText(Dictionary.get("Preferences.Mode.Librarian_Description"));
     681        }
     682        source = null;
    570683    }
    571684    }
Note: See TracChangeset for help on using the changeset viewer.