예제 #1
0
  /**
   * Automatically tries to create a proxy image from given element.
   *
   * @param element
   * @param alignImageToEvent if true, proxy image is aligned to start event, else next to mouse
   *     cursor
   * @deprecated As of 7.2, call or override {@link #createDragImage(Element,boolean)} instead
   */
  @Deprecated
  public void createDragImage(
      com.google.gwt.user.client.Element element, boolean alignImageToEvent) {
    Element cloneNode = (Element) element.cloneNode(true);

    // Set size explicitly for cloned node to avoid stretching #14617.
    cloneNode.getStyle().setWidth(element.getOffsetWidth(), Unit.PX);
    cloneNode.getStyle().setHeight(element.getOffsetHeight(), Unit.PX);

    syncContent(element, cloneNode);
    if (BrowserInfo.get().isIE()) {
      if (cloneNode.getTagName().toLowerCase().equals("tr")) {
        TableElement table = Document.get().createTableElement();
        TableSectionElement tbody = Document.get().createTBodyElement();
        table.appendChild(tbody);
        tbody.appendChild(cloneNode);
        cloneNode = table.cast();
      }
    }
    if (alignImageToEvent) {
      int absoluteTop = element.getAbsoluteTop();
      int absoluteLeft = element.getAbsoluteLeft();
      int clientX = WidgetUtil.getTouchOrMouseClientX(startEvent);
      int clientY = WidgetUtil.getTouchOrMouseClientY(startEvent);
      int offsetX = absoluteLeft - clientX;
      int offsetY = absoluteTop - clientY;
      setDragImage(cloneNode, offsetX, offsetY);
    } else {
      setDragImage(cloneNode);
    }
  }
예제 #2
0
  @Override
  public void hide() {

    /*
     * If the window has a RichTextArea and the RTA is focused at the time
     * of hiding in IE8 only the window will have some problems returning
     * the focus to the correct place. Curiously the focus will be returned
     * correctly if clicking on the "close" button in the window header but
     * closing the window from a button for example in the window will fail.
     * Symptom described in #10776
     *
     * The problematic part is that for the focus to be returned correctly
     * an input element needs to be focused in the root panel. Focusing some
     * other element apparently won't work.
     */
    if (BrowserInfo.get().isIE8()) {
      fixIE8FocusCaptureIssue();
    }

    if (vaadinModality) {
      hideModalityCurtain();
    }
    super.hide();

    // Remove window from windowOrder to avoid references being left
    // hanging.
    windowOrder.remove(this);
  }
 @Override
 protected void extend(ServerConnector target) {
   if (BrowserInfo.get().isIE8()) {
     LayoutManagerIE8 manager = (LayoutManagerIE8) LayoutManager.get(getConnection());
     configureGetMapSizeJS(manager);
   }
 }
예제 #4
0
 private void onResizeEvent(Event event) {
   if (resizable && Util.isTouchEventOrLeftMouseButton(event)) {
     switch (event.getTypeInt()) {
       case Event.ONMOUSEDOWN:
       case Event.ONTOUCHSTART:
         if (!isActive()) {
           bringToFront();
         }
         showResizingCurtain();
         if (BrowserInfo.get().isIE()) {
           DOM.setStyleAttribute(resizeBox, "visibility", "hidden");
         }
         resizing = true;
         startX = Util.getTouchOrMouseClientX(event);
         startY = Util.getTouchOrMouseClientY(event);
         origW = getElement().getOffsetWidth();
         origH = getElement().getOffsetHeight();
         DOM.setCapture(getElement());
         event.preventDefault();
         break;
       case Event.ONMOUSEUP:
       case Event.ONTOUCHEND:
         setSize(event, true);
       case Event.ONTOUCHCANCEL:
         DOM.releaseCapture(getElement());
       case Event.ONLOSECAPTURE:
         hideResizingCurtain();
         if (BrowserInfo.get().isIE()) {
           DOM.setStyleAttribute(resizeBox, "visibility", "");
         }
         resizing = false;
         break;
       case Event.ONMOUSEMOVE:
       case Event.ONTOUCHMOVE:
         if (resizing) {
           centered = false;
           setSize(event, false);
           event.preventDefault();
         }
         break;
       default:
         event.preventDefault();
         break;
     }
   }
 }
