Search in sources :

Example 1 with ActionLabelProvider

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);
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ActionItem(org.jcryptool.actions.core.types.ActionItem) StyleRange(org.eclipse.swt.custom.StyleRange) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableViewer(org.eclipse.jface.viewers.TableViewer) ActionLabelProvider(org.jcryptool.actions.ui.views.provider.ActionLabelProvider) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 ActionItem (org.jcryptool.actions.core.types.ActionItem)1 ActionLabelProvider (org.jcryptool.actions.ui.views.provider.ActionLabelProvider)1