Search in sources :

Example 31 with DciValue

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

the class StartDataRecalculation 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 32 with DciValue

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

the class ForceDciPoll 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 33 with DciValue

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

the class LinkDataSources method addItem.

/**
 * Add new item
 */
private void addItem() {
    SelectDciDialog dlg = new SelectDciDialog(getShell(), 0);
    if (dlg.open() == Window.OK) {
        List<DciValue> selection = dlg.getSelection();
        List<SingleDciConfig> select = new ArrayList<SingleDciConfig>();
        for (DciValue item : selection) {
            SingleDciConfig dci = new SingleDciConfig(item);
            select.add(dci);
            labelProvider.addCacheEntry(dci.getNodeId(), dci.dciId, dci.name);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog) SingleDciConfig(org.netxms.client.maps.configs.SingleDciConfig)

Example 34 with DciValue

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

the class LastValuesWidget method copySelectionDciName.

/**
 * Copy DCI name of selection
 */
private void copySelectionDciName() {
    IStructuredSelection selection = (IStructuredSelection) dataViewer.getSelection();
    if (selection.isEmpty())
        return;
    StringBuilder dciName = new StringBuilder();
    for (Object o : selection.toList()) {
        if (dciName.length() > 0)
            dciName.append(' ');
        DciValue v = (DciValue) o;
        dciName.append(v.getName());
    }
    WidgetHelper.copyToClipboard(dciName.toString());
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 35 with DciValue

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

the class DciList method getDataFromServer.

/**
 * Get data from server
 */
private void getDataFromServer() {
    if (node == null) {
        viewer.setInput(new DciValue[0]);
        return;
    }
    ConsoleJob job = new ConsoleJob(String.format(Messages.get().DciList_JobTitle, node.getObjectName()), viewPart, Activator.PLUGIN_ID, null) {

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().DciList_JobError, node.getObjectName());
        }

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<DciValue> data = (dcObjectType == -1) ? Arrays.asList(session.getLastValues(node.getObjectId(), false, false, allowNoValueObjects)) : new ArrayList<DciValue>(Arrays.asList(session.getLastValues(node.getObjectId(), false, false, allowNoValueObjects)));
            if (dcObjectType != -1) {
                Iterator<DciValue> it = data.iterator();
                while (it.hasNext()) {
                    DciValue dci = it.next();
                    if (dci.getDcObjectType() != dcObjectType)
                        it.remove();
                }
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    viewer.setInput(data.toArray());
                }
            });
        }
    };
    job.setUser(false);
    job.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DciValue(org.netxms.client.datacollection.DciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

DciValue (org.netxms.client.datacollection.DciValue)37 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 ArrayList (java.util.ArrayList)9 SelectDciDialog (org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)5 AbstractObject (org.netxms.client.objects.AbstractObject)4 Intent (android.content.Intent)3 NXCSession (org.netxms.client.NXCSession)3 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)3 DataCollectionObject (org.netxms.client.datacollection.DataCollectionObject)3 SimpleDciValue (org.netxms.client.datacollection.SimpleDciValue)3 SingleDciConfig (org.netxms.client.maps.configs.SingleDciConfig)3 CoreException (org.eclipse.core.runtime.CoreException)2 PartInitException (org.eclipse.ui.PartInitException)2 NXCPMessage (org.netxms.base.NXCPMessage)2 DataCollectionTarget (org.netxms.client.objects.DataCollectionTarget)2 DciIdMatchingData (org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)2 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)2