Search in sources :

Example 21 with NXCObjectCreationData

use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.

the class ImportDashboard method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final ImportDashboardDialog dlg = new ImportDashboardDialog(window.getShell());
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final Display display = Display.getCurrent();
    new ConsoleJob(Messages.get().ImportDashboard_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document dom = db.parse(dlg.getImportFile());
            Element root = dom.getDocumentElement();
            if (// $NON-NLS-1$
            !root.getNodeName().equals("dashboard"))
                throw new Exception(Messages.get().ImportDashboard_InvalidFile);
            root.normalize();
            List<DashboardElement> dashboardElements = new ArrayList<DashboardElement>();
            // $NON-NLS-1$
            NodeList elementsRoot = root.getElementsByTagName("elements");
            for (int i = 0; i < elementsRoot.getLength(); i++) {
                if (elementsRoot.item(i).getNodeType() != Node.ELEMENT_NODE)
                    continue;
                // $NON-NLS-1$
                NodeList elements = ((Element) elementsRoot.item(i)).getElementsByTagName("dashboardElement");
                for (int j = 0; j < elements.getLength(); j++) {
                    Element e = (Element) elements.item(j);
                    // $NON-NLS-1$ //$NON-NLS-2$
                    DashboardElement de = new DashboardElement(getNodeValueAsInt(e, "type", 0), getNodeValueAsXml(e, "element"));
                    // $NON-NLS-1$
                    de.setLayout(getNodeValueAsXml(e, "layout"));
                    dashboardElements.add(de);
                }
            }
            root.normalize();
            objectName = dlg.getObjectName();
            if (doIdMapping(display, session, dashboardElements, root)) {
                NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, objectName, parentId);
                final long objectId = session.createObject(cd);
                NXCObjectModificationData md = new NXCObjectModificationData(objectId);
                // $NON-NLS-1$
                md.setColumnCount(getNodeValueAsInt(root, "columns", 1));
                // $NON-NLS-1$
                md.setObjectFlags(getNodeValueAsInt(root, "options", 0));
                md.setDashboardElements(dashboardElements);
                session.modifyObject(md);
            }
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().ImportDashboard_Error, dlg.getObjectName());
        }
    }.start();
}
Also used : NXCSession(org.netxms.client.NXCSession) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) DashboardElement(org.netxms.client.dashboards.DashboardElement) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) DashboardElement(org.netxms.client.dashboards.DashboardElement) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DocumentBuilder(javax.xml.parsers.DocumentBuilder) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ImportDashboardDialog(org.netxms.ui.eclipse.dashboard.dialogs.ImportDashboardDialog) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Display(org.eclipse.swt.widgets.Display)

Example 22 with NXCObjectCreationData

use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.

the class CreateNetworkMap method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateNetworkMapDialog dlg = new CreateNetworkMapDialog(window.getShell());
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateNetworkMap_JobName, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_NETWORKMAP, dlg.getName(), parentId);
            cd.setMapType(dlg.getType());
            cd.setSeedObjectId(dlg.getSeedObject());
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateNetworkMap_JobError, dlg.getName());
        }
    }.start();
}
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) CreateNetworkMapDialog(org.netxms.ui.eclipse.networkmaps.dialogs.CreateNetworkMapDialog)

Example 23 with NXCObjectCreationData

use of org.netxms.client.NXCObjectCreationData 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)

Example 24 with NXCObjectCreationData

use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.

the class CreateContainer method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CreateContainer_Container);
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateContainer_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_CONTAINER, dlg.getObjectName(), parentId);
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateContainer_JobError, dlg.getObjectName());
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 25 with NXCObjectCreationData

use of org.netxms.client.NXCObjectCreationData in project netxms by netxms.

the class CreateMobileDevice method run.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
	 */
@Override
public void run(IAction action) {
    final CreateMobileDeviceDialog dlg = new CreateMobileDeviceDialog(window.getShell());
    if (dlg.open() != Window.OK)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().CreateMobileDevice_JobTitle, part, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_MOBILEDEVICE, dlg.getName(), parentId);
            cd.setDeviceId(dlg.getDeviceId());
            session.createObject(cd);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().CreateMobileDevice_JobError, dlg.getName());
        }
    }.start();
}
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) CreateMobileDeviceDialog(org.netxms.ui.eclipse.objectmanager.dialogs.CreateMobileDeviceDialog)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)28 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)28 NXCSession (org.netxms.client.NXCSession)28 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)28 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)15 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)3 List (java.util.List)2 CreateNodeDialog (org.netxms.ui.eclipse.objectmanager.dialogs.CreateNodeDialog)2 CreateServiceCheckDialog (org.netxms.ui.eclipse.slm.dialogs.CreateServiceCheckDialog)2 ArrayList (java.util.ArrayList)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 TransformerException (javax.xml.transform.TransformerException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Display (org.eclipse.swt.widgets.Display)1 AgentTunnel (org.netxms.client.AgentTunnel)1 DashboardElement (org.netxms.client.dashboards.DashboardElement)1 ImportDashboardDialog (org.netxms.ui.eclipse.dashboard.dialogs.ImportDashboardDialog)1 CreateNetworkMapDialog (org.netxms.ui.eclipse.networkmaps.dialogs.CreateNetworkMapDialog)1 CreateChassisDialog (org.netxms.ui.eclipse.objectmanager.dialogs.CreateChassisDialog)1