Пример #1
0
 /**
  * Tears down the test.
  *
  * @throws Exception in any error occurred during setup.
  */
 protected void tearDown() throws Exception {
   EventTarget eventTarget = (EventTarget) this.processor.getXForms();
   eventTarget.removeEventListener(
       BetterFormEventNames.RENDER_MESSAGE, this.messageCountListener, true);
   this.messageCountListener = null;
   super.tearDown();
 }
  /**
   * Tests deferred update behaviour of a replace instance submission.
   *
   * @throws Exception if any error occurred during the test.
   */
  public void testReplaceInstanceUpdateBehaviour() throws Exception {
    Model model = this.chibaBean.getContainer().getDefaultModel();
    UpdateHandler updateHandler = new UpdateHandler(model);
    updateHandler.doRebuild(true);
    updateHandler.doRecalculate(true);
    updateHandler.doRevalidate(true);
    updateHandler.doRefresh(true);
    model.setUpdateHandler(updateHandler);

    EventTarget target = model.getTarget();
    TestEventListener rebuildListener = new TestEventListener();
    TestEventListener recalculateListener = new TestEventListener();
    TestEventListener revalidateListener = new TestEventListener();
    TestEventListener refreshListener = new TestEventListener();
    target.addEventListener(XFormsEventNames.REBUILD, rebuildListener, false);
    target.addEventListener(XFormsEventNames.RECALCULATE, recalculateListener, false);
    target.addEventListener(XFormsEventNames.REVALIDATE, revalidateListener, false);
    target.addEventListener(XFormsEventNames.REFRESH, refreshListener, false);

    this.chibaBean.dispatch("submission-replace-instance", XFormsEventNames.SUBMIT);
    updateHandler.doUpdate();

    assertEquals("submission-replace-instance", this.submitDoneListener.getId());
    assertEquals(null, this.submitErrorListener.getId());

    assertEquals(null, rebuildListener.getId());
    assertEquals(null, recalculateListener.getId());
    assertEquals(null, revalidateListener.getId());
    assertEquals(null, refreshListener.getId());
  }
Пример #3
0
  @Override
  public void redraw() {
    setupCSS(svgp);
    final StyleLibrary style = context.getStyleResult().getStyleLibrary();
    double dotsize = style.getLineWidth(StyleLibrary.PLOT);

    for (DBIDIter id = sample.getSample().iter(); id.valid(); id.advance()) {
      double[] v = proj.fastProjectDataToRenderSpace(rel.get(id));
      if (v[0] != v[0] || v[1] != v[1]) {
        continue; // NaN!
      }
      Element tooltip = makeTooltip(id, v[0], v[1], dotsize);
      SVGUtil.addCSSClass(tooltip, TOOLTIP_HIDDEN);

      // sensitive area.
      Element area = svgp.svgRect(v[0] - dotsize, v[1] - dotsize, 2 * dotsize, 2 * dotsize);
      SVGUtil.addCSSClass(area, TOOLTIP_AREA);

      EventTarget targ = (EventTarget) area;
      targ.addEventListener(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE, hoverer, false);
      targ.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, hoverer, false);
      targ.addEventListener(SVGConstants.SVG_CLICK_EVENT_TYPE, hoverer, false);

      // NOTE: do not change the sequence in which these are inserted!
      layer.appendChild(area);
      layer.appendChild(tooltip);
    }
  }
Пример #4
0
  /**
   * Sets up the test.
   *
   * @throws Exception in any error occurred during setup.
   */
  protected void setUp() throws Exception {
    super.setUp();

    this.messageCountListener = new EventCountListener(BetterFormEventNames.RENDER_MESSAGE);
    EventTarget eventTarget = (EventTarget) this.processor.getXForms();
    eventTarget.addEventListener(
        BetterFormEventNames.RENDER_MESSAGE, this.messageCountListener, true);
  }
Пример #5
0
  protected void dispatchSVGDocEvent(String eventType) {
    SVGSVGElement root = (SVGSVGElement) document.getDocumentElement();
    // Event is dispatched on outermost SVG element.
    EventTarget t = root;

    DocumentEvent de = (DocumentEvent) document;
    AbstractEvent ev = (AbstractEvent) de.createEvent("SVGEvents");
    ev.initEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, eventType, false, false);
    t.dispatchEvent(ev);
  }
