Search in sources :

Example 1 with CreateNodeDialog

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());
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) CreateNodeDialog(org.netxms.ui.eclipse.objectmanager.dialogs.CreateNodeDialog)

Example 2 with CreateNodeDialog

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();
}
Also used : AgentTunnel(org.netxms.client.AgentTunnel) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) CreateNodeDialog(org.netxms.ui.eclipse.objectmanager.dialogs.CreateNodeDialog)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)2 NXCSession (org.netxms.client.NXCSession)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 CreateNodeDialog (org.netxms.ui.eclipse.objectmanager.dialogs.CreateNodeDialog)2 List (java.util.List)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 AgentTunnel (org.netxms.client.AgentTunnel)1