Search in sources :

Example 6 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData in project netxms by netxms.

the class ImportDashboard method readSourceDci.

/**
 * Read source DCI from XML document
 *
 * @param root
 * @return
 */
private Map<Long, DciIdMatchingData> readSourceDci(Element root) {
    Map<Long, DciIdMatchingData> dcis = new HashMap<Long, DciIdMatchingData>();
    // $NON-NLS-1$
    NodeList objectsRoot = root.getElementsByTagName("dciMap");
    for (int i = 0; i < objectsRoot.getLength(); i++) {
        if (objectsRoot.item(i).getNodeType() != Node.ELEMENT_NODE)
            continue;
        // $NON-NLS-1$
        NodeList elements = ((Element) objectsRoot.item(i)).getElementsByTagName("dci");
        for (int j = 0; j < elements.getLength(); j++) {
            Element e = (Element) elements.item(j);
            // $NON-NLS-1$
            long id = getAttributeAsLong(e, "id", 0);
            // $NON-NLS-1$
            dcis.put(id, new DciIdMatchingData(getAttributeAsLong(e, "node", 0), id, e.getTextContent()));
        }
    }
    return dcis;
}
Also used : HashMap(java.util.HashMap) NodeList(org.w3c.dom.NodeList) DashboardElement(org.netxms.client.dashboards.DashboardElement) Element(org.w3c.dom.Element) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Example 7 with DciIdMatchingData

use of org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData in project netxms by netxms.

the class IdMatchingDialog method okPressed.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
	 */
@Override
protected void okPressed() {
    // check if all elements have a match
    boolean ok = true;
    for (ObjectIdMatchingData o : objects.values()) if (o.dstId == 0) {
        ok = false;
        break;
    }
    for (DciIdMatchingData d : dcis.values()) if ((d.dstNodeId == 0) || (d.dstDciId == 0)) {
        ok = false;
        break;
    }
    if (!ok) {
        if (!MessageDialogHelper.openQuestion(getShell(), Messages.get().IdMatchingDialog_MatchingErrors, Messages.get().IdMatchingDialog_ConfirmationText))
            return;
    }
    super.okPressed();
}
Also used : ObjectIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData) DciIdMatchingData(org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)

Aggregations

DciIdMatchingData (org.netxms.ui.eclipse.dashboard.dialogs.helpers.DciIdMatchingData)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 DashboardElement (org.netxms.client.dashboards.DashboardElement)2 DciValue (org.netxms.client.datacollection.DciValue)2 ObjectIdMatchingData (org.netxms.ui.eclipse.dashboard.dialogs.helpers.ObjectIdMatchingData)2 HashMap (java.util.HashMap)1 UIJob (org.eclipse.ui.progress.UIJob)1 NXCSession (org.netxms.client.NXCSession)1 ChartDciConfig (org.netxms.client.datacollection.ChartDciConfig)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 IdMatchingDialog (org.netxms.ui.eclipse.dashboard.dialogs.IdMatchingDialog)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1