Search in sources :

Example 1 with ScheduleLabelProvider

use of org.netxms.ui.eclipse.reporter.widgets.helpers.ScheduleLabelProvider 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)

Aggregations

ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)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 ScheduleLabelProvider (org.netxms.ui.eclipse.reporter.widgets.helpers.ScheduleLabelProvider)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1