Search in sources :

Example 16 with NXCObjectModificationData

use of org.netxms.client.NXCObjectModificationData 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 17 with NXCObjectModificationData

use of org.netxms.client.NXCObjectModificationData 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 18 with NXCObjectModificationData

use of org.netxms.client.NXCObjectModificationData 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 19 with NXCObjectModificationData

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

Example 20 with NXCObjectModificationData

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

the class StatusCalculation method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    Composite dialogArea = new Composite(parent, SWT.NONE);
    object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
    currentState = new NXCObjectModificationData(object.getObjectId());
    currentState.setStatusCalculationMethod(object.getStatusCalculationMethod());
    currentState.setStatusPropagationMethod(object.getStatusPropagationMethod());
    currentState.setFixedPropagatedStatus(object.getFixedPropagatedStatus());
    currentState.setStatusShift(object.getStatusShift());
    currentState.setStatusTransformation(object.getStatusTransformation());
    currentState.setStatusSingleThreshold(object.getStatusSingleThreshold());
    currentState.setStatusThresholds(object.getStatusThresholds());
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    dialogArea.setLayout(layout);
    createLeftPanel(dialogArea);
    createRightPanel(dialogArea);
    changeCalculationMethod(object.getStatusCalculationMethod());
    changePropagationMethod(object.getStatusPropagationMethod());
    createCalcSelectionListener(radioCalcDefault, AbstractObject.CALCULATE_DEFAULT);
    createCalcSelectionListener(radioCalcMostCritical, AbstractObject.CALCULATE_MOST_CRITICAL);
    createCalcSelectionListener(radioCalcSingle, AbstractObject.CALCULATE_SINGLE_THRESHOLD);
    createCalcSelectionListener(radioCalcMultiple, AbstractObject.CALCULATE_MULTIPLE_THRESHOLDS);
    createPropSelectionListener(radioPropDefault, AbstractObject.PROPAGATE_DEFAULT);
    createPropSelectionListener(radioPropUnchanged, AbstractObject.PROPAGATE_UNCHANGED);
    createPropSelectionListener(radioPropFixed, AbstractObject.PROPAGATE_FIXED);
    createPropSelectionListener(radioPropRelative, AbstractObject.PROPAGATE_RELATIVE);
    createPropSelectionListener(radioPropTranslated, AbstractObject.PROPAGATE_TRANSLATED);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData)

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