Search in sources :

Example 1 with PvChangeEvent

use of com.fr3ts0n.pvs.PvChangeEvent in project AndrOBD by fr3ts0n.

the class PvXMLHandler method endElement.

/**
 * handle end tag of element
 *
 * @param namespaceURI element's namespace
 * @param localName    element's local name
 * @param qName        element's qualified name
 */
public void endElement(String namespaceURI, String localName, String qName) {
    log.fine("EndElement:" + qName);
    int tagID = getTagID(qName);
    switch(tagID) {
        case TAG_ID_PROCESSVAR:
            log.fine("PV:" + currPv.toString());
            firePvChanged(new PvChangeEvent(this, currPv.getKeyValue(), currPv, PvChangeEvent.PV_CONFIRMED));
            currValue = currPv;
            // If we have PV's on stack, the new PV is a recursive attribute
            if (!pvStack.empty()) {
                Object[] stackElems = (Object[]) pvStack.pop();
                currPv = (ProcessVar) stackElems[0];
                currAttrib = (String) stackElems[1];
            } else {
                log.severe("NO more PV's on Stack");
            }
            if (currPv == rootPv) {
                currAttrib = ((ProcessVar) currValue).getKeyValue();
            }
            currPv.put(currAttrib, currValue);
            break;
        case TAG_ID_PVATTRIBUTE:
            // if currently parsed PV is null, then we just finished a recursive one
            if (currPv != null) {
                // This is a plain attribute
                currPv.put(currAttrib, currValue);
            }
            currValue = null;
            break;
    }
}
Also used : PvChangeEvent(com.fr3ts0n.pvs.PvChangeEvent)

Example 2 with PvChangeEvent

use of com.fr3ts0n.pvs.PvChangeEvent in project AndrOBD by fr3ts0n.

the class PvTransferHandler method exportDone.

/* (non-Javadoc)
	   * @see javax.swing.TransferHandler#exportDone(javax.swing.JComponent, java.awt.datatransfer.Transferable, int)
	   */
@Override
protected void exportDone(JComponent c, Transferable t, int action) {
    try {
        if (action == MOVE) {
            ProcessVar pv = (ProcessVar) t.getTransferData(processVarFlavor);
            pv.firePvChanged(new PvChangeEvent(pv, pv.getKeyAttribute(), pv, PvChangeEvent.PV_ELIMINATED));
        }
    } catch (UnsupportedFlavorException e) {
        ProcessVar.log.severe(this.toString() + ":" + e.getMessage());
    } catch (IOException e) {
        ProcessVar.log.severe(this.toString() + ":" + e.getMessage());
    }
}
Also used : ProcessVar(com.fr3ts0n.pvs.ProcessVar) PvChangeEvent(com.fr3ts0n.pvs.PvChangeEvent) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Aggregations

PvChangeEvent (com.fr3ts0n.pvs.PvChangeEvent)2 ProcessVar (com.fr3ts0n.pvs.ProcessVar)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1