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


Ignore:
Timestamp:
2007-07-20T16:35:06+02:00 (18 years ago)
Author:
imi
Message:
  • changed the order which directories are searched for images (~/.josm/images goes first)
  • made the crosshair cursor configurable
File:
1 edited

Legend:

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

    r292 r293  
    11package org.openstreetmap.josm.plugins;
     2
     3import static org.openstreetmap.josm.tools.I18n.tr;
    24
    35import java.io.File;
     
    810import java.util.ArrayList;
    911import java.util.Collection;
     12import java.util.LinkedList;
    1013import java.util.List;
    1114import java.util.Map;
     
    3336        public final int stage;
    3437        public final String version;
    35         public final List<URL> libraries = new ArrayList<URL>();
     38        public final List<URL> libraries = new LinkedList<URL>();
    3639
    3740        public final Map<String, String> attr = new TreeMap<String, String>();
     
    5255                this(file, file.getName().substring(0, file.getName().length()-4), null);
    5356        }
    54        
     57
    5558        public PluginInformation(File file, String name, InputStream manifestStream) {
    5659                this.name = name;
     
    6871                        manifest.read(manifestStream);
    6972                        }
    70                         Attributes attr = manifest.getMainAttributes();
    71                         className = attr.getValue("Plugin-Class");
    72                         description = attr.getValue("Plugin-Description");
    73                         early = Boolean.parseBoolean(attr.getValue("Plugin-Early"));
    74                         String stageStr = attr.getValue("Plugin-Stage");
    75                         stage = stageStr == null ? 50 : Integer.parseInt(stageStr);
    76                         version = attr.getValue("Plugin-Version");
    77                         author = attr.getValue("Author");
     73                        if (manifest != null) {
     74                                Attributes attr = manifest.getMainAttributes();
     75                                className = attr.getValue("Plugin-Class");
     76                                description = attr.getValue("Plugin-Description");
     77                                early = Boolean.parseBoolean(attr.getValue("Plugin-Early"));
     78                                String stageStr = attr.getValue("Plugin-Stage");
     79                                stage = stageStr == null ? 50 : Integer.parseInt(stageStr);
     80                                version = attr.getValue("Plugin-Version");
     81                                author = attr.getValue("Author");
     82
     83                                String classPath = attr.getValue(Attributes.Name.CLASS_PATH);
     84                                if (classPath != null) {
     85                                        String[] cp = classPath.split(" ");
     86                                        StringBuilder entry = new StringBuilder();
     87                                        for (String s : cp) {
     88                                                entry.append(s);
     89                                                if (s.endsWith("\\")) {
     90                                                        entry.setLength(entry.length()-1);
     91                                                        entry.append("%20"); // append the split character " " as html-encode
     92                                                        continue;
     93                                                }
     94                                                s = entry.toString();
     95                                                entry = new StringBuilder();
     96                                                if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.\\:") && file != null)
     97                                                        s = file.getParent() + File.separator + s;
     98                                                libraries.add(new URL(getURLString(s)));
     99                                        }
     100                                }
     101                                for (Object o : attr.keySet())
     102                                        this.attr.put(o.toString(), attr.getValue(o.toString()));
     103                        } else {
     104                                // resource-only plugin
     105                                className = null;
     106                                description = tr("unknown");
     107                                early = false;
     108                                stage = 50;
     109                                version = null;
     110                                author = null;
     111                        }
    78112                        if (file != null)
    79                                 libraries.add(new URL(getURLString(file.getAbsolutePath())));
    80                         String classPath = attr.getValue(Attributes.Name.CLASS_PATH);
    81                         if (classPath != null) {
    82                                 String[] cp = classPath.split(" ");
    83                                 StringBuilder entry = new StringBuilder();
    84                                 for (String s : cp) {
    85                                         entry.append(s);
    86                                         if (s.endsWith("\\")) {
    87                                                 entry.setLength(entry.length()-1);
    88                                                 entry.append("%20"); // append the split character " " as html-encode
    89                                                 continue;
    90                                         }
    91                                         s = entry.toString();
    92                                         entry = new StringBuilder();
    93                                         if (!s.startsWith("/") && !s.startsWith("\\") && !s.matches("^.\\:") && file != null)
    94                                                 s = file.getParent() + File.separator + s;
    95                                         libraries.add(new URL(getURLString(s)));
    96                                 }
    97                         }
    98 
    99                         for (Object o : attr.keySet())
    100                                 this.attr.put(o.toString(), attr.getValue(o.toString()));
     113                                libraries.add(0, new URL(getURLString(file.getAbsolutePath())));
     114
    101115                        if (jar != null)
    102116                                jar.close();
     
    122136         */
    123137        public Class<?> loadClass(ClassLoader classLoader) {
     138                if (className == null)
     139                        return null;
    124140                try {
    125141                        Class<?> realClass = Class.forName(className, true, classLoader);
Note: See TracChangeset for help on using the changeset viewer.