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();
}
}
}
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);
}
}
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;
}
Aggregations