Пример #6
0
 @Override
 protected void onPause() {
   super.onPause();
   /// M: Code analyze 008, fix bug ALPS00236567, hide the mediaControl when activity paused
   /// so onTouchEvent excute show @{
   if (mMediaController != null) {
     /// M: Must do this so we don't leak a window.
     mMediaController.hide();
   }
   /// @}
   if (mSmilDoc != null) {
     ((EventTarget) mSmilDoc)
         .removeEventListener(SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, this, false);
   }
   /// M: Code analyze 002, fix bug ALPS00111374, whether need resume @{
   if ((null != mSmilPlayer)) {
     if (mSmilPlayer.isPlayingState()) {
       mSmilPlayer.pause();
       bNeedResume = true;
     } else if (mSmilPlayer.isPausedState()) {
       bNeedResume = false;
     }
   }
   /// @}
 }
  private synchronized void waitForEntry(long interval) throws InterruptedException {
    if (LOCAL_LOGV) {
      Log.v(TAG, "Waiting for " + interval + "ms.");
    }

    long overhead = 0;

    while (interval > 0) {
      long startAt = System.currentTimeMillis();
      long sleep = Math.min(interval, TIMESLICE);
      if (overhead < sleep) {
        wait(sleep - overhead);
        mCurrentTime += sleep;
      } else {
        sleep = 0;
        mCurrentTime += overhead;
      }

      if (isStopAction() || isReloadAction() || isPauseAction()) {
        return;
      }

      ((EventTarget) mRoot).dispatchEvent(mMediaTimeUpdatedEvent);

      interval -= TIMESLICE;
      overhead = System.currentTimeMillis() - startAt - sleep;
    }
  }
Пример #8
0
 private void refreshWebView(Resource resource) {
   if (isVisible) {
     WebEngine engine = webview.getEngine();
     engine
         .getLoadWorker()
         .stateProperty()
         .addListener(
             (observable, oldValue, newValue) -> {
               if (newValue.equals(Worker.State.SUCCEEDED)) {
                 Document document = engine.getDocument();
                 Element documentElement = document.getDocumentElement();
                 if (documentElement != null) {
                   ((EventTarget) documentElement)
                       .addEventListener(
                           "click",
                           evt -> {
                             if (evt.getTarget() instanceof ElementImpl) {
                               Deque<ElementPosition> positions = new ArrayDeque<>();
                               ElementImpl currentElement = ((ElementImpl) evt.getTarget());
                               ElementImpl parent =
                                   (ElementImpl) currentElement.getParentElement();
                               while (parent != null) {
                                 NodeList children;
                                 if (StringUtils.isNotEmpty(currentElement.getNamespaceURI())) {
                                   children =
                                       parent.getElementsByTagNameNS(
                                           currentElement.getNamespaceURI(),
                                           currentElement.getNodeName());
                                 } else {
                                   children =
                                       parent.getElementsByTagName(currentElement.getNodeName());
                                 }
                                 for (int i = 0; i < children.getLength(); i++) {
                                   if (children.item(i) == currentElement) {
                                     ElementPosition position =
                                         new ElementPosition(
                                             currentElement.getNodeName(),
                                             i,
                                             currentElement.getNamespaceURI());
                                     positions.push(position);
                                   }
                                 }
                                 currentElement = parent;
                                 parent = (ElementImpl) currentElement.getParentElement();
                               }
                               editorManager.scrollTo(positions);
                             } else {
                               logger.info("clicked class " + evt.getTarget());
                             }
                           },
                           false);
                 }
               }
             });
     engine.load("http://localhost:8777/" + resource.getHref());
   }
 }
Пример #9
0
  public void prepare(NodeList nodes) {
    // Gets an element from the loaded document.
    for (int i = 0; i < nodes.getLength(); i++) {
      Node node = nodes.item(i);

      // if (node instanceof Element) {
      // ((Element) node).setAttribute("style",
      // DEFAULT_STYLE);
      // }
      if (node instanceof EventTarget && !node.getNodeName().equals("g")) {
        EventTarget t = (EventTarget) node;
        t.addEventListener("mouseover", this, false);
        t.addEventListener("mouseout", this, false);
      }

      if (node.hasChildNodes()) {
        prepare(node.getChildNodes());
      }
    }
  }
