Search in sources :

Example 36 with NXCObjectModificationData

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

the class MapSeedNodes method applyChanges.

/**
 * Apply changes
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    if (!isModified)
        // Nothing to apply
        return;
    if (isApply)
        setValid(false);
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    List<Long> seedObjectIds = new ArrayList<Long>();
    for (AbstractObject o : seedNodes) seedObjectIds.add(o.getObjectId());
    md.setSeedObjectIds(seedObjectIds);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob("Update network map seed nodes", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
            isModified = false;
        }

        @Override
        protected String getErrorMessage() {
            return "Network map seed node update failed";
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        MapSeedNodes.this.setValid(true);
                    }
                });
            }
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) AbstractObject(org.netxms.client.objects.AbstractObject) ArrayList(java.util.ArrayList) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 37 with NXCObjectModificationData

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

the class ObjectPolling method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    if (object.containPollerNode())
        md.setPollerNode(pollerNode.getObjectId());
    md.setObjectFlags(collectNodeFlags(), collectNodeFlagsMask());
    if (object.containInterfaces())
        md.setIfXTablePolicy(collectIfXTablePolicy());
    if (object.containAgent())
        md.setAgentCacheMode(collectAgentCacheMode());
    if (object instanceof AbstractNode)
        md.setRequiredPolls(pollCount.getSelection());
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().NodePolling_JobName, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().NodePolling_JobError;
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        ObjectPolling.this.setValid(true);
                    }
                });
            }
        }
    }.start();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 38 with NXCObjectModificationData

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

the class RackPlacement method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    if (isApply)
        setValid(false);
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setRackPlacement(rackSelector.getObjectId(), rackImageFrontSelector.getImageGuid(), rackImageRearSelector.getImageGuid(), (short) rackPosition.getSelection(), (short) rackHeight.getSelection(), RackOrientation.getByValue(rackOrientation.getSelectionIndex()));
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format(Messages.get().RackPlacement_UpdatingRackPlacement, object.getObjectName()), null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().Comments_JobError;
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        RackPlacement.this.setValid(true);
                    }
                });
            }
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 39 with NXCObjectModificationData

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

the class SSH method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    final NXCObjectModificationData md = new NXCObjectModificationData(node.getObjectId());
    if (isApply)
        setValid(false);
    md.setSshProxy(sshProxy.getObjectId());
    md.setSshLogin(sshLogin.getText().trim());
    md.setSshPassword(sshPassword.getText());
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format("Updating SSH settings for node %s", node.getObjectName()), null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
        }

        @Override
        protected String getErrorMessage() {
            return String.format("Cannot update SSH settings for node %s", node.getObjectName());
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        SSH.this.setValid(true);
                    }
                });
            }
        }
    }.start();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 40 with NXCObjectModificationData

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

the class MapAppearance method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    if (isApply)
        setValid(false);
    final NXCObjectModificationData data = new NXCObjectModificationData(object.getObjectId());
    data.setImage(image.getImageGuid());
    if (drillDownObject != null)
        data.setDrillDownObjectId(drillDownObject.getObjectId());
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().MapAppearance_JobName, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(data);
        }

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().MapAppearance_JobError, object.getObjectName());
        }

        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        MapAppearance.this.setValid(true);
                    }
                });
            }
        }
    }.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)50 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)45 NXCSession (org.netxms.client.NXCSession)45 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)45 ArrayList (java.util.ArrayList)3 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)3 GeoLocation (org.netxms.base.GeoLocation)2 GeoLocationFormatException (org.netxms.base.GeoLocationFormatException)2 DashboardElement (org.netxms.client.dashboards.DashboardElement)2 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 List (java.util.List)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 TransformerException (javax.xml.transform.TransformerException)1 Point (org.eclipse.swt.graphics.Point)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Display (org.eclipse.swt.widgets.Display)1