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()));
}
}
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()));
}
}
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;
}
}
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());
}
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);
}
}
Aggregations