Search in sources :

Example 96 with SortableTableViewer

use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.

the class ReportExecutionForm method createSchedulesSection.

/**
 * Create "Schedules" section's content
 *
 * @param parent
 *            parent composite
 */
/**
 * @param section
 * @return
 */
private void createSchedulesSection(Composite parent) {
    GridLayout layout = new GridLayout();
    parent.setLayout(layout);
    final String[] names = { "Type", "Schedule", "Owner", "Comments" };
    final int[] widths = { 100, 140, 100, 300 };
    scheduleList = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    scheduleList.getControl().setLayoutData(gd);
    scheduleList.setContentProvider(new ArrayContentProvider());
    scheduleList.setLabelProvider(new ScheduleLabelProvider());
    WidgetHelper.restoreTableViewerSettings(scheduleList, Activator.getDefault().getDialogSettings(), "ReportExecutionForm.ScheduleList");
    scheduleList.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(scheduleList, Activator.getDefault().getDialogSettings(), "ReportExecutionForm.ScheduleList");
        }
    });
    ImageHyperlink link = toolkit.createImageHyperlink(parent, SWT.WRAP);
    // $NON-NLS-1$
    link.setImage(imageCache.add(Activator.getImageDescriptor("icons/schedule.png")));
    link.setText("Add Schedule");
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            addSchedule();
        }
    });
    createSchedulesContextMenu();
    scheduleList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) scheduleList.getSelection();
            actionDeleteSchedule.setEnabled(selection.size() > 0);
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ScheduleLabelProvider(org.netxms.ui.eclipse.reporter.widgets.helpers.ScheduleLabelProvider) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 97 with SortableTableViewer

use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.

the class MappingTableEditor method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    final int[] widths = { 200, 200, 400 };
    final String[] names = { Messages.get().MappingTableEditor_ColKey, Messages.get().MappingTableEditor_ColValue, Messages.get().MappingTableEditor_ColComments };
    viewer = new SortableTableViewer(parent, names, widths, COLUMN_KEY, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new MappingTableEntryLabelProvider());
    viewer.setComparator(new MappingTableEntryComparator());
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    viewer.setColumnProperties(new String[] { "key", "value", "comments" });
    CellEditor[] editors = new CellEditor[] { new TextCellEditor(viewer.getTable()), new TextCellEditor(viewer.getTable()), new TextCellEditor(viewer.getTable()) };
    viewer.setCellEditors(editors);
    viewer.setCellModifier(new CellModifier());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            actionDelete.setEnabled(selection.size() > 0);
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    activateContext();
    refresh();
}
Also used : ICellModifier(org.eclipse.jface.viewers.ICellModifier) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MappingTableEntryComparator(org.netxms.ui.eclipse.serverconfig.views.helpers.MappingTableEntryComparator) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) MappingTableEntryLabelProvider(org.netxms.ui.eclipse.serverconfig.views.helpers.MappingTableEntryLabelProvider)

Aggregations

SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)97 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)66 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)43 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)43 Composite (org.eclipse.swt.widgets.Composite)43 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)40 GridData (org.eclipse.swt.layout.GridData)38 GridLayout (org.eclipse.swt.layout.GridLayout)38 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)29 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)29 SelectionEvent (org.eclipse.swt.events.SelectionEvent)28 Button (org.eclipse.swt.widgets.Button)28 SelectionListener (org.eclipse.swt.events.SelectionListener)27 DisposeEvent (org.eclipse.swt.events.DisposeEvent)26 DisposeListener (org.eclipse.swt.events.DisposeListener)26 RowLayout (org.eclipse.swt.layout.RowLayout)24 RowData (org.eclipse.swt.layout.RowData)20 Event (org.eclipse.swt.widgets.Event)14 FillLayout (org.eclipse.swt.layout.FillLayout)12 Iterator (java.util.Iterator)11