|
39 | 39 |
|
40 | 40 | import org.scijava.AbstractUIDetails; |
41 | 41 | import org.scijava.Identifiable; |
| 42 | +import org.scijava.Locatable; |
42 | 43 | import org.scijava.ValidityProblem; |
43 | 44 | import org.scijava.event.EventService; |
44 | 45 | import org.scijava.module.event.ModulesUpdatedEvent; |
| 46 | +import org.scijava.util.ClassUtils; |
45 | 47 | import org.scijava.util.ConversionUtils; |
46 | 48 |
|
47 | 49 | /** |
|
54 | 56 | * @author Curtis Rueden |
55 | 57 | */ |
56 | 58 | public abstract class AbstractModuleInfo extends AbstractUIDetails implements |
57 | | - ModuleInfo, Identifiable |
| 59 | + ModuleInfo, Identifiable, Locatable |
58 | 60 | { |
59 | 61 |
|
60 | 62 | /** Table of inputs, keyed on name. */ |
@@ -170,6 +172,21 @@ public String getIdentifier() { |
170 | 172 | return "module:" + getDelegateClassName(); |
171 | 173 | } |
172 | 174 |
|
| 175 | + // -- Locatable methods -- |
| 176 | + |
| 177 | + @Override |
| 178 | + public String getLocation() { |
| 179 | + // NB: By default, we use the location of the delegate class. |
| 180 | + // If the same delegate class is used for more than one module, though, |
| 181 | + // it may need to override this method to indicate a different location. |
| 182 | + try { |
| 183 | + return ClassUtils.getLocation(loadDelegateClass()).toExternalForm(); |
| 184 | + } |
| 185 | + catch (final ClassNotFoundException exc) { |
| 186 | + return null; |
| 187 | + } |
| 188 | + } |
| 189 | + |
173 | 190 | // -- Internal methods -- |
174 | 191 |
|
175 | 192 | /** |
|
0 commit comments