Search in sources :

Example 16 with Interface

use of org.netxms.client.objects.Interface in project netxms by netxms.

the class VlanMap method processVlanPort.

/**
 * Process single member port of VLAN. Will add connected switch on other site to the map.
 *
 * @param page
 * @param root
 * @param port
 * @throws Exception
 */
private void processVlanPort(NetworkMapPage page, Node root, Port port, long rootElementId) throws Exception {
    Interface iface = (Interface) session.findObjectById(port.getObjectId(), Interface.class);
    if (iface != null) {
        Node peerNode = (Node) session.findObjectById(iface.getPeerNodeId(), Node.class);
        if ((peerNode != null) && ((peerNode.getCapabilities() & Node.NC_IS_BRIDGE) != 0)) {
            try {
                long nodeElementId = collectVlanInfo(page, peerNode);
                if (nodeElementId != -1) {
                    Interface peerIf = (Interface) session.findObjectById(iface.getPeerInterfaceId(), Interface.class);
                    page.addLink(new NetworkMapLink(null, NetworkMapLink.NORMAL, rootElementId, nodeElementId, iface.getObjectName(), (peerIf != null) ? peerIf.getObjectName() : "???", // $NON-NLS-1$ //$NON-NLS-2$
                    0));
                }
            } catch (NXCException e) {
            // Ignore NetXMS errors for remote bridges
            }
        }
    }
}
Also used : Node(org.netxms.client.objects.Node) Interface(org.netxms.client.objects.Interface) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) NXCException(org.netxms.client.NXCException)

Example 17 with Interface

use of org.netxms.client.objects.Interface in project netxms by netxms.

the class FindConnectionPoint method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
@Override
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && !selection.isEmpty()) {
        objects = new ArrayList<AbstractObject>();
        for (Object s : ((IStructuredSelection) selection).toList()) {
            if ((s instanceof Node) || (s instanceof Interface) || (s instanceof AccessPoint)) {
                action.setEnabled(true);
                objects.add((AbstractObject) s);
            }
        }
    } else {
        action.setEnabled(false);
        objects = null;
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) AccessPoint(org.netxms.client.objects.AccessPoint) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Interface(org.netxms.client.objects.Interface)

Example 18 with Interface

use of org.netxms.client.objects.Interface in project netxms by netxms.

the class Ports method createTabContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.objectview.objecttabs.ObjectTab#createTabContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createTabContent(Composite parent) {
    session = (NXCSession) ConsoleSharedData.getSession();
    scroller = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    deviceView = new DeviceView(scroller, SWT.NONE);
    deviceView.addSelectionListener(new PortSelectionListener() {

        @Override
        public void portSelected(PortInfo port) {
            if (port != null) {
                Interface iface = (Interface) session.findObjectById(port.getInterfaceObjectId(), Interface.class);
                if (iface != null) {
                    selection = new StructuredSelection(iface);
                } else {
                    selection = new StructuredSelection();
                }
            } else {
                selection = new StructuredSelection();
            }
            for (ISelectionChangedListener listener : selectionListeners) listener.selectionChanged(new SelectionChangedEvent(Ports.this, selection));
        }
    });
    scroller.setContent(deviceView);
    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));
        }
    });
    createPopupMenu();
}
Also used : PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) ControlAdapter(org.eclipse.swt.events.ControlAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DeviceView(org.netxms.ui.eclipse.topology.widgets.DeviceView) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) PortSelectionListener(org.netxms.ui.eclipse.topology.widgets.helpers.PortSelectionListener) Interface(org.netxms.client.objects.Interface)

Example 19 with Interface

use of org.netxms.client.objects.Interface in project netxms by netxms.

