Donnerstag, 5. November 2009

Eclipse RCP Forms part one

Eclipse Forms allow you to achieve the Web look. Eclipse Editors for Manifest files (f.e) are coded in Forms.

tutorials links:
vogella tutorial about forms
forms tutorial 2
forms tutorial 3

Forms use Views:

public class FormView extends ViewPart {
public void createPartControl(Composite parent) {
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createForm(parent);
form.setText("Hello, Eclipse Forms");

it create the form where you can set other widgets.

Therefore forms use GridLayot, GridData, Buttons and other similar as SWT.

GridLayout layout = new GridLayout();

layout.numColumns = 2;
GridData gd = new GridData();
gd.horizontalSpan = 2;
Label label = new Label(form.getBody(), SWT.NULL);
label.setText("Text field label:");
Text text = new Text(form.getBody(), SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button button = new Button(form.getBody(), SWT.CHECK);
button.setText("An example of a checkbox in a form");
gd = new GridData();
gd.horizontalSpan = 2;

Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP);
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
System.out.println("Link activated!");

create a hyperlink as a HTML hyperlink.

for more information look tutorials

Keine Kommentare:

Kommentar veröffentlichen