use of org.netxms.ui.eclipse.objectbrowser.dialogs.helpers.AddressListElement in project netxms by netxms.
the class IPAddressSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
// Label label = new Label(dialogArea, SWT.NONE);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
gd.widthHint = 250;
viewer.getControl().setLayoutData(gd);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ComparatorHelper.compareInetAddresses(((AddressListElement) e1).address, ((AddressListElement) e2).address);
}
});
viewer.setLabelProvider(new AddressListLabelProvider());
final Table table = viewer.getTable();
table.setHeaderVisible(true);
TableColumn tc = new TableColumn(table, SWT.LEFT);
tc.setText(Messages.get().IPAddressSelectionDialog_IPAddress);
tc.setWidth(90);
tc = new TableColumn(table, SWT.LEFT);
tc.setText(Messages.get().IPAddressSelectionDialog_Interface);
tc.setWidth(150);
Set<AddressListElement> addrList = new HashSet<AddressListElement>();
for (AbstractObject o : node.getChildsAsArray()) {
if (o instanceof Interface) {
for (InetAddressEx a : ((Interface) o).getIpAddressList()) {
if (a.isValidUnicastAddress()) {
addrList.add(new AddressListElement((Interface) o, a.getAddress()));
}
}
}
}
viewer.setInput(addrList.toArray());
return dialogArea;
}
Aggregations