Manual choice within a GenericDialog

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Manual choice within a GenericDialog

CARL Philippe (LBP)
Dear all,
Within a GenericDialog, I would like to give the possibility to choose between some preprogrammed choices and in the case the user isn't happy about the proposed offer that he manually types in an alternative choice (in String format).
This can of course easily be done by combining an addChoice and addStringField with a "manual choice" within the addChoice and the use of an if function that will then read the StringField content.
My question is if it would be possible to have a kind of "one stone, two birds" method that would be an addChoice method and within one of its choices could be transformed in a kind of StringField?
I thank you very much for your lighting on this.
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 42 89

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

Re: Manual choice within a GenericDialog

Gabriel Landini
Hi,
You could add a 2nd dialog if he user chooses "Manual entry" in the first one.
A bit like the Coloru deconvolution plugin, when you choose "User values".
Sorry if I am not understanding the problem fully.

Cheers

Gabriel


On Sunday, 5 July 2020 13:00:00 BST you wrote:

> Dear all,
> Within a GenericDialog, I would like to give the possibility to choose
> between some preprogrammed choices and in the case the user isn't happy
> about the proposed offer that he manually types in an alternative choice
> (in String format). This can of course easily be done by combining an
> addChoice and addStringField with a "manual choice" within the addChoice
> and the use of an if function that will then read the StringField content.
> My question is if it would be possible to have a kind of "one stone, two
> birds" method that would be an addChoice method and within one of its
> choices could be transformed in a kind of StringField? I thank you very
> much for your lighting on this.
> My best regards,
> Philippe

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

Re: Manual choice within a GenericDialog

CARL Philippe (LBP)
Dear Gabriel,
Indeed in the case the user chooses "manual choice" or "User values" within the choice field, there could be a second dialog to be opened requesting for the entry or like I described it below having a StringField just next to the choice field which entry would be ignored in the case the user didn't select the "manual choice".
But my request is for having a "all in one" field with a choice field which could then be "transformed into a stringField" within one of its choices (by using the Java langage).
Take care,
Philippe

----- Mail original -----
De: "Gabriel Landini" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Dimanche 5 Juillet 2020 14:17:32
Objet: Re: Manual choice within a GenericDialog

Hi,
You could add a 2nd dialog if he user chooses "Manual entry" in the first one.
A bit like the Coloru deconvolution plugin, when you choose "User values".
Sorry if I am not understanding the problem fully.

Cheers

Gabriel


On Sunday, 5 July 2020 13:00:00 BST you wrote:

> Dear all,
> Within a GenericDialog, I would like to give the possibility to choose
> between some preprogrammed choices and in the case the user isn't happy
> about the proposed offer that he manually types in an alternative choice
> (in String format). This can of course easily be done by combining an
> addChoice and addStringField with a "manual choice" within the addChoice
> and the use of an if function that will then read the StringField content.
> My question is if it would be possible to have a kind of "one stone, two
> birds" method that would be an addChoice method and within one of its
> choices could be transformed in a kind of StringField? I thank you very
> much for your lighting on this.
> My best regards,
> Philippe

--
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: Manual choice within a GenericDialog

Kenneth R Sloan-2
As I understand the question - and given that you prefer to not open a second dialog - I would create a dialog with a Choice field *and* a following String field.  If the user selects one of the pre-programmed Choices, you simply ignore the String.  

This isn't quite as nice looking as allowing the user to type into the Choice field, but it seems close enough.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

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

Re: Manual choice within a GenericDialog

CARL Philippe (LBP)
Der Kenneth,
I validate your suggestion which is actually what I had described as well.
But since then my thoughts evolved and it is possible to make a slight improvement to such a code by getting a handle to the String Field item (following the Choice item) through something like:
        Component[] dlgItems = gd.getComponents();
and then play with:
        dlgItems[i].setVisible( state );
        dlgItems[i].setEnabled( state );
(state being then equal to true or false), as it had been suggested to me by Herbie.
Take care,
Philippe

----- Mail original -----
De: "Kenneth Sloan" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Dimanche 5 Juillet 2020 20:31:42
Objet: Re: Manual choice within a GenericDialog

As I understand the question - and given that you prefer to not open a second dialog - I would create a dialog with a Choice field *and* a following String field.  If the user selects one of the pre-programmed Choices, you simply ignore the String.  

This isn't quite as nice looking as allowing the user to type into the Choice field, but it seems close enough.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

--
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: Manual choice within a GenericDialog

Kenneth R Sloan-2
yes - I have code that does similar things.  I finally decided that the extra complexity in the code was not compensated by an appreciable improvement in the interaction.

Note that you can change the priority given to the two fields (Choice and String).  As I described it, you can look at the String field *only* if the "Manual setting" choice is selected.  But, you
can also check the String field first.  If the user types something there, you can ignore the Choice field!  I suspect you can insert some text to make this clear to the user - something like:

"Select one of these:

 <Choice Field>

 or, type in a value here:

 <String Field> "

There's no need to force the user to make a particular *choice* in order to activate the "manual setting" *string* field.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

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

Re: Manual choice within a GenericDialog

Gabriel Landini
I suppose that the way to enable/disable a field based on the setting of
another field is to use the DialogListener.
A few plugins use that.

Cheers
Gabriel

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

Re: Manual choice within a GenericDialog

CARL Philippe (LBP)
Dear Gabriel,
You indeed suppose right!
Take care,
Philippe

----- Mail original -----
De: "Gabriel Landini" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Dimanche 5 Juillet 2020 23:38:38
Objet: Re: Manual choice within a GenericDialog

I suppose that the way to enable/disable a field based on the setting of
another field is to use the DialogListener.
A few plugins use that.

Cheers
Gabriel

--
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: Manual choice within a GenericDialog

Herbie
In reply to this post by Gabriel Landini
Dear Gabriel and Kenneth,

as initially mentioned by Philippe (thanks!), I strongly suggest to use the
DialogListener-approach.

Why?

The reason is mainly a socio-psychological one:
The number of users who are willing to read manuals is rapidly decreasing
which means that creating user interfaces needs more care than in older days
in order to avoid inadequate software use  Gen_Dialog.class
<http://imagej.1557.x6.nabble.com/file/t380516/Gen_Dialog.class>  .

Attached please find an example GUI using an IJ-GeneralDialog that shows
what can be done with the according IJ-API.

Best regards

Herbie

:::::::::::::::::::::::::::::::::::::::::::::


Gabriel Landini wrote
> I suppose that the way to enable/disable a field based on the setting of
> another field is to use the DialogListener.
> A few plugins use that.
>
> Cheers
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html





--
Sent from: http://imagej.1557.x6.nabble.com/

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

Re: Manual choice within a GenericDialog

Kenneth R Sloan-2
yes - as I noted - I have code that uses DialogListener, and I have tried several styles of presentation.  After evaluating feedback from *my* users, I concluded that the extra dynamic capabilities in the dialog were not worth the extra complexity in the code.

Your milage may vary.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

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