예제 #5
0
 private void hideModalityCurtain() {
   modalityCurtain.removeFromParent();
   if (BrowserInfo.get().isIE()) {
     // IE leaks memory in certain cases unless we release the reference
     // (#9197)
     modalityCurtain = null;
   }
 }
예제 #6
0
  @Override
  public void onBrowserEvent(Event event) {
    if (disabled || readonly) {
      return;
    }
    final Element targ = DOM.eventGetTarget(event);

    if (DOM.eventGetType(event) == Event.ONMOUSEWHEEL) {
      processMouseWheelEvent(event);
    } else if (dragging || targ == handle) {
      processHandleEvent(event);
    } else if (targ == smaller) {
      decreaseValue(true);
    } else if (targ == bigger) {
      increaseValue(true);
    } else if (DOM.eventGetType(event) == Event.MOUSEEVENTS) {
      processBaseEvent(event);
    } else if (BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYPRESS
        || !BrowserInfo.get().isGecko() && DOM.eventGetType(event) == Event.ONKEYDOWN) {

      if (handleNavigation(event.getKeyCode(), event.getCtrlKey(), event.getShiftKey())) {

        feedbackPopup.show();

        delayedValueUpdater.trigger();

        DOM.eventPreventDefault(event);
        DOM.eventCancelBubble(event, true);
      }
    } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONFOCUS) {
      feedbackPopup.show();
    } else if (targ.equals(getElement()) && DOM.eventGetType(event) == Event.ONBLUR) {
      feedbackPopup.hide();
    } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
      feedbackPopup.show();
    }
    if (WidgetUtil.isTouchEvent(event)) {
      event.preventDefault(); // avoid simulated events
      event.stopPropagation();
    }
  }
예제 #7
0
 protected VTextField(Element node) {
   super(node);
   setStyleName(CLASSNAME);
   addChangeHandler(this);
   if (BrowserInfo.get().isIE()) {
     // IE does not send change events when pressing enter in a text
     // input so we handle it using a key listener instead
     addKeyDownHandler(this);
   }
   addFocusHandler(this);
   addBlurHandler(this);
 }
예제 #8
0
  public VCustomLayout() {
    setElement(DOM.createDiv());
    // Clear any unwanted styling
    Style style = getElement().getStyle();
    style.setBorderStyle(BorderStyle.NONE);
    style.setMargin(0, Unit.PX);
    style.setPadding(0, Unit.PX);

    if (BrowserInfo.get().isIE()) {
      style.setPosition(Position.RELATIVE);
    }

    setStyleName(CLASSNAME);
  }
예제 #9
0
 private void iRender(RepeatingCommand rc, int graphs) {
   if (graphs > 1) {
     if (BrowserInfo.get().isIE8()) {
       /*
        * VML is so slow it needs to be done incrementally
        */
       Scheduler.get().scheduleIncremental(rc);
     } else {
       while (rc.execute()) {;
       }
     }
   } else if (graphs > 0) {
     rc.execute();
   }
 }
예제 #10
0
 /**
  * @deprecated Use static {@link #createNotification(int)} instead to enable GWT deferred binding.
  * @param delayMsec
  */
 @Deprecated
 public VNotification(int delayMsec) {
   this();
   this.delayMsec = delayMsec;
   if (BrowserInfo.get().isTouchDevice()) {
     new Timer() {
       @Override
       public void run() {
         if (isAttached()) {
           fade();
         }
       }
     }.schedule(delayMsec + TOUCH_DEVICE_IDLE_DELAY);
   }
 }
예제 #11
0
 public void show(Position position, String style) {
   setOpacity(getElement(), startOpacity);
   if (style != null) {
     temporaryStyle = style;
     addStyleName(style);
     addStyleDependentName(style);
   }
   super.show();
   notifications.add(this);
   setPosition(position);
   positionOrSizeUpdated();
   /** Android 4 fails to render notifications correctly without a little nudge (#8551) */
   if (BrowserInfo.get().isAndroid()) {
     Util.setStyleTemporarily(getElement(), "display", "none");
   }
 }
