GenericDialog programmatic "OK" ?

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

GenericDialog programmatic "OK" ?

Joachim Wesner
Hi,

just another question....

I have a plugin that somehow streches the possibilities of GenericDialog
but I am too lazy to rewrite the GUI using "standard java" in a plugin
frame.

I have a DialogListener thar directly responds to some checkboxes to, for
example, read a data file and fill in some of the dialog fields based on
that.

I would like to add the option that after reading these data, the dialog is
automatically closed and processing starts immediately, i.e. I somehow need
to
simulate clicking "OK" by the user from within the DialogListener . What
would be the easiest way to acchieve this?

Mit freundlichen Grüßen / Best regards

Joachim Wesner
Projektleiter Optik Technologiesysteme

Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis
www.leica-microsystems.com


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: GenericDialog programmatic "OK" ?

Michael Schmid
Hi Joachim,

you could call gd.actionPerformed with a new ActionEvent that has the  
OK button as a source. The problem: there is no GenericDialog method  
that returns a reference to this button.

It would be great to have GenericDialog function that returns the  
list of Buttons (this would be helpful also for other purposes, e.g.,  
enabling/disabling/changing a Button label).
Otherwise, you have to step through the components of gd.getComponents
() to find the panel with the buttons and then step through its  
getComponents() to find the OK button.

Michael
________________________________________________________________

On 17 Jul 2009, at 14:13, Joachim Wesner wrote:

> Hi,
>
> just another question....
>
> I have a plugin that somehow streches the possibilities of  
> GenericDialog
> but I am too lazy to rewrite the GUI using "standard java" in a plugin
> frame.
>
> I have a DialogListener thar directly responds to some checkboxes  
> to, for
> example, read a data file and fill in some of the dialog fields  
> based on
> that.
>
> I would like to add the option that after reading these data, the  
> dialog is
> automatically closed and processing starts immediately, i.e. I  
> somehow need
> to
> simulate clicking "OK" by the user from within the DialogListener .  
> What
> would be the easiest way to acchieve this?
>
> Mit freundlichen Grüßen / Best regards
>
> Joachim Wesner
Reply | Threaded
Open this post in threaded view
|

Re: GenericDialog programmatic "OK" ?

Wayne Rasband
In reply to this post by Joachim Wesner
The v1.43d daily build adds a getButtons() method to the GenericDialog
class. This is what it looks like:

     /** Returns references to the "OK" ("Yes"), "Cancel",
         and if present, "No" buttons as an array. */
     public Button[] getButtons() {
         Button[] buttons = new Button[3];
         buttons[0] = okay;
         buttons[1] = cancel;
         buttons[2] = no;
         return buttons;
     }

The daily build also allows you to drag images, text files (.txt,
.java, .js) and plugins (.jar, .class) from a browser window and drop
them on the ImageJ window. Images and text files are displayed and
plugins are installed.

-wayne

On Jul 17, 2009, at 14:31, Michael Schmid wrote:

>
> Hi Joachim,
>
> you could call gd.actionPerformed with a new ActionEvent that has the
> OK button as a source. The problem: there is no GenericDialog method
> that returns a reference to this button.
>
> It would be great to have GenericDialog function that returns the
> list of Buttons (this would be helpful also for other purposes, e.g.,
> enabling/disabling/changing a Button label).
> Otherwise, you have to step through the components of gd.getComponents
> () to find the panel with the buttons and then step through its
> getComponents() to find the OK button.
>
> Michael
> ________________________________________________________________
>
> On 17 Jul 2009, at 14:13, Joachim Wesner wrote:
>
> > Hi,
> >
> > just another question....
> >
> > I have a plugin that somehow streches the possibilities of
> > GenericDialog
> > but I am too lazy to rewrite the GUI using "standard java" in a
> plugin
> > frame.
> >
> > I have a DialogListener thar directly responds to some checkboxes
> > to, for
> > example, read a data file and fill in some of the dialog fields
> > based on
> > that.
> >
> > I would like to add the option that after reading these data, the
> > dialog is
> > automatically closed and processing starts immediately, i.e. I
> > somehow need
> > to
> > simulate clicking "OK" by the user from within the DialogListener .
> > What
> > would be the easiest way to acchieve this?
> >
> > Mit freundlichen Grüßen / Best regards
> >
> > Joachim Wesner
>
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: GenericDialog programmatic "OK" ?

Joachim Wesner
HI,

great, again another extremely quick and on the point response!!!!

I switched to the new version and imlemented Michaels suggestion, works
great!

Mit freundlichen Grüßen / Best regards

