Search in sources :

Example 1 with DciValue

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

the class IdMatchingDialog method mapDci.

/**
 * Map DCI
 *
 * @param data
 */
private void mapDci(DciIdMatchingData data) {
    if (data.dstNodeId == 0)
        return;
    SelectNodeDciDialog dlg = new SelectNodeDciDialog(getShell(), data.dstNodeId);
    if (dlg.open() == Window.OK) {
        DciValue v = dlg.getSelection();
        if (v != null) {
            data.dstDciId = v.getId();
            data.dstName = v.getDescription();
            viewer.update(data, null);
        }
    }
}
Also used : SelectNodeDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectNodeDciDialog) DciValue(org.netxms.client.datacollection.DciValue)

Example 2 with DciValue

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

the class IdMatchingDialog method updateDciMapping.

/**
 * Update mapping for all DCIs of given node after node mapping change
 *
 * @param objData
 */
private void updateDciMapping(final ObjectIdMatchingData objData) {
    if (objData.dcis.size() == 0)
        return;
    final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
    new ConsoleJob(Messages.get().IdMatchingDialog_JobTitle, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final DciValue[] dciValues = session.getLastValues(objData.dstId);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    for (DciIdMatchingData d : objData.dcis) {
                        d.dstNodeId = objData.dstId;
                        d.dstDciId = 0;
                        d.dstName = null;
                        for (DciValue v : dciValues) {
                            if (v.getDescription().equalsIgnoreCase(d.srcName)) {
                                d.dstDciId = v.getId();
                                d.dstName = v.getDescription();
                                break;
                            }
                        }
                    }
                    viewer.refresh(true);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().IdMatchingDialog_JobErrorText;
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NXCSession(org.netxms.client.NXCSession) DciValue(org.netxms.client.datacollection.DciValue) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 3 with DciValue

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

the class LastValuesWidget method copySelection.

/**
 * Copy selection to clipboard
 */
private void copySelection() {
    IStructuredSelection selection = (IStructuredSelection) dataViewer.getSelection();
    if (selection.isEmpty())
        return;
    // $NON-NLS-1$
    final String nl = System.getProperty("line.separator");
    StringBuilder sb = new StringBuilder();
    for (Object o : selection.toList()) {
        if (sb.length() > 0)
            sb.append(nl);
        DciValue v = (DciValue) o;
        sb.append(v.getDescription());
        // $NON-NLS-1$
        sb.append(" = ");
        sb.append(v.getValue());
    }
    if (selection.size() > 1)
        sb.append(nl);
    WidgetHelper.copyToClipboard(sb.toString());
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with DciValue

use of org.netxms.client.datacollection.DciValue 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 5 with DciValue

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

the class LastValuesWidget method getDataFromServer.

/**
 * Get data from server
 */
private void getDataFromServer() {
    if (dcTarget == null) {
        dataViewer.setInput(new DciValue[0]);
        return;
    }
    ConsoleJob job = new ConsoleJob(Messages.get(getDisplay()).LastValuesWidget_JobTitle + dcTarget.getObjectName(), viewPart, Activator.PLUGIN_ID, LastValuesWidget.JOB_FAMILY, getDisplay()) {

        @Override
        protected String getErrorMessage() {
            return String.format(Messages.get().LastValuesWidget_JobError, (dcTarget != null) ? dcTarget.getObjectName() : null);
        }

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            try {
                final DciValue[] data = session.getLastValues(dcTarget.getObjectId());
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        if (!isDisposed()) {
                            dataViewer.setInput(data);
                            hideMessage();
                        }
                    }
                });
            } catch (final Exception e) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        if (!isDisposed()) {
                            showMessage(ERROR, String.format("Cannot read data from server: %s", e.getLocalizedMessage()));
                        }
                    }
                });
            }
        }
    };
    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) CoreException(org.eclipse.core.runtime.CoreException)

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