Changeset 167 in josm for src/org/openstreetmap/josm/plugins


Ignore:
Timestamp:
2006-11-24T15:52:34+01:00 (17 years ago)
Author:
imi
Message:
  • removed external tools (superseeded by plugins)
  • added align-in-line mode
  • added delete_if_empty-attribute to annotation presets
  • fixed exception when help is not available
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/plugins/PluginInformation.java

    r159 r167  
    66import java.net.URL;
    77import java.net.URLClassLoader;
     8import java.util.ArrayList;
     9import java.util.List;
    810import java.util.Map;
    911import java.util.TreeMap;
     
    2527        public final boolean early;
    2628        public final String author;
     29        public final List<URL> libraries = new ArrayList<URL>();
    2730
    2831        public final Map<String, String> attr = new TreeMap<String, String>();
    2932
     33        /**
     34         * @param file the plugin jar file.
     35         */
    3036        public PluginInformation(File file) {
    3137                this.file = file;
     
    3945                        early = Boolean.parseBoolean(attr.getValue("Plugin-Early"));
    4046                        author = attr.getValue("Author");
     47                        libraries.add(new URL(getURLString(file.getAbsolutePath())));
     48                        String classPath = attr.getValue("Class-Path");
     49                        if (classPath != null) {
     50                                for (String s : classPath.split(classPath.contains(";") ? ";" : ":")) {
     51                                        if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.:"))
     52                                                s = file.getParent() + File.separator + s;
     53                                        libraries.add(new URL(getURLString(s)));
     54                                }
     55                        }
     56
    4157                        for (Object o : attr.keySet())
    4258                                this.attr.put(o.toString(), attr.getValue(o.toString()));
     
    6379        public Class<?> loadClass() {
    6480                try {
    65                         ClassLoader loader = URLClassLoader.newInstance(
    66                                         new URL[]{new URL(getURLString())},
    67                                         getClass().getClassLoader());
     81                        URL[] urls = new URL[libraries.size()];
     82                        urls = libraries.toArray(urls);
     83                        ClassLoader loader = URLClassLoader.newInstance(urls, getClass().getClassLoader());
    6884                        Class<?> realClass = Class.forName(className, true, loader);
    6985                        return realClass;
     
    7389        }
    7490
    75         private String getURLString() {
     91        private String getURLString(String fileName) {
    7692                if (System.getProperty("os.name").startsWith("Windows"))
    77                         return "file:/"+file.getAbsolutePath();
    78                 return "file://"+file.getAbsolutePath();
     93                        return "file:/"+fileName;
     94                return "file://"+fileName;
    7995        }
    8096}
Note: See TracChangeset for help on using the changeset viewer.