Search in sources :

Example 21 with NXCObjectModificationData

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

the class ServiceCheckScript method applyChanges.

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

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
            md.setScript(newScript);
            session.modifyObject(md);
            initialScript = newScript;
        }

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

        @Override
        protected void jobFinalize() {
            if (isApply) {
                getDisplay().asyncExec(new Runnable() {

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

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

the class SnmpConfig method savePortConfig.

private void savePortConfig(final NXCSession session) throws IOException, NXCException {
    // $NON-NLS-1$
    session.setServerVariable("SNMPPorts", parsePorts());
    for (Integer i : ports.keySet()) {
        if (ports.get(i).isEmpty() || session.findZone(i) == null)
            continue;
        final NXCObjectModificationData data = new NXCObjectModificationData(session.findZone(i).getObjectId());
        data.setSnmpPorts(ports.get(i));
        session.modifyObject(data);
    }
}
Also used : NXCObjectModificationData(org.netxms.client.NXCObjectModificationData)

Example 23 with NXCObjectModificationData

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

the class InterfacesFragment method modifyExpectedState.

/**
 * Modifies expected state of the selected interface
 * @param newState	The new infterface state
 * @return true if the command can be issued properly
 */
private boolean modifyExpectedState(int newState) {
    if (selectedObject != null) {
        NXCSession session = service.getSession();
        if (session != null) {
            NXCObjectModificationData md = new NXCObjectModificationData(selectedObject.getObjectId());
            md.setExpectedState(newState);
            try {
                session.modifyObject(md);
            } catch (NXCException e) {
                Log.e(TAG, "NXCException in modifyState...", e);
                e.printStackTrace();
            } catch (IOException e) {
                Log.e(TAG, "IOException in modifyState...", e);
                e.printStackTrace();
            }
            return true;
        }
    }
    return false;
}
Also used : NXCSession(org.netxms.client.NXCSession) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) IOException(java.io.IOException) NXCException(org.netxms.client.NXCException)

Example 24 with NXCObjectModificationData

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

the class DashboardElements method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
private boolean applyChanges(final boolean isApply) {
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setDashboardElements(elements);
    md.setColumnCount(columnCount.getSelection());
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().DashboardElements_JobTitle, null, Activator.PLUGIN_ID, null) {

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

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

        /* (non-Javadoc)
			 * @see org.netxms.ui.eclipse.jobs.ConsoleJob#jobFinalize()
			 */
        @Override
        protected void jobFinalize() {
            if (isApply) {
                runInUIThread(new Runnable() {

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

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

the class DashboardControl method saveDashboard.

/**
 * Save dashboard layout
 *
 * @param viewPart
 */
public void saveDashboard(IViewPart viewPart) {
    final NXCObjectModificationData md = new NXCObjectModificationData(dashboard.getObjectId());
    md.setDashboardElements(new ArrayList<DashboardElement>(elements));
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().DashboardControl_SaveLayout, viewPart, Activator.PLUGIN_ID, null) {

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

                @Override
                public void run() {
                    if (isDisposed())
                        return;
                    modified = false;
                    if (modifyListener != null)
                        modifyListener.save();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DashboardControl_SaveError + dashboard.getObjectName();
        }
    }.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) DashboardElement(org.netxms.client.dashboards.DashboardElement)

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