More GenericDialog fun

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

More GenericDialog fun

Michael Doube
Hi all

Thanks for your very useful comments regarding layout.

While messing around with layout, I noticed that GenericDialogs with a
dialog listener, added with:

gd.addDialogListener(this);

just before:

gd.showDialog();

Do not have their options recorded by the Macro Recorder.

Commenting out gd.addDialogListener(this); restores macro recordability.

Is this a known issue, and if so, how can I have dialog listeners while
maintaining macro recordability?

Michael
Reply | Threaded
Open this post in threaded view
|

Re: More GenericDialog fun

Michael Schmid
Hi Michael,

this cannot be a general problem with DialogListeners; most filters  
and some other functions in ImageJ use a DialogListener and get  
recorded.
Maybe your DialogListener causes an exception? You could check it  
like this:
try {
... DialogListener code ...
}
catch (Exception e) { IJ.log("Exception in DialogListener "+e); }

Michael
________________________________________________________________

On 11 May 2010, at 13:12, Michael Doube wrote:

> Hi all
>
> Thanks for your very useful comments regarding layout.
>
> While messing around with layout, I noticed that GenericDialogs  
> with a dialog listener, added with:
>
> gd.addDialogListener(this);
>
> just before:
>
> gd.showDialog();
>
> Do not have their options recorded by the Macro Recorder.
>
> Commenting out gd.addDialogListener(this); restores macro  
> recordability.
>
> Is this a known issue, and if so, how can I have dialog listeners  
> while maintaining macro recordability?
>
> Michael
Reply | Threaded
Open this post in threaded view
|

Re: More GenericDialog fun

Michael Doube
Michael

I tried catching exceptions and none were thrown.  My implementation is
pretty simple, as in this example, which adds a listener to a dialog
containing a choice menu.  If "voxel" is selected, the numeric field is
greyed out (setEnabled(false)) by the dialogItemChanged method.

http://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/VolumeFraction.java

If I include the DialogListener, options are not recorded.  Commenting
out gd.addDialogListener restores option recordability (tested on IJ
1.43u and 1.44a8).

Could this be a difference between ItemListeners (which I haven't yet
used) and DialogListeners (which I currently use)?

Michael

> this cannot be a general problem with DialogListeners; most filters
> and some other functions in ImageJ use a DialogListener and get
> recorded.
> Maybe your DialogListener causes an exception? You could check it
> like this:
> try {
> ... DialogListener code ...
> }
> catch (Exception e) { IJ.log("Exception in DialogListener "+e); }
>
> Michael
> ________________________________________________________________
>
> On 11 May 2010, at 13:12, Michael Doube wrote:
>
>> Hi all
>>
>> Thanks for your very useful comments regarding layout.
>>
>> While messing around with layout, I noticed that GenericDialogs
>> with a dialog listener, added with:
>>
>> gd.addDialogListener(this);
>>
>> just before:
>>
>> gd.showDialog();
>>
>> Do not have their options recorded by the Macro Recorder.
>>
>> Commenting out gd.addDialogListener(this); restores macro
>> recordability.
>>
>> Is this a known issue, and if so, how can I have dialog listeners
>> while maintaining macro recordability?
Reply | Threaded
Open this post in threaded view
|

Re: More GenericDialog fun

Michael Schmid
Hi Michael,

ok, I see, you read the values (gd.getNextNumber etc.) outside of the  
DialogItemChanged method, that's a situation I did not think about.  
If you have a DialogListener, macro recording works only if you read  
the values in the DialogItemChanged method (getNextNumber, etc.)

Michael
________________________________________________________________

On 11 May 2010, at 16:15, Michael Doube wrote:

> Michael
>
> I tried catching exceptions and none were thrown.  My  
> implementation is pretty simple, as in this example, which adds a  
> listener to a dialog containing a choice menu.  If "voxel" is  
> selected, the numeric field is greyed out (setEnabled(false)) by  
> the dialogItemChanged method.
>
> http://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/ 
> VolumeFraction.java
>
> If I include the DialogListener, options are not recorded.  
> Commenting out gd.addDialogListener restores option recordability  
> (tested on IJ 1.43u and 1.44a8).
>
> Could this be a difference between ItemListeners (which I haven't  
> yet used) and DialogListeners (which I currently use)?
>
> Michael
>
>> this cannot be a general problem with DialogListeners; most filters
>> and some other functions in ImageJ use a DialogListener and get
>> recorded.
>> Maybe your DialogListener causes an exception? You could check it
>> like this:
>> try {
>> ... DialogListener code ...
>> }
>> catch (Exception e) { IJ.log("Exception in DialogListener "+e); }
>>
>> Michael
>> ________________________________________________________________
>>
>> On 11 May 2010, at 13:12, Michael Doube wrote:
>>
>>> Hi all
>>>
>>> Thanks for your very useful comments regarding layout.
>>>
>>> While messing around with layout, I noticed that GenericDialogs
>>> with a dialog listener, added with:
>>>
>>> gd.addDialogListener(this);
>>>
>>> just before:
>>>
>>> gd.showDialog();
>>>
>>> Do not have their options recorded by the Macro Recorder.
>>>
>>> Commenting out gd.addDialogListener(this); restores macro
>>> recordability.
>>>
>>> Is this a known issue, and if so, how can I have dialog listeners
>>> while maintaining macro recordability?
Reply | Threaded
Open this post in threaded view
|

Re: More GenericDialog fun

Michael Doube
In reply to this post by Michael Doube
Actually, it was just me not putting gd.getNextBoolean() etc. in the
dialogItemChanged() method, so the values weren't registered by the
macro recorder.

Woops...