Changeset 10013


Ignore:
Timestamp:
2005-06-03T15:50:07+12:00 (19 years ago)
Author:
mdewsnip
Message:

Now all JAR-file related, base.getResource* stuff is in the JarTools class.

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

Legend:

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

    r9875 r10013  
    4747import org.greenstone.gatherer.gui.URLField;
    4848import org.greenstone.gatherer.gui.WarningDialog;
     49import org.greenstone.gatherer.util.JarTools;
    4950import org.greenstone.gatherer.util.StaticStrings;
    5051import org.greenstone.gatherer.util.Utility;
     
    114115    this.self = this;
    115116
    116     Utility.initImages(this);
     117    JarTools.initialise(this);
    117118    }
    118119
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r10012 r10013  
    6565import org.greenstone.gatherer.gui.NonWhitespaceField;
    6666import org.greenstone.gatherer.util.Codec;
     67import org.greenstone.gatherer.util.JarTools;
    6768import org.greenstone.gatherer.util.Utility;
    6869import org.greenstone.gatherer.util.XMLTools;
     
    175176    //Load configuration file
    176177    this.self = this;
    177     Utility.initImages(this);
     178    JarTools.initialise(this);
    178179    config = new Configuration(gsdl_path, null, null);
    179180
  • trunk/gli/src/org/greenstone/gatherer/gui/HelpFrame.java

    r10011 r10013  
    131131
    132132    // Try in the JAR/classes directory first
    133     URL help_folder_url = Utility.base.getResource("/" + help_folder);  // !!
     133    URL help_folder_url = JarTools.getResource("/" + help_folder);
    134134    if (help_folder_url != null) {
    135135        return help_folder;
     
    320320
    321321        if (name != null && !name.equals(NULL_STRING)) {
    322         url = Utility.base.getResource("/" + help_file);
     322        url = JarTools.getResource("/" + help_file);
    323323        if (url == null) {
    324324            File file = new File(Utility.BASE_DIR + help_file);
  • trunk/gli/src/org/greenstone/gatherer/util/JarTools.java

    r10012 r10013  
    3030import java.awt.*;
    3131import java.io.*;
     32import java.net.*;
    3233import javax.swing.*;
    3334
     
    3536public class JarTools
    3637{
     38    static private Class root_class = null;
    3739    static private ImageIcon ERROR_ICON = null;
    38     // static public Class base = null;
    3940
    4041
    41     static public void initialise()
     42    static public void initialise(Object root_object)
    4243    {
     44    root_class = root_object.getClass();
    4345    ERROR_ICON = getImage("error.gif");
    4446    }
     
    4951    try {
    5052        // setup input stream for slurping out file
    51         InputStream fis = Utility.base.getResourceAsStream("/"+filename);
     53        InputStream fis = root_class.getResourceAsStream("/"+filename);
    5254        BufferedInputStream fbis = new BufferedInputStream(fis);
    5355        DataInputStream fdbis = new DataInputStream(fbis);
     
    8688    static public ImageIcon getImage(String filename, boolean wait_until_complete)
    8789    {
    88     ImageIcon image = new ImageIcon(Utility.base.getResource("/images/" + filename));
     90    ImageIcon image = new ImageIcon(root_class.getResource("/images/" + filename));
    8991    if (image == null) {
    9092        image = ERROR_ICON;
     
    103105
    104106
     107    static public URL getResource(String resource_name)
     108    {
     109    return root_class.getResource(resource_name);
     110    }
     111
     112
     113    static public InputStream getResourceAsStream(String resource_name)
     114    {
     115    return root_class.getResourceAsStream(resource_name);
     116    }
     117
     118
    105119    static public boolean isInJar(String filename)
    106120    {
    107121    try {
    108         InputStream fis = Utility.base.getResourceAsStream("/" + filename);         
     122        InputStream fis = root_class.getResourceAsStream("/" + filename);           
    109123        fis.close();
    110124    }
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r10012 r10013  
    123123
    124124    static protected File gli_user_folder = null;
    125 
    126     /** The default icon to produce a 'help-icon' sized blank space before a menu entry. */
    127     static public Class base = null;
    128125   
    129126
     
    847844
    848845
    849     static public void initImages(Object base_object)
    850     {
    851     base = base_object.getClass();
    852     }
    853 
    854 
    855846    /** Method to determine if the host system is MacOS based.
    856847     * @return a boolean which is true if the platform is MacOS, false otherwise
  • trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java

    r10006 r10013  
    103103    {
    104104    if (use_class_loader == true) {
    105         InputStream is = Utility.base.getResourceAsStream("/" + xml_file_path);  // !!
     105        InputStream is = JarTools.getResourceAsStream("/" + xml_file_path);
    106106        if (is != null) {
    107107        return parseXML(is);
Note: See TracChangeset for help on using the changeset viewer.