Listening on commands

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

Listening on commands

Filip Sedlak
Hi,
I wonder if it's possible to access both the currently performed command
and its parameters. Something similar what Plugins > Macro > Record does
but from a plugin.

I'd like to do an analysis of the user's actions and I need to get the
performed operations without asking the user to e. g. copy-paste the
recorder output to an external app.

Using Executer.addCommandListener gives me only the command name and not
its parameters. I started playing with ij.plugin.frame.Recorder, trying
to patch it to support attaching listeners. The listeners would be
notified with similar information like what is added to the text area.

Can you see a simpler way to achieve this? Most importantly, it would be
great if I could avoid running a patched version of the application.

Thanks,
Filip

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Listening on commands

Jerome Mutterer-3
Dear Filip,
IJ 1.47o4 introduced a new Recorder constructor: new Recorder(boolean
visible).
So you can silently create a a Recorder with:
Recorder r = new Recorder(false);
and at any time, retrieve the recorded macro:
String recordedMacro = r.getText();
that will contain both commands and parameters.
Sincerely,

Jerome.



On 16 November 2014 21:28, Filip Sedlak <[hidden email]> wrote:

> Hi,
> I wonder if it's possible to access both the currently performed command
> and its parameters. Something similar what Plugins > Macro > Record does
> but from a plugin.
>
> I'd like to do an analysis of the user's actions and I need to get the
> performed operations without asking the user to e. g. copy-paste the
> recorder output to an external app.
>
> Using Executer.addCommandListener gives me only the command name and not
> its parameters. I started playing with ij.plugin.frame.Recorder, trying to
> patch it to support attaching listeners. The listeners would be notified
> with similar information like what is added to the text area.
>
> Can you see a simpler way to achieve this? Most importantly, it would be
> great if I could avoid running a patched version of the application.
>
> Thanks,
> Filip
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
Jerome Mutterer
CNRS - Institut de biologie moléculaire des plantes
12, rue du Général Zimmer
67084 Strasbourg Cedex
T 0367155339
www.ibmp.cnrs.fr

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Listening on commands

Filip Sedlak
Thanks Jerome, I'll try it.

Filip


Dne 16.11.2014 v 23:38 Jerome Mutterer napsal(a):

> Dear Filip,
> IJ 1.47o4 introduced a new Recorder constructor: new Recorder(boolean
> visible).
> So you can silently create a a Recorder with:
> Recorder r = new Recorder(false);
> and at any time, retrieve the recorded macro:
> String recordedMacro = r.getText();
> that will contain both commands and parameters.
> Sincerely,
>
> Jerome.
>
>
>
> On 16 November 2014 21:28, Filip Sedlak <[hidden email]> wrote:
>
>> Hi,
>> I wonder if it's possible to access both the currently performed command
>> and its parameters. Something similar what Plugins > Macro > Record does
>> but from a plugin.
>>
>> I'd like to do an analysis of the user's actions and I need to get the
>> performed operations without asking the user to e. g. copy-paste the
>> recorder output to an external app.
>>
>> Using Executer.addCommandListener gives me only the command name and not
>> its parameters. I started playing with ij.plugin.frame.Recorder, trying to
>> patch it to support attaching listeners. The listeners would be notified
>> with similar information like what is added to the text area.
>>
>> Can you see a simpler way to achieve this? Most importantly, it would be
>> great if I could avoid running a patched version of the application.
>>
>> Thanks,
>> Filip
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
>
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Listening on commands

ctrueden
Hi Filip,

> I wonder if it's possible to access both the currently performed
> command and its parameters.

In ImageJ2 you can subscribe to ModuleExecutedEvent [1] and/or other
ModuleExecutionEvent [2] subclasses of interest. There is an events
tutorial which is relevant [3].

But for ImageJ1 commands you'll have to use a different approach such as
what Jerome suggested.

Regards,
Curtis

[1]
http://javadoc.imagej.net/ImageJ/org/scijava/module/event/ModuleExecutedEvent.html
[2]
http://javadoc.imagej.net/ImageJ/org/scijava/module/event/ModuleExecutionEvent.html
[3]
https://github.com/imagej/imagej-tutorials/blob/master/listen-to-events/src/main/java/ListenToEvents.java

