use of org.netxms.ui.eclipse.objectmanager.dialogs.CreateNodeDialog in project netxms by netxms.
the class CreateNode method run.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
CreateNodeDialog dlg = null;
do {
dlg = new CreateNodeDialog(window.getShell(), dlg);
if (dlg.open() != Window.OK)
return;
final NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NODE, dlg.getObjectName(), parentId);
cd.setCreationFlags(dlg.getCreationFlags());
cd.setPrimaryName(dlg.getHostName());
cd.setAgentPort(dlg.getAgentPort());
cd.setSnmpPort(dlg.getSnmpPort());
cd.setAgentProxyId(dlg.getAgentProxy());
cd.setSnmpProxyId(dlg.getSnmpProxy());
cd.setIcmpProxyId(dlg.getIcmpProxy());
cd.setSshProxyId(dlg.getSshProxy());
cd.setZoneUIN(dlg.getZoneUIN());
cd.setSshLogin(dlg.getSshLogin());
cd.setSshPassword(dlg.getSshPassword());
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().CreateNode_JobTitle, part, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.createObject(cd);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().CreateNode_JobError, cd.getName());
}
}.start();
} while (dlg.isShowAgain());
}
use of org.netxms.ui.eclipse.objectmanager.dialogs.CreateNodeDialog in project netxms by netxms.
the class TunnelManager method createNode.
/**
* Create new node and bind tunnel
*/
private void createNode() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final AgentTunnel tunnel = (AgentTunnel) selection.getFirstElement();
if (tunnel.isBound())
return;
CreateNodeDialog dlg = new CreateNodeDialog(getSite().getShell(), null);
dlg.setEnableShowAgainFlag(false);
dlg.setObjectName(tunnel.getSystemName());
dlg.setZoneUIN(tunnel.getZoneUIN());
if (dlg.open() != Window.OK)
return;
final NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NODE, dlg.getObjectName(), 2);
cd.setCreationFlags(dlg.getCreationFlags());
cd.setPrimaryName(dlg.getHostName());
cd.setAgentPort(dlg.getAgentPort());
cd.setSnmpPort(dlg.getSnmpPort());
cd.setAgentProxyId(dlg.getAgentProxy());
cd.setSnmpProxyId(dlg.getSnmpProxy());
cd.setIcmpProxyId(dlg.getIcmpProxy());
cd.setSshProxyId(dlg.getSshProxy());
cd.setZoneUIN(dlg.getZoneUIN());
cd.setSshLogin(dlg.getSshLogin());
cd.setSshPassword(dlg.getSshPassword());
final NXCSession session = ConsoleSharedData.getSession();
new ConsoleJob("Create new node and bind tunnel", this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
long nodeId = session.createObject(cd);
session.bindAgentTunnel(tunnel.getId(), nodeId);
final List<AgentTunnel> tunnels = session.getAgentTunnels();
runInUIThread(new Runnable() {
@Override
public void run() {
viewer.setInput(tunnels);
}
});
}
@Override
protected String getErrorMessage() {
return "Cannot create node and bind tunnel";
}
}.start();
}
Aggregations