예제 #12
0
  @Override
  public void setVisible(boolean visible) {
    /*
     * Visibility with VWindow works differently than with other Paintables
     * in Vaadin. Invisible VWindows are not attached to DOM at all. Flag is
     * used to avoid visibility call from
     * ApplicationConnection.updateComponent();
     */
    if (!visibilityChangesDisabled) {
      super.setVisible(visible);
    }

    if (visible && BrowserInfo.get().isWebkit()) {

      /*
       * Shake up the DOM a bit to make the window shed unnecessary
       * scrollbars and resize correctly afterwards. This resulting code
       * took over a week to summon forth, and involved some pretty hairy
       * black magic. Don't touch it unless you know what you're doing!
       * Fixes ticket #11994
       */
      Scheduler.get()
          .scheduleFinally(
              new ScheduledCommand() {
                @Override
                public void execute() {
                  final com.google.gwt.dom.client.Element scrollable =
                      contents.getFirstChildElement();
                  final String oldWidth = scrollable.getStyle().getWidth();
                  final String oldHeight = scrollable.getStyle().getHeight();

                  scrollable.getStyle().setWidth(110, Unit.PCT);
                  scrollable.getOffsetWidth();
                  scrollable.getStyle().setProperty("width", oldWidth);

                  scrollable.getStyle().setHeight(110, Unit.PCT);
                  scrollable.getOffsetHeight();
                  scrollable.getStyle().setProperty("height", oldHeight);

                  updateContentsSize();
                  positionOrSizeUpdated();
                }
              });
    }
  }
예제 #13
0
  public static VNotification createNotification(int delayMsec, Widget owner) {
    final VNotification notification = GWT.create(VNotification.class);
    notification.setWaiAriaRole(null);

    notification.delayMsec = delayMsec;
    if (BrowserInfo.get().isTouchDevice()) {
      new Timer() {
        @Override
        public void run() {
          if (notification.isAttached()) {
            notification.fade();
          }
        }
      }.schedule(notification.delayMsec + TOUCH_DEVICE_IDLE_DELAY);
    }
    notification.setOwner(owner);
    return notification;
  }
예제 #14
0
 protected void onChildSizeChange() {
   ComponentConnector child = getContent();
   if (child == null) {
     return;
   }
   Style childStyle = child.getWidget().getElement().getStyle();
   /*
    * Must set absolute position if the child has relative height and
    * there's a chance of horizontal scrolling as some browsers will
    * otherwise not take the scrollbar into account when calculating the
    * height. Assuming v-ui does not have an undefined width for now, see
    * #8460.
    */
   if (child.isRelativeHeight() && !BrowserInfo.get().isIE9()) {
     childStyle.setPosition(Position.ABSOLUTE);
   } else {
     childStyle.clearPosition();
   }
 }
예제 #15
0
파일: VUI.java 프로젝트: horun/vaadin
  /**
   * Called when a resize event is received.
   *
   * <p>This may trigger a lazy refresh or perform the size check immediately depending on the
   * browser used and whether the server side requests resizes to be lazy.
   */
  private void triggerSizeChangeCheck() {
    /*
     * IE (pre IE9 at least) will give us some false resize events due to
     * problems with scrollbars. Firefox 3 might also produce some extra
     * events. We postpone both the re-layouting and the server side event
     * for a while to deal with these issues.
     *
     * We may also postpone these events to avoid slowness when resizing the
     * browser window. Constantly recalculating the layout causes the resize
     * operation to be really slow with complex layouts.
     */
    boolean lazy = resizeLazy || BrowserInfo.get().isIE8();

    if (lazy) {
      delayedResizeExecutor.trigger();
    } else {
      performSizeCheck();
    }
  }