Пример #10
0
 /** Removes all listeners attached to the document and that manage focus. */
 public void dispose() {
   if (document == null) return;
   EventTarget target = (EventTarget) document;
   target.removeEventListener("click", mouseclickListener, true);
   target.removeEventListener("mouseover", mouseoverListener, true);
   target.removeEventListener("mouseout", mouseoutListener, true);
   target.removeEventListener("DOMFocusIn", domFocusInListener, true);
   target.removeEventListener("DOMFocusOut", domFocusOutListener, true);
   lastFocusEventTarget = null;
   document = null;
 }
Пример #11
0
  @Override
  protected void onResume() {
    super.onResume();

    if (mMediaController != null) {
      // mMediaController.setMdragging(false);
      mMediaController.hide();
    }
    if (mSmilDoc != null) {
      ((EventTarget) mSmilDoc)
          .addEventListener(
              SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);
    }
    /// M: Code analyze 002, fix bug ALPS00111374, whether need resume @{
    if (!bNeedResume) {
      mRotate = false;
      return;
    }
    /// @}
    if (null == mSmilPlayer) {
      mSmilPlayer = SmilPlayer.getPlayer();
    }
    if (null != mSmilPlayer) {
      if (!isFinishing()) {
        if (mSmilPlayer.isPausedState()) {
          if (mRotate) {
            // if need resume the player, set the state playing.
            mSmilPlayer.setStateStart();
          } else {
            mSmilPlayer.start();
          }
        }
      }
    }
    mRotate = false;
  }
