Skip to main content



      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 15:23 Go to next message
Eclipse UserFriend
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 05:30 Go to previous messageGo to next message
Eclipse UserFriend
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 11:15 Go to previous message
Eclipse UserFriend
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: Wed Jul 02 20:38:39 EDT 2025

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

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

Back to the top