Search in sources :

Example 16 with SortableTableViewer

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

the class ClusterNetworks method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (Cluster) getElement().getAdapter(Cluster.class);
    if (// Paranoid check
    object == null)
        return dialogArea;
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().ClusterNetworks_ColAddress, Messages.get().ClusterNetworks_ColMask };
    final int[] columnWidths = { 150, 150 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new NetworkListLabelProvider());
    viewer.setComparator(new NetworkListComparator());
    networks = new ArrayList<InetAddressEx>(object.getSyncNetworks().size());
    for (InetAddressEx n : object.getSyncNetworks()) networks.add(new InetAddressEx(n));
    viewer.setInput(networks.toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().ClusterNetworks_Add);
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addNetwork();
        }
    });
    editButton = new Button(buttons, SWT.PUSH);
    editButton.setText(Messages.get().ClusterNetworks_Modify);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    editButton.setLayoutData(rd);
    editButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editNetwork();
        }
    });
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().ClusterNetworks_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteNetwork();
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editButton.notifyListeners(SWT.Selection, new Event());
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            editButton.setEnabled(selection.size() == 1);
            deleteButton.setEnabled(selection.size() > 0);
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) NetworkListComparator(org.netxms.ui.eclipse.objectmanager.propertypages.helpers.NetworkListComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) NetworkListLabelProvider(org.netxms.ui.eclipse.objectmanager.propertypages.helpers.NetworkListLabelProvider) InetAddressEx(org.netxms.base.InetAddressEx) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 17 with SortableTableViewer

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

the class ExternalResources method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    if (// Paranoid check
    object == null)
        return dialogArea;
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    final String[] columnNames = { "URL", "Description" };
    final int[] columnWidths = { 300, 300 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new UrlListLabelProvider());
    urls = new ArrayList<ObjectUrl>(object.getUrls());
    viewer.setInput(urls);
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttonsLeft = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    buttonsLeft.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.LEFT;
    buttonsLeft.setLayoutData(gridData);
    moveUpButton = new Button(buttonsLeft, SWT.PUSH);
    moveUpButton.setText("&Up");
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    moveUpButton.setLayoutData(rd);
    moveUpButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveSelection(true);
        }
    });
    moveDownButton = new Button(buttonsLeft, SWT.PUSH);
    moveDownButton.setText("&Down");
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    moveDownButton.setLayoutData(rd);
    moveDownButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveSelection(false);
        }
    });
    Composite buttonsRight = new Composite(dialogArea, SWT.NONE);
    buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonLayout.marginRight = 0;
    buttonsRight.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttonsRight.setLayoutData(gridData);
    addButton = new Button(buttonsRight, SWT.PUSH);
    addButton.setText(Messages.get().CustomAttributes_Add);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addUrl();
        }
    });
    editButton = new Button(buttonsRight, SWT.PUSH);
    editButton.setText(Messages.get().CustomAttributes_Modify);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    editButton.setLayoutData(rd);
    editButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editUrl();
        }
    });
    deleteButton = new Button(buttonsRight, SWT.PUSH);
    deleteButton.setText(Messages.get().CustomAttributes_Delete);
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            deleteUrl();
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editButton.notifyListeners(SWT.Selection, new Event());
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            moveUpButton.setEnabled(selection.size() == 1);
            moveDownButton.setEnabled(selection.size() == 1);
            editButton.setEnabled(selection.size() == 1);
            deleteButton.setEnabled(selection.size() > 0);
        }
    });
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) UrlListLabelProvider(org.netxms.ui.eclipse.objectmanager.propertypages.helpers.UrlListLabelProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ObjectUrl(org.netxms.client.ObjectUrl) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 18 with SortableTableViewer

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

the class TrustedNodes method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().TrustedNodes_Node };
    final int[] columnWidths = { 300 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
    AbstractObject[] nodes = object.getTrustedNodes();
    for (int i = 0; i < nodes.length; i++) {
        if (nodes[i] != null)
            trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
    }
    viewer.setInput(trustedNodes.values().toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().TrustedNodes_Add);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(true));
            if (dlg.open() == Window.OK) {
                AbstractObject[] nodes = dlg.getSelectedObjects(AbstractNode.class);
                for (int i = 0; i < nodes.length; i++) trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
                viewer.setInput(trustedNodes.values().toArray());
                isModified = true;
            }
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().TrustedNodes_Delete);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Iterator<AbstractObject> it = selection.iterator();
            if (it.hasNext()) {
                while (it.hasNext()) {
                    AbstractObject object = it.next();
                    trustedNodes.remove(object.getObjectId());
                }
                viewer.setInput(trustedNodes.values().toArray());
                isModified = true;
            }
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) AbstractNode(org.netxms.client.objects.AbstractNode) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) Composite(org.eclipse.swt.widgets.Composite) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 19 with SortableTableViewer

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

the class Dashboards method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    final String[] columnNames = { Messages.get().Dashboards_Dashboard };
    final int[] columnWidths = { 300 };
    viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
    for (AbstractObject d : object.getDashboards(false)) dashboards.put(d.getObjectId(), d);
    viewer.setInput(dashboards.values().toArray());
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 0;
    viewer.getControl().setLayoutData(gridData);
    Composite buttons = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttons.setLayout(buttonLayout);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttons.setLayoutData(gridData);
    addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().TrustedNodes_Add);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createDashboardSelectionFilter());
            dlg.showFilterToolTip(false);
            if (dlg.open() == Window.OK) {
                AbstractObject[] d = dlg.getSelectedObjects(Dashboard.class);
                for (int i = 0; i < d.length; i++) dashboards.put(d[i].getObjectId(), d[i]);
                viewer.setInput(dashboards.values().toArray());
                isModified = true;
            }
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    addButton.setLayoutData(rd);
    deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().TrustedNodes_Delete);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            Iterator<AbstractObject> it = selection.iterator();
            if (it.hasNext()) {
                while (it.hasNext()) {
                    AbstractObject object = it.next();
                    dashboards.remove(object.getObjectId());
                }
                viewer.setInput(dashboards.values().toArray());
                isModified = true;
            }
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    deleteButton.setLayoutData(rd);
    return dialogArea;
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ObjectLabelComparator(org.netxms.ui.eclipse.tools.ObjectLabelComparator) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) Dashboard(org.netxms.client.objects.Dashboard) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) AbstractObject(org.netxms.client.objects.AbstractObject) RowLayout(org.eclipse.swt.layout.RowLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 20 with SortableTableViewer

use of org.netxms.ui.eclipse.widgets.SortableTableViewer 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

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