Example #1
0
  protected Section bindNestedComplexProperties(
      FormToolkit toolkit,
      Composite parent,
      final IMessageManager mmng,
      ComplexPropertyDescriptor complexProperty,
      final Object id,
      String labelText,
      String tooltip) {
    Class<?> complexType = complexProperty.getPropertyType();
    Section section =
        toolkit.createSection(
            parent, Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    section.setText(labelText);
    section.setToolTipText(tooltip);
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new GridLayout(2, false));
    section.setClient(sectionClient);

    // now lets introspect the composite...
    Object value = node.getPropertyValue(id);
    if (value == null) {
      value = ObjectHelper.newInstance(complexType);
      node.setPropertyValue(id, value);
    }
    bindNestedComplexProperties(toolkit, mmng, complexProperty, complexType, sectionClient, value);
    sectionClient.layout(true, true);
    return section;
  }
Example #2
0
 public static C24IOTransform transform(Class<?> transformType) {
   Transform transformer = (Transform) ObjectHelper.newInstance(transformType);
   return transform(transformer);
 }
Example #3
0
  protected CTabFolder bindNestedComplexUnionProperties(
      final FormToolkit toolkit,
      Composite parent,
      final IMessageManager mmng,
      final Object id,
      String labelText,
      String tooltip,
      ComplexUnionPropertyDescriptor complexProperty) {

    Class<?> basePropertyType = complexProperty.getPropertyType();

    // final CTabFolder bar = new CTabFolder(parent, SWT.TITLE | SWT.BORDER);
    final CTabFolder bar = new CTabFolder(parent, SWT.BORDER);
    // section.setTitle(labelText);
    bar.setToolTipText(tooltip);
    final UnionTypeValue[] valueTypes = complexProperty.getValueTypes();
    final Object[] values = new Object[valueTypes.length];

    bar.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            int idx = bar.getSelectionIndex();
            if (idx >= 0 && idx < valueTypes.length) {
              // lets update the model with the value for this tab
              node.setPropertyValue(id, values[idx]);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}
        });

    Object value = node.getPropertyValue(id);
    int selectIdx = -1;
    int idx = 0;
    for (UnionTypeValue valueType : valueTypes) {
      Composite composite = new Composite(bar, SWT.NONE);
      composite.setLayout(new GridLayout(2, false));

      CTabItem item = new CTabItem(bar, SWT.BORDER);
      item.setText(valueType.getId());
      item.setControl(composite);

      Class<?> complexType = valueType.getValueType();
      Object tabValue;
      if (complexType.isInstance(value)) {
        selectIdx = idx;
        tabValue = value;
      } else {
        tabValue = ObjectHelper.newInstance(complexType);
      }
      values[idx++] = tabValue;
      bindNestedComplexProperties(toolkit, mmng, complexProperty, complexType, composite, tabValue);
      composite.layout(true, true);
    }
    if (selectIdx >= 0) {
      bar.setSelection(selectIdx);
    }
    bar.layout(true, true);
    return bar;
  }