Changeset 18352


Ignore:
Timestamp:
2009-01-12T11:17:16+13:00 (15 years ago)
Author:
kjdon
Message:

updated the rtl-gli branch with files from trunk. Result of a merge 14807:18318

Location:
gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/Argument.java

    r12824 r18352  
    5151 */
    5252public class Argument
    53     implements Comparable, Serializable {
    54     /** An element of the argument type enumeration specifying a combobox control. */
    55     static final public byte ENUM = 0;
    56     /** An element of the argument type enumeration specifying a checkbox control. */
    57     static final public byte FLAG = 1;
    58     /** An element of the argument type enumeration specifying a tree control. */
    59     static final public byte HIERARCHY = 2;
    60     /** An element of the argument type enumeration specifying a spinner control. */
    61     static final public byte INTEGER = 3;
    62     /** An element of the argument type enumeration specifying a language combobox control. */
    63     static final public byte LANGUAGE = 4;
    64     /** An element of the argument type enumeration specifying a list control. */
    65     static final public byte METADATA = 5;
    66     /** An element of the argument type enumeration specifying a metadata combobox control. */
    67     static final public byte METADATUM = 6;
    68     /** An element of the argument type enumeration specifying a text field. */
    69     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     /** An element of the argument type enumeration specifying a metadata set combobox control. */
    73     static final public byte METADATA_SET_NAMESPACE = 9;
    74 
    75  ///////////kk added the number was 9, I changed it to 10//////////////
    76   /** An element of the argument type enumeration specifying a text field. */
    77     static final public byte URL = 10;
    78     /////////////////////////////////////////////////////////////////
    79 
    80     /** true if this argument should actually be hidden within the GLI. This is important for arguments such as import dir or other location critical arguments. */
    81     private boolean hidden_gli = false;
    82     /** <i>true</i> if this argument is required for the applicable script to work properly, <i>false</i> otherwise. */
    83     private boolean required = false;
    84     /** The type of this argument. Used to be an int, but bytes are cheaper. */
    85     private byte type = STRING;
    86     /** The maximum value an integer based control can have. */
    87     private int maximum = Integer.MAX_VALUE;
    88     /** The minimum value an integer based control can have. */
    89     private int minimum = Integer.MIN_VALUE;
    90     /** Every argument has a detail mode level at which it becomes available to the user to edit.
    91      * @see org.greenstone.gatherer.Configuration
    92      */
    93     private int mode_level = Configuration.LIBRARIAN_MODE;
    94     /** The DOM element this argument is built around, if any. */
    95     private Element element;
    96     /** 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. */
    97     private ArrayList option_list = null;
    98     /** A default value for parameter-type arguments. May be a Perl pattern. */
    99     private String default_value = null;
    100     /** The text description of this argument parsed from the pluginfo output. */
    101     private String description = null;
    102     /** The argument flag as it appears in the command. Also used as the unique identifier of an argument. */
    103     private String name = null;
    104     /** The plugin that owns this argument, for the purposes of visualising inheritance. */
    105     private String owner = null;
    106 
    107     private String display_name = null;
    108 
    109     /** Default Constructor. */
    110     public Argument() {
    111     }
    112 
    113     /** Another constructor but this one is a little more interesting as it takes a DOM element.
    114      * @param element the Element this argument is based around
    115      */
    116     public Argument(Element element) {
    117     this.element = element;
    118     }
    119 
    120     /** Method to add an element to the option_list.
    121      * @param name the name value of the option as a String
    122      * @param desc the description of this options as a String
    123      */
    124     public void addOption(String name, String desc) {
    125     if(type == ENUM && name != null) {
    126         if(desc == null) {
    127         desc = "";
    128         }
    129         if(option_list == null) {
    130         option_list = new ArrayList();
    131         }
    132         option_list.add(new ArgumentOption(name, desc));
    133     }
    134     }
    135 
    136     /** Method to compare two arguments for ordering.
    137      * @param object the argument we are comparing to, as an Object
    138      * @return an int specifying the argument order, using values as set out in String
    139      * @see org.greenstone.gatherer.cdm.Argument
    140      */
    141     public int compareTo(Object object) {
    142     if(object instanceof Argument) {
    143         return getName().compareTo(((Argument)object).getName());
    144     }
    145     else {
    146         return toString().compareTo(object.toString());
    147     }
    148     }
    149 
    150     /** Create a copy of this argument.
    151      * @return a newly created Argument with the same details as this one
    152      */
    153     public Argument copy() {
    154     Argument copy = new Argument();
    155     copy.setDefaultValue(default_value);
    156     copy.setDescription(description);
    157     copy.setOptions(option_list);
    158     copy.setOwner(owner);
    159     copy.setName(name);
    160     copy.setRequired(required);
    161     copy.setType(type);
    162     copy.setMinimum(minimum);
    163     copy.setMaximum(maximum);
    164     copy.setModeLevel(mode_level);
    165     copy.setHiddenGLI(hidden_gli);
    166     return copy;
    167     }
    168 
    169     /** Method to determine if two arguments are equal.
    170      * @param object the argument to test against, as an Object
    171      * @return true if the arguments names match, false otherwise
    172      */
    173     public boolean equals(Object object) {
    174     return (compareTo(object) == 0);
    175     }
    176 
    177     /** Method to retrieve the value of default_value.
    178      * @return a String containing the default value
    179      */
    180     public String getDefaultValue() {
    181     return default_value;
    182     }
    183 
    184     /** Method to retrieve this arguments description.
    185      * @return a String containing the description
    186      */
    187     public String getDescription() {
    188     return description;
    189     }
    190 
    191     public Element getElement() {
    192     return element;
    193     }
    194     /** Retrieve the upper bound of a range based argument.
    195      * @return the maximum as an int
    196      */
    197     public int getMaximum() {
    198     return maximum;
    199     }
    200 
    201     /** Retrieve the lower bound of a range based argument.
    202      * @return the minimum as an int
    203      */
    204     public int getMinimum() {
    205     return minimum;
    206     }
    207 
    208     /** Retrieves the mode level at which this argument should become available. Any higher levels should also see this argument.
    209      * @return the mode level as an int
    210      */
    211     public int getModeLevel() {
    212     return mode_level;
    213     }
    214 
    215     /** Method to retrieve the value of name.
    216      * @return a String containing the argument name
    217      * @see org.greenstone.gatherer.util.StaticStrings#NAME_ATTRIBUTE
    218      */
    219     public String getName() {
    220     if(name == null && element != null) {
    221         name = element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
    222     }
    223     return name;
    224     }
    225 
    226     public String getDisplayName() {
    227     return display_name;
    228     }
    229 
    230 
    231     /** Method to retrieve the option list for this argument.
    232      * @return a HashMap containing &lt;option value&gt; -&gt; &lt;description&gt; entries
    233      */
    234     public ArrayList getOptions() {
    235     return option_list;
    236     }
    237 
    238     /** Retrieve the name of the owner of this argument.
    239      * @return the owners name as a String
    240      */
    241     public String getOwner() {
    242     return owner;
    243     }
    244    
    245     /** Method to determine the type of this argument.
    246      * @return a byte specifying the type
    247      */
    248     public byte getType() {
    249     return type;
    250     }
    251 
    252     /** Method to retrieve the value of value.
    253      * @return the value of value as a String
    254      * @see org.greenstone.gatherer.Gatherer#c_man
    255      * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
    256      */
    257     public String getValue()
    258     {
    259     // Only assigned arguments have values.
    260     if (element == null) {
    261         return null;
    262     }
    263 
    264     return XMLTools.getValue(element);
    265     }
    266 
    267 
    268     /** Method to determine if this argument has been assigned.
    269      * @return true if it has, false otherwise
    270      * @see org.greenstone.gatherer.util.StaticStrings#ASSIGNED_ATTRIBUTE
    271      * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
    272      */
    273     public boolean isAssigned() {
    274     return (element != null && element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.TRUE_STR));
    275     }
    276 
    277     /** 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.
    278      * @return true if this argument is a custom, false otherwise
    279      * @see org.greenstone.gatherer.util.StaticStrings#CUSTOM_ATTRIBUTE
    280      * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
    281      */
    282     public boolean isCustomArgument() {
    283     return (element != null && element.getAttribute(StaticStrings.CUSTOM_ATTRIBUTE).equals(StaticStrings.TRUE_STR));
    284     }
    285 
    286     /** Determine if this argument is hidden in GLI
    287      * @return true if the argument is hidden, false otherwise
    288      */
    289     public boolean isHiddenGLI() {
    290     return hidden_gli;
    291     }
    292 
    293     /** Method to determine of this argument is required for the associated script to work.
    294      * @return true if this argument is required, false otherwise
    295      */
    296     public boolean isRequired() {
    297     return required;
    298     }
    299 
    300     /** Method to allow for the activation of arguments that might never have their setValue() method called.
    301      * @param assigned the desired state as a boolean
    302      * @see org.greenstone.gatherer.util.StaticStrings#ASSIGNED_ATTRIBUTE
    303      * @see org.greenstone.gatherer.util.StaticStrings#FALSE_STR
    304      * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
    305      */
    306     public void setAssigned(boolean assigned) {
    307     if(element != null) {
    308         element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (assigned ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
    309     }
    310     }
    311 
    312     /** Sets the value of default_value.
    313      * @param default_value The new value for default_value as a <strong>String</strong>.
    314      */
    315     public void setDefaultValue(String default_value) {
    316     this.default_value = default_value;
    317     }
    318 
    319     /** Set the value of desc.
    320      * @param description the new value of desc as a String
    321      */
    322     public void setDescription(String description) {
    323     this.description = description;
    324     }
    325 
    326     /** Set the element this argument should be based upon.
    327      * @param element the Element
    328      */
    329     public void setElement(Element element) {
    330     this.element = element;
    331     }
    332 
    333     /** Mark this argument as being hidden in GLI. */
    334     public void setHiddenGLI(boolean hidden) {
    335     this.hidden_gli = hidden;
    336     }
    337 
    338     /** Set the upper bound for a range type argument.
    339      * @param maximum the maximum as an int
    340      */
    341     public void setMaximum(int maximum) {
    342     this.maximum = maximum;
    343     }
    344 
    345     /** Set the lower bound for a range type argument.
    346      * @param minimum the minimum as an int
    347      */
    348     public void setMinimum(int minimum) {
    349     this.minimum = minimum;
    350     }
    351 
    352     /** Set the detail mode level where this argument will become available.
    353      * @param mode_level the mode level as an int
    354      */
    355     public void setModeLevel(int mode_level) {
    356     this.mode_level = mode_level;
    357     }
    358 
    359     /** Set the value of name.
    360      * @param name the new value of name as a String
    361      */
    362     public void setName(String name) {
    363     this.name = name;
    364     }
    365 
    366     /** Sets the value of the options list.
    367      * @param list the new options list as a HashMap
    368      */
    369     public void setOptions(ArrayList list) {
    370     this.option_list = list;
    371     }
    372 
    373     /** Set the owner of this argument.
    374      * @param owner the name of the owner of this argument as a String
    375      */
    376     public void setOwner(String owner) {
    377     this.owner = owner;
    378     }
    379 
    380     /** Set the value of required.
    381      * @param required the new value of required as a boolean
    382      */
    383     public void setRequired(boolean required) {
    384     this.required = required;
    385     }
    386 
    387     /** Set the value of type.
    388      * @param type the new value of type as an byte
    389      */
    390     public void setType(byte type) {
    391     this.type = type;
    392     }
    393 
    394     /** Set the value of type, by matching a type to the given string.
    395      * @param new_type a String which contains the name of a certain argument type
    396      * @see org.greenstone.gatherer.util.StaticStrings#ENUM_STR
    397      * @see org.greenstone.gatherer.util.StaticStrings#FLAG_STR
    398      * @see org.greenstone.gatherer.util.StaticStrings#HIERARCHY_STR
    399      * @see org.greenstone.gatherer.util.StaticStrings#INT_STR
    400      * @see org.greenstone.gatherer.util.StaticStrings#LANGUAGE_STR
    401      * @see org.greenstone.gatherer.util.StaticStrings#METADATA_TYPE_STR
    402      * @see org.greenstone.gatherer.util.StaticStrings#METADATUM_TYPE_STR
    403      * @see org.greenstone.gatherer.util.StaticStrings#REGEXP_STR
    404      */
    405     public void setType(String new_type) {
    406     if(new_type.equalsIgnoreCase(StaticStrings.ENUM_STR)) {
    407         this.type = ENUM;
    408         option_list = new ArrayList();
    409     }
    410     else if(new_type.equalsIgnoreCase(StaticStrings.FLAG_STR)) {
    411         this.type = FLAG;
    412     }
    413     else if(new_type.equalsIgnoreCase(StaticStrings.HIERARCHY_STR)) {
    414         this.type = HIERARCHY;
    415     }
    416     else if(new_type.equalsIgnoreCase(StaticStrings.INT_STR)) {
    417         this.type = INTEGER;
    418     }
    419     else if(new_type.equalsIgnoreCase(StaticStrings.LANGUAGE_STR)) {
    420         this.type = LANGUAGE;
    421     }
    422     else if(new_type.equalsIgnoreCase(StaticStrings.METADATA_TYPE_STR)) {
    423         this.type = METADATA;
    424     }
    425     else if(new_type.equalsIgnoreCase(StaticStrings.METADATUM_TYPE_STR)) {
    426         this.type = METADATUM;
    427     }
    428     else if(new_type.equalsIgnoreCase(StaticStrings.REGEXP_STR)) {
    429         this.type = REGEXP;
    430     }
    431     else {
    432         this.type = STRING;
    433     }
    434     }
    435 
    436     /** Method to set the value of this argument.
    437      * @param value the new value for the argument
    438      * @see org.greenstone.gatherer.Gatherer#println
    439      */
    440     public void setValue(String value) {
    441     if(element != null) {
    442         XMLTools.setValue(element, value);
    443     }
    444     else {
    445         DebugStream.println("Argument.setValue(" + value + ") called on a base Argument.");
    446     }
    447     }
    448 
    449     /** 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.
    450      * @param values an ArrayList of values
    451      * @see org.greenstone.gatherer.Gatherer#println
    452      */
    453     public void setValues(ArrayList values) {
    454     if(element != null) {
    455         StringBuffer value = new StringBuffer();
    456         int value_length = values.size();
    457         for(int i = 0; i < value_length; i++) {
    458         value.append(values.get(i));
    459         value.append(StaticStrings.COMMA_CHARACTER);
    460         }
    461         value.deleteCharAt(value.length() - 1); // Remove last ','
    462         XMLTools.setValue(element, value.toString());
    463     }
    464     else {
    465         DebugStream.println("Argument.setValues([" + values.size() + " items]) called on a base Argument.");
    466     }
    467     }
    468 
    469     /** Method for translating the data of this class into a string.
    470      * @return a String containing a fragment of the total arguments string
    471      * @see org.greenstone.gatherer.Gatherer#c_man
    472      * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
    473      * @see org.greenstone.gatherer.util.StaticStrings#COMMA_CHARACTER
    474      * @see org.greenstone.gatherer.util.StaticStrings#NAME_ATTRIBUTE
    475      * @see org.greenstone.gatherer.util.StaticStrings#SPACE_CHARACTER
    476      * @see org.greenstone.gatherer.util.StaticStrings#SPEECH_CHARACTER
    477      */
    478     public String toString()
    479     {
    480     StringBuffer text = new StringBuffer("-");
    481 
    482     if (element == null) {
    483         return text.toString();
    484     }
    485 
    486     if (name == null) {
    487         name = element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
    488     }
    489     text.append(name);
    490 
    491     String value = XMLTools.getValue(element);
    492     if (value.length() == 0) {
    493         return text.toString();
    494     }
    495 
    496     text.append(StaticStrings.SPACE_CHARACTER);
    497 
    498 //  // Handle metadata elements specially
    499 //  if (type == METADATA || type == METADATUM) {
    500 //      // Tokenize the string
    501 //      StringTokenizer tokenizer = new StringTokenizer(value, ",");
    502 //      while (tokenizer.hasMoreTokens()) {
    503 //      String token = tokenizer.nextToken();
    504 
    505 //      MetadataElement metadata_element = MetadataTools.getMetadataElementWithDisplayName(token);
    506 //      if (metadata_element != null) {
    507 //          text.append(metadata_element.getFullName());
    508 //      }
    509 //      else {
    510 //          text.append(token);
    511 //      }
    512 
    513 //      if (tokenizer.hasMoreTokens()) {
    514 //          text.append(StaticStrings.COMMA_CHARACTER);
    515 //      }
    516 //      }
    517 //      return text.toString();
    518 //  }
    519 
    520     // If the value contains a space, add speech marks
    521     //   (Except for metadata elements, which won't have spaces when written out to collect.cfg)
    522     if (value.indexOf(StaticStrings.SPACE_CHARACTER) != -1 && !(type == METADATUM || type == METADATA)) {
    523         value = StaticStrings.SPEECH_CHARACTER + value + StaticStrings.SPEECH_CHARACTER;
    524     }
    525 
    526     text.append(value);
    527     return text.toString();
    528     }
    529 
    530     /** parse the <Option> XML from eg import.pl -xml or pluginfo.pl -xml */
    531     public void parseXML(Element option) {
    532 
    533     for(Node node = option.getFirstChild(); node != null; node = node.getNextSibling()) {
    534         String node_name = node.getNodeName();
    535         if(node_name.equals("Name")) {
    536         setName(XMLTools.getValue(node));
    537         }
    538         else if(node_name.equals("Desc")) {
    539         setDescription(XMLTools.getValue(node));
    540         }
    541         else if(node_name.equals("Type")) {
    542         setType(XMLTools.getValue(node));
    543         }
    544         else if(node_name.equals("Default")) {
    545         setDefaultValue(XMLTools.getValue(node));
    546         }
    547         else if(node_name.equals("Required")) {
    548         String v = XMLTools.getValue(node);
    549         if(v != null && v.equals("yes")) {
    550             setRequired(true);
    551         }
    552         }
    553         else if(node_name.equals("List")) {
    554         // Two final loops are required to parse lists.
    555         for(Node value = node.getFirstChild(); value != null; value = value.getNextSibling()) {
    556             if(value.getNodeName().equals("Value")) {
    557             String key = null;
    558             String desc = "";
    559             for(Node subvalue = value.getFirstChild(); subvalue != null; subvalue = subvalue.getNextSibling()) {
    560                 node_name = subvalue.getNodeName();
    561                 if(node_name.equals("Name")) {
    562                 key = XMLTools.getValue(subvalue);
    563                 }
    564                 else if(node_name.equals("Desc")) {
    565                 desc = XMLTools.getValue(subvalue);
    566                 }
    567             }
    568             if(key != null) {
    569                 addOption(key, desc);
    570             }
    571             }
    572         }
    573         }
    574         else if(node_name.equals("Range")) {
    575         String range_raw = XMLTools.getValue(node);
    576         int index = -1;
    577         if((index = range_raw.indexOf(StaticStrings.COMMA_CHARACTER)) != -1) {
    578             if(index > 0) {
    579             try {
    580                 String first_number = range_raw.substring(0, index);
    581                 setMinimum(Integer.parseInt(first_number));
    582                 first_number = null;
    583             }
    584             catch(Exception exception) {
    585             }
    586             }
    587            
    588             if(index + 1 < range_raw.length()) {
    589             try {
    590                 String second_number = range_raw.substring(index + 1);
    591                 setMaximum(Integer.parseInt(second_number));
    592                 second_number = null;   
    593             }
    594             catch(Exception exception) {
    595             }
    596             }
    597         }
    598         // Else it wasn't a valid range anyway, so ignore it
    599         }
    600         else if(node_name.equals("HiddenGLI")) {
    601         setHiddenGLI(true);
    602         }
    603         else if(node_name.equals("ModeGLI")) {
    604         String mode_level_str = XMLTools.getValue(node);
    605         try {
    606             int mode_level = Integer.parseInt(mode_level_str);
    607             setModeLevel(mode_level);
    608         }
    609         catch(Exception exception) {
    610             DebugStream.println("Exception in Argument.parseXML() - Unexpected but non-fatal");
    611             DebugStream.printStackTrace(exception);
    612         }
    613         }
    614        
    615     } // for each option
     53implements Comparable, Serializable {
     54    /** An element of the argument type enumeration specifying a combobox control. */
     55    static final public byte ENUM = 0;
     56    /** An element of the argument type enumeration specifying a checkbox control. */
     57    static final public byte FLAG = 1;
     58    /** An element of the argument type enumeration specifying a tree control. */
     59    static final public byte HIERARCHY = 2;
     60    /** An element of the argument type enumeration specifying a spinner control. */
     61    static final public byte INTEGER = 3;
     62    /** An element of the argument type enumeration specifying a language combobox control. */
     63    static final public byte LANGUAGE = 4;
     64    /** An element of the argument type enumeration specifying a list control. */
     65    static final public byte METADATA = 5;
     66    /** An element of the argument type enumeration specifying a metadata combobox control. */
     67    static final public byte METADATUM = 6;
     68    /** An element of the argument type enumeration specifying a text field. */
     69    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    /** An element of the argument type enumeration specifying a metadata set combobox control. */
     73    static final public byte METADATA_SET_NAMESPACE = 9;
     74
     75    ///////////kk added the number was 9, I changed it to 10//////////////
     76    /** An element of the argument type enumeration specifying a text field. */
     77    static final public byte URL = 10;
     78    /////////////////////////////////////////////////////////////////
     79
     80    /** true if this argument should actually be hidden within the GLI. This is important for arguments such as import dir or other location critical arguments. */
     81    private boolean hidden_gli = false;
     82    /** <i>true</i> if this argument is required for the applicable script to work properly, <i>false</i> otherwise. */
     83    private boolean required = false;
     84    /** The type of this argument. Used to be an int, but bytes are cheaper. */
     85    private byte type = STRING;
     86    /** The maximum value an integer based control can have. */
     87    private int maximum = Integer.MAX_VALUE;
     88    /** The minimum value an integer based control can have. */
     89    private int minimum = Integer.MIN_VALUE;
     90    /** Every argument has a detail mode level at which it becomes available to the user to edit.
     91     * @see org.greenstone.gatherer.Configuration
     92     */
     93    private int mode_level = Configuration.LIBRARIAN_MODE;
     94    /** The DOM element this argument is built around, if any. */
     95    private Element element;
     96    /** 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. */
     97    private ArrayList option_list = null;
     98    /** A default value for parameter-type arguments. May be a Perl pattern. */
     99    private String default_value = null;
     100    /** The text description of this argument parsed from the pluginfo output. */
     101    private String description = null;
     102    /** The argument flag as it appears in the command. Also used as the unique identifier of an argument. */
     103    private String name = null;
     104    /** The plugin that owns this argument, for the purposes of visualising inheritance. */
     105    private String owner = null;
     106
     107    private String display_name = null;
     108
     109    /** Default Constructor. */
     110    public Argument() {
     111    }
     112
     113    /** Another constructor but this one is a little more interesting as it takes a DOM element.
     114     * @param element the Element this argument is based around
     115     */
     116    public Argument(Element element) {
     117        this.element = element;
     118    }
     119
     120    /** Method to add an element to the option_list.
     121     * @param name the name value of the option as a String
     122     * @param desc the description of this options as a String
     123     */
     124    public void addOption(String name, String desc) {
     125        if(type == ENUM && name != null) {
     126            if(desc == null) {
     127                desc = "";
     128            }
     129            if(option_list == null) {
     130                option_list = new ArrayList();
     131            }
     132            option_list.add(new ArgumentOption(name, desc));
     133        }
     134    }
     135
     136    /** Method to compare two arguments for ordering.
     137     * @param object the argument we are comparing to, as an Object
     138     * @return an int specifying the argument order, using values as set out in String
     139     * @see org.greenstone.gatherer.cdm.Argument
     140     */
     141    public int compareTo(Object object) {
     142        if(object instanceof Argument) {
     143            return getName().compareTo(((Argument)object).getName());
     144        }
     145        else {
     146            return toString().compareTo(object.toString());
     147        }
     148    }
     149
     150    /** Create a copy of this argument.
     151     * @return a newly created Argument with the same details as this one
     152     */
     153    public Argument copy() {
     154        Argument copy = new Argument();
     155        copy.setDefaultValue(default_value);
     156        copy.setDescription(description);
     157        copy.setOptions(option_list);
     158        copy.setOwner(owner);
     159        copy.setName(name);     
     160        copy.setDisplayName(display_name);
     161        copy.setRequired(required);
     162        copy.setType(type);
     163        copy.setMinimum(minimum);
     164        copy.setMaximum(maximum);
     165        copy.setModeLevel(mode_level);
     166        copy.setHiddenGLI(hidden_gli);
     167        return copy;
     168    }
     169
     170    /** Method to determine if two arguments are equal.
     171     * @param object the argument to test against, as an Object
     172     * @return true if the arguments names match, false otherwise
     173     */
     174    public boolean equals(Object object) {
     175        return (compareTo(object) == 0);
     176    }
     177
     178    /** Method to retrieve the value of default_value.
     179     * @return a String containing the default value
     180     */
     181    public String getDefaultValue() {
     182        return default_value;
     183    }
     184
     185    /** Method to retrieve this arguments description.
     186     * @return a String containing the description
     187     */
     188    public String getDescription() {
     189        return description;
     190    }
     191
     192    public Element getElement() {
     193        return element;
     194    }
     195    /** Retrieve the upper bound of a range based argument.
     196     * @return the maximum as an int
     197     */
     198    public int getMaximum() {
     199        return maximum;
     200    }
     201
     202    /** Retrieve the lower bound of a range based argument.
     203     * @return the minimum as an int
     204     */
     205    public int getMinimum() {
     206        return minimum;
     207    }
     208
     209    /** Retrieves the mode level at which this argument should become available. Any higher levels should also see this argument.
     210     * @return the mode level as an int
     211     */
     212    public int getModeLevel() {
     213        return mode_level;
     214    }
     215
     216    /** Method to retrieve the value of name.
     217     * @return a String containing the argument name
     218     * @see org.greenstone.gatherer.util.StaticStrings#NAME_ATTRIBUTE
     219     */
     220    public String getName() {
     221        if(name == null && element != null) {
     222            name = element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
     223        }
     224        return name;
     225    }
     226
     227    public String getDisplayName() {
     228        if(display_name==null)
     229            return "";
     230        return display_name;
     231    }
     232
     233    /** Method to retrieve the option list for this argument.
     234     * @return a HashMap containing &lt;option value&gt; -&gt; &lt;description&gt; entries
     235     */
     236    public ArrayList getOptions() {
     237        return option_list;
     238    }
     239
     240    /** Retrieve the name of the owner of this argument.
     241     * @return the owners name as a String
     242     */
     243    public String getOwner() {
     244        return owner;
     245    }
     246
     247    /** Method to determine the type of this argument.
     248     * @return a byte specifying the type
     249     */
     250    public byte getType() {
     251        return type;
     252    }
     253
     254    /** Method to retrieve the value of value.
     255     * @return the value of value as a String
     256     * @see org.greenstone.gatherer.Gatherer#c_man
     257     * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
     258     */
     259    public String getValue()
     260    {
     261        // Only assigned arguments have values.
     262        if (element == null) {
     263            return null;
     264        }
     265
     266        return XMLTools.getValue(element);
     267    }
     268
     269
     270    /** Method to determine if this argument has been assigned.
     271     * @return true if it has, false otherwise
     272     * @see org.greenstone.gatherer.util.StaticStrings#ASSIGNED_ATTRIBUTE
     273     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
     274     */
     275    public boolean isAssigned() {
     276        return (element != null && element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.TRUE_STR));
     277    }
     278
     279    /** 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.
     280     * @return true if this argument is a custom, false otherwise
     281     * @see org.greenstone.gatherer.util.StaticStrings#CUSTOM_ATTRIBUTE
     282     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
     283     */
     284    public boolean isCustomArgument() {
     285        return (element != null && element.getAttribute(StaticStrings.CUSTOM_ATTRIBUTE).equals(StaticStrings.TRUE_STR));
     286    }
     287
     288    /** Determine if this argument is hidden in GLI
     289     * @return true if the argument is hidden, false otherwise
     290     */
     291    public boolean isHiddenGLI() {
     292        return hidden_gli;
     293    }
     294
     295    /** Method to determine of this argument is required for the associated script to work.
     296     * @return true if this argument is required, false otherwise
     297     */
     298    public boolean isRequired() {
     299        return required;
     300    }
     301
     302    /** Method to allow for the activation of arguments that might never have their setValue() method called.
     303     * @param assigned the desired state as a boolean
     304     * @see org.greenstone.gatherer.util.StaticStrings#ASSIGNED_ATTRIBUTE
     305     * @see org.greenstone.gatherer.util.StaticStrings#FALSE_STR
     306     * @see org.greenstone.gatherer.util.StaticStrings#TRUE_STR
     307     */
     308    public void setAssigned(boolean assigned) {
     309        if(element != null) {
     310            element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (assigned ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
     311        }
     312    }
     313
     314    /** Sets the value of default_value.
     315     * @param default_value The new value for default_value as a <strong>String</strong>.
     316     */
     317    public void setDefaultValue(String default_value) {
     318        this.default_value = default_value;
     319    }
     320
     321    /** Set the value of desc.
     322     * @param description the new value of desc as a String
     323     */
     324    public void setDescription(String description) {
     325        this.description = description;
     326    }
     327
     328    /** Set the element this argument should be based upon.
     329     * @param element the Element
     330     */
     331    public void setElement(Element element) {
     332        this.element = element;
     333    }
     334
     335    /** Mark this argument as being hidden in GLI. */
     336    public void setHiddenGLI(boolean hidden) {
     337        this.hidden_gli = hidden;
     338    }
     339
     340    /** Set the upper bound for a range type argument.
     341     * @param maximum the maximum as an int
     342     */
     343    public void setMaximum(int maximum) {
     344        this.maximum = maximum;
     345    }
     346
     347    /** Set the lower bound for a range type argument.
     348     * @param minimum the minimum as an int
     349     */
     350    public void setMinimum(int minimum) {
     351        this.minimum = minimum;
     352    }
     353
     354    /** Set the detail mode level where this argument will become available.
     355     * @param mode_level the mode level as an int
     356     */
     357    public void setModeLevel(int mode_level) {
     358        this.mode_level = mode_level;
     359    }
     360
     361    /** Set the value of name.
     362     * @param name the new value of name as a String
     363     */
     364    public void setName(String name) {
     365        this.name = name;
     366    }
    616367   
    617     } // parseXML
    618 
    619     public class ArgumentOption
     368    public void setDisplayName(String name) {       
     369        this.display_name = name;
     370    }   
     371
     372    /** Sets the value of the options list.
     373     * @param list the new options list as a HashMap
     374     */
     375    public void setOptions(ArrayList list) {
     376        this.option_list = list;
     377    }
     378
     379    /** Set the owner of this argument.
     380     * @param owner the name of the owner of this argument as a String
     381     */
     382    public void setOwner(String owner) {
     383        this.owner = owner;
     384    }
     385
     386    /** Set the value of required.
     387     * @param required the new value of required as a boolean
     388     */
     389    public void setRequired(boolean required) {
     390        this.required = required;
     391    }
     392
     393    /** Set the value of type.
     394     * @param type the new value of type as an byte
     395     */
     396    public void setType(byte type) {
     397        this.type = type;
     398    }
     399
     400    /** Set the value of type, by matching a type to the given string.
     401     * @param new_type a String which contains the name of a certain argument type
     402     * @see org.greenstone.gatherer.util.StaticStrings#ENUM_STR
     403     * @see org.greenstone.gatherer.util.StaticStrings#FLAG_STR
     404     * @see org.greenstone.gatherer.util.StaticStrings#HIERARCHY_STR
     405     * @see org.greenstone.gatherer.util.StaticStrings#INT_STR
     406     * @see org.greenstone.gatherer.util.StaticStrings#LANGUAGE_STR
     407     * @see org.greenstone.gatherer.util.StaticStrings#METADATA_TYPE_STR
     408     * @see org.greenstone.gatherer.util.StaticStrings#METADATUM_TYPE_STR
     409     * @see org.greenstone.gatherer.util.StaticStrings#REGEXP_STR
     410     */
     411    public void setType(String new_type) {
     412        if(new_type.equalsIgnoreCase(StaticStrings.ENUM_STR)) {
     413            this.type = ENUM;
     414            option_list = new ArrayList();
     415        }
     416        else if(new_type.equalsIgnoreCase(StaticStrings.FLAG_STR)) {
     417            this.type = FLAG;
     418        }
     419        else if(new_type.equalsIgnoreCase(StaticStrings.HIERARCHY_STR)) {
     420            this.type = HIERARCHY;
     421        }
     422        else if(new_type.equalsIgnoreCase(StaticStrings.INT_STR)) {
     423            this.type = INTEGER;
     424        }
     425        else if(new_type.equalsIgnoreCase(StaticStrings.LANGUAGE_STR)) {
     426            this.type = LANGUAGE;
     427        }
     428        else if(new_type.equalsIgnoreCase(StaticStrings.METADATA_TYPE_STR)) {
     429            this.type = METADATA;
     430        }
     431        else if(new_type.equalsIgnoreCase(StaticStrings.METADATUM_TYPE_STR)) {
     432            this.type = METADATUM;
     433        }
     434        else if(new_type.equalsIgnoreCase(StaticStrings.REGEXP_STR)) {
     435            this.type = REGEXP;
     436        }
     437        else {
     438            this.type = STRING;
     439        }
     440    }
     441
     442    /** Method to set the value of this argument.
     443     * @param value the new value for the argument
     444     * @see org.greenstone.gatherer.Gatherer#println
     445     */
     446    public void setValue(String value) {
     447        if(element != null) {
     448            XMLTools.setValue(element, value);
     449        }
     450        else {
     451            DebugStream.println("Argument.setValue(" + value + ") called on a base Argument.");
     452        }
     453    }
     454
     455    /** 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.
     456     * @param values an ArrayList of values
     457     * @see org.greenstone.gatherer.Gatherer#println
     458     */
     459    public void setValues(ArrayList values) {
     460        if(element != null) {
     461            StringBuffer value = new StringBuffer();
     462            int value_length = values.size();
     463            for(int i = 0; i < value_length; i++) {
     464                value.append(values.get(i));
     465                value.append(StaticStrings.COMMA_CHARACTER);
     466            }
     467            value.deleteCharAt(value.length() - 1); // Remove last ','
     468            XMLTools.setValue(element, value.toString());
     469        }
     470        else {
     471            DebugStream.println("Argument.setValues([" + values.size() + " items]) called on a base Argument.");
     472        }
     473    }
     474
     475    /** Method for translating the data of this class into a string.
     476     * @return a String containing a fragment of the total arguments string
     477     * @see org.greenstone.gatherer.Gatherer#c_man
     478     * @see org.greenstone.gatherer.collection.CollectionManager#getCollection
     479     * @see org.greenstone.gatherer.util.StaticStrings#COMMA_CHARACTER
     480     * @see org.greenstone.gatherer.util.StaticStrings#NAME_ATTRIBUTE
     481     * @see org.greenstone.gatherer.util.StaticStrings#SPACE_CHARACTER
     482     * @see org.greenstone.gatherer.util.StaticStrings#SPEECH_CHARACTER
     483     */
     484    public String toString()
     485    {
     486        StringBuffer text = new StringBuffer("-");
     487
     488        if (element == null) {
     489            return text.toString();
     490        }
     491
     492        if (name == null) {
     493            name = element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
     494        }
     495        text.append(name);
     496
     497        String value = XMLTools.getValue(element);
     498        if (value.length() == 0) {
     499            return text.toString();
     500        }
     501
     502        text.append(StaticStrings.SPACE_CHARACTER);
     503
     504//      // Handle metadata elements specially
     505//      if (type == METADATA || type == METADATUM) {
     506//      // Tokenize the string
     507//      StringTokenizer tokenizer = new StringTokenizer(value, ",");
     508//      while (tokenizer.hasMoreTokens()) {
     509//      String token = tokenizer.nextToken();
     510
     511//      MetadataElement metadata_element = MetadataTools.getMetadataElementWithDisplayName(token);
     512//      if (metadata_element != null) {
     513//      text.append(metadata_element.getFullName());
     514//      }
     515//      else {
     516//      text.append(token);
     517//      }
     518
     519//      if (tokenizer.hasMoreTokens()) {
     520//      text.append(StaticStrings.COMMA_CHARACTER);
     521//      }
     522//      }
     523//      return text.toString();
     524//      }
     525
     526        // If the value contains a space, add speech marks
     527        //   (Except for metadata elements, which won't have spaces when written out to collect.cfg)
     528        if (value.indexOf(StaticStrings.SPACE_CHARACTER) != -1 && !(type == METADATUM || type == METADATA)) {
     529            value = StaticStrings.SPEECH_CHARACTER + value + StaticStrings.SPEECH_CHARACTER;
     530        }
     531
     532        text.append(value);
     533        return text.toString();
     534    }
     535
     536    /** parse the <Option> XML from eg import.pl -xml or pluginfo.pl -xml */
     537    public void parseXML(Element option) {
     538
     539        for(Node node = option.getFirstChild(); node != null; node = node.getNextSibling()) {
     540            String node_name = node.getNodeName();
     541            if(node_name.equals("Name")) {
     542                setName(XMLTools.getValue(node));
     543            }
     544            else if(node_name.equals("DisplayName")) {
     545                setDisplayName(XMLTools.getValue(node));
     546            }
     547            else if(node_name.equals("Desc")) {
     548                setDescription(XMLTools.getValue(node));
     549            }
     550            else if(node_name.equals("Type")) {
     551                setType(XMLTools.getValue(node));
     552            }
     553            else if(node_name.equals("Default")) {
     554                setDefaultValue(XMLTools.getValue(node));
     555            }
     556            else if(node_name.equals("Required")) {
     557                String v = XMLTools.getValue(node);
     558                if(v != null && v.equals("yes")) {
     559                    setRequired(true);
     560                }
     561            }
     562            else if(node_name.equals("List")) {
     563                // Two final loops are required to parse lists.
     564                for(Node value = node.getFirstChild(); value != null; value = value.getNextSibling()) {
     565                    if(value.getNodeName().equals("Value")) {
     566                        String key = null;
     567                        String desc = "";
     568                        for(Node subvalue = value.getFirstChild(); subvalue != null; subvalue = subvalue.getNextSibling()) {
     569                            node_name = subvalue.getNodeName();
     570                            if(node_name.equals("Name")) {
     571                                key = XMLTools.getValue(subvalue);
     572                            }
     573                            else if(node_name.equals("Desc")) {
     574                                desc = XMLTools.getValue(subvalue);
     575                            }
     576                        }
     577                        if(key != null) {
     578                            addOption(key, desc);
     579                        }
     580                    }
     581                }
     582            }
     583            else if(node_name.equals("Range")) {
     584                String range_raw = XMLTools.getValue(node);
     585                int index = -1;
     586                if((index = range_raw.indexOf(StaticStrings.COMMA_CHARACTER)) != -1) {
     587                    if(index > 0) {
     588                        try {
     589                            String first_number = range_raw.substring(0, index);
     590                            setMinimum(Integer.parseInt(first_number));
     591                            first_number = null;
     592                        }
     593                        catch(Exception exception) {
     594                        }
     595                    }
     596
     597                    if(index + 1 < range_raw.length()) {
     598                        try {
     599                            String second_number = range_raw.substring(index + 1);
     600                            setMaximum(Integer.parseInt(second_number));
     601                            second_number = null;   
     602                        }
     603                        catch(Exception exception) {
     604                        }
     605                    }
     606                }
     607                // Else it wasn't a valid range anyway, so ignore it
     608            }
     609            else if(node_name.equals("HiddenGLI")) {
     610                setHiddenGLI(true);
     611            }
     612            else if(node_name.equals("ModeGLI")) {
     613                String mode_level_str = XMLTools.getValue(node);
     614                try {
     615                    int mode_level = Integer.parseInt(mode_level_str);
     616                    setModeLevel(mode_level);
     617                }
     618                catch(Exception exception) {
     619                    DebugStream.println("Exception in Argument.parseXML() - Unexpected but non-fatal");
     620                    DebugStream.printStackTrace(exception);
     621                }
     622            }
     623
     624        } // for each option
     625
     626    } // parseXML
     627
     628    public class ArgumentOption
    620629    implements Comparable {
    621     public String name;
    622     public String description;
    623     private String text; // cached version
    624 
    625     public ArgumentOption(String name, String desc) {
    626         this.name = name;
    627         this.description = desc;
    628     }
    629    
    630     public int compareTo(Object obj) {
    631         return toString().compareTo(obj.toString());
    632     }
    633 
    634     public boolean equals(Object obj) {     
    635         return (obj != null && compareTo(obj) == 0);
    636     }
    637    
    638     public String toString() {
    639         return name + " "+ StaticStrings.MINUS_CHARACTER + " "+ description;
    640     }
    641    
    642     public String getToolTip() {
    643         return Utility.formatHTMLWidth(name+": "+description, 80);
    644     }
    645     }
     630        public String name;
     631        public String description;
     632        private String text; // cached version
     633
     634        public ArgumentOption(String name, String desc) {
     635            this.name = name;
     636            this.description = desc;
     637        }
     638
     639        public int compareTo(Object obj) {
     640            return toString().compareTo(obj.toString());
     641        }
     642
     643        public boolean equals(Object obj) {     
     644            return (obj != null && compareTo(obj) == 0);
     645        }
     646
     647        public String toString() {
     648            return name + " "+ StaticStrings.MINUS_CHARACTER + " "+ description;
     649        }
     650
     651        public String getToolTip() {
     652            return Utility.formatHTMLWidth(name+": "+description, 80);
     653        }
     654    }
    646655}
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/ArgumentConfiguration.java

    r12749 r18352  
    211211    int current_mode = Configuration.getMode();
    212212
    213     String previous_owner = ((Argument) arguments.get(0)).getOwner();
    214     addHeader(previous_owner, colour_two);
     213    String previous_owner = "";
     214    if(arguments.size() > 0) {
     215        previous_owner = ((Argument) arguments.get(0)).getOwner();
     216        addHeader(previous_owner, colour_two);
     217    }
    215218
    216219    for(int i = 0; i < arguments.size(); i++) {
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/ArgumentContainer.java

    r12826 r18352  
    4343 */
    4444abstract public class ArgumentContainer
    45     extends ArrayList
    46     implements Comparable, DOMProxyListEntry, Serializable  {
    47 
    48     // The DOM Element this container is modelled on
    49     protected Element element;
    50     protected boolean is_abstract = false;
    51     protected ArgumentContainer super_container;
    52     protected String description;
    53     protected String name;
    54 
    55     /** Constructor used in DOMProxyListModel initializations
    56      */
    57     public ArgumentContainer() {
    58     }
    59 
    60     public ArgumentContainer(Element element, ArgumentContainer base_container) {
    61 
    62     super();
    63     this.element = element;
    64     this.name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
    65 
    66     // Parse in any argument options for this container, keeping a list of the ones found
    67     HashMap known_arguments = new HashMap();
    68     NodeList option_elements = element.getElementsByTagName(StaticStrings.OPTION_ELEMENT);
    69     int option_elements_length = option_elements.getLength();
    70     for(int i = 0; i < option_elements_length; i++) {
    71         Element option_element = (Element) option_elements.item(i);
    72         Argument argument = new Argument(option_element);
    73         ///ystem.err.println("Rebuilding existing argument: " + argument.getName());
    74         known_arguments.put(argument.getName(), argument);
    75     }
    76     // If a base classifier was given
    77     if(base_container != null) {
    78         // Copy the details, and add a reference to whatever the base container's super container is
    79         description = base_container.getDescription();
    80         // Now search through the 'dummy' arguments belonging to the base container. For each found, if it is already assigned, fill out further details such as type. If any are found that are not already assigned for this container, copy them and add them, but without a value.
    81         ArrayList all_arguments = base_container.getArguments();
    82         int argument_count = all_arguments.size();
    83         for(int j = 0; j < argument_count; j++) {
    84         Argument base_argument = (Argument) all_arguments.get(j);
    85         String base_argument_name = base_argument.getName();
    86         ///ystem.err.println("Library indicates this container should have an argument: " + base_argument_name);
    87         Argument existing_argument = (Argument) known_arguments.get(base_argument_name);
    88         // Found an existing argument. Complete its details
    89         if(existing_argument != null) {
    90             ///ystem.err.println("Found existing argument. Filling out details.");
    91             known_arguments.remove(base_argument_name);
    92             existing_argument.setDefaultValue(base_argument.getDefaultValue());
    93             existing_argument.setDescription(base_argument.getDescription());
    94             existing_argument.setOptions(base_argument.getOptions());
    95             existing_argument.setRequired(base_argument.isRequired());
    96             existing_argument.setType(base_argument.getType());
    97             existing_argument.setMinimum(base_argument.getMinimum());
    98             existing_argument.setMaximum(base_argument.getMaximum());
    99             existing_argument.setOwner(base_argument.getOwner());
    100             existing_argument.setHiddenGLI(base_argument.isHiddenGLI());
    101             add(existing_argument);
    102         }
    103         // No existing argument. Copy base_argument and add it, but set its assigned flag to false
    104         else {
    105             ///atherer.println("No such argument. Adding new, unassigned, argument.");
    106             // The trick thing is that we have to create a new element in the DOM as well.
    107             Argument new_argument = base_argument.copy();
    108             Element argument_element = CollectionConfiguration.createElement(StaticStrings.OPTION_ELEMENT);
    109             argument_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, base_argument_name);
    110             argument_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR);
    111             new_argument.setElement(argument_element);
    112             // All done. Add it.
    113             element.appendChild(argument_element);
    114             add(new_argument);
    115         }
    116         }
    117     }
    118    
    119     // The first time we do this, the args come from the config file and
    120     // may contain invalid args. Here we remove them from the DOM.
    121     if (!known_arguments.isEmpty()) {
    122         Set entry_set = known_arguments.entrySet();
    123         Iterator entry_iterator = entry_set.iterator();
    124         while (entry_iterator.hasNext()) {
    125         Argument arg = (Argument)((Map.Entry)entry_iterator.next()).getValue();
    126         Element e = arg.getElement();
    127         element.removeChild(e);
    128         }
    129     }
    130     }
    131 
    132 
    133    
    134 
    135     /** Constructor used for the plugins that are in the DOMProxyList */
    136     /** Method to add an argument to this container. Only adds the argument if it isn't already present.
    137      * @param argument The <strong>Argument</strong> to add.
    138      */
    139     public void addArgument(Argument argument) {
    140     if(element == null && !contains(argument)) {
    141         add(argument);
    142         argument.setOwner(name);
    143     }
    144     }
    145 
    146     /** Method to compare two containers for ordering.
    147      * @param object The container we are comparing to, as an <strong>Object</strong>.
    148      * @return An <i>int</i> specifying the container order, using values as set out in String.
    149      * @see java.lang.String#compareTo
    150      */
    151     public int compareTo(Object object) {
    152     if(object == null ) {
    153         return -1;
    154     }
    155     return toString().compareTo(object.toString());
    156     }
    157 
    158     /** Method to determine if two containers are equal.
    159      * @param object The container to test against, as an <strong>Object</strong>.
    160      * @return <i>true</i> if they match (based on the equals method), <i>false</i> otherwise.
    161      */
    162 
    163     public boolean equals(Object object) {
    164     return (compareTo(object) == 0);
    165     }
    166 
    167     abstract public DOMProxyListEntry create(Element element);
    168     /** Method to retrieve an argument by its name.
    169      * @param name The name of the argument as a <strong>String</strong>.
    170      * @return The <strong>Argument</strong> requested, or <i>null</i> if no such argument.
    171      */
    172     public Argument getArgument(String name) {
    173     // The name given may still include the '-'
    174     if(name.startsWith("-")) {
    175         name = name.substring(1);
    176     }
    177     //ArrayList arguments = getArguments(true, true);
    178     ArrayList arguments = getArguments();
    179     for(int i = 0; i < arguments.size(); i++) {
    180         Argument argument = (Argument)arguments.get(i);
    181         if(argument.getName().equals(name)) {
    182         return argument;
    183         }
    184     }
    185     return null;
    186     }
    187 
    188     /** Method to retrieve the list of arguments from this container. Note that this method returns both the containers arguments plus its 'supers' arguments if any, and alphabetically orders them.
    189      * @return the arguments within a ArrayList
    190      */
    191     public ArrayList getArguments() {
    192     ArrayList arguments = new ArrayList();
    193     arguments.addAll(this);
    194     if(super_container != null) {
    195         ArrayList remainder = super_container.getArguments();
    196         remainder.removeAll(arguments);
    197         arguments.addAll(remainder);
    198     }
    199     return arguments;
    200 
    201     }
    202 
    203     public String getDescription() {
    204     return description;
    205     }
    206 
    207     public Element getElement() {
    208     return element;
    209     }
    210     /** Method to retrieve the name associated with this argument container.
    211      * @return the name as a String
    212      */
    213     public String getName() {
    214     if(name == null && element != null) {
    215         name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
    216     }
    217     return name;
    218     }
    219 
    220     public boolean isAbstract() {
    221     return is_abstract;
    222     }
    223 
    224     public boolean isAssigned() {
    225     return (element != null && !element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.FALSE_STR));
    226     }
    227 
    228     public void setAssigned(boolean assigned) {
    229     if(element != null) {
    230         element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (assigned ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
    231     }
    232     }
    233 
    234     public void setDescription(String description) {
    235     this.description = description;
    236     }
    237 
    238     public void setElement(Element element) {
    239     this.element = element;
    240     }
    241 
    242     public void setIsAbstract(boolean is_abstract) {
    243     this.is_abstract = is_abstract;
    244     }
    245 
    246     public void setName(String name) {
    247     this.name = name;
    248     }
    249 
    250     /** Method to set the value of the super_container.
    251      * @param super_container The new value of super_container as a <strong>ArgumentContainer</strong>, or <i>null</i> if this class has no inheritance.
    252      */
    253     public void setSuper(ArgumentContainer super_container) {
    254     this.super_container = super_container;
    255     }
    256 
    257     public String toString()
    258     {
    259     if (element == null) {
    260         return name;
    261     }
    262 
    263     if (name == null) {
    264         name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
    265     }
    266 
    267     StringBuffer text = new StringBuffer(" ");
    268     if (!isAssigned()) {
    269         text.append("#");
    270     }
    271     text.append(name);
    272 
    273     ArrayList arguments = getArguments();
    274     for (int i = 0; i < arguments.size(); i++) {
    275         Argument argument = (Argument) arguments.get(i);
    276         if (argument.isAssigned()) {
    277         text.append(" ");
    278         text.append(argument.toString());
    279         }
    280     }
    281 
    282     return text.toString();
    283     }
    284 
    285     public ArrayList getArguments(boolean include_normal, boolean include_custom){
    286     return this;
    287     }
     45extends ArrayList
     46implements Comparable, DOMProxyListEntry, Serializable  {
     47
     48    // The DOM Element this container is modelled on
     49    protected Element element;
     50    protected boolean is_abstract = false;
     51    protected ArgumentContainer super_container;
     52    protected String description;
     53    protected String name;
     54
     55    /** Constructor used in DOMProxyListModel initializations
     56     */
     57    public ArgumentContainer() {
     58    }
     59
     60    public ArgumentContainer(Element element, ArgumentContainer base_container) {
     61
     62        super();
     63        this.element = element;
     64        this.name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
     65
     66        // Parse in any argument options for this container, keeping a list of the ones found
     67        HashMap known_arguments = new HashMap();
     68        NodeList option_elements = element.getElementsByTagName(StaticStrings.OPTION_ELEMENT);
     69        int option_elements_length = option_elements.getLength();
     70        for(int i = 0; i < option_elements_length; i++) {
     71            Element option_element = (Element) option_elements.item(i);
     72            Argument argument = new Argument(option_element);
     73            ///ystem.err.println("Rebuilding existing argument: " + argument.getName());
     74            known_arguments.put(argument.getName(), argument);
     75        }
     76        // If a base classifier was given
     77        if(base_container != null) {
     78            // Copy the details, and add a reference to whatever the base container's super container is
     79            description = base_container.getDescription();
     80            // Now search through the 'dummy' arguments belonging to the base container. For each found, if it is already assigned, fill out further details such as type. If any are found that are not already assigned for this container, copy them and add them, but without a value.
     81            ArrayList all_arguments = base_container.getArguments();
     82            int argument_count = all_arguments.size();
     83            for(int j = 0; j < argument_count; j++) {
     84                Argument base_argument = (Argument) all_arguments.get(j);
     85                String base_argument_name = base_argument.getName();
     86                ///ystem.err.println("Library indicates this container should have an argument: " + base_argument_name);
     87                Argument existing_argument = (Argument) known_arguments.get(base_argument_name);
     88                // Found an existing argument. Complete its details
     89                if(existing_argument != null) {
     90                    ///ystem.err.println("Found existing argument. Filling out details.");
     91                    known_arguments.remove(base_argument_name);
     92                    existing_argument.setDisplayName(base_argument.getDisplayName());
     93                    existing_argument.setDefaultValue(base_argument.getDefaultValue());
     94                    existing_argument.setDescription(base_argument.getDescription());
     95                    existing_argument.setOptions(base_argument.getOptions());
     96                    existing_argument.setRequired(base_argument.isRequired());
     97                    existing_argument.setType(base_argument.getType());
     98                    existing_argument.setMinimum(base_argument.getMinimum());
     99                    existing_argument.setMaximum(base_argument.getMaximum());
     100                    existing_argument.setOwner(base_argument.getOwner());
     101                    existing_argument.setHiddenGLI(base_argument.isHiddenGLI());
     102                    add(existing_argument);
     103                }
     104                // No existing argument. Copy base_argument and add it, but set its assigned flag to false
     105                else {
     106                    ///atherer.println("No such argument. Adding new, unassigned, argument.");
     107                    // The trick thing is that we have to create a new element in the DOM as well.
     108                    Argument new_argument = base_argument.copy();
     109                    Element argument_element = CollectionConfiguration.createElement(StaticStrings.OPTION_ELEMENT);
     110                    argument_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, base_argument_name);
     111                    argument_element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR);
     112                    new_argument.setElement(argument_element);
     113                    // All done. Add it.
     114                    element.appendChild(argument_element);
     115                    add(new_argument);
     116                }
     117            }
     118        }
     119
     120        // The first time we do this, the args come from the config file and
     121        // may contain invalid args. Here we remove them from the DOM.
     122        if (!known_arguments.isEmpty()) {
     123            Set entry_set = known_arguments.entrySet();
     124            Iterator entry_iterator = entry_set.iterator();
     125            while (entry_iterator.hasNext()) {
     126                Argument arg = (Argument)((Map.Entry)entry_iterator.next()).getValue();
     127                Element e = arg.getElement();
     128                element.removeChild(e);
     129            }
     130        }
     131    }
     132
     133
     134
     135
     136    /** Constructor used for the plugins that are in the DOMProxyList */
     137    /** Method to add an argument to this container. Only adds the argument if it isn't already present.
     138     * @param argument The <strong>Argument</strong> to add.
     139     */
     140    public void addArgument(Argument argument) {
     141        if(element == null && !contains(argument)) {
     142            add(argument);
     143            argument.setOwner(name);
     144        }
     145    }
     146
     147    /** Method to compare two containers for ordering.
     148     * @param object The container we are comparing to, as an <strong>Object</strong>.
     149     * @return An <i>int</i> specifying the container order, using values as set out in String.
     150     * @see java.lang.String#compareTo
     151     */
     152    public int compareTo(Object object) {
     153        if(object == null ) {
     154            return -1;
     155        }
     156        return toString().compareTo(object.toString());
     157    }
     158
     159    /** Method to determine if two containers are equal.
     160     * @param object The container to test against, as an <strong>Object</strong>.
     161     * @return <i>true</i> if they match (based on the equals method), <i>false</i> otherwise.
     162     */
     163
     164    public boolean equals(Object object) {
     165        return (compareTo(object) == 0);
     166    }
     167
     168    abstract public DOMProxyListEntry create(Element element);
     169    /** Method to retrieve an argument by its name.
     170     * @param name The name of the argument as a <strong>String</strong>.
     171     * @return The <strong>Argument</strong> requested, or <i>null</i> if no such argument.
     172     */
     173    public Argument getArgument(String name) {
     174        // The name given may still include the '-'
     175        if(name.startsWith("-")) {
     176            name = name.substring(1);
     177        }
     178        //ArrayList arguments = getArguments(true, true);
     179        ArrayList arguments = getArguments();
     180        for(int i = 0; i < arguments.size(); i++) {
     181            Argument argument = (Argument)arguments.get(i);
     182            if(argument.getName().equals(name)) {
     183                return argument;
     184            }
     185        }
     186        return null;
     187    }
     188
     189    /** Method to retrieve the list of arguments from this container. Note that this method returns both the containers arguments plus its 'supers' arguments if any, and alphabetically orders them.
     190     * @return the arguments within a ArrayList
     191     */
     192    public ArrayList getArguments() {
     193        ArrayList arguments = new ArrayList();
     194        arguments.addAll(this);
     195        if(super_container != null) {
     196            ArrayList remainder = super_container.getArguments();
     197            remainder.removeAll(arguments);
     198            arguments.addAll(remainder);
     199        }
     200        return arguments;
     201
     202    }
     203
     204    public String getDescription() {
     205        return description;
     206    }
     207
     208    public Element getElement() {
     209        return element;
     210    }
     211    /** Method to retrieve the name associated with this argument container.
     212     * @return the name as a String
     213     */
     214    public String getName() {
     215        if(name == null && element != null) {
     216            name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
     217        }
     218        return name;
     219    }
     220
     221    public boolean isAbstract() {
     222        return is_abstract;
     223    }
     224
     225    public boolean isAssigned() {
     226        return (element != null && !element.getAttribute(StaticStrings.ASSIGNED_ATTRIBUTE).equals(StaticStrings.FALSE_STR));
     227    }
     228
     229    public void setAssigned(boolean assigned) {
     230        if(element != null) {
     231            element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, (assigned ? StaticStrings.TRUE_STR : StaticStrings.FALSE_STR));
     232        }
     233    }
     234
     235    public void setDescription(String description) {
     236        this.description = description;
     237    }
     238
     239    public void setElement(Element element) {
     240        this.element = element;
     241    }
     242
     243    public void setIsAbstract(boolean is_abstract) {
     244        this.is_abstract = is_abstract;
     245    }
     246
     247    public void setName(String name) {
     248        this.name = name;
     249    }
     250
     251    /** Method to set the value of the super_container.
     252     * @param super_container The new value of super_container as a <strong>ArgumentContainer</strong>, or <i>null</i> if this class has no inheritance.
     253     */
     254    public void setSuper(ArgumentContainer super_container) {
     255        this.super_container = super_container;
     256    }
     257
     258    public String toString()
     259    {
     260        if (element == null) {
     261            return name;
     262        }
     263
     264        if (name == null) {
     265            name = element.getAttribute(StaticStrings.TYPE_ATTRIBUTE);
     266        }
     267
     268        StringBuffer text = new StringBuffer(" ");
     269        if (!isAssigned()) {
     270            text.append("#");
     271        }
     272        text.append(name);
     273
     274        ArrayList arguments = getArguments();
     275        for (int i = 0; i < arguments.size(); i++) {
     276            Argument argument = (Argument) arguments.get(i);
     277            if (argument.isAssigned()) {
     278                text.append(" ");
     279                text.append(argument.toString());
     280            }
     281        }
     282
     283        return text.toString();
     284    }
     285
     286    public ArrayList getArguments(boolean include_normal, boolean include_custom){
     287        return this;
     288    }
    288289}
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/CollectionConfiguration.java

    r14636 r18352  
    293293                value = tokenizer.nextToken ();
    294294                // Test if the value is actually a name, and if so add the name by itself, then put value into name so that it is parsed correctly during the next loop.
    295                 if(value.startsWith (StaticStrings.MINUS_CHARACTER)) {
     295        // The value is not a name if it contains a space character: it's a quoted value
     296                if (value.startsWith(StaticStrings.MINUS_CHARACTER) && value.indexOf(StaticStrings.SPACE_CHARACTER) == -1) {
    296297                    arguments.put (name, null);
    297298                    name = value;
     
    439440        int option_elements_length = option_elements.getLength ();
    440441        for(int j = 0; j < option_elements_length; j++) {
    441             Element option_element = (Element) option_elements.item (j);
     442      Element option_element = (Element) option_elements.item (j);
    442443            if(option_element.getAttribute (StaticStrings.ASSIGNED_ATTRIBUTE).equals (StaticStrings.TRUE_STR)) {
    443                 text.append (StaticStrings.SPACE_CHARACTER);
    444                 text.append (StaticStrings.MINUS_CHARACTER);
    445                 text.append (option_element.getAttribute (StaticStrings.NAME_ATTRIBUTE));
    446                 String value_str = XMLTools.getValue (option_element);
    447                
     444          text.append (StaticStrings.SPACE_CHARACTER);
     445          text.append (StaticStrings.MINUS_CHARACTER);
     446          text.append (option_element.getAttribute (StaticStrings.NAME_ATTRIBUTE));
     447          String value_str = XMLTools.getValue (option_element);
     448             
    448449                // Convert metadata element names to internal names, and remove extracted metadata namespaces
    449450                if (value_str.length () > 0) {
     
    13301331                // The next token is the type
    13311332                String type = tokenizer.nextToken ();
     1333        type = ensureNewPluginName(type);
    13321334                command_element.setAttribute (StaticStrings.TYPE_ATTRIBUTE, type);
    13331335                // Now we parse out the remaining arguments into a hashmapping from name to value
     
    13721374        }
    13731375        catch(Exception exception) {
     1376        // This catch clause had been left empty.  If this is deliberate then
     1377        // we should have a comment here explaining why there is no need to
     1378        // print anything out.  Am assuming this is mistake for now, and
     1379        // have added in a call to printStackTrace()
     1380        System.err.println("Malformed plugin statement");
     1381        exception.printStackTrace();
    13741382        }
    13751383        return command_element;
     
    14201428                    command_element.setAttribute (StaticStrings.TYPE_ATTRIBUTE, StaticStrings.INCLUDE_STR);
    14211429                }
    1422                 StringTokenizer pattern_tokenizer = new StringTokenizer (full_pattern_str, StaticStrings.SEPARATOR_CHARACTER);
    1423                 if(pattern_tokenizer.countTokens () >= 2) {
    1424                     String content_str = pattern_tokenizer.nextToken ();
     1430
     1431                // Let's make sure it is a valid Greenstone configuration line
     1432                String[] results = full_pattern_str.split("\\" + StaticStrings.SEPARATOR_CHARACTER, 3);
     1433
     1434                if (results.length >= 2) {
     1435                    String content_str = results[0];
    14251436                    // Since the contents of indexes have to be certain keywords, or metadata elements, if the content isn't a keyword and doesn't yet have a namespace, append the extracted metadata namespace.
    1426                     if(!content_str.equals (StaticStrings.FILENAME_STR) && content_str.indexOf (StaticStrings.NS_SEP) == -1) {
     1437                    if (!content_str.equals (StaticStrings.FILENAME_STR) && content_str.indexOf (StaticStrings.NS_SEP) == -1) {
    14271438                        content_str = StaticStrings.EXTRACTED_NAMESPACE + content_str;
    14281439                    }
    14291440                    command_element.setAttribute (StaticStrings.CONTENT_ATTRIBUTE, content_str);
    1430                     XMLTools.setValue (command_element, pattern_tokenizer.nextToken ());
    1431                     if(pattern_tokenizer.hasMoreTokens ()) {
    1432                         command_element.setAttribute (StaticStrings.OPTIONS_ATTRIBUTE, pattern_tokenizer.nextToken ());
    1433                     }
    1434                 }
    1435                 pattern_tokenizer = null;
     1441                    XMLTools.setValue (command_element, results[1]);
     1442                    if (results.length >= 3) {
     1443                        command_element.setAttribute (StaticStrings.OPTIONS_ATTRIBUTE, results[2]);
     1444                    }
     1445                }
    14361446            }
    14371447        }
     
    15211531   
    15221532    static private String pluginToString (Element command_element, boolean show_extracted_namespace) {
    1523         StringBuffer text = new StringBuffer ();
    1524         if(!command_element.getAttribute (StaticStrings.SEPARATOR_ATTRIBUTE).equals (StaticStrings.TRUE_STR)) {
    1525             text.append (StaticStrings.PLUGIN_STR);
    1526             text.append (StaticStrings.TAB_CHARACTER);
    1527             text.append (StaticStrings.TAB_CHARACTER);
    1528             text.append (command_element.getAttribute (StaticStrings.TYPE_ATTRIBUTE));
    1529             // Retrieve, and output, the arguments
    1530             NodeList option_elements = command_element.getElementsByTagName (StaticStrings.OPTION_ELEMENT);
    1531             int option_elements_length = option_elements.getLength ();
    1532             if(option_elements_length > 0) {
    1533                 for(int j = 0; j < option_elements_length; j++) {
    1534                     Element option_element = (Element) option_elements.item (j);
    1535                     if(option_element.getAttribute (StaticStrings.ASSIGNED_ATTRIBUTE).equals (StaticStrings.TRUE_STR)) {
    1536                         text.append (StaticStrings.SPACE_CHARACTER);
    1537                         text.append (StaticStrings.MINUS_CHARACTER);
    1538                         text.append (option_element.getAttribute (StaticStrings.NAME_ATTRIBUTE));
    1539                         String value_str = XMLTools.getValue (option_element);
    1540                         if(!show_extracted_namespace && value_str.startsWith (StaticStrings.EXTRACTED_NAMESPACE)) {
    1541                             value_str = value_str.substring (StaticStrings.EXTRACTED_NAMESPACE.length ());
    1542                         }
    1543                         if(value_str.length () > 0) {
    1544                             text.append (StaticStrings.SPACE_CHARACTER);
    1545                             if(value_str.indexOf (StaticStrings.SPACE_CHARACTER) == -1) {
    1546                                 text.append (value_str);
    1547                             }
    1548                             else {
    1549                                 text.append (StaticStrings.SPEECH_CHARACTER);
    1550                                 text.append (value_str);
    1551                                 text.append (StaticStrings.SPEECH_CHARACTER);
    1552                             }
    1553                         }
    1554                         value_str = null;
    1555                     }
    1556                     option_element = null;
    1557                 }
    1558             }
    1559             option_elements = null;
    1560         }
    1561         return text.toString ();
     1533        if(command_element.getAttribute (StaticStrings.SEPARATOR_ATTRIBUTE).equals (StaticStrings.TRUE_STR)) {
     1534      return "";
     1535    }
     1536        StringBuffer text = new StringBuffer (StaticStrings.PLUGIN_STR);
     1537    text.append (StaticStrings.TAB_CHARACTER);
     1538    text.append (command_element.getAttribute (StaticStrings.TYPE_ATTRIBUTE));
     1539    // Retrieve, and output, the arguments
     1540    NodeList option_elements = command_element.getElementsByTagName (StaticStrings.OPTION_ELEMENT);
     1541    int option_elements_length = option_elements.getLength ();
     1542    if(option_elements_length > 0) {
     1543      for(int j = 0; j < option_elements_length; j++) {
     1544        Element option_element = (Element) option_elements.item (j);
     1545        if(option_element.getAttribute (StaticStrings.ASSIGNED_ATTRIBUTE).equals (StaticStrings.TRUE_STR)) {
     1546          text.append (StaticStrings.SPACE_CHARACTER);
     1547          text.append (StaticStrings.MINUS_CHARACTER);
     1548          text.append (option_element.getAttribute (StaticStrings.NAME_ATTRIBUTE));
     1549          String value_str = XMLTools.getValue (option_element);
     1550
     1551         
     1552          // Convert metadata element names to internal names, and remove extracted metadata namespaces
     1553          if (value_str.length () > 0) {
     1554        StringTokenizer string_tokenizer = new StringTokenizer (value_str, ",");
     1555        StringBuffer value_buffer = new StringBuffer ();
     1556        while (string_tokenizer.hasMoreElements ()) {
     1557          String raw_token = (String) string_tokenizer.nextElement ();
     1558          String token = raw_token.trim ();
     1559          MetadataElement metadata_element = MetadataTools.getMetadataElementWithDisplayName (token);
     1560          if (metadata_element != null) {
     1561            token = metadata_element.getFullName ();
     1562          }
     1563                       
     1564          if (token.startsWith (StaticStrings.EXTRACTED_NAMESPACE)) {
     1565            token = token.substring (StaticStrings.EXTRACTED_NAMESPACE.length ());
     1566          }
     1567          value_buffer.append (token);
     1568          if (string_tokenizer.hasMoreElements ()) {
     1569            value_buffer.append (",");
     1570          }
     1571        }
     1572        value_str = value_buffer.toString ();
     1573          }
     1574
     1575          // if(!show_extracted_namespace && value_str.startsWith (StaticStrings.EXTRACTED_NAMESPACE)) {
     1576          //            value_str = value_str.substring (StaticStrings.EXTRACTED_NAMESPACE.length ());
     1577          //        }
     1578          if(value_str.length () > 0) {
     1579        text.append (StaticStrings.SPACE_CHARACTER);
     1580        if(value_str.indexOf (StaticStrings.SPACE_CHARACTER) == -1) {
     1581          text.append (value_str);
     1582        }
     1583        else {
     1584          text.append (StaticStrings.SPEECH_CHARACTER);
     1585          text.append (value_str);
     1586          text.append (StaticStrings.SPEECH_CHARACTER);
     1587        }
     1588          }
     1589          value_str = null;
     1590        }
     1591        option_element = null;
     1592      }
     1593    }
     1594    option_elements = null;
     1595   
     1596    return text.toString ();
    15621597    }
    15631598   
     
    17191754            e.setAttribute (StaticStrings.LANGUAGE_ATTRIBUTE, lang);
    17201755            XMLTools.setNodeText (e, text);
    1721            
    17221756            display_item_list.add (e);
    17231757        }
     
    18731907            Element e = (Element)index_children.item (i);
    18741908            String index_str = e.getAttribute (StaticStrings.NAME_ATTRIBUTE);
    1875             String index_str_display = index_str;//for creating collectionmetadata for this index
     1909            String index_str_display = index_str;//for creating collectionmetadata for this index 
    18761910           
    18771911            // Handling 'index' element
     
    20472081            Element e = (Element)plugin_children.item (i);
    20482082            String str = e.getAttribute (StaticStrings.NAME_ATTRIBUTE);
     2083        str = ensureNewPluginName(str);
    20492084            Element plugin_element = to.createElement (StaticStrings.PLUGIN_ELEMENT);
    20502085            plugin_element.setAttribute (StaticStrings.TYPE_ATTRIBUTE, str);
     
    21972232            }
    21982233            if (format != null) {
    2199                 String gsf_text = XMLTools.xmlNodeToStringWithoutNewline(format);
    2200                 
     2234                String gsf_text = XMLTools.xmlNodeToStringWithoutIndenting(format);
     2235               
    22012236                if (gsf_text.startsWith("<") && (gsf_text.indexOf("<") != gsf_text.lastIndexOf("<"))) {
    22022237                    gsf_text = gsf_text.substring(gsf_text.indexOf("<gsf"),
     
    30903125            StaticStrings.NAME_ATTRIBUTE, index_value);
    30913126           
    3092             if (collectionmetadata_list == null) {
    3093                 //try adding the "." prefix
    3094                 index_value = StaticStrings.DOT_CHARACTER + index_value;
    3095                 collectionmetadata_list = XMLTools.getNamedElementList (source,
    3096                 StaticStrings.COLLECTIONMETADATA_ELEMENT,
    3097                 StaticStrings.NAME_ATTRIBUTE, index_value);
    3098             }
    30993127            if (collectionmetadata_list != null) {
    31003128               
     
    31493177            StaticStrings.NAME_ATTRIBUTE, name_str);
    31503178           
    3151             if (collectionmetadata_list == null) {
    3152                 //try adding the "." prefix
    3153                 name_str = StaticStrings.DOT_CHARACTER + name_str;
    3154                 collectionmetadata_list = XMLTools.getNamedElementList (source,
    3155                 StaticStrings.COLLECTIONMETADATA_ELEMENT,
    3156                 StaticStrings.NAME_ATTRIBUTE, name_str);
    3157             }
    31583179            if (collectionmetadata_list != null) {
    31593180               
     
    32913312            StaticStrings.NAME_ATTRIBUTE, temp_str);
    32923313           
    3293             if (collectionmetadata_list == null) {
    3294                 //try adding the "." prefix
    3295                 String with_dot_str = StaticStrings.DOT_CHARACTER + temp_str;
    3296                 collectionmetadata_list = XMLTools.getNamedElementList (source,
    3297                 StaticStrings.COLLECTIONMETADATA_ELEMENT,
    3298                 StaticStrings.NAME_ATTRIBUTE, with_dot_str);
    3299                
    3300                 if (collectionmetadata_list == null) {
    3301                     //try the full name, i.e. with 'ex.'
    3302                     if (mg_indexer == true) {
    3303                         full_index_name = level_str+StaticStrings.COLON_CHARACTER+full_index_name;
    3304                     }
    3305                     collectionmetadata_list = XMLTools.getNamedElementList (source,
    3306                     StaticStrings.COLLECTIONMETADATA_ELEMENT,
    3307                     StaticStrings.NAME_ATTRIBUTE, full_index_name);
    3308                 }
    3309                 if (collectionmetadata_list == null) {
    3310                     with_dot_str = StaticStrings.DOT_CHARACTER + full_index_name;
    3311                     collectionmetadata_list = XMLTools.getNamedElementList (source,
    3312                     StaticStrings.COLLECTIONMETADATA_ELEMENT,
    3313                     StaticStrings.NAME_ATTRIBUTE, with_dot_str);
    3314                 }
    3315             }
     3314        if (collectionmetadata_list == null) {
     3315          //try the full name, i.e. with 'ex.'
     3316          if (mg_indexer == true) {
     3317        // but first append level info if we are mg
     3318        full_index_name = level_str+StaticStrings.COLON_CHARACTER+full_index_name;
     3319          }
     3320          collectionmetadata_list = XMLTools.getNamedElementList (source,
     3321                 StaticStrings.COLLECTIONMETADATA_ELEMENT,
     3322                 StaticStrings.NAME_ATTRIBUTE, full_index_name);
     3323        }
     3324   
    33163325            if (collectionmetadata_list != null) {
    33173326               
     
    33683377            StaticStrings.NAME_ATTRIBUTE, name_str);
    33693378           
    3370             if (collectionmetadata_list == null) {
    3371                 //try adding the "." prefix
    3372                 name_str = StaticStrings.DOT_CHARACTER + name_str;
    3373                 collectionmetadata_list = XMLTools.getNamedElementList (source,
    3374                 StaticStrings.COLLECTIONMETADATA_ELEMENT,
    3375                 StaticStrings.NAME_ATTRIBUTE, name_str);
    3376             }
    33773379            if (collectionmetadata_list != null) {
    33783380               
     
    37323734        // If we're using a remote Greenstone server, upload the new 'collectionConfig.xml' file
    37333735        if (Gatherer.isGsdlRemote) {
    3734             RemoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
     3736            Gatherer.remoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
    37353737        }
    37363738       
     
    38243826            // If we're using a remote Greenstone server, upload the new collect.cfg file
    38253827            if (Gatherer.isGsdlRemote) {
    3826                 RemoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
     3828                Gatherer.remoteGreenstoneServer.uploadCollectionFile (collection_name, collect_cfg_file);
    38273829            }
    38283830        }
     
    38863888        return skeleton;
    38873889    }
     3890
     3891  static private HashMap plugin_map = null;
     3892 
     3893  private void setUpPluginNameMap() {
     3894    plugin_map = new HashMap();
     3895    plugin_map.put("GAPlug", "GreenstoneXMLPlugin");
     3896    plugin_map.put("RecPlug", "DirectoryPlugin");
     3897    plugin_map.put("ArcPlug","ArchivesInfPlugin");
     3898    plugin_map.put("TEXTPlug","TextPlugin");
     3899    plugin_map.put("XMLPlug","ReadXMLFile");
     3900    plugin_map.put("EMAILPlug","EmailPlugin");
     3901    plugin_map.put("SRCPlug","SourceCodePlugin");
     3902    plugin_map.put("NULPlug","NulPlugin");
     3903    plugin_map.put("W3ImgPlug","HTMLImagePlugin");
     3904    plugin_map.put("PagedImgPlug","PagedImagePlugin");
     3905    plugin_map.put("METSPlug", "GreenstoneMETSPlugin");
     3906    plugin_map.put("DBPlug", "DatabasePlugin");
     3907    plugin_map.put("PPTPlug", "PowerPointPlugin");
     3908    plugin_map.put("PSPlug", "PostScriptPlugin");
     3909  }
     3910
     3911  private String ensureNewPluginName(String plugin) {
     3912    if (plugin.endsWith("Plugin")) return plugin;
     3913    if (plugin_map == null) {
     3914      setUpPluginNameMap();
     3915    }
     3916    String new_name = (String)plugin_map.get(plugin);
     3917    if (new_name != null) return new_name;
     3918    new_name = plugin.replaceAll("Plug", "Plugin");
     3919    return new_name;
     3920  }
     3921   
     3922
    38883923    ///*********************************************************************************************************///
    38893924}
     3925
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/CollectionDesignManager.java

    r14237 r18352  
    7878    /** The text translation manager. */
    7979    static public TranslationView translation_manager;
     80    /** A manager of configuring depositor metadata */
     81    static public DepositorMetadataManager depositormetadata_manager;
    8082    /** These mark what needs to happen when building a collection where ONLY design options have been changed.
    8183        The build requirements of the higher numbers must include doing everything from the lower numbers. */
     
    128130    supercollection_manager = new SuperCollectionManager(collect_config.getSuperCollection());
    129131    searchmetadata_manager = new SearchMetadataManager();
     132    depositormetadata_manager = new DepositorMetadataManager();
    130133    translation_manager = new TranslationView();
    131134    if (Gatherer.GS3) {
     
    160163    supercollection_manager.destroy();
    161164    supercollection_manager = null;
     165    depositormetadata_manager.destroy();
     166    depositormetadata_manager = null;
    162167    translation_manager.destroy();
    163168    translation_manager = null;
     
    178183    language_manager.modeChanged(mode);
    179184    searchmetadata_manager.modeChanged(mode);
     185    depositormetadata_manager.modeChanged(mode);
    180186    }
    181187
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/Format.java

    r13368 r18352  
    4242
    4343    /** The default features (not all of these are in the Greenstone Developer's Guide). */
    44     static final public String DEFAULT_FEATURES[] = { "", "AllowExtendedOptions", "Document", "DocumentArrowsBottom", "DocumentArrowsTop","DocumentSearchResultLinks", "DocumentButtons", "DocumentContents", "DocumentHeading", "DocumentImages", "DocumentText", "DocumentTitles", "DocumentUseHTML", "RelatedDocuments", "Search", "SearchTypes" };
     44    static final public String DEFAULT_FEATURES[] = { "", "AllowExtendedOptions", "Document", "DocumentArrowsBottom", "DocumentArrowsTop","DocumentSearchResultLinks", "DocumentButtons", "DocumentContents", "DocumentHeading", "DocumentImages", "DocumentText", "DocumentTitles", "DocumentUseHTML", "NavigationBar", "RelatedDocuments", "Search", "SearchTypes" };
    4545    /** The list of known feature parts. */
    4646    static final public String DEFAULT_PARTS[] = { "", "DateList", "HList", "VList" };
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/FormatManager.java

    r14746 r18352  
    7777  static final private String SEARCHTYPES_DEFAULT_FORMAT = "plain,form";
    7878 
     79  static final private String NAVBAR = "NavigationBar";
     80  static final private String NAVBAR_OPTION = "pulldown";
     81
    7982  static private HashMap default_format_map = null;
    8083 
     
    98101    default_format_map.put(DOCUMENTBUTTONS, DOCUMENTBUTTONS_DEFAULT_FORMAT);
    99102    default_format_map.put(SEARCHTYPES, SEARCHTYPES_DEFAULT_FORMAT);
     103    default_format_map.put(NAVBAR, NAVBAR_OPTION);
    100104    default_format_map.put("", "");
    101105   
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r14587 r18352  
    299299        String creator_email_str = creator_emailfield.getText();
    300300        creator_collectionmeta.setValue(creator_email_str);
    301         // If the email is currently empty, store this email
    302         if(Configuration.getEmail() == null) {
    303         Configuration.setEmail(creator_email_str); // Store the email address in the configuration
    304         }
    305301        collection_extra_collectionmeta.setValue(description_textarea.getText());
    306302        icon_collection_collectionmeta.setValue(icon_textfield.getText());
     
    348344                // If we're using a remote Greenstone server, upload the image
    349345                if (Gatherer.isGsdlRemote) {
    350                 RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), collection_image_file);
     346                Gatherer.remoteGreenstoneServer.uploadCollectionFile(
     347                                   CollectionManager.getLoadedCollectionName(), collection_image_file);
    351348                }
    352349            }
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/IndexOptionManager.java

    r13468 r18352  
    190190    private JCheckBox casefold_checkbox = new JCheckBox();
    191191    private JCheckBox accentfold_checkbox = new JCheckBox();
    192 
     192    private JCheckBox separate_cjk_checkbox =new JCheckBox();
     193   
    193194    public StemmingControl()
    194195    {
     
    197198       
    198199        stem_checkbox.setText(Dictionary.get("CDM.IndexingManager.Stem"));
     200        stem_checkbox.setToolTipText(Dictionary.get("CDM.IndexingManager.Stem_Tooltip"));
    199201        stem_checkbox.setActionCommand(StaticStrings.STEM_OPTION_STR);
    200202       
    201203        casefold_checkbox.setText(Dictionary.get("CDM.IndexingManager.Casefold"));
     204        casefold_checkbox.setToolTipText(Dictionary.get("CDM.IndexingManager.Casefold_Tooltip"));
    202205        casefold_checkbox.setActionCommand(StaticStrings.CASEFOLD_OPTION_STR);
    203206       
    204207        accentfold_checkbox.setText(Dictionary.get("CDM.IndexingManager.Accent_fold"));
     208        accentfold_checkbox.setToolTipText(Dictionary.get("CDM.IndexingManager.Accent_fold_Tooltip"));
    205209        accentfold_checkbox.setActionCommand(StaticStrings.ACCENTFOLD_OPTION_STR);
    206210        // Accent-folding is currently not available for MG
    207211        accentfold_checkbox.setEnabled(!build_type.equals(BuildTypeManager.BUILD_TYPE_MG));
    208        
     212   
     213        separate_cjk_checkbox.setText(Dictionary.get("CDM.IndexingManager.Separate_cjk"));
     214        separate_cjk_checkbox.setToolTipText(Dictionary.get("CDM.IndexingManager.Separate_cjk_Tooltip"));
     215        separate_cjk_checkbox.setActionCommand(StaticStrings.SEPARATE_CJK_OPTION_STR);
     216
    209217        JPanel checkbox_panel = new JPanel();
    210         checkbox_panel.setLayout(new GridLayout(1, 3));
    211         checkbox_panel.add(stem_checkbox);
    212         checkbox_panel.add(casefold_checkbox);
    213         checkbox_panel.add(accentfold_checkbox);
    214        
     218        checkbox_panel.setLayout(new GridLayout(2, 1));
     219       
     220        JPanel stem_panel = new JPanel();
     221        stem_panel.setLayout(new GridLayout(1,3));
     222        stem_panel.add(stem_checkbox);
     223        stem_panel.add(casefold_checkbox);
     224        stem_panel.add(accentfold_checkbox);
     225       
     226        JPanel other_panel = new JPanel();
     227        other_panel.setLayout(new GridLayout(1,1));
     228        other_panel.add(separate_cjk_checkbox);
     229
     230        checkbox_panel.add(stem_panel);
     231        checkbox_panel.add(other_panel);
     232
    215233        add(new JLabel(Dictionary.get("CDM.IndexingManager.Options")), BorderLayout.WEST);
    216234        add(checkbox_panel, BorderLayout.CENTER);
     
    227245            stem_model.addOption(StaticStrings.ACCENTFOLD_OPTION_STR);
    228246        }
     247        separate_cjk_checkbox.setSelected(false);
    229248        }
    230249        else {
     
    238257            accentfold_checkbox.setSelected(true);
    239258        }
     259        if (stem_model.getOption(StaticStrings.SEPARATE_CJK_OPTION_STR) != null) {
     260            separate_cjk_checkbox.setSelected(true);
     261        }
     262       
    240263       
    241264        }
     
    245268        casefold_checkbox.addActionListener(cbl);
    246269        accentfold_checkbox.addActionListener(cbl);
    247 
     270        separate_cjk_checkbox.addActionListener(cbl);
     271       
    248272        // changing stem indexes changes build settings
    249273        stem_checkbox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    250274        casefold_checkbox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    251275        accentfold_checkbox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    252 
     276        separate_cjk_checkbox.addActionListener(CollectionDesignManager.buildcol_change_listener);
    253277       
    254278    }
     
    258282        if (new_build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
    259283        //changing to MG
     284        accentfold_checkbox.setSelected(false);
    260285        accentfold_checkbox.setEnabled(false);
    261286        if (accentfold_checkbox.isSelected()) {
     
    307332        document_checkbox = new JCheckBox();
    308333        document_checkbox.setText(Dictionary.get("CDM.LevelManager.Document"));
     334        document_checkbox.setActionCommand(StaticStrings.DOCUMENT_STR);
    309335        document_default_radio = new JRadioButton();
    310336        document_default_radio.setBackground(Configuration.getColor("coloring.collection_tree_background", false));
     
    316342        section_checkbox = new JCheckBox();
    317343        section_checkbox.setText(Dictionary.get("CDM.LevelManager.Section"));
     344        section_checkbox.setActionCommand(StaticStrings.SECTION_STR);
    318345        section_default_radio = new JRadioButton();
    319346        section_default_radio.setOpaque(true);
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/MacrosManager.java

    r13591 r18352  
    217217        // Users need to wait until the upload has finished before pressing Preview Collection!
    218218        if (Gatherer.isGsdlRemote) {
    219             RemoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), extra_dm_file);
     219            Gatherer.remoteGreenstoneServer.uploadCollectionFile(CollectionManager.getLoadedCollectionName(), extra_dm_file);
    220220        }
    221221        }
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/Plugin.java

    r13177 r18352  
    4242    private String default_process_expression = "";
    4343    private boolean does_explode_metadata_databases = false;
    44     private boolean loading_options_failed = false;
    45 
    46    
     44    private boolean does_replace_srcdocs_with_html = false; // to work with replace_srcdoc_with_html.pl
     45    /** Plugins are loaded as needed. This variable indicates 1. whether a plugin has been loaded already; 2. whether a
     46     * plugin has been successfully loaded. When both are true, has_loaded_options will be true. */
     47    private boolean has_loaded_options = false;
     48
    4749    /** Constructor used in DOMProxyListModel initializations, and Library Level. Used for Base plugins (those in the list of available plugins, not ones that are in the DOMProxyList)
    4850     */
     
    8486
    8587
    86     public boolean didLoadingOptionsFail()
    87     {
    88     return loading_options_failed;
     88    public boolean hasLoadedOptions()
     89    {
     90    return has_loaded_options;
    8991    }
    9092
     
    100102    }
    101103
     104    /** Checks whether the plugin this instance is based on processes source documents that can be replaced with their Greenstone generated html variants.
     105     * This method works with replace_srcdoc_with_html.pl */
     106    public boolean doesReplaceSrcDocsWithHtml()
     107    {
     108    //return does_replace_srcdocs_with_html;
     109    Plugin base_plugin = Plugins.getPlugin(getName(), false);
     110    if (base_plugin == null) {
     111      return false;
     112    }
     113    return base_plugin.does_replace_srcdocs_with_html;
     114    }
    102115
    103116    /** Checks whether this plugin instance will process the specified file (given its block_exp). */
     
    211224    }
    212225
    213 
    214     public void setLoadingOptionsFailed()
    215     {
    216     this.loading_options_failed = true;
     226    // To work with replace_srcdoc_with_html.pl
     227    public void setDoesReplaceSrcDocsWithHtml(boolean does_replace_srcdocs_with_html)
     228    {
     229    this.does_replace_srcdocs_with_html = does_replace_srcdocs_with_html;
     230    }
     231
     232    public void setHasLoadedOptions(boolean hasLoadedOptions)
     233    {
     234    this.has_loaded_options = hasLoadedOptions;
    217235    }
    218236}
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/PluginManager.java

    r14234 r18352  
    7070    private JPanel separator;
    7171    private Plugin separator_plugin;
     72
     73  /** The number of plugins that are fixed 'below the line' */
     74  private static int NUM_FIXED_PLUGINS = 3;
    7275    /** Constructor.
    7376     */
     
    9396    private void ensureMetadataXMLPlugIsLoaded() {
    9497
    95     Plugin metaxmlplug = Plugins.getPlugin("MetadataXMLPlug", false);
     98    Plugin metaxmlplug = Plugins.getPlugin(StaticStrings.METADATAXMLPLUG_STR, false);
    9699    if (metaxmlplug!= null) {
    97100        if (!contains(metaxmlplug)) {
     
    117120        if (!plugin.isAbstract()) {
    118121        String plugin_name = plugin.getName();
    119         if (!plugin_name.equals(StaticStrings.ARCPLUG_STR) && !plugin_name.equals(StaticStrings.RECPLUG_STR)) {
    120             available.add(plugin);
     122        if (!plugin_name.equals(StaticStrings.ARCPLUG_STR) && !plugin_name.equals(StaticStrings.RECPLUG_STR) && !plugin_name.equals(StaticStrings.METADATAXMLPLUG_STR)) {
     123          available.add(plugin);
    121124        }
    122125        }
     
    148151    return exploder_plugins;   
    149152    }
    150 
    151153   
    152154    public boolean isFileExplodable(File file)
     
    163165    }
    164166
     167    // Works with replace_srcdoc_with_html.pl
     168    public ArrayList getSrcReplacerPlugins(File file)
     169    {
     170    ArrayList srcreplacer_plugins = new ArrayList();
     171    ArrayList plugins_list = Plugins.getPluginsList();
     172    for (int i = 0; i < plugins_list.size(); i++) {
     173        Plugin plugin = (Plugin) plugins_list.get(i);
     174        if (plugin.doesReplaceSrcDocsWithHtml() == true && plugin.doesProcessFile(file)) {
     175        srcreplacer_plugins.add(plugin);
     176        }
     177    }
     178
     179    return srcreplacer_plugins;
     180    }   
     181
     182    // Works with replace_srcdoc_with_html.pl
     183    public boolean isFileSrcReplaceable(File file)
     184    {
     185    ArrayList plugins_list = Plugins.getPluginsList();
     186    for (int i = 0; i < plugins_list.size(); i++) {
     187        Plugin plugin = (Plugin) plugins_list.get(i);
     188       
     189        if (plugin.doesReplaceSrcDocsWithHtml() == true && plugin.doesProcessFile(file) == true) {
     190        return true;
     191        }
     192    }
     193
     194    return false;
     195    }   
    165196
    166197    /** Method to assign a plugin
     
    168199     */
    169200    private void assignPlugin(Plugin plugin) {
    170     if(plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.ARCPLUG_STR)) {
     201      if(plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.METADATAXMLPLUG_STR)) {
    171202        addAfter(plugin, separator_plugin); // Adds after separator
    172203    } else {
     
    245276    int result = super.getSize();
    246277    if(modify_row_count) {
    247         result = result-3;
     278      result = result-(NUM_FIXED_PLUGINS+1);
    248279    }
    249280    return result;
     
    267298    private void movePlugin(Plugin plugin, boolean direction, boolean all) {
    268299    // Can't ever move RecPlug or ArcPlug
    269     if(super.getSize() < 4) {
     300      if(super.getSize() < (NUM_FIXED_PLUGINS+2)) {
    270301        //DebugStream.println("Not enough plugins to allow moving.");
    271302        return;
    272303    }
    273     if(plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.RECPLUG_STR)) {
     304    if(plugin.getName().equals(StaticStrings.ARCPLUG_STR) || plugin.getName().equals(StaticStrings.RECPLUG_STR) || plugin.getName().equals(StaticStrings.METADATAXMLPLUG_STR)) {
    274305        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CDM.Move.Fixed"), Dictionary.get("CDM.Move.Title"), JOptionPane.ERROR_MESSAGE);
    275306        return;
     
    336367        Plugin plugin = (Plugin) getElementAt(index);
    337368        String name = plugin.getName();
    338         if(name.equals(StaticStrings.RECPLUG_STR) || name.equals(StaticStrings.ARCPLUG_STR)) {
     369        if(name.equals(StaticStrings.RECPLUG_STR) || name.equals(StaticStrings.ARCPLUG_STR) || name.equals(StaticStrings.METADATAXMLPLUG_STR)) {
    339370            found_fixed = true;
    340371            index--;
     
    370401
    371402
    372     /** Inform the model to hide/show the last three lines on the list.
    373      * @param modify_row_count true to hide the last three lines, false otherwise
     403    /** Inform the model to hide/show the last four lines on the list.
     404     * @param modify_row_count true to hide the last four lines, false otherwise
    374405     */
    375406    private void setHideLines(boolean modify_row_count) {
     
    377408    int original_size = super.getSize();
    378409    if(modify_row_count) {
    379         fireIntervalRemoved(this, original_size - 4, original_size - 1);
     410      fireIntervalRemoved(this, original_size - (NUM_FIXED_PLUGINS+2), original_size - 1);
    380411    }
    381412    else {
    382         fireIntervalAdded(this, original_size - 4, original_size - 1);
     413      fireIntervalAdded(this, original_size - (NUM_FIXED_PLUGINS+2), original_size - 1);
    383414    }
    384415    }
     
    696727            String plugin_name = selected_plugin.getName();
    697728            // Some buttons are only available for plugins other than ArcPlug and RecPlug
    698             if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR) ) {
     729            if(plugin_name.equals(StaticStrings.ARCPLUG_STR) || plugin_name.equals(StaticStrings.RECPLUG_STR) || plugin_name.equals(StaticStrings.METADATAXMLPLUG_STR)) {
    699730              move_up_button.setEnabled(false);
    700731              move_down_button.setEnabled(false);
    701732              remove.setEnabled(false);
    702             } else if (plugin_name.equals(StaticStrings.METADATAXMLPLUG_STR)) {
    703               remove.setEnabled(false);
    704             }
     733            }
    705734           
    706735            else {
    707               // don't let people remove special plugins such GAPlug an METSPlug,
     736              // don't let people remove special plugins such GreenstoneXMLPlug and GreenstoneMETSPlug,
    708737              // unless they are in systems mode or above
    709738              int mode = Configuration.getMode();
  • gli/branches/rtl-gli/src/org/greenstone/gatherer/cdm/SearchMetadataManager.java

    r13057 r18352  
    3333import org.greenstone.gatherer.Configuration;
    3434import org.greenstone.gatherer.Dictionary;
     35import org.greenstone.gatherer.Gatherer;
    3536import org.greenstone.gatherer.gui.DesignPaneHeader;
    3637import org.greenstone.gatherer.util.StaticStrings;
     
    182183   
    183184    public String getMetaID() {
    184         return StaticStrings.STOP_CHARACTER+id;
     185      if (Gatherer.GS3) {
     186        // we don't use any dots in gs3
     187        return id;
     188      }
     189      return StaticStrings.STOP_CHARACTER+id;
     190     
    185191    }
    186192    public String getValue() {
Note: See TracChangeset for help on using the changeset viewer.