GenericDialogPlus Preview update parameters

Hi,

I’m using the GenericDialogPlus Dialog for one of my plugins. I’ve added a preview checkbox which works perfectly in most of the cases. Unfortunately, one parameter leads to a calculation intensive procedure and if I change it, e.g from 24 to 30, it always only recognizes the first number (e.g. the 3 and not the 0).

Has anyone made the same experience and give me a hint?

Best,
Thorsten

Hi @twagner

are you sure it only recognises the 3? I could imagine, that it recognizes the 3, starts the calculation and later recognizes the 30.

I had such an issue as well when programming a search bar these days. I had the problem that I don’t want to run a search until the user actually has finished typing into a search text field. My solution was delaying the actual search with a timer. You find the code here:
https://github.com/haesleinhuepf/imagej-legacy/blob/search-bar/src/main/java/net/imagej/legacy/search/WikiSearchPlugin.java#L38

The timer is cancelled and restarted whenever the user enters something to the text field. If the user doesn’t enter something for longer than 500 msec, then the seach is actually started…

I hope that helps.

Cheers,
Robert

No! At least it never starts a run with “30” as parameter. I will try your suggestion and give feedback!

1 Like

Hi,

I’ve added

try {
			TimeUnit.SECONDS.sleep(1);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

It now recognizes the 30 after it finished the run with the “3”. But it should interrupt the run with “3”, right? Is there any way to improve that behavior?

Best,
Thorsten

Hi @twagner,

well, in my case, the run with “3” does not need to be interrupted, because I expect the user to enter the “0” within 0.5 seconds. In other words: there is a delay between the last keyboard-hit and the actual action to be started. The run with “3” never started :wink: And that’s ok, because the user didn’t wanted to enter a “3”, he wanted to enter “30”…

Where did you put this sleep(1) code snipped?

Cheers,
Robert

Hi @haesleinhuepf !

I put the code at beginning of the run method.

Best,
Thorsten