Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to get value from RCP forms
How to get value from RCP forms [message #992504] Fri, 21 December 2012 20:23 Go to next message
davy huFriend
Messages: 2
Registered: December 2012
Junior Member
I created a form by using the forms API:

My question is how can write the code to get the values of "first name" and "last name" when "submit" button is clicked. Theanks.

here is my code in View.java

public class View extends ViewPart {
public static final String ID = "com.test.forms.view";

private TableViewer viewer;

public void createPartControl(Composite parent) {
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
Composite client = toolkit.createComposite(parent, SWT.WRAP);
Table t = toolkit.createTable(client, SWT.NULL);
viewer = new TableViewer(t);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setInput(getViewSite());

Form form = toolkit.createForm(parent);
Composite composite = form.getBody();
composite.setLayout (new GridLayout(2, true));

Label lblFirstName = toolkit.createLabel(composite, "First Name");
Label lblLastName = toolkit.createLabel(composite, "Last Name");
Text txtFirstName = toolkit.createText(composite, "");
Text txtLastName = toolkit.createText(composite, "");
Button b = toolkit.createButton(composite, "Submit", SWT.PUSH);
}

public void setFocus() {
viewer.getControl().setFocus();
}
}

Re: How to get value from RCP forms [message #994443 is a reply to message #992504] Thu, 27 December 2012 10:30 Go to previous messageGo to next message
Simon Scholz is currently offline Simon ScholzFriend
Messages: 73
Registered: April 2012
Location: Germany
Member
Hello davy,

you just have to add an selection listener to the button in order to get to know when the button is clicked.

And then use the txtFirstName.getText() and txtLastName.getText() methods to get the values.

By the way the FormToolkit also does only create SWT widgets internally.

Best regards,

Simon
Re: How to get value from RCP forms [message #995952 is a reply to message #994443] Mon, 31 December 2012 16:15 Go to previous message
davy huFriend
Messages: 2
Registered: December 2012
Junior Member
Thank you very much Simon! I got it now!
Previous Topic:How can i add an perspective from a plugin to my e4 application model?
Next Topic:Databinding, IListener, and Data Retention post application close
Goto Forum:
  


Current Time: Thu Apr 25 02:18:22 GMT 2024

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

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

Back to the top