use of org.jcryptool.actions.ui.views.provider.ActionLabelProvider in project core by jcryptool.
the class ActionView method createActionTable.
private void createActionTable(Composite parent) {
// Creating a table viewer
viewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.ActionView_5);
column.getColumn().setToolTipText(Messages.ActionView_6);
column.getColumn().setWidth(50);
column.getColumn().setMoveable(true);
column = new TableViewerColumn(viewer, SWT.LEFT);
column.getColumn().setText(Messages.ActionView_0);
column.getColumn().setToolTipText(Messages.ActionView_1);
column.getColumn().setWidth(80);
column.getColumn().setMoveable(true);
filenameColumn = new TableViewerColumn(viewer, SWT.LEFT);
filenameColumn.getColumn().setText(Messages.ActionView_2);
filenameColumn.getColumn().setToolTipText(Messages.ActionView_3);
filenameColumn.getColumn().setMoveable(true);
setFilenameVisibility();
viewer.setContentProvider(new ObservableListContentProvider());
viewer.setLabelProvider(new ActionLabelProvider());
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent e) {
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
ActionItem action = (ActionItem) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
if (action != null) {
detailTextfield.setText(action.getDetails());
if (detailTextfield.getLineCount() > 0) {
detailTextfield.setLineBackground(0, 1, colorLightShadow);
StyleRange styleRange = new StyleRange();
styleRange.start = 0;
styleRange.length = detailTextfield.getText().indexOf(CRLF);
styleRange.fontStyle = SWT.BOLD;
detailTextfield.setStyleRange(styleRange);
detailTextfield.setTabs(20);
int i = 0;
int l = 0;
while (i >= 0) {
i = detailTextfield.getText().indexOf(CRLF, i + 1);
// $NON-NLS-1$
l = detailTextfield.getText().indexOf(":", i + 1) - i;
if (l > 0 && i >= 0) {
styleRange.start = i;
styleRange.length = l;
detailTextfield.setStyleRange(styleRange);
}
}
}
} else {
// $NON-NLS-1$
detailTextfield.setText("");
}
}
});
viewer.setInput(ActionCascadeService.getInstance().observeActionItems());
ActionCascadeService.getInstance().observeActionItems().addListChangeListener(this);
getSite().setSelectionProvider(viewer);
}
Aggregations