Changeset 10009


Ignore:
Timestamp:
2005-06-03T14:49:55+12:00 (19 years ago)
Author:
mdewsnip
Message:

Moved Utility.getHelpFolder into HelpFrame, as part of tidying up the Utility class.

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

Legend:

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

    r10006 r10009  
    4444import javax.swing.event.*;
    4545import javax.swing.tree.*;
     46import org.greenstone.gatherer.Configuration;
    4647import org.greenstone.gatherer.DebugStream;
    4748import org.greenstone.gatherer.Dictionary;
     
    121122
    122123
     124    /** Retrieve the full file path to the help index xml file.
     125     * @return the full path as a String
     126     */
     127    private String getHelpFolder()
     128    {
     129    String help_folder = "help/" + Configuration.getLanguage() + "/";
     130
     131    // Try in the JAR/classes directory first
     132    URL help_folder_url = Utility.base.getResource("/" + help_folder);  // !!
     133    if (help_folder_url != null) {
     134        return help_folder;
     135    }
     136
     137    // Look in the base directory next
     138    File help_folder_file = new File(help_folder);
     139    if (help_folder_file.exists()) {
     140        return help_folder;
     141    }
     142
     143    // Resort to English
     144    return "help/" + StaticStrings.ENGLISH_LANGUAGE_STR  + "/";
     145    }
     146
     147
    123148    static public void setView(String section_name)
    124149    {
     
    162187        // Load the XML help file and build the contents structure from it
    163188        try {
    164         String help_index = Utility.getHelpFolder() + StaticStrings.HELP_INDEX_FILENAME;
     189        String help_index = getHelpFolder() + StaticStrings.HELP_INDEX_FILENAME;
    165190        Document document = XMLTools.parseXMLFile(help_index, true);
    166191
     
    291316        URL url = null;
    292317
    293         String help_file = Utility.getHelpFolder() + name + StaticStrings.HTM_FILE_EXTENSION;
     318        String help_file = getHelpFolder() + name + StaticStrings.HTM_FILE_EXTENSION;
    294319
    295320        if (name != null && !name.equals(NULL_STRING)) {
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r10008 r10009  
    412412
    413413
    414     /** Retrieve the full file path to the help index xml file.
    415      * @return the full path as a String
    416      */
    417     static public String getHelpFolder() {
    418 
    419     String help_folder = "help/" + Configuration.getLanguage() + "/";
    420 
    421     // Try in the JAR/classes directory first
    422     URL help_folder_url = base.getResource("/" + help_folder);
    423     if (help_folder_url != null) {
    424         return help_folder;
    425     }
    426 
    427     // Look in the base directory next
    428     File help_folder_file = new File(help_folder);
    429     if (help_folder_file.exists()) {
    430         return help_folder;
    431     }
    432 
    433     // Resort to English
    434     return "help/" + StaticStrings.ENGLISH_LANGUAGE_STR  + "/";
    435     }
    436 
    437414    /** Method to retrieve an image icon with the given filename found in classpath or the resouces directory.
    438415     *  @return The specified <strong>ImageIcon</strong>, or an error image replacement if no such images exists.
Note: See TracChangeset for help on using the changeset viewer.