use of org.netxms.client.topology.VlanInfo in project netxms by netxms.
the class VlanView method showVlanMap.
/**
* Show map for currently selected VLAN
*/
private void showVlanMap() {
IStructuredSelection selection = (IStructuredSelection) vlanList.getSelection();
IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
for (final Object o : selection.toList()) {
final VlanInfo vlan = (VlanInfo) o;
try {
// $NON-NLS-1$ //$NON-NLS-2$
page.showView("org.netxms.ui.eclipse.networkmaps.views.VlanMap", Long.toString(nodeId) + "&" + Integer.toString(vlan.getVlanId()), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().VlanView_Error, String.format(Messages.get().VlanView_OpenMapError, vlan.getVlanId(), e.getLocalizedMessage()));
}
}
}
use of org.netxms.client.topology.VlanInfo in project netxms by netxms.
the class NXCSession method getVlans.
/**
* Get list of VLANs configured on given node
*
* @param nodeId node object ID
* @return list of VLANs
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<VlanInfo> getVlans(long nodeId) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_VLANS);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_VLANS);
List<VlanInfo> vlans = new ArrayList<VlanInfo>(count);
long varId = NXCPCodes.VID_VLAN_LIST_BASE;
for (int i = 0; i < count; i++) {
vlans.add(new VlanInfo(response, varId));
varId += 10;
}
return vlans;
}
use of org.netxms.client.topology.VlanInfo in project netxms by netxms.
the class VlanMap method collectVlanInfo.
/**
* Recursively collect VLAN information starting from given node
*
* @param page map page
* @param root root node
* @throws Exception
* @throws NXCException
*/
private long collectVlanInfo(NetworkMapPage page, Node root) throws Exception {
if (page.findObjectElement(root.getObjectId()) != null)
return -1;
long rootElementId = mapPage.createElementId();
page.addElement(new NetworkMapObject(rootElementId, root.getObjectId()));
List<VlanInfo> vlans = session.getVlans(root.getObjectId());
for (VlanInfo vlan : vlans) {
if (vlan.getVlanId() == vlanId) {
Port[] ports = vlan.getPorts();
for (Port port : ports) {
processVlanPort(page, root, port, rootElementId);
}
break;
}
}
return rootElementId;
}
use of org.netxms.client.topology.VlanInfo in project netxms by netxms.
the class VlanView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
parent.setLayout(layout);
final String[] names = { Messages.get().VlanView_ColumnID, Messages.get().VlanView_ColumnName, Messages.get().VlanView_ColumnPorts };
final int[] widths = { 80, 180, 400 };
vlanList = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SWT.FULL_SELECTION | SWT.MULTI);
vlanList.setContentProvider(new ArrayContentProvider());
final VlanLabelProvider labelProvider = new VlanLabelProvider();
vlanList.setLabelProvider(labelProvider);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
vlanList.getTable().setLayoutData(gd);
vlanList.setInput(vlans.toArray());
vlanList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) vlanList.getSelection();
VlanInfo vlan = (VlanInfo) selection.getFirstElement();
if (vlan != null) {
deviceView.setHighlight(vlan.getPorts());
actionShowVlanMap.setEnabled(true);
} else {
deviceView.clearHighlight(true);
actionShowVlanMap.setEnabled(false);
}
if (labelProvider.setSelectedPort(null)) {
vlanList.refresh();
}
}
});
Composite deviceViewArea = new Composite(parent, SWT.NONE);
deviceViewArea.setLayout(new FillLayout());
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
deviceViewArea.setLayoutData(gd);
scroller = new ScrolledComposite(deviceViewArea, SWT.H_SCROLL | SWT.V_SCROLL);
deviceView = new DeviceView(scroller, SWT.NONE);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
deviceView.setLayoutData(gd);
deviceView.setPortStatusVisible(false);
deviceView.setNodeId(nodeId);
deviceView.addSelectionListener(new PortSelectionListener() {
@Override
public void portSelected(PortInfo port) {
vlanList.setSelection(null);
labelProvider.setSelectedPort(port);
vlanList.refresh();
}
});
scroller.setContent(deviceView);
scroller.setBackground(deviceView.getBackground());
scroller.setExpandVertical(true);
scroller.setExpandHorizontal(true);
// scroller.getVerticalBar().setIncrement(20);
// scroller.getHorizontalBar().setIncrement(20);
scroller.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
scroller.setMinSize(deviceView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
createActions();
contributeToActionBars();
createPopupMenu();
if (refreshOnStartup)
refreshVlanList();
}
Aggregations