Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TitleAreaDialog: Widgets disposed after click on the OK-Button
TitleAreaDialog: Widgets disposed after click on the OK-Button [message #490423] Thu, 08 October 2009 15:39 Go to next message
Michelle Davidson is currently offline Michelle DavidsonFriend
Messages: 41
Registered: August 2009
Member
Hello,

I have a JFace TitleAreaDialog, which change some properties for a given person.

In this dialog there are some textfields and some radio-Buttons.

I generate the OK and Cancel Button in the methode createButtonsForButtonBar().

@Override
	protected void createButtonsForButtonBar(Composite parent) {
		okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
		okButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				person.setName(name.getText());			
				....
				setReturnCode(OK);
				close();
			}
		});	
		cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
	   	cancelButton.addSelectionListener(new SelectionAdapter() {
	      public void widgetSelected(SelectionEvent e) {
	        setReturnCode(CANCEL);
	        close();
	      }
	    });
		
	}



But the problem is, when I click the ok Button and want to set the properties for the person., all textfields, radiobuttons are disposed and I don't get any values.

What is the reason for that, and what must I changed to set the values after click on the ok-Button.

Re: TitleAreaDialog: Widgets disposed after click on the OK-Button [message #490447 is a reply to message #490423] Thu, 08 October 2009 16:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evelyne.rien.com

You can override okPressed() like this :

/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed() {
person.setName(name.getText());
....
super.okPressed();
}

Don't call super.okPressed() if you want to cancel validation on some
controls (empty name for example).
It works for me when i'm subclassing JFace Dialog.

BTW : like okPressed(), okCancel() is called on Cancel Button.

Evelyne.


"Michelle Davidson" <michelle.davidson@gmx.de> a
Re: TitleAreaDialog: Widgets disposed after click on the OK-Button [message #490448 is a reply to message #490447] Thu, 08 October 2009 16:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evelyne.rien.com

oups.

instead of okCancel(), read cancelPressed().
Re: TitleAreaDialog: Widgets disposed after click on the OK-Button [message #490545 is a reply to message #490448] Fri, 09 October 2009 06:18 Go to previous message
Michelle Davidson is currently offline Michelle DavidsonFriend
Messages: 41
Registered: August 2009
Member
Thanks, that works fine for me.

Previous Topic:Editor with JFace Text
Next Topic:Get imagefilename for a column of a tableviewer
Goto Forum:
  


Current Time: Thu Apr 18 20:12:40 GMT 2024

Powered by FUDForum. Page generated in 0.02136 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top