the class ConnectionPointComparator 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;
    // $NON-NLS-1$
    int column = (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID");
    switch(column) {
        case HostSearchResults.COLUMN_SEQUENCE:
            result = (Integer) ((ConnectionPoint) e1).getData() - (Integer) ((ConnectionPoint) e2).getData();
            break;
        case HostSearchResults.COLUMN_NODE:
        case HostSearchResults.COLUMN_INTERFACE:
        case HostSearchResults.COLUMN_MAC_ADDRESS:
        case HostSearchResults.COLUMN_SWITCH:
        case HostSearchResults.COLUMN_PORT:
            result = labelProvider.getColumnText(e1, column).compareToIgnoreCase(labelProvider.getColumnText(e2, column));
            break;
        case HostSearchResults.COLUMN_IP_ADDRESS:
            Interface iface1 = (Interface) session.findObjectById(((ConnectionPoint) e1).getLocalInterfaceId(), Interface.class);
            Interface iface2 = (Interface) session.findObjectById(((ConnectionPoint) e2).getLocalInterfaceId(), Interface.class);
            InetAddress a1 = ((ConnectionPoint) e1).getLocalIpAddress();
            InetAddress a2 = ((ConnectionPoint) e2).getLocalIpAddress();
            if ((a1 == null) && (iface1 != null))
                a1 = iface1.getFirstUnicastAddress();
            if ((a2 == null) && (iface2 != null))
                a2 = iface2.getFirstUnicastAddress();
            result = ComparatorHelper.compareInetAddresses(a1, a2);
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) InetAddress(java.net.InetAddress) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) Interface(org.netxms.client.objects.Interface) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Example 20 with Interface

use of org.netxms.client.objects.Interface in project netxms by netxms.

the class DeviceView method refresh.

/**
 * Refresh widget
 */
public void refresh() {
    AbstractObject object = session.findObjectById(nodeId);
    if ((object == null) || !(object instanceof Node))
        return;
    for (SlotView s : slots.values()) {
        s.setMenu(null);
        s.dispose();
    }
    slots.clear();
    ports.clear();
    List<Interface> interfaces = new ArrayList<Interface>();
    for (AbstractObject o : object.getAllChilds(AbstractObject.OBJECT_INTERFACE)) {
        if (((Interface) o).isPhysicalPort())
            interfaces.add((Interface) o);
    }
    Collections.sort(interfaces, new Comparator<Interface>() {

        @Override
        public int compare(Interface arg0, Interface arg1) {
            if (arg0.getSlot() == arg1.getSlot())
                return arg0.getPort() - arg1.getPort();
            return arg0.getSlot() - arg1.getSlot();
        }
    });
    for (Interface iface : interfaces) {
        int slot = iface.getSlot();
        SlotView sv = slots.get(slot);
        if (sv == null) {
            sv = new SlotView(this, SWT.NONE, String.format(Messages.get().DeviceView_SlotName, slot), ((Node) object).getPortRowCount(), ((Node) object).getPortNumberingScheme());
            sv.setPortStatusVisible(portStatusVisible);
            slots.put(slot, sv);
        }
        PortInfo p = new PortInfo(iface);
        ports.put(iface.getObjectId(), p);
        sv.addPort(p);
    }
    layout();
    for (SlotView sv : slots.values()) {
        sv.setMenu(getMenu());
        sv.addSelectionListener(listener);
    }
}
Also used : PortInfo(org.netxms.ui.eclipse.topology.widgets.helpers.PortInfo) AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) ArrayList(java.util.ArrayList) Interface(org.netxms.client.objects.Interface)

Aggregations

Interface (org.netxms.client.objects.Interface)23 AbstractObject (org.netxms.client.objects.AbstractObject)12 AbstractNode (org.netxms.client.objects.AbstractNode)6 AccessPoint (org.netxms.client.objects.AccessPoint)6 Node (org.netxms.client.objects.Node)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)3 Sensor (org.netxms.client.objects.Sensor)3 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)3 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)3 SuppressLint (android.annotation.SuppressLint)2 InetAddress (java.net.InetAddress)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Action (org.eclipse.jface.action.Action)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 InetAddressEx (org.netxms.base.InetAddressEx)2 NXCSession (org.netxms.client.NXCSession)2 GenericObject (org.netxms.client.objects.GenericObject)2 NetworkService (org.netxms.client.objects.NetworkService)2