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;
}
Aggregations