Search in sources :

Example 1 with NXCObjectModificationData

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

the class CloneDashboard method run.

@Override
public void run(final IAction action) {
    final long parentId = sourceObject.getParentIdList()[0];
    final CreateObjectDialog dlg = new CreateObjectDialog(window.getShell(), Messages.get().CloneDashboard_Dashboard);
    if (dlg.open() == Window.OK) {
        final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        new ConsoleJob(Messages.get().CloneDashboard_JobTitle, part, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                NXCObjectCreationData cd = new NXCObjectCreationData(AbstractObject.OBJECT_DASHBOARD, dlg.getObjectName(), parentId);
                final long newDashboardId = session.createObject(cd);
                final NXCObjectModificationData md = new NXCObjectModificationData(newDashboardId);
                md.setDashboardElements(sourceObject.getElements());
                md.setColumnCount(sourceObject.getNumColumns());
                md.setObjectFlags(sourceObject.getOptions());
                session.modifyObject(md);
            }

            @Override
            protected String getErrorMessage() {
                return String.format(Messages.get().CloneDashboard_Error, dlg.getObjectName());
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CreateObjectDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.CreateObjectDialog) NXCSession(org.netxms.client.NXCSession) NXCObjectCreationData(org.netxms.client.NXCObjectCreationData) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 2 with NXCObjectModificationData

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

the class MapBackground 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());
    if (radioTypeNone.getSelection()) {
        md.setMapBackground(NXCommon.EMPTY_GUID, new GeoLocation(false), 0, ColorConverter.rgbToInt(backgroundColor.getColorValue()));
    } else if (radioTypeImage.getSelection()) {
        md.setMapBackground(image.getImageGuid(), new GeoLocation(false), 0, ColorConverter.rgbToInt(backgroundColor.getColorValue()));
    } else if (!disableGeolocationBackground && radioTypeGeoMap.getSelection()) {
        GeoLocation location;
        try {
            location = GeoLocation.parseGeoLocation(latitude.getText(), longitude.getText());
        } catch (GeoLocationFormatException e) {
            MessageDialogHelper.openError(getShell(), Messages.get().MapBackground_Error, Messages.get().MapBackground_GeoLocFormatError);
            return false;
        }
        md.setMapBackground(NetworkMap.GEOMAP_BACKGROUND, location, zoomSpinner.getSelection(), ColorConverter.rgbToInt(backgroundColor.getColorValue()));
    }
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().MapBackground_JobTitle + object.getObjectName(), null, Activator.PLUGIN_ID, null) {

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

        @Override
        protected String getErrorMessage() {
            return Messages.get().MapBackground_JobError + object.getObjectName();
        }

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

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

Example 3 with NXCObjectModificationData

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

the class MapObjectFilter method applyChanges.

/**
 * Apply changes
 *
 * @param isApply true if update operation caused by "Apply" button
 */
protected void applyChanges(final boolean isApply) {
    final String filter = filterSource.getText();
    if (initialFilter.equals(filter) && (checkboxEnableFilter.getSelection() == initialEnable))
        // Nothing to apply
        return;
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    final NXCObjectModificationData md = new NXCObjectModificationData(object.getObjectId());
    md.setFilter(filter);
    md.setObjectFlags(checkboxEnableFilter.getSelection() ? NetworkMap.MF_FILTER_OBJECTS : 0, NetworkMap.MF_FILTER_OBJECTS);
    new ConsoleJob(Messages.get().MapObjectFilter_JobTitle, 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() {
                        initialFilter = filter;
                        initialEnable = checkboxEnableFilter.getSelection();
                        MapObjectFilter.this.setValid(true);
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().MapObjectFilter_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 4 with NXCObjectModificationData

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

the class PredefinedMap method saveMap.

/**
 * Save map on server
 */
private void saveMap() {
    updateObjectPositions();
    final NXCObjectModificationData md = new NXCObjectModificationData(rootObject.getObjectId());
    md.setMapContent(mapPage.getElements(), mapPage.getLinks());
    md.setMapLayout(automaticLayoutEnabled ? layoutAlgorithm : MapLayoutAlgorithm.MANUAL);
    md.setConnectionRouting(routingAlgorithm);
    md.setMapObjectDisplayMode(labelProvider.getObjectFigureType());
    int flags = mapObject.getFlags();
    if (labelProvider.isShowStatusIcons())
        flags |= NetworkMap.MF_SHOW_STATUS_ICON;
    else
        flags &= ~NetworkMap.MF_SHOW_STATUS_ICON;
    if (labelProvider.isShowStatusFrame())
        flags |= NetworkMap.MF_SHOW_STATUS_FRAME;
    else
        flags &= ~NetworkMap.MF_SHOW_STATUS_FRAME;
    if (labelProvider.isShowStatusBackground())
        flags |= NetworkMap.MF_SHOW_STATUS_BKGND;
    else
        flags &= ~NetworkMap.MF_SHOW_STATUS_BKGND;
    if (labelProvider.isShowLinkDirection())
        flags |= NetworkMap.MF_SHOW_LINK_DIRECTION;
    else
        flags &= ~NetworkMap.MF_SHOW_LINK_DIRECTION;
    md.setObjectFlags(flags);
    new ConsoleJob(String.format(Messages.get().PredefinedMap_SaveJobTitle, rootObject.getObjectName()), this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

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

                @Override
                public void run() {
                    viewer.setInput(mapPage);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().PredefinedMap_SaveJobError;
        }
    }.start();
    addDciToRequestList();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCObjectModificationData(org.netxms.client.NXCObjectModificationData) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Point(org.eclipse.swt.graphics.Point) PartInitException(org.eclipse.ui.PartInitException)

Example 5 with NXCObjectModificationData

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

the class MapOptions 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());
    int flags = 0;
    if ((checkIncludeEndNodes != null) && checkIncludeEndNodes.getSelection())
        flags |= NetworkMap.MF_SHOW_END_NODES;
    if (checkShowStatusIcon.getSelection())
        flags |= NetworkMap.MF_SHOW_STATUS_ICON;
    if (checkShowStatusFrame.getSelection())
        flags |= NetworkMap.MF_SHOW_STATUS_FRAME;
    if (checkShowStatusBkgnd.getSelection())
        flags |= NetworkMap.MF_SHOW_STATUS_BKGND;
    if (checkCalculateStatus.getSelection())
        flags |= NetworkMap.MF_CALCULATE_STATUS;
    if (checkShowLinkDirection.getSelection())
        flags |= NetworkMap.MF_SHOW_LINK_DIRECTION;
    md.setObjectFlags(flags, 0x5F);
    md.setMapObjectDisplayMode(MapObjectDisplayMode.getByValue(objectDisplayMode.getSelectionIndex()));
    md.setConnectionRouting(routingAlgorithm.getSelectionIndex() + 1);
    if (radioColorCustom.getSelection()) {
        md.setLinkColor(ColorConverter.rgbToInt(linkColor.getColorValue()));
    } else {
        md.setLinkColor(-1);
    }
    if (checkCustomRadius != null) {
        if (checkCustomRadius.getSelection())
            md.setDiscoveryRadius(topologyRadius.getSelection());
        else
            md.setDiscoveryRadius(-1);
    }
    if (isApply)
        setValid(false);
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().MapOptions_JobTitle + object.getObjectName(), null, Activator.PLUGIN_ID, null) {

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

        @Override
        protected String getErrorMessage() {
            return Messages.get().MapOptions_JobError + object.getObjectName();
        }

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

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