Search in sources :

Example 11 with NXCObjectModificationData

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

the class ResponsibleUsers 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 NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    List<Long> userIds = new ArrayList<Long>(userList.size());
    for (AbstractUserObject o : userList) userIds.add(o.getId());
    md.setResponsibleUsers(userIds);
    new ConsoleJob(String.format(Messages.get().AccessControl_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() {
                        ResponsibleUsers.this.setValid(true);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().AccessControl_JobError;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ArrayList(java.util.ArrayList) AbstractUserObject(org.netxms.client.users.AbstractUserObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 12 with NXCObjectModificationData

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

the class RackPassiveElements 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(rack.getObjectId());
    try {
        md.setPassiveElements(passiveElements.createXml());
    } catch (Exception e) {
        MessageDialogHelper.openError(getShell(), "Rack attribute error", "Unable to save rack attribute configuration" + e.getMessage());
    }
    final NXCSession session = ConsoleSharedData.getSession();
    new ConsoleJob("Update rack attributes", null, Activator.PLUGIN_ID, null) {

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

        @Override
        protected String getErrorMessage() {
            return "Rack attribute update error";
        }

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

                    @Override
                    public void run() {
                        isModified = 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 13 with NXCObjectModificationData

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

the class SNMP 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.setSnmpVersion(snmpIndexToVersion(snmpVersion.getSelectionIndex()));
    try {
        md.setSnmpPort(Integer.parseInt(snmpPort.getText(), 10));
    } catch (NumberFormatException e) {
        MessageDialog.openWarning(getShell(), Messages.get().Communication_Warning, Messages.get().Communication_WarningInvalidSNMPPort);
        if (isApply)
            setValid(true);
        return false;
    }
    md.setSnmpProxy(snmpProxy.getObjectId());
    md.setSnmpAuthMethod(snmpAuth.getSelectionIndex());
    md.setSnmpPrivMethod(snmpPriv.getSelectionIndex());
    md.setSnmpAuthName(snmpAuthName.getText());
    md.setSnmpAuthPassword(snmpAuthPassword.getText());
    md.setSnmpPrivPassword(snmpPrivPassword.getText());
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format("Updating SNMP 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 SNMP settings for node %s", node.getObjectName());
        }

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

                    @Override
                    public void run() {
                        SNMP.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 14 with NXCObjectModificationData

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

the class TrustedNodes 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 = trustedNodes.keySet();
    long[] nodes = new long[idList.size()];
    int i = 0;
    for (long id : idList) nodes[i++] = id;
    md.setTrustedNodes(nodes);
    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() {
                        TrustedNodes.this.setValid(true);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().TrustedNodes_JobError;
        }
    }.schedule();
}
Also used : NXCSession(org.netxms.client.NXCSession) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 15 with NXCObjectModificationData

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

the class ZoneCommunications method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    if (isApply)
        setValid(false);
    final NXCObjectModificationData md = new NXCObjectModificationData(zone.getObjectId());
    md.setZoneProxy(agentProxy.getObjectId());
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format(Messages.get().ZoneCommunications_JobName, zone.getObjectName()), null, Activator.PLUGIN_ID, null) {

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

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

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

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

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