Search in sources :

Example 1 with ReportResultLabelProvider

use of org.netxms.ui.eclipse.reporter.widgets.helpers.ReportResultLabelProvider in project netxms by netxms.

the class ReportExecutionForm method createResultsSection.

/**
 * Create "Results" section's content
 *
 * @param parent
 *            parent composite
 */
private void createResultsSection(Composite parent) {
    GridLayout layout = new GridLayout();
    parent.setLayout(layout);
    final String[] names = { "Execution Time", "Started by", "Status" };
    final int[] widths = { 180, 140, 100 };
    resultList = 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;
    resultList.getControl().setLayoutData(gd);
    resultList.setContentProvider(new ArrayContentProvider());
    resultList.setLabelProvider(new ReportResultLabelProvider());
    WidgetHelper.restoreTableViewerSettings(resultList, Activator.getDefault().getDialogSettings(), "ReportExecutionForm.ResultList");
    resultList.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(resultList, Activator.getDefault().getDialogSettings(), "ReportExecutionForm.ResultList");
        }
    });
    ImageHyperlink link = toolkit.createImageHyperlink(parent, SWT.WRAP);
    link.setImage(SharedIcons.IMG_EXECUTE);
    link.setText("Execute Report");
    link.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            executeReport();
        }
    });
    createResultsContextMenu();
    resultList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) resultList.getSelection();
            actionDeleteResult.setEnabled(selection.size() > 0);
            actionRenderPDF.setEnabled(selection.size() == 1);
            actionRenderXLS.setEnabled(selection.size() == 1);
        }
    });
}
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) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ReportResultLabelProvider(org.netxms.ui.eclipse.reporter.widgets.helpers.ReportResultLabelProvider) 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 ReportResultLabelProvider (org.netxms.ui.eclipse.reporter.widgets.helpers.ReportResultLabelProvider)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1