|
53 | 53 | import fiji.plugin.trackmate.helper.model.parameter.AbstractParamSweepModel; |
54 | 54 | import fiji.plugin.trackmate.helper.model.parameter.AbstractParamSweepModelIO; |
55 | 55 | import fiji.plugin.trackmate.helper.model.parameter.EnumParamSweepModel; |
| 56 | +import fiji.plugin.trackmate.helper.model.parameter.InfoParamSweepModel; |
56 | 57 | import fiji.plugin.trackmate.helper.model.tracker.TrackerSweepModel; |
57 | 58 | import fiji.plugin.trackmate.providers.DetectorProvider; |
58 | 59 | import fiji.plugin.trackmate.providers.TrackerProvider; |
@@ -315,8 +316,36 @@ public TrackerSweepModel deserialize( final JsonElement json, final Type typeOfT |
315 | 316 | } |
316 | 317 | } |
317 | 318 |
|
318 | | - // Normal case. |
319 | | - return context.deserialize( element, Class.forName( "fiji.plugin.trackmate.helper.model.tracker." + type ) ); |
| 319 | + // Deserialize from Json |
| 320 | + final TrackerSweepModel ds = ( TrackerSweepModel ) context.deserialize( element, Class.forName( "fiji.plugin.trackmate.helper.model.tracker." + type ) ); |
| 321 | + |
| 322 | + /* |
| 323 | + * We may have serialized that the module was not available or |
| 324 | + * properly configured at the time of serialization. In that |
| 325 | + * case, the submodel is only one information parameter. Instead |
| 326 | + * of returning it, we try to instantiate a new model, so that |
| 327 | + * the user is presented something par with the current |
| 328 | + * configuration they have. |
| 329 | + */ |
| 330 | + // Test if we serialized an error. |
| 331 | + if ( ds.models.size() == 1 ) |
| 332 | + { |
| 333 | + final AbstractParamSweepModel< ? > sm = ds.models.values().iterator().next(); |
| 334 | + if ( sm instanceof InfoParamSweepModel ) |
| 335 | + { |
| 336 | + try |
| 337 | + { |
| 338 | + final Object obj2 = Class.forName( "fiji.plugin.trackmate.helper.model.tracker." + type ).getConstructor().newInstance(); |
| 339 | + return ( TrackerSweepModel ) obj2; |
| 340 | + } |
| 341 | + catch ( InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e ) |
| 342 | + { |
| 343 | + e.printStackTrace(); |
| 344 | + } |
| 345 | + } |
| 346 | + } |
| 347 | + // Otherwise we return it. |
| 348 | + return ds; |
320 | 349 | } |
321 | 350 | catch ( final ClassNotFoundException cnfe ) |
322 | 351 | { |
|
0 commit comments