public class PersoenlicheDaten extends FormPage {
private Person person;
private Text vorname;
private Text nachname;
private DateChooserCombo geburtsdatum;
private Text staatsabgehoerigkeit;
public PersoenlicheDaten(FormEditor editor, Person person) {
super(editor, "Personalien", "Persönliche Daten");
this.person = person;
}
// Getter und Setter
protected void createFormContent(IManagedForm managedForm) {
ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
form.setText("Titel");
//form.setBackgroundImage(FormArticlePlugin.getDefault().getImage(
// FormArticlePlugin.IMG_FORM_BG));
ColumnLayout layout = new ColumnLayout();
form.getBody().setLayout(layout);
createPersonalienSection(form, toolkit, "Personalien");
}
@Override
public boolean isDirty() {
if(!nachname.getText().equals(person.getNachname())){
return true;
}
return false;
}
private void createPersonalienSection(final ScrolledForm form,
FormToolkit toolkit, String title) {
Section sectionPersonalien = toolkit.createSection(form.getBody(),
Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE
| Section.EXPANDED);
toolkit.createCompositeSeparator(sectionPersonalien);
Composite client = toolkit
.createComposite(sectionPersonalien, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
client.setLayout(layout);
GridData gdPer = new GridData(GridData.FILL_HORIZONTAL);
Label labelVorname = toolkit.createLabel(client, "Vorname", SWT.NONE);
labelVorname.setVisible(true);
vorname = toolkit.createText(client, person.getVorname(), SWT.BORDER);
vorname.setLayoutData(gdPer);
Label labelNachname = toolkit.createLabel(client, "Nachname", SWT.NONE);
labelNachname.setVisible(true);
nachname = toolkit.createText(client, person.getNachname(), SWT.BORDER);
nachname.setLayoutData(gdPer);
Label labelGeburtsdatum = toolkit.createLabel(client, "Geburtsdatum",
SWT.NONE);
labelGeburtsdatum.setVisible(true);
Composite dateChooser = toolkit.createComposite(client, SWT.BORDER);
geburtsdatum = new DateChooserCombo(dateChooser, SWT.NONE);
geburtsdatum.setTheme(DateChooserTheme.CLASSIC);
geburtsdatum.setWeeksVisible(true);
geburtsdatum.setFooterVisible(true);
Label labelStaatsangehörigkeit = toolkit.createLabel(client,
"Staatsangehörigkeit", SWT.NONE);
labelStaatsangehörigkeit.setVisible(true);
staatsabgehoerigkeit = toolkit.createText(client, person
.getStaatsangehoerigkeit(), SWT.BORDER);
staatsabgehoerigkeit.setLayoutData(gdPer);
sectionPersonalien.setText(title);
sectionPersonalien.setDescription("Hier werden die Personalien");
sectionPersonalien.setClient(client);
sectionPersonalien.setExpanded(true);
sectionPersonalien.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(false);
}
});
}
@Override
public void dispose() {
super.dispose();
}