use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class ScheduleTableEntryComparator 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;
ScheduledTask task1 = (ScheduledTask) e1;
ScheduledTask task2 = (ScheduledTask) e2;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case ScheduledTaskView.SCHEDULE_ID:
result = (int) (task1.getId() - task2.getId());
break;
case ScheduledTaskView.CALLBACK_ID:
result = task1.getScheduledTaskId().compareToIgnoreCase(task2.getScheduledTaskId());
break;
case ScheduledTaskView.OBJECT:
AbstractObject obj1 = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(task1.getObjectId());
AbstractObject obj2 = ((NXCSession) ConsoleSharedData.getSession()).findObjectById(task2.getObjectId());
String name1 = (obj1 != null) ? obj1.getObjectName() : "Unknown";
String name2 = (obj2 != null) ? obj2.getObjectName() : "Unknown";
result = name1.compareToIgnoreCase(name2);
break;
case ScheduledTaskView.PARAMETERS:
result = task1.getParameters().compareToIgnoreCase(task2.getParameters());
break;
case ScheduledTaskView.EXECUTION_TIME:
if (task1.getSchedule().isEmpty()) {
if (task2.getSchedule().isEmpty()) {
result = task1.getExecutionTime().compareTo(task2.getExecutionTime());
break;
} else {
result = 1;
break;
}
}
if (task2.getSchedule().isEmpty()) {
result = -1;
}
result = task1.getSchedule().compareToIgnoreCase(task2.getSchedule());
break;
case ScheduledTaskView.LAST_EXECUTION_TIME:
result = task1.getLastExecutionTime().compareTo(task2.getLastExecutionTime());
break;
case ScheduledTaskView.STATUS:
result = task1.getStatus().compareToIgnoreCase(task2.getStatus());
break;
case ScheduledTaskView.OWNER:
String user1 = "";
String user2 = "";
if ((task1.getFlags() & ScheduledTask.SYSTEM) > 0)
user1 = "Internal";
else
user1 = ((NXCSession) ConsoleSharedData.getSession()).findUserDBObjectById(task1.getOwner()).getName();
if ((task2.getFlags() & ScheduledTask.SYSTEM) > 0)
user2 = "Internal";
else
user2 = ((NXCSession) ConsoleSharedData.getSession()).findUserDBObjectById(task2.getOwner()).getName();
result = user1.compareTo(user2);
break;
case ScheduledTaskView.COMMENTS:
result = task1.getComments().compareToIgnoreCase(task2.getComments());
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class ServerJobManager 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 = { Messages.get().ServerJobManager_ColStatus, Messages.get().ServerJobManager_ColInitiator, Messages.get().ServerJobManager_ColNode, Messages.get().ServerJobManager_ColDescription, Messages.get().ServerJobManager_ColProgress, Messages.get().ServerJobManager_ColMessage };
final int[] widths = { 80, 100, 150, 250, 100, 300 };
viewer = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SortableTableViewer.DEFAULT_STYLE);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ServerJobLabelProvider());
viewer.setComparator(new ServerJobComparator());
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
createActions();
contributeToActionBars();
createPopupMenu();
session = (NXCSession) ConsoleSharedData.getSession();
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null) {
actionCancelJob.setEnabled(selection.size() > 0);
actionHoldJob.setEnabled(selection.size() > 0);
actionUnholdJob.setEnabled(selection.size() > 0);
}
}
});
// Create listener for notifications received from server via client library
clientListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if (n.getCode() != SessionNotification.JOB_CHANGE)
return;
refreshJobList(false);
}
};
session.addListener(clientListener);
refreshJobList(false);
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class FDBComparator 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) {
FdbEntry fdb1 = (FdbEntry) e1;
FdbEntry fdb2 = (FdbEntry) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case SwitchForwardingDatabaseView.COLUMN_INTERFACE:
result = fdb1.getInterfaceName().compareToIgnoreCase(fdb2.getInterfaceName());
break;
case SwitchForwardingDatabaseView.COLUMN_MAC_ADDRESS:
result = fdb1.getAddress().compareTo(fdb2.getAddress());
break;
case SwitchForwardingDatabaseView.COLUMN_NODE:
// $NON-NLS-1$
String n1 = (fdb1.getNodeId() != 0) ? session.getObjectName(fdb1.getNodeId()) : "";
// $NON-NLS-1$
String n2 = (fdb2.getNodeId() != 0) ? session.getObjectName(fdb2.getNodeId()) : "";
result = n1.compareToIgnoreCase(n2);
break;
case SwitchForwardingDatabaseView.COLUMN_PORT:
result = fdb1.getPort() - fdb2.getPort();
break;
case SwitchForwardingDatabaseView.COLUMN_VLAN:
result = fdb1.getVlanId() - fdb2.getVlanId();
break;
case SwitchForwardingDatabaseView.COLUMN_TYPE:
result = fdb1.getType() - fdb2.getType();
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class RadioInterfaceComparator 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) {
RadioInterface rif1 = (RadioInterface) e1;
RadioInterface rif2 = (RadioInterface) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case RadioInterfaces.COLUMN_AP_MAC_ADDR:
result = rif1.getAccessPoint().getMacAddress().compareTo(rif2.getAccessPoint().getMacAddress());
break;
case RadioInterfaces.COLUMN_AP_MODEL:
result = rif1.getAccessPoint().getModel().compareToIgnoreCase(rif2.getAccessPoint().getModel());
break;
case RadioInterfaces.COLUMN_AP_NAME:
result = rif1.getAccessPoint().getObjectName().compareToIgnoreCase(rif2.getAccessPoint().getObjectName());
break;
case RadioInterfaces.COLUMN_AP_SERIAL:
result = rif1.getAccessPoint().getSerialNumber().compareToIgnoreCase(rif2.getAccessPoint().getSerialNumber());
break;
case RadioInterfaces.COLUMN_AP_VENDOR:
result = rif1.getAccessPoint().getVendor().compareToIgnoreCase(rif2.getAccessPoint().getVendor());
break;
case RadioInterfaces.COLUMN_CHANNEL:
result = rif1.getChannel() - rif2.getChannel();
break;
case RadioInterfaces.COLUMN_INDEX:
result = rif1.getIndex() - rif2.getIndex();
break;
case RadioInterfaces.COLUMN_MAC_ADDR:
result = rif1.getMacAddress().compareTo(rif2.getMacAddress());
break;
case RadioInterfaces.COLUMN_NAME:
result = rif1.getName().compareToIgnoreCase(rif2.getName());
break;
case RadioInterfaces.COLUMN_TX_POWER_DBM:
result = rif1.getPowerDBm() - rif2.getPowerDBm();
break;
case RadioInterfaces.COLUMN_TX_POWER_MW:
result = rif1.getPowerMW() - rif2.getPowerMW();
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class RoutingTableComparator 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) {
Route r1 = (Route) e1;
Route r2 = (Route) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case RoutingTableView.COLUMN_DESTINATION:
result = ComparatorHelper.compareInetAddresses(r1.getDestination(), r2.getDestination());
if (result == 0) {
result = r1.getPrefixLength() - r2.getPrefixLength();
}
break;
case RoutingTableView.COLUMN_NEXT_HOP:
result = ComparatorHelper.compareInetAddresses(r1.getNextHop(), r2.getNextHop());
break;
case RoutingTableView.COLUMN_INTERFACE:
result = r1.getIfName().compareToIgnoreCase(r2.getIfName());
break;
case RoutingTableView.COLUMN_TYPE:
result = r1.getType() - r2.getType();
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Aggregations