quaylar
quaylar

Reputation: 2635

JFace-Dialog: How to query user-input

I am using an org.eclipse.ui.forms.FormDialog-derived class to query users of my RCP-Application for input. This is a modal dialog which is closed after the user clicked the OK-Button. I have created member-variables for the Text-widgets and trying to get the user's input with getText() after the user has clicked the OK-Button (and therefore has closed the dialog).

Unfortunately the widgets are disposed when the dialog closes (so, with clicking the OK-Button), and there is no way to call getText() on the Text-Widgets anymore.

I was wondering how others solve this use-case?

Upvotes: 0

Views: 652

Answers (2)

Tonny Madsen
Tonny Madsen

Reputation: 12718

Simply extend Dialog.okPressed() in your code to retrieve the current values before the dialogis closed...

Upvotes: 2

Tom Seidel
Tom Seidel

Reputation: 9535

Use a datamodel, e.g. simple Pojos to store user-inputs. This model is bound via the Eclipse Databinding to your Ui, e.g. to a Textfield and is synchronized every time the user modifies the value of the textfield. Take a look at the tutorial how to integrate databinding in your application, see http://www.vogella.de/articles/EclipseDataBinding/article.html

Upvotes: 1

Related Questions