Search in sources :

Example 1 with DataCollectionObject

use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.

the class DataCollectionObjectPropertyTester method test.

/* (non-Javadoc)
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
	 */
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (!(receiver instanceof DataCollectionObject))
        return false;
    if (// $NON-NLS-1$
    property.equals("isClusterObject")) {
        NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
        if (owner instanceof Cluster)
            return true;
        if (owner instanceof AbstractNode) {
            for (AbstractObject o : owner.getParentsAsArray()) {
                if (o instanceof Cluster)
                    return true;
            }
        }
        return false;
    }
    if (// $NON-NLS-1$
    property.equals("isTemplateObject")) {
        NXCSession session = (NXCSession) ConsoleSharedData.getSession();
        AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
        return (owner instanceof Template);
    }
    return false;
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) Template(org.netxms.client.objects.Template)

Example 2 with DataCollectionObject

use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.

the class ClearCollectedData method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
@Override
public void selectionChanged(IAction action, ISelection selection) {
    Set<DCI> dciList = null;
    if (selection instanceof IStructuredSelection) {
        dciList = new HashSet<DCI>();
        for (Object o : ((IStructuredSelection) selection).toList()) {
            if (o instanceof DciValue) {
                dciList.add(new DCI(((DciValue) o).getNodeId(), ((DciValue) o).getId()));
            } else if (o instanceof DataCollectionObject) {
                dciList.add(new DCI(((DataCollectionObject) o).getNodeId(), ((DataCollectionObject) o).getId()));
            } else {
                dciList = null;
                break;
            }
        }
    }
    objects = dciList;
    action.setEnabled((objects != null) && (objects.size() > 0));
}
Also used : DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) DciValue(org.netxms.client.datacollection.DciValue) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 3 with DataCollectionObject

use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.

the class DataCollectionEditor method copyItems.

/**
 * Copy items to another node
 */
private void copyItems(final boolean doMove) {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeAndTemplateSelectionFilter(true));
    if (dlg.open() != Window.OK)
        return;
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    Iterator<?> it = selection.iterator();
    final long[] dciList = new long[selection.size()];
    for (int i = 0; (i < dciList.length) && it.hasNext(); i++) dciList[i] = ((DataCollectionObject) it.next()).getId();
    new ConsoleJob(Messages.get().DataCollectionEditor_CopyJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (AbstractObject o : dlg.getSelectedObjects(AbstractNode.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Template.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Cluster.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(MobileDevice.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            for (AbstractObject o : dlg.getSelectedObjects(Sensor.class)) dciConfig.copyObjects(o.getObjectId(), dciList);
            if (doMove) {
                for (long id : dciList) dciConfig.deleteObject(id);
                runInUIThread(new Runnable() {

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

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_CopyJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) Cluster(org.netxms.client.objects.Cluster) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) NXCException(org.netxms.client.NXCException) Template(org.netxms.client.objects.Template) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Sensor(org.netxms.client.objects.Sensor)

Example 4 with DataCollectionObject

use of org.netxms.client.datacollection.DataCollectionObject in project netxms by netxms.

the class DataCollectionEditor method deleteItems.

/**
 * Delete currently selected DCIs
 */
private void deleteItems() {
    final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() <= 0)
        return;
    if (!MessageDialogHelper.openConfirm(getSite().getShell(), Messages.get().DataCollectionEditor_DeleteConfirmTitle, Messages.get().DataCollectionEditor_DeleteConfirmText))
        return;
    new ConsoleJob(Messages.get().DataCollectionEditor_DeleteJob_Title + object.getObjectName(), this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            for (Object dci : selection.toList()) {
                dciConfig.deleteObject(((DataCollectionObject) dci).getId());
            }
            runInUIThread(new Runnable() {

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

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataCollectionEditor_DeleteJob_Error + object.getObjectName();
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) 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)

Example 5 with DataCollectionObject

use of org.netxms.client.datacollection.DataCollectionObject 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

DataCollectionObject (org.netxms.client.datacollection.DataCollectionObject)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 PartInitException (org.eclipse.ui.PartInitException)6 NXCException (org.netxms.client.NXCException)6 AbstractObject (org.netxms.client.objects.AbstractObject)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 Template (org.netxms.client.objects.Template)4 DciValue (org.netxms.client.datacollection.DciValue)3 AbstractNode (org.netxms.client.objects.AbstractNode)2 Cluster (org.netxms.client.objects.Cluster)2 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)2 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)2 Iterator (java.util.Iterator)1 Action (org.eclipse.jface.action.Action)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1