コード例 #1
0
  @Override
  protected Control createContents(Composite parent) {
    init();
    Composite comp = new Composite(parent, SWT.None);
    comp.setLayout(new GridLayout(2, false));

    Label lblNewLabel = new Label(comp, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText("Strasse");

    textStrasse = new Text(comp, SWT.BORDER);
    textStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textStrasse.setTextLimit(80);

    Label lblPostleitzahl = new Label(comp, SWT.NONE);
    lblPostleitzahl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblPostleitzahl.setText("Postleitzahl");

    textPostleitzahl = new Text(comp, SWT.BORDER);
    textPostleitzahl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textPostleitzahl.setTextLimit(6);

    Label lblOrtschaft = new Label(comp, SWT.NONE);
    lblOrtschaft.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblOrtschaft.setText("Ortschaft");

    textOrtschaft = new Text(comp, SWT.BORDER);
    textOrtschaft.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    textOrtschaft.setTextLimit(50);

    Label lblLand = new Label(comp, SWT.NONE);
    lblLand.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblLand.setText("Land");

    TableComboViewer countryComboViewer = new TableComboViewer(comp);
    tableCombo = countryComboViewer.getTableCombo();
    tableCombo.setTableWidthPercentage(90);
    tableCombo.setShowFontWithinSelection(false);
    tableCombo.setShowColorWithinSelection(false);
    tableCombo.setShowTableLines(false);
    tableCombo.setShowTableHeader(false);
    tableCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    countryComboViewer.setLabelProvider(new CountryComboLabelProvider());
    countryComboViewer.setContentProvider(new ArrayContentProvider());
    String[] items = new String[] {"CH", "FL", "AT", "DE", "FR", "IT"};
    countryComboViewer.setInput(items);

    super.setTitle(pat.getLabel());
    textStrasse.setText(pat.get(Patient.FLD_STREET));
    textPostleitzahl.setText(pat.get(Patient.FLD_ZIP));
    textOrtschaft.setText(pat.get(Patient.FLD_PLACE));
    String country = pat.get(Patient.FLD_COUNTRY).trim();
    for (int i = 0; i < items.length; i++) {
      if (country.equalsIgnoreCase(items[i])) {
        countryComboViewer.setSelection(new StructuredSelection(items[i]), true);
      }
    }

    setUnlocked(CoreHub.getLocalLockService().isLocked(pat));

    return comp;
  }