Search in sources :

Example 41 with NXCObjectModificationData

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

the class AccessControl 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 boolean inheritAccessRights = checkInherit.getSelection();
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setACL(acl.values().toArray(new AccessListElement[acl.size()]));
    md.setInheritAccessRights(inheritAccessRights);
    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() {
                        AccessControl.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) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) AccessListElement(org.netxms.client.AccessListElement)

Example 42 with NXCObjectModificationData

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

the class AutoBind 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 (checkboxEnableBind.getSelection())
        flags |= Container.CF_AUTO_BIND;
    else
        flags &= ~Container.CF_AUTO_BIND;
    if (checkboxEnableUnbind.getSelection())
        flags |= Container.CF_AUTO_UNBIND;
    else
        flags &= ~Container.CF_AUTO_UNBIND;
    if ((flags == initialFlags) && initialAutoBindFilter.equals(filterSource.getText()))
        // Nothing to apply
        return;
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setObjectFlags(flags);
    md.setAutoBindFilter(filterSource.getText());
    new ConsoleJob(Messages.get().AutoBind_JobName, null, Activator.PLUGIN_ID, null) {

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

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

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

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

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

the class NetworkServicePolling 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());
    try {
        int ipPort = Integer.parseInt(port.getText());
        if ((ipPort < 1) || (ipPort > 65535))
            throw new NumberFormatException();
        md.setIpPort(ipPort);
    } catch (NumberFormatException e) {
        MessageDialogHelper.openWarning(getShell(), Messages.get().NetworkServicePolling_Warning, Messages.get().NetworkServicePolling_WarningInvalidPort);
        return false;
    }
    md.setRequiredPolls(pollCount.getSelection());
    md.setServiceType(serviceType.getSelectionIndex());
    String addr = ipAddress.getText().trim();
    if (!addr.isEmpty()) {
        try {
            md.setIpAddress(new InetAddressEx(InetAddress.getByName(addr)));
        } catch (UnknownHostException e) {
            MessageDialogHelper.openWarning(getShell(), Messages.get().AddAddressListElementDialog_Warning, Messages.get().AddAddressListElementDialog_AddressValidationError);
            return false;
        }
    } else {
        md.setIpAddress(new InetAddressEx());
    }
    md.setRequest(request.getText());
    md.setResponse(response.getText());
    md.setPollerNode(pollerNode.getObjectId());
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().NetworkServicePolling_JobName, null, Activator.PLUGIN_ID, null) {

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

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

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

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

Example 44 with NXCObjectModificationData

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

the class RackProperties 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(rack.getObjectId());
    md.setHeight(rackHeight.getSelection());
    md.setRackNumberingTopBottom(numberingScheme.getSelectionIndex() == 1);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(String.format(Messages.get().RackProperties_UpdatingRackProperties, rack.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() {
                        RackProperties.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 45 with NXCObjectModificationData

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

the class SensorProperties method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected boolean applyChanges(final boolean isApply) {
    if (!commonData.validate())
        return false;
    final NXCObjectModificationData md = new NXCObjectModificationData(sensor.getObjectId());
    md.setMacAddress(commonData.getMacAddress());
    md.setDeviceClass(commonData.getDeviceClass());
    md.setVendor(commonData.getVendor());
    md.setSerialNumber(commonData.getSerial());
    md.setDeviceAddress(commonData.getDeviceAddress());
    md.setMetaType(commonData.getMetaType());
    md.setDescription(commonData.getDescription());
    md.setSensorProxy(commonData.getProxyNode());
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().SensorPolling_JobName, null, Activator.PLUGIN_ID, null) {

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

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

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

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