Search in sources :

Example 1 with ProcessFlag

use of org.erlide.tracing.core.ProcessFlag 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)

Example 2 with ProcessFlag

use of org.erlide.tracing.core.ProcessFlag in project erlide_eclipse by erlang.

the class ProcessLabelProvider method getColumnImage.

@Override
public Image getColumnImage(final Object element, final int columnIndex) {
    final TracedProcess process = (TracedProcess) element;
    if (ProcessColumn.SELECTED.ordinal() == columnIndex) {
        // process columns
        if (process.isSelected()) {
            return Activator.getDefault().getImageRegistry().get(Images.CHECKED.toString());
        }
        return Activator.getDefault().getImageRegistry().get(Images.UNCHECKED.toString());
    }
    // flag columns
    final ProcessFlag flag = ProcessFlag.getByIndex(columnIndex - ProcessColumn.values().length);
    if (flag != null) {
        if (process.hasFlag(flag)) {
            return Activator.getDefault().getImageRegistry().get(Images.CHECKED.toString());
        }
        return Activator.getDefault().getImageRegistry().get(Images.UNCHECKED.toString());
    }
    return null;
}
Also used : TracedProcess(org.erlide.tracing.core.mvc.model.TracedProcess) ProcessFlag(org.erlide.tracing.core.ProcessFlag)

Example 3 with ProcessFlag

use of org.erlide.tracing.core.ProcessFlag in project erlide_eclipse by erlang.

the class ControlPanelView method createProcessCheckBoxes.

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ProcessFlag(org.erlide.tracing.core.ProcessFlag)

Example 4 with ProcessFlag

use of org.erlide.tracing.core.ProcessFlag in project erlide_eclipse by erlang.

the class ProcessCellModifier method modify.

@Override
public void modify(final Object element, final String property, final Object value) {
    final TracedProcess process = (TracedProcess) ((TableItem) element).getData();
    // processes column
    try {
        if (ProcessColumn.SELECTED.equals(ProcessColumn.valueOf(property))) {
            process.setSelected((Boolean) value);
            tableViewer.update(process, null);
        }
        return;
    } catch (final Exception e) {
    }
    // flag column
    final ProcessFlag flag = ProcessFlag.valueOf(property);
    if ((Boolean) value) {
        process.setFlag(flag);
    } else {
        process.unSetFlag(flag);
    }
    tableViewer.update(process, null);
}
Also used : TracedProcess(org.erlide.tracing.core.mvc.model.TracedProcess) ProcessFlag(org.erlide.tracing.core.ProcessFlag)

Aggregations

ProcessFlag (org.erlide.tracing.core.ProcessFlag)4 Composite (org.eclipse.swt.widgets.Composite)2 TracedProcess (org.erlide.tracing.core.mvc.model.TracedProcess)2 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 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Button (org.eclipse.swt.widgets.Button)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)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