Package de.mhus.lib.form.objects

Examples of de.mhus.lib.form.objects.IDynTableProvider


   
   
    table = new Table(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    table.setLayoutData(data);
   
    IDynTableProvider provider = ((FStringList)target).getDataProvider();
    initTable(provider);

    table.addFocusListener(new FocusAdapter() {

      public void focusGained(FocusEvent arg0) {
//TODO        control.fireDescriptionChanged(false, desc);
      }

    });
   
    table.addMenuDetectListener(new MenuDetectListener() {

      @Override
      public void menuDetected(MenuDetectEvent arg0) {
        final IDynTableProvider provider = ((FStringList) target)
            .getDataProvider();
        if (!table.isEnabled() || provider == null)
          return;
        final Menu menu = new Menu(parent.getShell(), SWT.POP_UP);

        MenuItem item = new MenuItem(menu, SWT.PUSH);
        item.setText("Create");
        item.addListener(SWT.Selection,
            new org.eclipse.swt.widgets.Listener() {
              public void handleEvent(Event e) {
                int pos = table.getSelectionIndex();
                TableItem item = null;
                if (pos >= 0) {
                  item = new TableItem(table, SWT.NONE, pos);
                } else {
                  item = new TableItem(table, SWT.NONE);
                }
                IDynTableProvider provider = ((FStringList) target)
                    .getDataProvider();
                item.setText(provider.getDefaultRow());
              }
            });

        int pos = table.getSelectionIndex();
        if (pos > 0) {
          item = new MenuItem(menu, SWT.PUSH);
          item.setText("Move Up");
          item.addListener(SWT.Selection,
              new org.eclipse.swt.widgets.Listener() {
                public void handleEvent(Event e) {
                  int pos = table.getSelectionIndex();
                  TableItem it1 = table.getItem(pos);
                  String[] sa = new String[provider
                      .getColumnCount()];
                  for (int i = 0; i < sa.length; i++)
                    sa[i] = it1.getText(i);
                  table.remove(pos);
                  TableItem it2 = new TableItem(table,
                      SWT.NONE, pos - 1);
                  it2.setText(sa);
                }
              });
        }

        if (pos < table.getItemCount() - 1 && pos >= 0) {
          item = new MenuItem(menu, SWT.PUSH);
          item.setText("Move Down");
          item.addListener(SWT.Selection,
              new org.eclipse.swt.widgets.Listener() {
                public void handleEvent(Event e) {
                  int pos = table.getSelectionIndex();
                  TableItem it1 = table.getItem(pos);
                  String[] sa = new String[provider
                      .getColumnCount()];
                  for (int i = 0; i < sa.length; i++)
                    sa[i] = it1.getText(i);
                  table.remove(pos);
                  TableItem it2 = new TableItem(table,
View Full Code Here


    }
    table.setHeaderVisible(true);
  }
  public void getValue() throws FormException {
    table.removeAll();
    IDynTableProvider provider = ((FStringList)target).getDataProvider();
    if (provider == null) return;
    initTable(provider);
    for (int r = 0; r < provider.getRowCount(); r++ ) {
      TableItem item = new TableItem(table, SWT.NONE);
      item.setText(provider.getRow(r));
    }
  }
View Full Code Here

    table.dispose();
  }

  public void setValue() {
    LinkedList<String[]> out = new LinkedList<String[]>();
    IDynTableProvider provider = ((FStringList)target).getDataProvider();
    if (provider == null) return;

    for (TableItem item : table.getItems()) {
      int cc = provider.getColumnCount();
      String[] items = new String[cc];
      for (int c = 0; c < cc; c++)
        items[c] = item.getText(c);
      out.add(items);
    }
    provider.setData(out.toArray(new String[out.size()][]));
  }
View Full Code Here

TOP

Related Classes of de.mhus.lib.form.objects.IDynTableProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.