Search in sources :

Example 1 with AgentTable

use of org.netxms.client.AgentTable in project netxms by netxms.

the class AgentTableComparator 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;
    AgentTable p1 = (AgentTable) e1;
    AgentTable p2 = (AgentTable) e2;
    switch(// $NON-NLS-1$
    (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
        case AbstractSelectParamDlg.COLUMN_NAME:
            result = p1.getName().compareToIgnoreCase(p2.getName());
            break;
        case AbstractSelectParamDlg.COLUMN_TYPE:
            result = p1.getInstanceColumnsAsList().compareToIgnoreCase(p2.getInstanceColumnsAsList());
            break;
        case AbstractSelectParamDlg.COLUMN_DESCRIPTION:
            result = p1.getDescription().compareToIgnoreCase(p2.getDescription());
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : AgentTable(org.netxms.client.AgentTable) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer)

Aggregations

AgentTable (org.netxms.client.AgentTable)1 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)1