On Mon, Nov 17, 2014 at 2:14 AM, Filip Sedlák <[hidden email]> wrote:

> Thanks Jerome, I'll try it.
>
> Filip
>
>
> Dne 16.11.2014 v 23:38 Jerome Mutterer napsal(a):
> > Dear Filip,
> > IJ 1.47o4 introduced a new Recorder constructor: new Recorder(boolean
> > visible).
> > So you can silently create a a Recorder with:
> > Recorder r = new Recorder(false);
> > and at any time, retrieve the recorded macro:
> > String recordedMacro = r.getText();
> > that will contain both commands and parameters.
> > Sincerely,
> >
> > Jerome.
> >
> >
> >
> > On 16 November 2014 21:28, Filip Sedlak <[hidden email]> wrote:
> >
> >> Hi,
> >> I wonder if it's possible to access both the currently performed command
> >> and its parameters. Something similar what Plugins > Macro > Record does
> >> but from a plugin.
> >>
> >> I'd like to do an analysis of the user's actions and I need to get the
> >> performed operations without asking the user to e. g. copy-paste the
> >> recorder output to an external app.
> >>
> >> Using Executer.addCommandListener gives me only the command name and not
> >> its parameters. I started playing with ij.plugin.frame.Recorder, trying
> to
> >> patch it to support attaching listeners. The listeners would be notified
> >> with similar information like what is added to the text area.
> >>
> >> Can you see a simpler way to achieve this? Most importantly, it would be
> >> great if I could avoid running a patched version of the application.
> >>
> >> Thanks,
> >> Filip
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> >
> >
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Listening on commands

Filip Sedlak
Thanks, Curtis.

Filip

Dne 17.11.2014 17:55, Curtis Rueden napsal(a):

> Hi Filip,
>
>> I wonder if it's possible to access both the currently performed
>> command and its parameters.
>
> In ImageJ2 you can subscribe to ModuleExecutedEvent [1] and/or other
> ModuleExecutionEvent [2] subclasses of interest. There is an events
> tutorial which is relevant [3].
>
> But for ImageJ1 commands you'll have to use a different approach such as
> what Jerome suggested.
>
> Regards,
> Curtis
>
> [1]
> http://javadoc.imagej.net/ImageJ/org/scijava/module/event/ModuleExecutedEvent.html
> [2]
> http://javadoc.imagej.net/ImageJ/org/scijava/module/event/ModuleExecutionEvent.html
> [3]
> https://github.com/imagej/imagej-tutorials/blob/master/listen-to-events/src/main/java/ListenToEvents.java
>
> On Mon, Nov 17, 2014 at 2:14 AM, Filip Sedlák <[hidden email]> wrote:
>
>> Thanks Jerome, I'll try it.
>>
>> Filip
>>
>>
>> Dne 16.11.2014 v 23:38 Jerome Mutterer napsal(a):
>>> Dear Filip,
>>> IJ 1.47o4 introduced a new Recorder constructor: new Recorder(boolean
>>> visible).
>>> So you can silently create a a Recorder with:
>>> Recorder r = new Recorder(false);
>>> and at any time, retrieve the recorded macro:
>>> String recordedMacro = r.getText();
>>> that will contain both commands and parameters.
>>> Sincerely,
>>>
>>> Jerome.
>>>
>>>
>>>
>>> On 16 November 2014 21:28, Filip Sedlak <[hidden email]> wrote:
>>>
>>>> Hi,
>>>> I wonder if it's possible to access both the currently performed command
>>>> and its parameters. Something similar what Plugins > Macro > Record does
>>>> but from a plugin.
>>>>
>>>> I'd like to do an analysis of the user's actions and I need to get the
>>>> performed operations without asking the user to e. g. copy-paste the
>>>> recorder output to an external app.
>>>>
>>>> Using Executer.addCommandListener gives me only the command name and not
>>>> its parameters. I started playing with ij.plugin.frame.Recorder, trying
>> to
>>>> patch it to support attaching listeners. The listeners would be notified
>>>> with similar information like what is added to the text area.
>>>>
>>>> Can you see a simpler way to achieve this? Most importantly, it would be
>>>> great if I could avoid running a patched version of the application.
>>>>
>>>> Thanks,
>>>> Filip
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>
>>>
>>>
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html