- Timestamp:
- 2009-05-28T17:45:04+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r1588 r1623 29 29 */ 30 30 public class PluginInformation { 31 32 public final File file; 33 public final String name; 34 public final String mainversion; 35 public final String className; 36 public final String requires; 37 public final String link; 38 public final String description; 39 public final boolean early; 40 public final String author; 41 public final int stage; 42 public final String version; 31 public File file = null; 32 public String name = null; 33 public String mainversion = null; 34 public String className = null; 35 public String requires = null; 36 public String link = null; 37 public String description = null; 38 public boolean early = false; 39 public String author = null; 40 public int stage = 50; 41 public String version = null; 43 42 public String downloadlink = null; 44 public finalList<URL> libraries = new LinkedList<URL>();43 public List<URL> libraries = new LinkedList<URL>(); 45 44 46 45 public final Map<String, String> attr = new TreeMap<String, String>(); … … 59 58 */ 60 59 public PluginInformation(File file) { 61 this(file, file.getName().substring(0, file.getName().length()-4) , null);62 } 63 64 public PluginInformation(File file, String name , InputStream manifestStream) {60 this(file, file.getName().substring(0, file.getName().length()-4)); 61 } 62 63 public PluginInformation(File file, String name) { 65 64 this.name = name; 66 65 this.file = file; 67 66 try { 68 Manifest manifest; 69 JarInputStream jar = null; 70 if (file != null) { 71 jar = new JarInputStream(new FileInputStream(file)); 72 manifest = jar.getManifest(); 73 if (manifest == null) 74 throw new IOException(file+" contains no manifest."); 75 } else { 76 manifest = new Manifest(); 77 manifest.read(manifestStream); 67 JarInputStream jar = new JarInputStream(new FileInputStream(file)); 68 Manifest manifest = jar.getManifest(); 69 if (manifest == null) 70 throw new IOException(file+" contains no manifest."); 71 scanManifest(manifest); 72 libraries.add(0, fileToURL(file)); 73 jar.close(); 74 } catch (IOException e) { 75 throw new PluginException(null, name, e); 76 } 77 } 78 79 public PluginInformation(InputStream manifestStream, String name) { 80 this.name = name; 81 try { 82 Manifest manifest = new Manifest(); 83 manifest.read(manifestStream); 84 scanManifest(manifest); 85 } catch (IOException e) { 86 throw new PluginException(null, name, e); 87 } 88 } 89 90 private void scanManifest(Manifest manifest) 91 { 92 String lang = Main.getLanguageCode()+"_"; 93 Attributes attr = manifest.getMainAttributes(); 94 className = attr.getValue("Plugin-Class"); 95 String s = attr.getValue(lang+"Plugin-Link"); 96 if(s == null) 97 s = attr.getValue("Plugin-Link"); 98 link = s; 99 requires = attr.getValue("Plugin-Requires"); 100 s = attr.getValue(lang+"Plugin-Description"); 101 if(s == null) 102 { 103 s = attr.getValue("Plugin-Description"); 104 if(s != null) 105 s = tr(s); 106 } 107 description = s; 108 early = Boolean.parseBoolean(attr.getValue("Plugin-Early")); 109 String stageStr = attr.getValue("Plugin-Stage"); 110 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 111 version = attr.getValue("Plugin-Version"); 112 mainversion = attr.getValue("Plugin-Mainversion"); 113 author = attr.getValue("Author"); 114 115 String classPath = attr.getValue(Attributes.Name.CLASS_PATH); 116 if (classPath != null) { 117 for (String entry : classPath.split(" ")) { 118 File entryFile; 119 if (new File(entry).isAbsolute()) 120 entryFile = new File(entry); 121 else 122 entryFile = new File(file.getParent(), entry); 123 124 libraries.add(fileToURL(entryFile)); 78 125 } 79 if (manifest != null) { 80 String s; 81 String lang = Main.getLanguageCode()+"_"; 82 Attributes attr = manifest.getMainAttributes(); 83 className = attr.getValue("Plugin-Class"); 84 s = attr.getValue(lang+"Plugin-Link"); 85 if(s == null) 86 s = attr.getValue("Plugin-Link"); 87 link = s; 88 requires = attr.getValue("Plugin-Requires"); 89 s = attr.getValue(lang+"Plugin-Description"); 90 if(s == null) 91 { 92 s = attr.getValue("Plugin-Description"); 93 if(s != null) 94 s = tr(s); 95 } 96 description = s; 97 early = Boolean.parseBoolean(attr.getValue("Plugin-Early")); 98 String stageStr = attr.getValue("Plugin-Stage"); 99 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 100 version = attr.getValue("Plugin-Version"); 101 mainversion = attr.getValue("Plugin-Mainversion"); 102 author = attr.getValue("Author"); 103 104 String classPath = attr.getValue(Attributes.Name.CLASS_PATH); 105 if (classPath != null) { 106 for (String entry : classPath.split(" ")) { 107 File entryFile; 108 if (new File(entry).isAbsolute()) { 109 entryFile = new File(entry); 110 } else { 111 entryFile = new File(file.getParent(), entry); 112 } 113 114 libraries.add(fileToURL(entryFile)); 115 } 116 } 117 for (Object o : attr.keySet()) 118 this.attr.put(o.toString(), attr.getValue(o.toString())); 119 } else { 120 // resource-only plugin 121 className = null; 122 mainversion = null; 123 description = null; 124 early = false; 125 stage = 50; 126 requires = null; 127 link = null; 128 version = null; 129 author = null; 130 } 131 if (file != null) 132 libraries.add(0, fileToURL(file)); 133 134 if (jar != null) 135 jar.close(); 136 } catch (IOException e) { 137 throw new PluginException(null, name, e); 138 } 126 } 127 for (Object o : attr.keySet()) 128 this.attr.put(o.toString(), attr.getValue(o.toString())); 139 129 } 140 130 … … 221 211 InputStream manifestStream = PluginInformation.class.getResourceAsStream("/org/openstreetmap/josm/plugins/"+name+"/MANIFEST.MF"); 222 212 if (manifestStream != null) 223 return new PluginInformation( null, pluginName, manifestStream);213 return new PluginInformation(manifestStream, pluginName); 224 214 225 215 Collection<String> locations = getPluginLocations(); -
trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java
r1603 r1623 141 141 if (availablePlugins.get(pname) == null) pluginsToRemove.add(pname); 142 142 } 143 143 144 144 for (String pname : pluginsToRemove) { 145 145 pluginMap.remove(pname); … … 272 272 if (fname.endsWith(".jar")) { 273 273 try { 274 PluginInformation info = new PluginInformation(f,fname.substring(0,fname.length()-4) , null);274 PluginInformation info = new PluginInformation(f,fname.substring(0,fname.length()-4)); 275 275 if (!availablePlugins.containsKey(info.name)) 276 276 availablePlugins.put(info.name, info); … … 302 302 try 303 303 { 304 PluginInformation info = new PluginInformation(null, name.substring(0,name.length()-4), 305 new ByteArrayInputStream(manifest.getBytes())); 304 PluginInformation info = new PluginInformation( 305 new ByteArrayInputStream(manifest.getBytes("utf-8")), 306 name.substring(0,name.length()-4)); 306 307 info.downloadlink = url; 307 308 if(!availablePlugins.containsKey(info.name)) … … 322 323 if(name != null) 323 324 { 324 PluginInformation info = new PluginInformation(null, name.substring(0,name.length()-4), 325 new ByteArrayInputStream(manifest.getBytes())); 325 PluginInformation info = new PluginInformation( 326 new ByteArrayInputStream(manifest.getBytes("utf-8")), 327 name.substring(0,name.length()-4)); 326 328 info.downloadlink = url; 327 329 if(!availablePlugins.containsKey(info.name))
Note:
See TracChangeset
for help on using the changeset viewer.