use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class MappingTableEntryComparator 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;
MappingTableEntry me1 = (MappingTableEntry) e1;
MappingTableEntry me2 = (MappingTableEntry) e2;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case MappingTableEditor.COLUMN_KEY:
result = me1.getKey().compareToIgnoreCase(me2.getKey());
break;
case MappingTableEditor.COLUMN_VALUE:
result = me1.getValue().compareToIgnoreCase(me2.getValue());
break;
case MappingTableEditor.COLUMN_DESCRIPTION:
result = me1.getDescription().compareToIgnoreCase(me2.getDescription());
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 HostSearchResults 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().HostSearchResults_ColSeq, Messages.get().HostSearchResults_ColNode, Messages.get().HostSearchResults_ColIface, Messages.get().HostSearchResults_ColMac, Messages.get().HostSearchResults_ColIp, Messages.get().HostSearchResults_ColSwitch, Messages.get().HostSearchResults_ColPort, Messages.get().HostSearchResults_ColType };
final int[] widths = { 70, 120, 120, 90, 90, 120, 120, 60 };
viewer = new SortableTableViewer(parent, names, widths, COLUMN_SEQUENCE, SWT.UP, SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
ConnectionPointLabelProvider labelProvider = new ConnectionPointLabelProvider();
viewer.setLabelProvider(labelProvider);
viewer.setComparator(new ConnectionPointComparator(labelProvider));
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), TABLE_CONFIG_PREFIX);
}
});
createActions();
contributeToActionBars();
createPopupMenu();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class RadioInterfaces 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().RadioInterfaces_ColApName, Messages.get().RadioInterfaces_ColApMac, Messages.get().RadioInterfaces_ColApVendor, Messages.get().RadioInterfaces_ColApModel, Messages.get().RadioInterfaces_ColApSerial, Messages.get().RadioInterfaces_ColRadioIndex, Messages.get().RadioInterfaces_ColRadioName, Messages.get().RadioInterfaces_ColRadioMac, Messages.get().RadioInterfaces_ColChannel, Messages.get().RadioInterfaces_ColTxPowerDbm, Messages.get().RadioInterfaces_ColTxPowerMw };
final int[] widths = { 120, 100, 140, 140, 100, 90, 120, 100, 90, 90, 90 };
viewer = new SortableTableViewer(parent, names, widths, 1, SWT.UP, SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new RadioInterfaceLabelProvider());
viewer.setComparator(new RadioInterfaceComparator());
// $NON-NLS-1$
WidgetHelper.restoreTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "RadioInterfaces");
viewer.getTable().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
// $NON-NLS-1$
WidgetHelper.saveTableViewerSettings(viewer, Activator.getDefault().getDialogSettings(), "RadioInterfaces");
}
});
createActions();
contributeToActionBars();
createPopupMenu();
refresh();
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class Members method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
session = ConsoleSharedData.getSession();
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (UserGroup) getElement().getAdapter(UserGroup.class);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().Members_LoginName };
final int[] columnWidths = { 300 };
userList = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
userList.setContentProvider(new ArrayContentProvider());
userList.setLabelProvider(new WorkbenchLabelProvider());
userList.setComparator(new UserComparator());
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
userList.getControl().setLayoutData(gd);
Composite buttons = new Composite(dialogArea, SWT.NONE);
FillLayout buttonsLayout = new FillLayout();
buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
buttons.setLayout(buttonsLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = 184;
buttons.setLayoutData(gd);
final Button addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().Members_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
SelectUserDialog dlg = new SelectUserDialog(Members.this.getShell(), AbstractUserObject.class);
if (dlg.open() == Window.OK) {
AbstractUserObject[] selection = dlg.getSelection();
for (AbstractUserObject user : selection) members.put(user.getId(), user);
userList.setInput(members.values().toArray(new AbstractUserObject[members.size()]));
}
}
});
final Button deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().Members_Delete);
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection sel = (IStructuredSelection) userList.getSelection();
Iterator<AbstractUserObject> it = sel.iterator();
while (it.hasNext()) {
AbstractUserObject element = it.next();
members.remove(element.getId());
}
userList.setInput(members.values().toArray());
}
});
userList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
deleteButton.setEnabled(!userList.getSelection().isEmpty());
}
});
// Initial data
for (long userId : object.getMembers()) {
final AbstractUserObject user = session.findUserDBObjectById(userId);
if (user != null) {
members.put(user.getId(), user);
}
}
userList.setInput(members.values().toArray());
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.SortableTableViewer in project netxms by netxms.
the class WirelessStationComparator 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) {
WirelessStation ws1 = (WirelessStation) e1;
WirelessStation ws2 = (WirelessStation) e2;
int result;
switch(// $NON-NLS-1$
(Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
case WirelessStations.COLUMN_MAC_ADDRESS:
result = ws1.getMacAddress().compareTo(ws2.getMacAddress());
break;
case WirelessStations.COLUMN_IP_ADDRESS:
result = ComparatorHelper.compareInetAddresses(ws1.getIpAddress(), ws2.getIpAddress());
break;
case WirelessStations.COLUMN_NODE_NAME:
result = session.getObjectName(ws1.getNodeObjectId()).compareToIgnoreCase(session.getObjectName(ws2.getNodeObjectId()));
break;
case WirelessStations.COLUMN_ACCESS_POINT:
result = session.getObjectName(ws1.getAccessPointId()).compareToIgnoreCase(session.getObjectName(ws2.getAccessPointId()));
break;
case WirelessStations.COLUMN_SSID:
result = ws1.getSsid().compareToIgnoreCase(ws2.getSsid());
break;
case WirelessStations.COLUMN_RADIO:
result = ws1.getRadioInterface().compareToIgnoreCase(ws2.getRadioInterface());
break;
default:
result = 0;
break;
}
return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Aggregations