Search in sources :

Example 6 with SortableTreeViewer

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

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

the class SoftwareInventory method createTreeViewer.

/**
 * Create viewer for tree mode
 */
private void createTreeViewer() {
    viewer = new SortableTreeViewer(this, names, widths, 0, SWT.UP, SWT.MULTI | SWT.FULL_SELECTION);
    WidgetHelper.restoreColumnViewerSettings(viewer, Activator.getDefault().getDialogSettings(), configPrefix);
    viewer.getControl().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            WidgetHelper.saveColumnViewerSettings(viewer, Activator.getDefault().getDialogSettings(), configPrefix);
        }
    });
    viewer.setContentProvider(new SoftwareInventoryContentProvider());
    viewer.setLabelProvider(new SoftwarePackageLabelProvider(true));
    viewer.setComparator(new SoftwarePackageComparator());
    if (menuManager != null) {
        Menu menu = menuManager.createContextMenu(viewer.getControl());
        viewer.getControl().setMenu(menu);
        viewPart.getSite().registerContextMenu(menuManager, viewer);
    }
}
Also used : SortableTreeViewer(org.netxms.ui.eclipse.widgets.SortableTreeViewer) DisposeListener(org.eclipse.swt.events.DisposeListener) SoftwarePackageComparator(org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwarePackageComparator) SoftwarePackageLabelProvider(org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwarePackageLabelProvider) SoftwareInventoryContentProvider(org.netxms.ui.eclipse.objectview.widgets.helpers.SoftwareInventoryContentProvider) Menu(org.eclipse.swt.widgets.Menu) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 8 with SortableTreeViewer

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

Aggregations

SortableTreeViewer (org.netxms.ui.eclipse.widgets.SortableTreeViewer)8 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 Composite (org.eclipse.swt.widgets.Composite)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Node (org.netxms.client.objects.Node)2 FilterText (org.netxms.ui.eclipse.widgets.FilterText)2 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)2 Action (org.eclipse.jface.action.Action)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1