Search in sources :

Example 1 with VlanInfo

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()));
        }
    }
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) VlanInfo(org.netxms.client.topology.VlanInfo)

Example 2 with VlanInfo

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;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) VlanInfo(org.netxms.client.topology.VlanInfo) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 3 with VlanInfo

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;
}
Also used : Port(org.netxms.client.topology.Port) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) VlanInfo(org.netxms.client.topology.VlanInfo)

Example 4 with VlanInfo

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();
}
Also used : VlanLabelProvider(org.netxms.ui.eclipse.topology.views.helpers.VlanLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FillLayout(org.eclipse.swt.layout.FillLayout) VlanInfo(org.netxms.client.topology.VlanInfo) PortSelectionListener(org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener) PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) GridLayout(org.eclipse.swt.layout.GridLayout) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DeviceView(org.netxms.ui.eclipse.topology.widgets.DeviceView) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

VlanInfo (org.netxms.client.topology.VlanInfo)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ArrayList (java.util.ArrayList)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 NXCPMessage (org.netxms.base.NXCPMessage)1 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 AccessPoint (org.netxms.client.objects.AccessPoint)1 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)1