Search in sources :

Example 86 with NXCSession

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

the class Comments method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    if (initialComments.equals(comments.getText()))
        // Nothing to apply
        return;
    if (isApply)
        setValid(false);
    final String newComments = new String(comments.getText());
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format(Messages.get().Comments_JobName, object.getObjectName()), null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.updateObjectComments(object.getObjectId(), newComments);
            initialComments = newComments;
        }

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

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

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

Example 87 with NXCSession

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

the class ConditionData 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());
    md.setDciList(dciList);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().ConditionData_JobName, null, Activator.PLUGIN_ID, null) {

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

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

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

                    @Override
                    public void run() {
                        ConditionData.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 88 with NXCSession

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

the class Dashboards 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 NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    Set<Long> idList = dashboards.keySet();
    Long[] dlist = new Long[idList.size()];
    int i = 0;
    for (Long id : idList) dlist[i++] = id;
    md.setDashboards(dlist);
    new ConsoleJob(String.format(Messages.get().TrustedNodes_JobName, object.getObjectName()), null, Activator.PLUGIN_ID, null) {

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

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

                    @Override
                    public void run() {
                        Dashboards.this.setValid(true);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().TrustedNodes_JobError;
        }
    }.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)

Example 89 with NXCSession

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

the class AutoDeploy method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    int flags = object.getFlags();
    if (checkboxEnableDeploy.getSelection())
        flags |= AgentPolicy.PF_AUTO_DEPLOY;
    else
        flags &= ~AgentPolicy.PF_AUTO_DEPLOY;
    if (checkboxEnableUninstall.getSelection())
        flags |= AgentPolicy.PF_AUTO_UNINSTALL;
    else
        flags &= ~Container.CF_AUTO_UNBIND;
    if ((flags == initialFlags) && initialAutoDeployFilter.equals(filterSource.getText()))
        // Nothing to apply
        return;
    if (isApply)
        setValid(false);
    final NXCSession session = ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setObjectFlags(flags);
    md.setAutoBindFilter(filterSource.getText());
    new ConsoleJob("Updating autodeploy configuration", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.modifyObject(md);
            initialFlags = md.getObjectFlags();
            initialAutoDeployFilter = md.getAutoBindFilter();
        }

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

                    @Override
                    public void run() {
                        AutoDeploy.this.setValid(true);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot update autodeploy configuration";
        }
    }.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 90 with NXCSession

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

the class ClusterResources 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 NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setResourceList(resources);
    new ConsoleJob(Messages.get().ClusterResources_JobName, null, Activator.PLUGIN_ID, null) {

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

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

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

                    @Override
                    public void run() {
                        ClusterResources.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)

Aggregations

NXCSession (org.netxms.client.NXCSession)248 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)167 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)163 AbstractObject (org.netxms.client.objects.AbstractObject)54 NXCObjectModificationData (org.netxms.client.NXCObjectModificationData)45 PartInitException (org.eclipse.ui.PartInitException)31 NXCObjectCreationData (org.netxms.client.NXCObjectCreationData)28 List (java.util.List)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 NXCException (org.netxms.client.NXCException)22 ArrayList (java.util.ArrayList)19 GridData (org.eclipse.swt.layout.GridData)18 GridLayout (org.eclipse.swt.layout.GridLayout)17 Composite (org.eclipse.swt.widgets.Composite)17 CreateObjectDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog)15 AbstractNode (org.netxms.client.objects.AbstractNode)14 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)13 IOException (java.io.IOException)11 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10