use of org.netxms.base.InetAddressEx 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;
}
use of org.netxms.base.InetAddressEx in project netxms by netxms.
the class ClusterNetworks method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (Cluster) getElement().getAdapter(Cluster.class);
if (// Paranoid check
object == null)
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().ClusterNetworks_ColAddress, Messages.get().ClusterNetworks_ColMask };
final int[] columnWidths = { 150, 150 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new NetworkListLabelProvider());
viewer.setComparator(new NetworkListComparator());
networks = new ArrayList<InetAddressEx>(object.getSyncNetworks().size());
for (InetAddressEx n : object.getSyncNetworks()) networks.add(new InetAddressEx(n));
viewer.setInput(networks.toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().ClusterNetworks_Add);
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addNetwork();
}
});
editButton = new Button(buttons, SWT.PUSH);
editButton.setText(Messages.get().ClusterNetworks_Modify);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editButton.setLayoutData(rd);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editNetwork();
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().ClusterNetworks_Delete);
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteNetwork();
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
});
return dialogArea;
}
use of org.netxms.base.InetAddressEx in project netxms by netxms.
the class ClusterNetworks method editNetwork.
/**
* Edit currently selected network
*/
private void editNetwork() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
InetAddressEx n = (InetAddressEx) selection.getFirstElement();
ClusterNetworkEditDialog dlg = new ClusterNetworkEditDialog(getShell(), n.getAddress(), n.maskFromBits());
if (dlg.open() == Window.OK) {
n.setAddress(dlg.getAddress());
n.setMask(InetAddressEx.bitsInMask(dlg.getMask()));
viewer.update(n, null);
isModified = true;
}
}
use of org.netxms.base.InetAddressEx in project netxms by netxms.
the class VPNSubnets method addTargetAddressListElement.
/**
* Add element to subnet list
*/
private void addTargetAddressListElement(TableViewer elementList, List<InetAddressEx> elements) {
AddSubnetDialog dlg = new AddSubnetDialog(getShell());
if (dlg.open() == Window.OK) {
InetAddressEx subnet = dlg.getSubnet();
if (!elements.contains(subnet)) {
elements.add(subnet);
elementList.setInput(elements.toArray());
modified = true;
}
}
}
use of org.netxms.base.InetAddressEx in project netxms by netxms.
the class AddSubnetDialog method okPressed.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
@Override
protected void okPressed() {
try {
InetAddress a = InetAddress.getByName(address.getText().trim());
subnet = new InetAddressEx(a, mask.getSelection());
} catch (UnknownHostException e) {
MessageDialogHelper.openWarning(getShell(), Messages.get().AddAddressListElementDialog_Warning, Messages.get().AddAddressListElementDialog_AddressValidationError);
return;
}
super.okPressed();
}
Aggregations