public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final CompositeTable table = new CompositeTable(shell, SWT.NONE);
    new Header(table, SWT.NONE);
    new Row(table, SWT.NONE);
    table.setRunTime(true);

    final ICompositeTableRidget ridget =
        (ICompositeTableRidget) SwtRidgetFactory.createRidget(table);
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    ridget.bindToModel(input, Person.class, RowRidget.class);
    ridget.updateFromModel();

    shell.setSize(400, 160);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
  public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setText(SnippetMasterDetailsRidget003.class.getSimpleName());
    shell.setLayout(new FillLayout());

    final PersonMasterDetails details = new PersonMasterDetails(shell, SWT.NONE);

    final IMasterDetailsRidget ridget =
        (IMasterDetailsRidget) SwtRidgetFactory.createRidget(details);
    ridget.setDelegate(new PersonDelegate());
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    final String[] properties = {Person.PROPERTY_LASTNAME, Person.PROPERTY_FIRSTNAME};
    final String[] headers = {"Last Name", "First Name"}; // $NON-NLS-1$ //$NON-NLS-2$
    ridget.bindToModel(input, Person.class, properties, headers);
    ridget.updateFromModel();

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
Пример #3
0
  public SnippetTreeTableRidget006(final Shell shell) {
    final Composite tableComposite = new Composite(shell, SWT.NONE);
    tableComposite.setLayout(new GridLayout());
    final GridData layoutData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
    tableComposite.setLayoutData(layoutData2);

    final Tree tree = new Tree(tableComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.heightHint = 100;
    tree.setLayoutData(layoutData);
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);

    final TreeColumnLayout columnLayout = new TreeColumnLayout();
    final TreeColumn tableColumn = new TreeColumn(tree, SWT.FILL);
    tableColumn.setText("Test");
    columnLayout.setColumnData(tableColumn, new ColumnWeightData(10, 100));
    tableComposite.setLayout(columnLayout);

    final ITreeTableRidget treeRiget = (ITreeTableRidget) SwtRidgetFactory.createRidget(tree);
    treeRiget.setSelectionType(ISelectableRidget.SelectionType.MULTI);

    treeRiget.setColumnFormatter(
        0,
        new ColumnFormatter() {
          @Override
          public String getText(final Object element) {
            final TestTreeNode node = (TestTreeNode) element;
            if (node.getName() == null) {
              return "";
            }
            return node.getName();
          }
        });

    final Object[] roots = new Object[] {new TestTreeNode(null), new TestTreeNode("name")};
    treeRiget.bindToModel(
        roots,
        TestTreeNode.class,
        "children",
        "parent",
        new String[] {"name"},
        new String[] {"Name"});
  }