Changeset 6843 in josm
- Timestamp:
- 2014-02-12T11:10:01+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r6830 r6843 40 40 */ 41 41 public class PluginInformation { 42 43 /** The plugin jar file. */ 42 44 public File file = null; 45 /** The plugin name. */ 43 46 public String name = null; 47 /** The lowest JOSM version required by this plugin (from plugin list). **/ 44 48 public int mainversion = 0; 49 /** The lowest JOSM version required by this plugin (from locally available jar). **/ 45 50 public int localmainversion = 0; 51 /** The plugin class name. */ 46 52 public String className = null; 47 53 public boolean oldmode = false; 54 /** The list of required plugins, separated by ';' (from plugin list). */ 48 55 public String requires = null; 56 /** The list of required plugins, separated by ';' (from locally available jar). */ 49 57 public String localrequires = null; 58 /** The plugin link (for documentation). */ 50 59 public String link = null; 60 /** The plugin description. */ 51 61 public String description = null; 62 /** Determines if the plugin must be loaded early or not. */ 52 63 public boolean early = false; 64 /** The plugin author. */ 53 65 public String author = null; 66 /** The plugin stage, determining the loading sequence order of plugins. */ 54 67 public int stage = 50; 68 /** The plugin version (from plugin list). **/ 55 69 public String version = null; 70 /** The plugin version (from locally available jar). **/ 56 71 public String localversion = null; 72 /** The plugin download link. */ 57 73 public String downloadlink = null; 58 74 public String iconPath; 75 /** The plugin icon. */ 59 76 public ImageIcon icon; 60 77 public List<URL> libraries = new LinkedList<URL>(); … … 136 153 * update site. 137 154 * 138 * @param other the plugin information object retrieved from the update 139 * site 155 * @param other the plugin information object retrieved from the update site 140 156 */ 141 157 public void updateFromPluginSite(PluginInformation other) { … … 176 192 } 177 193 178 private void scanManifest(Manifest manifest, boolean oldcheck) {194 private void scanManifest(Manifest manifest, boolean oldcheck) { 179 195 String lang = LanguageInfo.getLanguageCodeManifest(); 180 196 Attributes attr = manifest.getMainAttributes(); 181 197 className = attr.getValue("Plugin-Class"); 182 198 String s = attr.getValue(lang+"Plugin-Link"); 183 if (s == null) {199 if (s == null) { 184 200 s = attr.getValue("Plugin-Link"); 185 201 } 186 if (s != null) {202 if (s != null) { 187 203 try { 188 204 new URL(s); … … 195 211 requires = attr.getValue("Plugin-Requires"); 196 212 s = attr.getValue(lang+"Plugin-Description"); 197 if(s == null) 198 { 213 if (s == null) { 199 214 s = attr.getValue("Plugin-Description"); 200 if (s != null) {215 if (s != null) { 201 216 try { 202 217 s = tr(s); … … 213 228 stage = stageStr == null ? 50 : Integer.parseInt(stageStr); 214 229 version = attr.getValue("Plugin-Version"); 215 try { 216 mainversion = Integer.parseInt(attr.getValue("Plugin-Mainversion")); 217 } catch(NumberFormatException e) { 218 Main.warn(e); 230 s = attr.getValue("Plugin-Mainversion"); 231 if (s != null) { 232 try { 233 mainversion = Integer.parseInt(s); 234 } catch(NumberFormatException e) { 235 Main.warn(tr("Invalid plugin main version ''{0}'' in plugin {1}", s, name)); 236 } 237 } else { 238 Main.warn(tr("Missing plugin main version in plugin {0}", name)); 219 239 } 220 240 author = attr.getValue("Author"); … … 224 244 icon = new ImageProvider(iconPath).setArchive(file).setMaxWidth(24).setMaxHeight(24).setOptional(true).get(); 225 245 } 226 if(oldcheck && mainversion > Version.getInstance().getVersion()) 227 { 246 if (oldcheck && mainversion > Version.getInstance().getVersion()) { 228 247 int myv = Version.getInstance().getVersion(); 229 for(Map.Entry<Object, Object> entry : attr.entrySet()) 230 { 248 for (Map.Entry<Object, Object> entry : attr.entrySet()) { 231 249 try { 232 250 String key = ((Attributes.Name)entry.getKey()).toString(); 233 if(key.endsWith("_Plugin-Url")) 234 { 251 if (key.endsWith("_Plugin-Url")) { 235 252 int mv = Integer.parseInt(key.substring(0,key.length()-11)); 236 if(mv <= myv && (mv > mainversion || mainversion > myv)) 237 { 253 if (mv <= myv && (mv > mainversion || mainversion > myv)) { 238 254 String v = (String)entry.getValue(); 239 255 int i = v.indexOf(';'); 240 if(i > 0) 241 { 256 if (i > 0) { 242 257 downloadlink = v.substring(i+1); 243 258 mainversion = mv; … … 248 263 } 249 264 } 250 catch(Exception e) { Main.error(e); } 265 catch(Exception e) { 266 Main.error(e); 267 } 251 268 } 252 269 } … … 292 309 293 310 /** 294 * Load and instantiate the plugin311 * Loads and instantiates the plugin. 295 312 * 296 313 * @param klass the plugin class 297 314 * @return the instantiated and initialized plugin 298 */ 299 public PluginProxy load(Class<?> klass) throws PluginException{ 315 * @throws PluginException if the plugin cannot be loaded or instanciated 316 */ 317 public PluginProxy load(Class<?> klass) throws PluginException { 300 318 try { 301 319 Constructor<?> c = klass.getConstructor(PluginInformation.class); … … 314 332 315 333 /** 316 * Load the class of the plugin334 * Loads the class of the plugin. 317 335 * 318 336 * @param classLoader the class loader to use 319 337 * @return the loaded class 338 * @throws PluginException if the class cannot be loaded 320 339 */ 321 340 public Class<?> loadClass(ClassLoader classLoader) throws PluginException {
Note:
See TracChangeset
for help on using the changeset viewer.