Search in sources :

Example 11 with DciValue

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

the class LastValuesComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    int result;
    DciValue v1 = (DciValue) e1;
    DciValue v2 = (DciValue) e2;
    switch(// $NON-NLS-1$
    (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
        case LastValuesWidget.COLUMN_ID:
            result = (int) (v1.getId() - v2.getId());
            break;
        case LastValuesWidget.COLUMN_DESCRIPTION:
            result = v1.getDescription().compareToIgnoreCase(v2.getDescription());
            break;
        case LastValuesWidget.COLUMN_VALUE:
            result = compareValue(v1, v2);
            break;
        case LastValuesWidget.COLUMN_TIMESTAMP:
            result = v1.getTimestamp().compareTo(v2.getTimestamp());
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer)

Example 12 with DciValue

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

the class ImportDashboard method doIdMapping.

/**
 * Map node and DCI ID from source system to destination system
 * @throws Exception
 * @return true if import operation should continue
 */
private boolean doIdMapping(final Display display, final NXCSession session, List<DashboardElement> dashboardElements, Element root) throws Exception {
    final Map<Long, ObjectIdMatchingData> objects = readSourceObjects(root);
    final Map<Long, DciIdMatchingData> dcis = readSourceDci(root);
    // add all node IDs from DCI list if they are missing
    for (DciIdMatchingData d : dcis.values()) {
        if (!objects.containsKey(d.srcNodeId))
            // $NON-NLS-1$
            objects.put(d.srcNodeId, new ObjectIdMatchingData(d.srcNodeId, "", AbstractObject.OBJECT_NODE));
    }
    // try to match objects
    for (ObjectIdMatchingData d : objects.values()) {
        if (d.srcId < 10) {
            // built-in object
            d.dstId = d.srcId;
            continue;
        }
        if (d.srcName.isEmpty())
            continue;
        AbstractObject object = session.findObjectByName(d.srcName);
        if ((object != null) && isCompatibleClasses(object.getObjectClass(), d.objectClass)) {
            d.dstId = object.getObjectId();
            d.dstName = object.getObjectName();
        }
    }
    // try to match DCIs
    for (DciIdMatchingData d : dcis.values()) {
        // get node ID on target system
        ObjectIdMatchingData od = objects.get(d.srcNodeId);
        // bind DCI data to appropriate node data
        od.dcis.add(d);
        if (od.dstId == 0)
            // no match for node
            continue;
        d.dstNodeId = od.dstId;
        DciValue[] dciValues = session.getLastValues(d.dstNodeId);
        for (DciValue v : dciValues) {
            if (v.getDescription().equalsIgnoreCase(d.srcName)) {
                d.dstDciId = v.getId();
                d.dstName = v.getDescription();
                break;
            }
        }
    }
    // show matching results to user
    UIJob job = new // $NON-NLS-1$
    UIJob(// $NON-NLS-1$
    display, // $NON-NLS-1$
    "") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            IdMatchingDialog dlg = new IdMatchingDialog(window.getShell(), objects, dcis);
            return (dlg.open() == Window.OK) ? Status.OK_STATUS : Status.CANCEL_STATUS;
        }
    };
    job.schedule();
    job.join();
    if (job.getResult().equals(Status.OK_STATUS)) {
        // update dashboard elements with mapping data
        for (DashboardElement e : dashboardElements) updateDashboardElement(e, objects, dcis);
        return true;
    }
    return false;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IdMatchingDialog(org.netxms.ui.eclipse.dashboard.dialogs.IdMatchingDialog) ObjectIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData) AbstractObject(org.netxms.client.objects.AbstractObject) DciValue(org.netxms.client.datacollection.DciValue) UIJob(org.eclipse.ui.progress.UIJob) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData) DashboardElement(org.netxms.client.dashboards.DashboardElement)

Example 13 with DciValue

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

the class DataSources 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<ChartDciConfig> select = new ArrayList<ChartDciConfig>();
        for (DciValue item : selection) {
            ChartDciConfig dci = new ChartDciConfig(item);
            select.add(dci);
            labelProvider.addCacheEntry(dci.nodeId, dci.dciId, dci.name);
            dciList.add(dci);
        }
        viewer.setInput(dciList.toArray());
        viewer.setSelection(new StructuredSelection(select));
    }
}
Also used : ChartDciConfig(org.netxms.client.datacollection.ChartDciConfig) 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)

Example 14 with DciValue

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

the class DciSelector method selectionButtonHandler.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.widgets.AbstractSelector#selectionButtonHandler()
	 */
@Override
protected void selectionButtonHandler() {
    SelectDciDialog dlg = new SelectDciDialog(getShell(), fixedNode ? nodeId : 0);
    dlg.setEnableEmptySelection(true);
    dlg.setDcObjectType(dcObjectType);
    dlg.setSingleSelection(true);
    dlg.setAllowNoValueObjects(allowNoValueObjects);
    if (dlg.open() == Window.OK) {
        List<DciValue> dci = dlg.getSelection();
        if (dci != null && dci.size() == 1) {
            setDciId(dci.get(0).getNodeId(), dci.get(0).getId());
            dciName = dci.get(0).getName();
            dciObjectType = dci.get(0).getDcObjectType();
        } else {
            setDciId(fixedNode ? nodeId : 0, 0);
            dciName = null;
        }
    }
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) SelectDciDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectDciDialog)

Example 15 with DciValue

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

the class DciListComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    int result;
    DciValue v1 = (DciValue) e1;
    DciValue v2 = (DciValue) e2;
    switch(// $NON-NLS-1$
    (Integer) ((SortableTableViewer) viewer).getTable().getSortColumn().getData("ID")) {
        case DciList.COLUMN_ID:
            result = (int) (v1.getId() - v2.getId());
            break;
        case DciList.COLUMN_PARAMETER:
            result = v1.getName().compareToIgnoreCase(v2.getName());
            break;
        case DciList.COLUMN_DESCRIPTION:
            result = v1.getDescription().compareToIgnoreCase(v2.getDescription());
            break;
        default:
            result = 0;
            break;
    }
    return (((SortableTableViewer) viewer).getTable().getSortDirection() == SWT.UP) ? result : -result;
}
Also used : DciValue(org.netxms.client.datacollection.DciValue) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer)

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