Пример #12
0
  /**
   * Constructs a new <tt>FocusManager</tt> for the specified document.
   *
   * @param doc the document
   */
  public FocusManager(Document doc) {
    document = doc;
    EventTarget target = (EventTarget) doc;

    mouseclickListener = new MouseClickTacker();
    target.addEventListener("click", mouseclickListener, true);

    mouseoverListener = new MouseOverTacker();
    target.addEventListener("mouseover", mouseoverListener, true);

    mouseoutListener = new MouseOutTacker();
    target.addEventListener("mouseout", mouseoutListener, true);

    domFocusInListener = new DOMFocusInTracker();
    target.addEventListener("DOMFocusIn", domFocusInListener, true);

    domFocusOutListener = new DOMFocusOutTracker();
    target.addEventListener("DOMFocusOut", domFocusOutListener, true);
  }
  public SVGGraph(SVGGraphController graphController) {
    super(graphController);
    this.graphController = graphController;

    mouseClickAction = new SVGMouseClickEventListener(this);
    mouseMovedAction = new SVGMouseMovedEventListener(this);
    mouseUpAction = new SVGMouseUpEventListener(this);
    mouseOverAction = new SVGMouseOverEventListener(this);
    mouseOutAction = new SVGMouseOutEventListener(this);

    mainGroup = graphController.createGElem();
    mainGroup.setAttribute(SVG_FONT_SIZE_ATTRIBUTE, "10");
    mainGroup.setAttribute(SVG_FONT_FAMILY_ATTRIBUTE, "Helvetica");
    mainGroup.setAttribute(SVG_STROKE_ATTRIBUTE, CSS_BLACK_VALUE);
    mainGroup.setAttribute(SVG_STROKE_DASHARRAY_ATTRIBUTE, CSS_NONE_VALUE);
    mainGroup.setAttribute(SVG_STROKE_WIDTH_ATTRIBUTE, "1");
    mainGroup.setAttribute(SVG_FILL_ATTRIBUTE, CSS_NONE_VALUE);

    EventTarget t = (EventTarget) mainGroup;
    t.addEventListener(SVG_CLICK_EVENT_TYPE, mouseClickAction, false);
    t.addEventListener(SVG_MOUSEMOVE_EVENT_TYPE, mouseMovedAction, false);
    t.addEventListener(SVG_MOUSEUP_EVENT_TYPE, mouseUpAction, false);
    // t.addEventListener(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE, mouseOverAction, false);
    // t.addEventListener(SVGConstants.SVG_MOUSEOUT_EVENT_TYPE, mouseOutAction, false);

    polygon = graphController.createPolygon();
    mainGroup.appendChild(polygon);

    completedPolygon = graphController.createPolygon();
    completedPolygon.setAttribute(SVG_POINTS_ATTRIBUTE, calculatePoints(getShape(), 0, 0));
    completedPolygon.setAttribute(SVG_FILL_ATTRIBUTE, COMPLETED_COLOUR);
    // completedPolygon.setAttribute(SVGConstants.SVG_FILL_OPACITY_ATTRIBUTE, "0.8");
    // completedPolygon.setAttribute(SVG_STROKE_ATTRIBUTE, SVG_NONE_VALUE);
    mainGroup.appendChild(completedPolygon);

    labelText = graphController.createText("");
    label = graphController.createText(labelText);
    label.setAttribute(SVG_TEXT_ANCHOR_ATTRIBUTE, SVG_MIDDLE_VALUE);
    label.setAttribute(SVG_FILL_ATTRIBUTE, CSS_BLACK_VALUE);
    label.setAttribute(SVG_STROKE_ATTRIBUTE, SVG_NONE_VALUE);
    labelGroup = graphController.createGElem();
    labelGroup.appendChild(label);
    mainGroup.appendChild(labelGroup);

    iterationText = graphController.createText("");
    iteration = graphController.createText(iterationText);
    iteration.setAttribute(SVG_TEXT_ANCHOR_ATTRIBUTE, SVG_END_VALUE);
    iteration.setAttribute(SVG_FONT_SIZE_ATTRIBUTE, "6");
    iteration.setAttribute(SVG_FONT_FAMILY_ATTRIBUTE, "sans-serif");
    iteration.setAttribute(SVG_FILL_ATTRIBUTE, CSS_BLACK_VALUE);
    iteration.setAttribute(SVG_STROKE_ATTRIBUTE, SVG_NONE_VALUE);
    polygon.appendChild(iteration);

    errorsText = graphController.createText("");
    error = graphController.createText(errorsText);
    error.setAttribute(SVG_TEXT_ANCHOR_ATTRIBUTE, SVG_END_VALUE);
    error.setAttribute(SVG_FONT_SIZE_ATTRIBUTE, "6");
    error.setAttribute(SVG_FONT_FAMILY_ATTRIBUTE, "sans-serif");
    error.setAttribute(SVG_FILL_ATTRIBUTE, CSS_BLACK_VALUE);
    error.setAttribute(SVG_STROKE_ATTRIBUTE, SVG_NONE_VALUE);
    polygon.appendChild(error);

    animateShape =
        createAnimationElement(graphController, SVG_ANIMATE_TAG, SVG_POINTS_ATTRIBUTE, null);

    animatePosition =
        createAnimationElement(
            graphController,
            SVG_ANIMATE_TRANSFORM_TAG,
            SVG_TRANSFORM_ATTRIBUTE,
            TRANSFORM_TRANSLATE);

    animateLabel =
        createAnimationElement(
            graphController,
            SVG_ANIMATE_TRANSFORM_TAG,
            SVG_TRANSFORM_ATTRIBUTE,
            TRANSFORM_TRANSLATE);

    delegate = new SVGGraphElementDelegate(graphController, this, mainGroup);
  }
Пример #14
0
 /**
  * Fires a 'DOMActivate' event to the specified target.
  *
  * @param target the event target
  * @param detailArg the detailArg parameter of the event
  */
 protected void fireDOMActivateEvent(EventTarget target, int detailArg) {
   DocumentEvent docEvt = (DocumentEvent) ((Element) target).getOwnerDocument();
   UIEvent uiEvt = (UIEvent) docEvt.createEvent("UIEvents");
   uiEvt.initUIEvent("DOMActivate", true, true, null, detailArg);
   target.dispatchEvent(uiEvt);
 }
Пример #15
0
 /**
  * Fires a 'DOMFocusOut' event to the specified target.
  *
  * @param target the event target
  */
 protected void fireDOMFocusOutEvent(EventTarget target) {
   DocumentEvent docEvt = (DocumentEvent) ((Element) target).getOwnerDocument();
   UIEvent uiEvt = (UIEvent) docEvt.createEvent("UIEvents");
   uiEvt.initUIEvent("DOMFocusOut", true, false, null, 0);
   target.dispatchEvent(uiEvt);
 }