[ImageJ-devel] @Parameter fields - don't make them final
Curtis Rueden
ctrueden at wisc.edu
Thu May 26 12:00:39 CDT 2011
Hi Dscho,
I implemented a fix yesterday:
http://dev.imagejdev.org/trac/imagej/ticket/543
http://dev.imagejdev.org/trac/imagej/changeset/2957
It simply flags the parameter as "resolved," meaning it will not appear in
the input dialog.
I also added a warning message if a final parameter is detected:
http://dev.imagejdev.org/trac/imagej/changeset/2958
However, we could be stricter and throw an exception instead, as you
suggest. What do you think?
Regards,
Curtis
On Thu, May 26, 2011 at 2:35 AM, Johannes Schindelin <
Johannes.Schindelin at gmx.de> wrote:
> Hi,
>
> On Wed, 25 May 2011, Grant B. Harris wrote:
>
> > On 5/25/2011 2:53 AM, Johannes Schindelin wrote:
> > > Can we have some check when the class is parsed to make sure that
> > > @Parameter fields are not final?
> > >
> > Johannes,
> > Ya, I was thinking the same thing. We can add a check using
> > Field.getModifiers() and not add an input widget if the field is final.
> I've
> > filed a ticket for it.
>
> Maybe this is already half the solution?
>
> -- snipsnap --
> diff --git a/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
> b/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
> index d520260..bd6d988 100644
> --- a/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
> +++ b/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
> @@ -165,6 +165,8 @@ public class PluginModuleInfo<T extends BasePlugin>
> implements ModuleInfo {
> if (param == null) continue; // not a parameter
>
> final String name = f.getName();
> + if (Modifier.isFinal(f.getModifiers()))
> + throw new RuntimeException("Invalid 'final'
> parameter: " + name);
> if (presets.containsKey(name)) {
> // assign preset value to field, and exclude
> from the list of inputs
> PluginModule.setValue(f, plugin,
> presets.get(name));
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20110526/fac10d00/attachment.html>
More information about the ImageJ-devel
mailing list