Search in sources :

Example 16 with Node

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

the class HostSearchResults method showConnection.

/**
 * Show connection point information
 * @param cp connection point information
 */
public static void showConnection(ConnectionPoint cp) {
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    if (cp == null) {
        MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, Messages.get().HostSearchResults_NotFound);
        return;
    }
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    try {
        Node host = (Node) session.findObjectById(cp.getLocalNodeId());
        Node bridge = (Node) session.findObjectById(cp.getNodeId());
        AbstractObject iface = session.findObjectById(cp.getInterfaceId());
        if ((bridge != null) && (iface != null)) {
            if (cp.getType() == ConnectionPointType.WIRELESS) {
                if (host != null) {
                    MessageDialogHelper.openInformation(shell, Messages.get().HostSearchResults_ConnectionPoint, String.format(Messages.get().HostSearchResults_NodeConnectedToWiFi, host.getObjectName(), bridge.getObjectName(), iface.getObjectName()));
                } else {
                    if (cp.getLocalIpAddress() != null) {
                        MessageDialogHelper.openInformation(shell, Messages.get().HostSearchResults_ConnectionPoint, String.format(Messages.get().HostSearchResults_NodeIpMacConnectedToWiFi, cp.getLocalIpAddress().getHostAddress(), cp.getLocalMacAddress(), bridge.getObjectName(), iface.getObjectName()));
                    } else {
                        MessageDialogHelper.openInformation(shell, Messages.get().HostSearchResults_ConnectionPoint, String.format(Messages.get().HostSearchResults_NodeMacConnectedToWiFi, cp.getLocalMacAddress(), bridge.getObjectName(), iface.getObjectName()));
                    }
                }
            } else {
                if (host != null) {
                    MessageDialogHelper.openInformation(shell, Messages.get().HostSearchResults_ConnectionPoint, String.format(Messages.get().HostSearchResults_NodeConnected, host.getObjectName(), cp.getType() == ConnectionPointType.DIRECT ? Messages.get().HostSearchResults_ModeDirectly : Messages.get().HostSearchResults_ModeIndirectly, bridge.getObjectName(), iface.getObjectName()));
                } else {
                    if (cp.getLocalIpAddress() != null) {
                        MessageDialogHelper.openInformation(shell, Messages.get().HostSearchResults_ConnectionPoint, String.format(Messages.get().HostSearchResults_NodeIpMacConnected, cp.getLocalIpAddress().getHostAddress(), cp.getLocalMacAddress(), cp.getType() == ConnectionPointType.DIRECT ? Messages.get().HostSearchResults_ModeDirectly : Messages.get().HostSearchResults_ModeIndirectly, bridge.getObjectName(), iface.getObjectName()));
                    } else {
                        MessageDialogHelper.openInformation(shell, Messages.get().HostSearchResults_ConnectionPoint, String.format(Messages.get().HostSearchResults_NodeMacConnected, cp.getLocalMacAddress(), cp.getType() == ConnectionPointType.DIRECT ? Messages.get().HostSearchResults_ModeDirectly : Messages.get().HostSearchResults_ModeIndirectly, bridge.getObjectName(), iface.getObjectName()));
                    }
                }
            }
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            IViewPart part = page.showView(ID);
            ((HostSearchResults) part).addResult(cp);
        } else if ((host != null) && (cp.getType() == ConnectionPointType.UNKNOWN)) {
            MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, String.format("Found node %s but it's connection point is unknown", host.getObjectName()));
            IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            IViewPart part = page.showView(ID);
            ((HostSearchResults) part).addResult(cp);
        } else {
            MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, Messages.get().HostSearchResults_NotFound);
        }
    } catch (Exception e) {
        Activator.logError("Exception in host search result view", e);
        MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, String.format(Messages.get().HostSearchResults_ShowError, e.getLocalizedMessage()));
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IViewPart(org.eclipse.ui.IViewPart) NXCSession(org.netxms.client.NXCSession) Node(org.netxms.client.objects.Node) AbstractObject(org.netxms.client.objects.AbstractObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 17 with Node

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

the class HostSearchResults method showConnection.

/**
 * Show connection point information
 *
 * @param cp[] connection point information
 */
public static void showConnection(ConnectionPoint[] cps) {
    final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    int counter = 0;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    try {
        Node host;
        AbstractObject iface;
        for (ConnectionPoint p : cps) {
            host = (Node) session.findObjectById(p.getLocalNodeId());
            iface = session.findObjectById(p.getLocalInterfaceId());
            if (!p.hasConnection())
                counter++;
            if ((host != null) && (iface != null)) {
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IViewPart part = page.showView(ID);
                ((HostSearchResults) part).addResult(p);
            }
        }
        if (counter > 0) {
            MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, Messages.get().HostSearchResults_NotFound + " for " + counter + " interfaces!");
        }
    } catch (Exception e) {
        MessageDialogHelper.openWarning(shell, Messages.get().HostSearchResults_Warning, String.format(Messages.get().HostSearchResults_ShowError, e.getLocalizedMessage()));
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IViewPart(org.eclipse.ui.IViewPart) NXCSession(org.netxms.client.NXCSession) Node(org.netxms.client.objects.Node) AbstractObject(org.netxms.client.objects.AbstractObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) ConnectionPoint(org.netxms.client.topology.ConnectionPoint)

Example 18 with Node

use of org.netxms.client.objects.Node 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 19 with Node

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

the class RadioInterfaces method refresh.

/**
 * Refresh content
 */
private void refresh() {
    Node node = (Node) session.findObjectById(rootObject, Node.class);
    if (node == null)
        return;
    List<RadioInterface> list = new ArrayList<RadioInterface>();
    for (AbstractObject o : node.getAllChilds(AbstractObject.OBJECT_ACCESSPOINT)) {
        if (o instanceof AccessPoint) {
            for (RadioInterface rif : ((AccessPoint) o).getRadios()) list.add(rif);
        }
    }
    viewer.setInput(list.toArray());
}
Also used : Node(org.netxms.client.objects.Node) AbstractObject(org.netxms.client.objects.AbstractObject) AccessPoint(org.netxms.client.objects.AccessPoint) ArrayList(java.util.ArrayList) RadioInterface(org.netxms.client.topology.RadioInterface)

Example 20 with Node

use of org.netxms.client.objects.Node 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

Node (org.netxms.client.objects.Node)23 AbstractObject (org.netxms.client.objects.AbstractObject)19 Container (org.netxms.client.objects.Container)7 NXCSession (org.netxms.client.NXCSession)6 Cluster (org.netxms.client.objects.Cluster)6 Condition (org.netxms.client.objects.Condition)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Interface (org.netxms.client.objects.Interface)5 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)4 AccessPoint (org.netxms.client.objects.AccessPoint)4 ServiceRoot (org.netxms.client.objects.ServiceRoot)4 Subnet (org.netxms.client.objects.Subnet)4 ArrayList (java.util.ArrayList)3 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)3 AgentPolicy (org.netxms.client.objects.AgentPolicy)3 EntireNetwork (org.netxms.client.objects.EntireNetwork)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Shell (org.eclipse.swt.widgets.Shell)2 IViewPart (org.eclipse.ui.IViewPart)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2