Search in sources :

Example 1 with DataCollectionObjectEditor

use of org.netxms.ui.eclipse.datacollection.api.DataCollectionObjectEditor in project netxms by netxms.

the class DataCollectionEditor method setItemStatus.

/**
 * Change status for selected items
 *
 * @param newStatus New status
 */
private void setItemStatus(final int newStatus) {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() <= 0)
        return;
    new ConsoleJob(Messages.get().DataCollectionEditor_ChStatusJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final long[] itemList = new long[selection.size()];
            int pos = 0;
            for (Object dci : selection.toList()) {
                itemList[pos++] = ((DataCollectionObject) dci).getId();
            }
            dciConfig.setObjectStatus(itemList, newStatus);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (Object dci : selection.toList()) {
                        ((DataCollectionObject) dci).setStatus(newStatus);
                        viewer.update(dci, null);
                        new DataCollectionObjectEditor((DataCollectionObject) dci).modify();
                    }
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_ChStatusJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) DataCollectionObjectEditor(org.netxms.ui.eclipse.datacollection.api.DataCollectionObjectEditor) AbstractObject(org.netxms.client.objects.AbstractObject) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PartInitException (org.eclipse.ui.PartInitException)1 NXCException (org.netxms.client.NXCException)1 DataCollectionObject (org.netxms.client.datacollection.DataCollectionObject)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 DataCollectionObjectEditor (org.netxms.ui.eclipse.datacollection.api.DataCollectionObjectEditor)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1