Ticket #804 (closed defect: fixed)

Opened 8 years ago

Last modified 7 years ago

Allow plugins to cancel themselves

Reported by: bdezonia Owned by: curtis
Priority: major Milestone: imagej2-b3-headless
Component: Plugin Framework Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking: #1051


The ImageMath plugin needs to check that the two input datasets have compatible dimensions before it creates output data. It is natural for this to happen in the plugin's run() method.

Currently we can notify user there is a problem and avoid doing anything. But the command will get recorded by the script recorder. We need to extend the plugin code to allow plugins to cancel themselves such that they are never recorded.

One way to do this might be for a plugin to throw a ModuleException of some sort and have ModuleRunner::run() catch it and react correctly.

The current exception is a checked exception and would be inconvenient to work with. We may need to make it unchecked by inheriting from RuntimeException. This requires further investigation.

Change History

comment:1 Changed 8 years ago by bdezonia

After further discussion: we need to be consistent in how we handle errors. So to be compatible with ModulePreprocessor we'll define a Cancelable interface. Any plugin can implement it and ModulePreprocesor implements it.

ModuleRunner would then call run and afterwards check if cancel was called. Plugins who implement Cancelable can check their params in their run method. If desired they can set their cancel state to true, record a message, and return from processing.

comment:2 Changed 8 years ago by bdezonia

  • Milestone changed from imagej-2.0-beta1 to imagej-2.0-beta2

comment:3 Changed 8 years ago by curtis

  • Blocking 11 added

comment:4 Changed 8 years ago by curtis

  • Blocking 1051 added; 11 removed

comment:5 Changed 8 years ago by bdezonia

  • Milestone changed from imagej-2.0.0-beta3 to imagej-2.0.0-beta4

comment:6 Changed 8 years ago by curtis

  • Owner changed from bdezonia to curtis
  • Status changed from new to assigned
  • Milestone changed from imagej-2.0.0-beta4 to imagej-2.0.0-beta3

comment:7 Changed 8 years ago by curtis

  • Blocking 1052 added; 1051 removed

comment:8 Changed 8 years ago by curtis

  • Blocking 1051 added; 1052 removed

comment:9 Changed 7 years ago by curtis

  • Status changed from assigned to closed
  • Resolution set to fixed

Implemented in 3e68f242 and a83a9d0f. I also updated RealImageCalculator to serve as an example cancelable plugin.

Note: See TracTickets for help on using tickets.