Esempio n. 1
0
  private Composite createProcessCheckBoxes(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new RowLayout());

    TraceBackend.getInstance().removeAllProcessFlag();

    for (final ProcessFlag flag : ProcessFlag.values()) {
      final Button button = new Button(container, SWT.CHECK);
      button.setText(flag.getName());
      button.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
              if (button.getSelection()) {
                TraceBackend.getInstance().addProcessFlag(flag);
              } else {
                TraceBackend.getInstance().removeProcessFlag(flag);
              }
            }
          });
    }
    return container;
  }
Esempio n. 2
0
  private Composite createProcessesTable(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout());
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final int style =
        SWT.SINGLE
            | SWT.BORDER
            | SWT.H_SCROLL
            | SWT.V_SCROLL
            | SWT.FULL_SELECTION
            | SWT.HIDE_SELECTION;
    final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.grabExcessVerticalSpace = true;

    processesTableViewer = new TableViewer(container, style);
    processesTableViewer.setUseHashlookup(true);

    // table
    final Table table = processesTableViewer.getTable();
    table.setLayoutData(gridData);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    // columns
    final String columnProperties[] =
        new String[ProcessColumn.values().length + ProcessFlag.values().length];

    // columns: process properties
    for (final ProcessColumn column : ProcessColumn.values()) {
      final TableColumn tableColumn = new TableColumn(table, SWT.LEFT, column.ordinal());
      tableColumn.setResizable(true);
      tableColumn.setMoveable(false);
      tableColumn.setWidth(column.getWidth());
      tableColumn.setText(column.getName());
      columnProperties[column.ordinal()] = column.name();
    }
    // columns: process flags
    for (final ProcessFlag flag : ProcessFlag.values()) {
      final TableColumn tableColumn =
          new TableColumn(table, SWT.CENTER, ProcessColumn.values().length + flag.ordinal());
      tableColumn.setResizable(true);
      tableColumn.setMoveable(false);
      tableColumn.setWidth(60);
      tableColumn.setText(flag.getName());
      columnProperties[ProcessColumn.values().length + flag.ordinal()] = flag.name();
    }
    processesTableViewer.setColumnProperties(columnProperties);

    // providers
    processesTableViewer.setLabelProvider(new ProcessLabelProvider());
    processesTableViewer.setContentProvider(new ProcessContentProvider());

    // input
    fillProcessesList(processesTableViewer);
    processesTableViewer.setInput(TraceBackend.getInstance().getProcesses());

    // editors
    final CellEditor[] editors =
        new CellEditor[ProcessFlag.values().length + ProcessFlag.values().length];
    editors[ProcessColumn.SELECTED.ordinal()] = new CheckboxCellEditor(table);
    for (final ProcessFlag flag : ProcessFlag.values()) {
      editors[ProcessColumn.values().length + flag.ordinal()] = new CheckboxCellEditor(table);
    }
    processesTableViewer.setCellEditors(editors);
    processesTableViewer.setCellModifier(new ProcessCellModifier(processesTableViewer));

    return container;
  }