|
34 | 34 | import java.net.URL; |
35 | 35 |
|
36 | 36 | import org.scijava.AbstractUIDetails; |
| 37 | +import org.scijava.Identifiable; |
37 | 38 | import org.scijava.Instantiable; |
38 | 39 | import org.scijava.InstantiableException; |
| 40 | +import org.scijava.Locatable; |
39 | 41 | import org.scijava.MenuEntry; |
40 | 42 | import org.scijava.MenuPath; |
41 | 43 | import org.scijava.Priority; |
42 | 44 | import org.scijava.UIDetails; |
| 45 | +import org.scijava.Versioned; |
43 | 46 | import org.scijava.input.Accelerator; |
44 | 47 | import org.scijava.util.ClassUtils; |
45 | 48 | import org.scijava.util.StringMaker; |
| 49 | +import org.scijava.util.VersionUtils; |
46 | 50 |
|
47 | 51 | /** |
48 | 52 | * A collection of metadata about a particular plugin. |
|
61 | 65 | * @see PluginService |
62 | 66 | */ |
63 | 67 | public class PluginInfo<PT extends SciJavaPlugin> extends AbstractUIDetails |
64 | | - implements Instantiable<PT> |
| 68 | + implements Instantiable<PT>, Identifiable, Locatable, Versioned |
65 | 69 | { |
66 | 70 |
|
67 | 71 | /** Fully qualified class name of this plugin. */ |
@@ -304,6 +308,42 @@ public PT createInstance() throws InstantiableException { |
304 | 308 | return instance; |
305 | 309 | } |
306 | 310 |
|
| 311 | + // -- Identifiable methods -- |
| 312 | + |
| 313 | + @Override |
| 314 | + public String getIdentifier() { |
| 315 | + try { |
| 316 | + return "plugin:" + loadClass(); |
| 317 | + } |
| 318 | + catch (final InstantiableException exc) { |
| 319 | + return null; |
| 320 | + } |
| 321 | + } |
| 322 | + |
| 323 | + // -- Locatable methods -- |
| 324 | + |
| 325 | + @Override |
| 326 | + public String getLocation() { |
| 327 | + try { |
| 328 | + return ClassUtils.getLocation(loadClass()).toExternalForm(); |
| 329 | + } |
| 330 | + catch (InstantiableException exc) { |
| 331 | + return null; |
| 332 | + } |
| 333 | + } |
| 334 | + |
| 335 | + // -- Versioned methods -- |
| 336 | + |
| 337 | + @Override |
| 338 | + public String getVersion() { |
| 339 | + try { |
| 340 | + return VersionUtils.getVersion(loadClass()); |
| 341 | + } |
| 342 | + catch (InstantiableException exc) { |
| 343 | + return null; |
| 344 | + } |
| 345 | + } |
| 346 | + |
307 | 347 | // -- Helper methods -- |
308 | 348 |
|
309 | 349 | /** Populates the entry to match the associated @{@link Plugin} annotation. */ |
|
0 commit comments