Search in sources :

Example 1 with ProcessCellModifier

use of org.erlide.tracing.core.mvc.controller.ProcessCellModifier in project erlide_eclipse by erlang.

the class ControlPanelView method createProcessesTable.

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;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) MatchSpecCellEditor(org.erlide.tracing.core.mvc.view.MatchSpecCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ProcessLabelProvider(org.erlide.tracing.core.mvc.view.ProcessLabelProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) ProcessFlag(org.erlide.tracing.core.ProcessFlag) ProcessColumn(org.erlide.tracing.core.mvc.view.ProcessColumn) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ProcessCellModifier(org.erlide.tracing.core.mvc.controller.ProcessCellModifier) ProcessContentProvider(org.erlide.tracing.core.mvc.view.ProcessContentProvider) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

CellEditor (org.eclipse.jface.viewers.CellEditor)1 CheckboxCellEditor (org.eclipse.jface.viewers.CheckboxCellEditor)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 ProcessFlag (org.erlide.tracing.core.ProcessFlag)1 ProcessCellModifier (org.erlide.tracing.core.mvc.controller.ProcessCellModifier)1 MatchSpecCellEditor (org.erlide.tracing.core.mvc.view.MatchSpecCellEditor)1 ProcessColumn (org.erlide.tracing.core.mvc.view.ProcessColumn)1 ProcessContentProvider (org.erlide.tracing.core.mvc.view.ProcessContentProvider)1 ProcessLabelProvider (org.erlide.tracing.core.mvc.view.ProcessLabelProvider)1