NOTICE! This is a static HTML version of a legacy ImageJ Trac ticket.

The ImageJ project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Ticket #804 (closed defect: fixed)

Opened 2011-10-05T13:59:48-05:00

Last modified 2012-07-10T17:35:51-05:00

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

Description

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 2011-12-01T10:13:28-06:00 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 2012-01-19T12:06:47-06:00 by bdezonia

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

comment:3 Changed 2012-02-26T21:29:09-06:00 by curtis

  • Blocking 11 added

comment:4 Changed 2012-03-05T14:44:13-06:00 by curtis

  • Blocking 1051 added; 11 removed

comment:5 Changed 2012-05-14T10:58:41-05:00 by bdezonia

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

comment:6 Changed 2012-05-15T09:40:16-05:00 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 2012-05-15T09:40:50-05:00 by curtis

  • Blocking 1052 added; 1051 removed

comment:8 Changed 2012-05-15T09:41:07-05:00 by curtis

  • Blocking 1051 added; 1052 removed

comment:9 Changed 2012-07-10T17:35:51-05:00 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.