/**
   * 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());
  }
Ejemplo n.º 2
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);
    }
  }
Ejemplo n.º 3
0
  /**
   * Sets up the test.
   *
   * @throws Exception in any error occurred during setup.
   */
  protected void setUp() throws Exception {
    super.setUp();

    this.setvalueCountListener = new EventCountListener(XFormsEventNames.VALUE_CHANGED);
    this.messageCountListener = new EventCountListener(BetterFormEventNames.RENDER_MESSAGE);
    EventTarget eventTarget = (EventTarget) this.processor.getXForms();
    eventTarget.addEventListener(XFormsEventNames.VALUE_CHANGED, this.setvalueCountListener, true);
    eventTarget.addEventListener(
        BetterFormEventNames.RENDER_MESSAGE, this.messageCountListener, true);
  }
Ejemplo n.º 4
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());
   }
 }
Ejemplo n.º 5
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);
  }
Ejemplo n.º 6
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());
      }
    }
  }
Ejemplo n.º 7
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;
  }
  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);
  }