use of org.netxms.ui.eclipse.topology.dialogs.EnterPrimaryHostnameDlg in project netxms by netxms.
the class FindNodeByPrimaryHostname method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
final EnterPrimaryHostnameDlg dlg = new EnterPrimaryHostnameDlg(window.getShell());
if (dlg.open() != Window.OK)
return;
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob("Searching for hostname" + dlg.getHostname() + "in the network", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<AbstractNode> nodes = session.findNodesByHostname((int) dlg.getZoneId(), dlg.getHostname());
runInUIThread(new Runnable() {
@Override
public void run() {
if (nodes != null && !nodes.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("The following nodes matching the criteria have been found: ");
for (int i = 0; i < nodes.size(); i++) {
sb.append("\n" + nodes.get(i).getPrimaryName());
}
MessageDialogHelper.openInformation(shell, "Result", sb.toString());
} else
MessageDialogHelper.openInformation(shell, "Result", "No nodes found!");
}
});
}
@Override
protected String getErrorMessage() {
return "Search for hostname" + dlg.getHostname() + "failed.";
}
}.start();
}
Aggregations