Search in sources :

Example 1 with OrderingColumnEditingSupport

use of org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingColumnEditingSupport in project netxms by netxms.

the class FilterBuilder method createOrderingSection.

/**
 * Create ordering section
 */
private void createOrderingSection() {
    ordering = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    ordering.setText(Messages.get().FilterBuilder_Ordering);
    TableWrapData twd = new TableWrapData();
    twd.grabHorizontal = false;
    twd.align = TableWrapData.FILL;
    ordering.setLayoutData(twd);
    final Composite clientArea = toolkit.createComposite(ordering);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    clientArea.setLayout(layout);
    ordering.setClient(clientArea);
    orderingList = new TableViewer(clientArea, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    toolkit.adapt(orderingList.getTable());
    TableViewerColumn column = new TableViewerColumn(orderingList, SWT.LEFT);
    column.getColumn().setText(Messages.get().FilterBuilder_Column);
    column.getColumn().setWidth(200);
    column = new TableViewerColumn(orderingList, SWT.LEFT);
    column.getColumn().setText(Messages.get().FilterBuilder_Descending);
    column.getColumn().setWidth(60);
    column.setEditingSupport(new OrderingColumnEditingSupport(orderingList));
    orderingList.getTable().setLinesVisible(true);
    orderingList.getTable().setHeaderVisible(true);
    orderingList.setContentProvider(new ArrayContentProvider());
    orderingList.setLabelProvider(new OrderingListLabelProvider());
    orderingList.setInput(orderingColumns.toArray());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalSpan = 2;
    gd.heightHint = 60;
    orderingList.getControl().setLayoutData(gd);
    final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkAdd.setText(Messages.get().FilterBuilder_Add);
    linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
    linkAdd.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            addSortingColumn(linkAdd);
        }
    });
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkAdd.setLayoutData(gd);
    final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
    linkRemove.setText(Messages.get().FilterBuilder_Remove);
    linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
    linkRemove.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            removeSortingColumn();
        }
    });
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    linkRemove.setLayoutData(gd);
    linkRemove.setEnabled(false);
    orderingList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            linkRemove.setEnabled(!orderingList.getSelection().isEmpty());
        }
    });
}
Also used : OrderingColumnEditingSupport(org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingColumnEditingSupport) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) OrderingListLabelProvider(org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingListLabelProvider) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)1 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)1 ImageHyperlink (org.eclipse.ui.forms.widgets.ImageHyperlink)1 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)1 OrderingColumnEditingSupport (org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingColumnEditingSupport)1 OrderingListLabelProvider (org.netxms.ui.eclipse.logviewer.widgets.helpers.OrderingListLabelProvider)1