コード例 #1
0
  private void createWidgetRows(Composite parent) {
    if (konsultation != null) {
      List<ResourceItem> items = new ArrayList<ResourceItem>();

      RadioGroupListener radioGroupListener = new RadioGroupListener();

      VersionedResource vr = konsultation.getEintrag();
      int last = vr.getHeadVersion();
      for (int i = last; i >= 0; i--) {
        ResourceItem ri = vr.getVersion(i);

        int version = i;
        String label = ri.getLabel();
        String data = ri.data;
        String labelText = "Rev " + version + ": " + label;

        Composite rowComposite = new Composite(parent, SWT.NONE);
        rowComposite.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
        GridLayout gridLayout = new GridLayout(1, false);
        gridLayout.verticalSpacing = 0;
        rowComposite.setLayout(gridLayout);

        Button radioButton = new Button(rowComposite, SWT.RADIO);
        GridData gd = SWTHelper.getFillGridData(1, true, 1, false);
        gd.verticalAlignment = GridData.BEGINNING;
        radioButton.setLayoutData(gd);
        radioButton.setText(labelText);
        radioGroupListener.addButton(radioButton);

        /*
         * Label labelWidget = new Label(rowComposite, SWT.LEFT);
         * labelWidget.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
         * labelWidget.setText(labelText);
         */

        /*
         * Composite filler = new Composite(rowComposite, SWT.NONE); gd =
         * SWTHelper.getFillGridData(1, false, 1, false); gd.widthHint = 0; gd.heightHint =
         * 0; filler.setLayoutData(gd);
         */

        EnhancedTextFieldRO text = new EnhancedTextFieldRO(rowComposite);
        text.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
        text.setText(data);

        WidgetRow widgetRow = new WidgetRow(radioButton, version);
        widgetRows.add(widgetRow);
      }

      // check the first radio button
      if (widgetRows.size() > 0) {
        widgetRows.get(0).radio.setSelection(true);
      }
    }
  }