/**
   * WhiteboardObjectTextJabberImpl constructor.
   *
   * @param xml the XML string object to parse.
   */
  public WhiteboardObjectTextJabberImpl(String xml) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;
    try {
      builder = factory.newDocumentBuilder();
      InputStream in = new ByteArrayInputStream(xml.getBytes());
      Document doc = builder.parse(in);

      Element e = doc.getDocumentElement();
      String elementName = e.getNodeName();
      if (elementName.equals("text")) {
        // we have a text
        String id = e.getAttribute("id");
        double x = Double.parseDouble(e.getAttribute("x"));
        double y = Double.parseDouble(e.getAttribute("y"));
        String fill = e.getAttribute("fill");
        String fontFamily = e.getAttribute("font-family");
        int fontSize = Integer.parseInt(e.getAttribute("font-size"));
        String text = e.getTextContent();

        this.setID(id);
        this.setWhiteboardPoint(new WhiteboardPoint(x, y));
        this.setFontName(fontFamily);
        this.setFontSize(fontSize);
        this.setText(text);
        this.setColor(Color.decode(fill).getRGB());
      }
    } catch (ParserConfigurationException ex) {
      if (logger.isDebugEnabled()) logger.debug("Problem WhiteboardObject : " + xml);
    } catch (IOException ex) {
      if (logger.isDebugEnabled()) logger.debug("Problem WhiteboardObject : " + xml);
    } catch (Exception ex) {
      if (logger.isDebugEnabled()) logger.debug("Problem WhiteboardObject : " + xml);
    }
  }
 /**
  * Called when the underlying implementation has received an indication that a WhiteboardObject,
  * sent earlier has been successfully received by the destination.
  *
  * @param evt the WhiteboardObjectDeliveredEvent containing the id of the WhiteboardObject that
  *     has caused the event.
  */
 public void whiteboardObjectDelivered(WhiteboardObjectDeliveredEvent evt) {
   logger.debug(
       "WBObjectDeliveredEvent: The following object: "
           + evt.getSourceWhiteboardObject()
           + " has been delivered to "
           + evt.getDestinationContact().getDisplayName());
 }
  /**
   * Called to indicate that delivery of a WhiteboardObject sent earlier has failed. Reason code and
   * phrase are contained by the <tt>WhiteboardObjectDeliveryFailedEvent</tt>
   *
   * @param evt the <tt>WhiteboardObjectDeliveryFailedEvent</tt> containing the ID of the
   *     WhiteboardObject whose delivery has failed.
   */
  public void whiteboardObjectDeliveryFailed(WhiteboardObjectDeliveryFailedEvent evt) {
    String errorMessage = null;

    if (evt.getErrorCode() == WhiteboardObjectDeliveryFailedEvent.NETWORK_FAILURE) {
      errorMessage = "Network failure.";
    } else if (evt.getErrorCode()
        == WhiteboardObjectDeliveryFailedEvent.OFFLINE_MESSAGES_NOT_SUPPORTED) {
      errorMessage = "Offline messages aren't supported.";
    } else if (evt.getErrorCode() == WhiteboardObjectDeliveryFailedEvent.PROVIDER_NOT_REGISTERED) {
      errorMessage = "Protocol provider is not registered.";
    } else if (evt.getErrorCode() == WhiteboardObjectDeliveryFailedEvent.INTERNAL_ERROR) {
      errorMessage = "An internal error occured.";
    } else if (evt.getErrorCode() == WhiteboardObjectDeliveryFailedEvent.UNKNOWN_ERROR) {
      errorMessage = "An unknown error occured.";
    }

    String debugErrorMessage =
        "WBObjectDeliveryFailedEvent: The following object: "
            + evt.getSourceWhiteboardObject()
            + " has NOT been delivered to "
            + evt.getDestinationContact().getDisplayName()
            + " because of the following error: "
            + errorMessage;

    logger.debug(debugErrorMessage);

    WhiteboardActivator.getUiService()
        .getPopupDialog()
        .showMessagePopupDialog(errorMessage, "Error", PopupDialog.ERROR_MESSAGE);
  }
  /**
   * Called when a new incoming <tt>WhiteboardObject</tt> has been received.
   *
   * @param evt the <tt>WhiteboardObjectReceivedEvent</tt> containing the newly received
   *     WhiteboardObject, its sender and other details.
   */
  public void whiteboardObjectReceived(WhiteboardObjectReceivedEvent evt) {
    /*
     * There are 2 cases when a message is received:
     * - an existing session
     * - or a new session
     */
    WhiteboardFrame wbFrame = getWhiteboardFrame(evt.getSourceWhiteboardSession());

    if (wbFrame == null) {
      logger.debug("New WBParticipant" + evt.getSourceContact().getDisplayName());

      wbFrame = new WhiteboardFrame(this, evt.getSourceWhiteboardSession());

      wbFrames.add(wbFrame);
    }

    wbFrame.setVisible(true);
    WhiteboardObject wbObject = evt.getSourceWhiteboardObject();
    wbFrame.receiveWhiteboardObject(wbObject);
  }