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