Search in sources :

Example 1 with RealEditingSupport

use of org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport in project statecharts by Yakindu.

the class ExecutionContextViewerFactory method createViewer.

public static TreeViewer createViewer(Composite parent, boolean readOnly, ITypeSystemProvider provider) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    TreeColumnLayout layout = new TreeColumnLayout();
    comp.setLayout(layout);
    final TreeViewer viewer = new TreeViewer(comp, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    ExecutionContextContentProvider contentProvider = new ExecutionContextContentProvider();
    viewer.setContentProvider(contentProvider);
    viewer.setFilters(new ViewerFilter[] { new TimeEventViewerFilter() });
    TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.NONE);
    nameColumn.getColumn().setText("Name");
    nameColumn.getColumn().setResizable(true);
    nameColumn.setLabelProvider(new ExecutionContextLabelProvider(0, readOnly));
    TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.NONE);
    valueColumn.getColumn().setText("Value");
    valueColumn.getColumn().setResizable(false);
    valueColumn.setLabelProvider(new ExecutionContextLabelProvider(1, readOnly));
    layout.setColumnData(nameColumn.getColumn(), new ColumnWeightData(NAME_COL_WIDTH_RATIO, NAME_COL_MIN_WIDTH));
    layout.setColumnData(valueColumn.getColumn(), new ColumnWeightData(VALUE_COL_WIDTH_RATIO, VALUE_COL_MIN_WIDTH));
    if (!readOnly)
        valueColumn.setEditingSupport(new MultiEditingSupport(viewer, // 
        new EnumerationEditingSupport(viewer, provider), // 
        new IntegerEditingSupport(viewer, provider), // 
        new RealEditingSupport(viewer, provider), // 
        new BooleanEditingSupport(viewer, provider), // 
        new StringEditingSupport(viewer, provider)));
    valueColumn.getViewer().getColumnViewerEditor().addEditorActivationListener(new ColumnViewerEditorActivationListener() {

        @Override
        public void afterEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
            contentProvider.setShouldUpdate(true);
            viewer.refresh();
        }

        @Override
        public void afterEditorActivated(ColumnViewerEditorActivationEvent event) {
            contentProvider.setShouldUpdate(false);
        }

        @Override
        public void beforeEditorDeactivated(ColumnViewerEditorDeactivationEvent event) {
        }

        @Override
        public void beforeEditorActivated(ColumnViewerEditorActivationEvent event) {
        }
    });
    return viewer;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ColumnViewerEditorDeactivationEvent(org.eclipse.jface.viewers.ColumnViewerEditorDeactivationEvent) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) ColumnViewerEditorActivationListener(org.eclipse.jface.viewers.ColumnViewerEditorActivationListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) RealEditingSupport(org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport) BooleanEditingSupport(org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport) StringEditingSupport(org.yakindu.sct.simulation.ui.view.editing.StringEditingSupport) ColumnViewerEditorActivationEvent(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) EnumerationEditingSupport(org.yakindu.sct.simulation.ui.view.editing.EnumerationEditingSupport) IntegerEditingSupport(org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport) GridData(org.eclipse.swt.layout.GridData) MultiEditingSupport(org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport)

Aggregations

TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)1 ColumnViewerEditorActivationEvent (org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent)1 ColumnViewerEditorActivationListener (org.eclipse.jface.viewers.ColumnViewerEditorActivationListener)1 ColumnViewerEditorDeactivationEvent (org.eclipse.jface.viewers.ColumnViewerEditorDeactivationEvent)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 BooleanEditingSupport (org.yakindu.sct.simulation.ui.view.editing.BooleanEditingSupport)1 EnumerationEditingSupport (org.yakindu.sct.simulation.ui.view.editing.EnumerationEditingSupport)1 IntegerEditingSupport (org.yakindu.sct.simulation.ui.view.editing.IntegerEditingSupport)1 MultiEditingSupport (org.yakindu.sct.simulation.ui.view.editing.MultiEditingSupport)1 RealEditingSupport (org.yakindu.sct.simulation.ui.view.editing.RealEditingSupport)1 StringEditingSupport (org.yakindu.sct.simulation.ui.view.editing.StringEditingSupport)1