Search in sources :

Example 91 with SortableTableViewer

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

the class TemplateGraphView method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    final String[] names = { "Graph name", "DCI names", "DCI descriptions" };
    final int[] widths = { 150, 400, 400 };
    viewer = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SWT.FULL_SELECTION | SWT.MULTI);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new TemplateGraphLabelProvider());
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            actionEdit.run();
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    refreshData();
    session.addListener(this);
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) TemplateGraphLabelProvider(org.netxms.ui.eclipse.perfview.views.helpers.TemplateGraphLabelProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Example 92 with SortableTableViewer

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

the class SoftwareInventory method setRootObjectId.

/**
 * @param rootObjectId the rootObjectId to set
 */
public void setRootObjectId(long rootObjectId) {
    this.rootObjectId = rootObjectId;
    AbstractObject object = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(rootObjectId);
    if (object instanceof Node) {
        if (!(viewer instanceof SortableTableViewer)) {
            viewer.getControl().dispose();
            createTableViewer();
        }
    } else {
        if (!(viewer instanceof SortableTreeViewer)) {
            viewer.getControl().dispose();
            createTreeViewer();
        }
    }
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) NXCSession(org.netxms.client.NXCSession) AbstractObject(org.netxms.client.objects.AbstractObject) AbstractNode(org.netxms.client.objects.AbstractNode) SoftwareInventoryNode(org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwareInventoryNode) Node(org.netxms.client.objects.Node) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer)

Example 93 with SortableTableViewer

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

the class SoftwarePackageComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    int result;
    // $NON-NLS-1$ //$NON-NLS-2$
    final int column = (viewer instanceof SortableTableViewer) ? (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID") : (Integer) ((SortableTreeViewer) viewer).getTree().getSortColumn().getData("ID");
    if (e1 instanceof SoftwareInventoryNode) {
        if (column == 0) {
            result = ((SoftwareInventoryNode) e1).getNode().getObjectName().compareToIgnoreCase(((SoftwareInventoryNode) e2).getNode().getObjectName());
        } else {
            result = 0;
        }
    } else {
        SoftwarePackage p1 = (SoftwarePackage) e1;
        SoftwarePackage p2 = (SoftwarePackage) e2;
        switch(column) {
            case SoftwareInventory.COLUMN_DATE:
                result = Long.signum(p1.getInstallDateMs() - p2.getInstallDateMs());
                break;
            case SoftwareInventory.COLUMN_DESCRIPTION:
                result = p1.getDescription().compareToIgnoreCase(p2.getDescription());
                break;
            case SoftwareInventory.COLUMN_NAME:
                result = p1.getName().compareToIgnoreCase(p2.getName());
                break;
            case SoftwareInventory.COLUMN_URL:
                result = p1.getSupportUrl().compareToIgnoreCase(p2.getSupportUrl());
                break;
            case SoftwareInventory.COLUMN_VENDOR:
                result = p1.getVendor().compareToIgnoreCase(p2.getVendor());
                break;
            case SoftwareInventory.COLUMN_VERSION:
                result = p1.getVersion().compareToIgnoreCase(p2.getVersion());
                break;
            default:
                result = 0;
                break;
        }
    }
    int direction = (viewer instanceof SortableTableViewer) ? ((SortableTableViewer) viewer).getTable().getSortDirection() : ((SortableTreeViewer) viewer).getTree().getSortDirection();
    return (direction == SWT.UP) ? result : -result;
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SoftwarePackage(org.netxms.client.SoftwarePackage)

Example 94 with SortableTableViewer

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

the class ScheduledTaskView 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 = { 50, 100, 200, 400, 150, 150, 100, 200, 250, 200 };
    final String[] names = { "Id", "Schedule Type", "Object", "Parameters", "Execution time", "Last execution time", "Execution status", "Administrative status", "Owner", "Comments" };
    viewer = new SortableTableViewer(parent, names, widths, SCHEDULE_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new ScheduleTableEntryLabelProvider());
    viewer.setComparator(new ScheduleTableEntryComparator());
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            actionEdit.run();
        }
    });
    WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "ScheduledTasks");
    viewer.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "ScheduledTasks");
        }
    });
    activateContext();
    createActions();
    contributeToActionBars();
    createPopupMenu();
    refresh();
    final Display display = getSite().getShell().getDisplay();
    listener = new SessionListener() {

        @Override
        public void notificationHandler(SessionNotification n) {
            if (n.getCode() == SessionNotification.SCHEDULE_UPDATE) {
                display.asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        refresh();
                    }
                });
            }
        }
    };
    session.addListener(listener);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ScheduleTableEntryComparator(org.netxms.ui.eclipse.serverconfig.views.helpers.ScheduleTableEntryComparator) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ScheduleTableEntryLabelProvider(org.netxms.ui.eclipse.serverconfig.views.helpers.ScheduleTableEntryLabelProvider) SessionListener(org.netxms.client.SessionListener) SessionNotification(org.netxms.client.SessionNotification) Display(org.eclipse.swt.widgets.Display)

Example 95 with SortableTableViewer

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

the class SnmpTrapEditor method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    parent.setLayout(new FillLayout());
    final String[] columnNames = { Messages.get().SnmpTrapEditor_ColID, Messages.get().SnmpTrapEditor_ColOID, Messages.get().SnmpTrapEditor_ColEvent, Messages.get().SnmpTrapEditor_ColDescription };
    final int[] columnWidths = { 70, 200, 100, 200 };
    viewer = new SortableTableViewer(parent, columnNames, columnWidths, COLUMN_ID, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
    WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new SnmpTrapLabelProvider());
    viewer.setComparator(new SnmpTrapComparator());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection != null) {
                actionEdit.setEnabled(selection.size() == 1);
                actionDelete.setEnabled(selection.size() > 0);
            }
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            actionEdit.run();
        }
    });
    viewer.getTable().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
        }
    });
    createActions();
    contributeToActionBars();
    createPopupMenu();
    session.addListener(this);
    refreshTrapList();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SnmpTrapLabelProvider(org.netxms.ui.eclipse.snmp.views.helpers.SnmpTrapLabelProvider) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SnmpTrapComparator(org.netxms.ui.eclipse.snmp.views.helpers.SnmpTrapComparator)

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