예제 #16
0
파일: Slot.java 프로젝트: raehalme/vaadin
  /** Detaches resize listeners from the widget, caption and spacing elements */
  private void detachListeners() {
    if (getWidget() != null && layout.getLayoutManager() != null) {
      LayoutManager lm = layout.getLayoutManager();
      if (getCaptionElement() != null && captionResizeListener != null) {
        lm.removeElementResizeListener(getCaptionElement(), captionResizeListener);
      }
      if (widgetResizeListener != null) {
        lm.removeElementResizeListener(getWidget().getElement(), widgetResizeListener);
      }
      if (getSpacingElement() != null && spacingResizeListener != null) {
        lm.removeElementResizeListener(getSpacingElement(), spacingResizeListener);
      }

      if (BrowserInfo.get().isIE8()) {
        lm.removeElementResizeListener(
            getWidget().getElement(), ie8CaptionElementResizeUpdateListener);
      }
    }
  }
예제 #17
0
  /**
   * Plots a line graph
   *
   * @param xCoordinates The x-coordinates
   * @param yCoordinates The y-coordinates
   */
  private void plotLineGraph(
      List<Float> xCoordinates, List<Float> yCoordinates, boolean lineCaps, double lineThickness) {

    canvas.setLineWidth(lineThickness);
    canvas.setLineJoin("round");

    // First draw the filling
    canvas.setStrokeStyle("rgba(0,0,0,255)");
    canvas.setFillStyle(fillColor);
    canvas.beginPath();

    float x = xCoordinates.get(0);
    float y = yCoordinates.get(0);

    canvas.moveTo(x, zero);
    canvas.lineTo(x, y);

    for (int i = 1; i < xCoordinates.size(); i++) {
      x = xCoordinates.get(i);
      y = yCoordinates.get(i);
      canvas.lineTo(x, y);
    }

    canvas.lineTo(x, zero);

    x = xCoordinates.get(0);
    canvas.moveTo(x, zero);

    canvas.closePath();
    canvas.fill();

    if (useShadows) {
      enableShadows(lineThickness, PlotMode.LINE);
    }

    // Then draw the outline
    if (lineCaps) {
      canvas.setLineJoin(Canvas.BEVEL);
    }

    canvas.setStrokeStyle(color);
    canvas.beginPath();

    x = xCoordinates.get(0);
    y = yCoordinates.get(0);

    canvas.moveTo(x, zero);
    canvas.moveTo(x, y);

    for (int i = 1; i < xCoordinates.size(); i++) {
      x = xCoordinates.get(i);
      y = yCoordinates.get(i);
      canvas.lineTo(x, y);
    }

    if (BrowserInfo.get().isIE8() || BrowserInfo.get().isChrome()) {
      /*
       * In IE we have to draw a line down to zero so the path can get
       * closed. If we don't then then there will be a line through the
       * whole graph due to the VML implementation. After we move we also
       * have to draw a 1px line, else IE will not draw anything when
       * stroke width > 1.5px. IE 9-> uses canvas implementation where
       * this problem does not exist
       *
       * Apparently Chrome 18-> joined the club :(
       */
      canvas.moveTo(xCoordinates.get(0), yCoordinates.get(0));
      canvas.lineTo(xCoordinates.get(0) + 1, yCoordinates.get(0));

    } else {
      canvas.moveTo(xCoordinates.get(0), zero);
    }

    canvas.closePath();
    canvas.stroke();

    // Finally, if we have any linecaps then draw them
    if (lineCaps) {
      plotLineCaps(xCoordinates, yCoordinates, lineThickness);
    }
  }
예제 #18
0
 /**
  * Forces IE8 to reinterpret CSS rules. {@link
  * com.vaadin.client.Util#forceIE8Redraw(com.google.gwt.dom.client.Element)} doesn't work in this
  * case.
  *
  * @param element the element to redraw
  */
 private void forceRedrawIfIE8(Element element) {
   if (BrowserInfo.get().isIE8()) {
     element.addClassName("foo");
     element.removeClassName("foo");
   }
 }
예제 #19
0
 private void setOpacity(Element el, int opacity) {
   DOM.setStyleAttribute(el, "opacity", "" + (opacity / 100.0));
   if (BrowserInfo.get().isIE()) {
     DOM.setStyleAttribute(el, "filter", "Alpha(opacity=" + opacity + ")");
   }
 }