Joachim Wesner
Projektleiter Optik Technologiesysteme

Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis
www.leica-microsystems.com



                                                                           
             Wayne Rasband                                                
             <[hidden email]>                                                
             Gesendet von:                                              An
             ImageJ Interest            [hidden email]                
             Group                                                   Kopie
             <[hidden email].                                            
             GOV>                                                    Thema
                                        Re: GenericDialog programmatic    
                                        "OK" ?                            
             17.07.2009 23:25                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




The v1.43d daily build adds a getButtons() method to the GenericDialog
class. This is what it looks like:

     /** Returns references to the "OK" ("Yes"), "Cancel",
         and if present, "No" buttons as an array. */
     public Button[] getButtons() {
         Button[] buttons = new Button[3];
         buttons[0] = okay;
         buttons[1] = cancel;
         buttons[2] = no;
         return buttons;
     }

The daily build also allows you to drag images, text files (.txt,
.java, .js) and plugins (.jar, .class) from a browser window and drop
them on the ImageJ window. Images and text files are displayed and
plugins are installed.

-wayne

On Jul 17, 2009, at 14:31, Michael Schmid wrote:

>
> Hi Joachim,
>
> you could call gd.actionPerformed with a new ActionEvent that has the
> OK button as a source. The problem: there is no GenericDialog method
> that returns a reference to this button.
>
> It would be great to have GenericDialog function that returns the
> list of Buttons (this would be helpful also for other purposes, e.g.,
> enabling/disabling/changing a Button label).
> Otherwise, you have to step through the components of gd.getComponents
> () to find the panel with the buttons and then step through its
> getComponents() to find the OK button.
>
> Michael
>



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

(Macro) argument substitution and backslash handling, problem with windows file association

Joachim Wesner
Hi list

(I see that this has already been discussed partly in another thread, but
in a different context...)

I was trying to do the following:

I have set up a Windows file association that should lauch ImageJ and an
associated plugin when the user click on a certain file (extension) via
something like

"c:\imagej\imagej.exe -eval "run('Plugin Name', 'file=%1' )"

Launching the plugin works as expected, but when passing the
(automatically) appended file name by %1, it only contains singe
backslashes which are already dropped somewhere on the chain to
the plugin (I use Macro.getOptions as described in the Wiki FAQ), because
they are parsed as "\x" control characters (actually not even that, it
seems only a few known combinations are  converted,
on "unsusual" ones, the "\" is simply dropped, but the character after it,
remains)

However, I do not (yet see) a way to force windows to use "/" or double the
"\\", so automatic filename passing won´t work this way.

Any ideas to fix or circumvent this?

Could probably the newly added "drag and drop" support be made use
configurable, so that one could like plugins to a certain extension? This
would also avoid launching a new ImageJ instance (probably including it´s
own JVM) as in my approach

Sincerely


Mit freundlichen Grüßen / Best regards

Joachim Wesner


Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis
www.leica-microsystems.com


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Small bugs / inconvenience

Joachim Wesner
HI

1) Page setup options (border, print title) are not remembered between
separate runs of ImageJ

2) The width set in the line selection tool influences other graphics, as
the monitor memory plot - Intended ?

Seen with 1.43c resp. 1.43d


Mit freundlichen Grüßen / Best regards

Joachim Wesner


Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis
www.leica-microsystems.com


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Keyevent problem

Joachim Wesner
Hi again,

I just noted some other inconvenience where I don´t see a simple solution:

I have a plugin that creates an image window with an ImageListener that
monitors the close event.

The idea behind it is that when the user closes the window, normally the
initial plugin dialog will reappear, so she/he can makesome changes to the
parameters and try again
without having to restart all over again.

However, if she/he keeps the Ctrl-key pressed while closing the window with
the mouse (I use IJ.controlKeyDown()), the plugin will terminate and not
show the dialog again.

This works flawlessly so far on it´s own, however, if the user uses
*certain* shortcuts involving the control key, the Imagelistener will still
see a
depressed control key even if it has already been released.

It seems this is due to the fact that the key-release event goes to a
different window and is lost for the initial window resp. IJ!?

I did some quick checks, the problem happens for ex. when one uses
control-P to print the window (where I noted it), it seem that the event is
lost to the "printer setup" window,
it only will work is control is released AFTER closing the print window.

I contrast, there is no problem with "Adjust" Control-Shift-C, even when
released early.

Any simple idea to fix this? From what I find in the net, this seems to be
not an easy issue in Java!

Probably for a quick solution, I will try changing to the Alt-key, which is
normally not active in IJ.


Mit freundlichen Grüßen / Best regards

Joachim Wesner
____________________________________________

Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
Wetzlar  HRB 2432
Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr. David Roy
Martyr | Colin Davis
www.leica-microsystems.com


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________