Beispiel #1
0
    @Override
    public void onBrowserEvent(Event event) {
      if (cancelled) {
        return;
      }

      assertEquals(eventType, event.getType());
      if (supportsShiftKeys) {
        assertAllShiftKeys(event, expectedCtrl, expectedAlt, expectedShift, expectedMeta);
      }

      EventTarget target = event.getCurrentEventTarget();
      if (Element.is(target)) {
        if (Element.as(target) == child) {
          assertFalse("Expecting child to receive the event only once", childReceived);
          assertFalse("Expecting child to receive the event before parent", parentReceived);

          childReceived = true;
        } else if (Element.as(target) == parent) {
          assertFalse("Expecting parent to receive the event only once", parentReceived);
          assertTrue("Expecting parent to receive the event after the child", childReceived);

          parentReceived = true;
        }
      }
    }
  /**
   * Called when an event occurs in a rendered instance of this Cell. The parent element refers to
   * the element that contains the rendered cell, NOT to the outermost element that the Cell
   * rendered.
   */
  @Override
  public void onBrowserEvent(
      final Context context,
      final Element parent,
      final List<FlashCardDto> flashCardList,
      final NativeEvent event,
      final ValueUpdater<List<FlashCardDto>> valueUpdater) {
    // Let AbstractCell handle the keydown event.
    super.onBrowserEvent(context, parent, flashCardList, event, valueUpdater);

    // Handle the click event.
    if ("click".equals(event.getType())) {
      // Ignore clicks that occur outside of the outermost element.
      EventTarget eventTarget = event.getEventTarget();

      if (parent.isOrHasChild(Element.as(eventTarget))) {
        // use this to get the selected element!!
        Element el = Element.as(eventTarget);

        // check if we really click on the image
        if (el.getParentElement().getNodeName().equalsIgnoreCase("DIV")) {
          doAction(el.getParentElement().getAttribute("name"), valueUpdater);
        }
      }
    }
  }
  /**
   * Called when an event occurs in a rendered instance of this Cell. The parent element refers to
   * the element that contains the rendered cell, NOT to the outermost element that the Cell
   * rendered.
   */
  @Override
  public void onBrowserEvent(
      com.google.gwt.cell.client.Cell.Context context,
      Element parent,
      String value,
      NativeEvent event,
      com.google.gwt.cell.client.ValueUpdater<String> valueUpdater) {

    // Let AbstractCell handle the keydown event.
    super.onBrowserEvent(context, parent, value, event, valueUpdater);

    // Handle the click event.
    if ("click".equals(event.getType())) {

      // Ignore clicks that occur outside of the outermost element.
      EventTarget eventTarget = event.getEventTarget();

      if (parent.isOrHasChild(Element.as(eventTarget))) {
        // if (parent.getFirstChildElement().isOrHasChild(
        // Element.as(eventTarget))) {

        // use this to get the selected element!!
        Element el = Element.as(eventTarget);

        // check if we really click on the image
        if (callback != null && el.getNodeName().equalsIgnoreCase("IMG")) {
          final String s = el.getParentElement().getAttribute("name");
          final KieContainer container = containersProvider.getContainer(value);
          final boolean isUp = SharedUtils.getContainerStatus(container);
          final boolean isKieApp =
              container.getType() != null
                  && KieImageCategory.KIEAPP.equals(container.getType().getCategory());
          if (ContainerActionsCell.PLAY.equals(s) && !isUp) {
            callback.onStart(container);
          } else if (ContainerActionsCell.STOP.equals(s) && isUp) {
            callback.onStop(container);
          } else if (ContainerActionsCell.RELOAD.equals(s) && isUp) {
            callback.onRestart(container);
          } else if (ContainerActionsCell.REMOVE.equals(s)) {
            callback.onRemove(container);
          } else if (ContainerActionsCell.VIEW_LOGS.equals(s)) {
            callback.onViewLogs(container);
          } else if (ContainerActionsCell.VIEW_DETAILS.equals(s) && isUp && isKieApp) {
            callback.onViewDetails(container);
          } else if (ContainerActionsCell.NAVIGATE.equals(s) && isUp && isKieApp) {
            callback.onNavigate(container);
          }
        }
      }
    }
  };
Beispiel #4
0
 /**
  * Does the event target this popup?
  *
  * @param event the native event
  * @return true if the event targets the popup
  */
 private boolean eventTargetsPopup(NativeEvent event) {
   EventTarget target = event.getEventTarget();
   if (Element.is(target)) {
     return getElement().isOrHasChild(Element.as(target));
   }
   return false;
 }
 @Override
 public void onBrowserEvent(Event event) {
   PerfTimer timer = PerfTimer.get(this, "onBrowserEvent");
   Element target = Element.as(event.getEventTarget());
   int index = getTargetItemIndex(target);
   if (index != -1) {
     // Don't need to support de-select since there is no gesture modifier
     Element.as(getElement().getChildNodes().getItem(selected))
         .removeClassName(AppResources.INSTANCE.css().selected());
     Element.as(getElement().getChildNodes().getItem(index))
         .addClassName(AppResources.INSTANCE.css().selected());
     SelectionEvent.fire(this, data.get(index));
     this.selected = index;
   }
   timer.end();
 }
 private Element getLastChildElement(Element parent) {
   Node lastTab = parent.getLastChild();
   while (lastTab.getNodeType() != Node.ELEMENT_NODE) {
     lastTab = lastTab.getPreviousSibling();
   }
   return Element.as(lastTab);
 }
Beispiel #7
0
    @Override
    protected void onPreviewNativeEvent(NativePreviewEvent event) {
      Element target = Element.as(event.getNativeEvent().getEventTarget());
      switch (event.getTypeInt()) {
        case Event.ONCLICK:
          if (isOrHasChildOfButton(target)) {
            updateState(false, true);
          }
          break;
        case Event.ONMOUSEDOWN:
          if (!isOrHasChildOfPopup(target)
              && !isOrHasChildOfConsole(target)
              && !isOrHasChildOfButton(target)) {
            updateState(false, true);
          }
          break;
        case Event.ONKEYPRESS:
          if (isOrHasChildOfPopup(target)) {
            // Catch children that use keyboard, so we can unfocus
            // them
            // when
            // hiding
            activeChildren.add(target);
          }
          break;
        default:
          break;
      }

      super.onPreviewNativeEvent(event);
    }
Beispiel #8
0
    /** Return the element that was the actual target of the element. */
    private Element getEventTarget(Event e) {
      EventTarget eventTarget = e.getEventTarget();

      if (!Element.is(eventTarget)) {
        return null;
      }

      return Element.as(eventTarget);
    }
Beispiel #9
0
 private boolean isResizeHandle(EventTarget eventTarget) {
   if (Element.is(eventTarget)) {
     Element e = Element.as(eventTarget);
     if (e.getClassName().contains("-column-resize-handle")) {
       return true;
     }
   }
   return false;
 }
 /**
  * Overwrites the default rich text area behavior when the user releases the mouse button.
  *
  * @param event the native event that was fired
  */
 protected void onBeforeMouseUp(Event event) {
   // The height of the body element is given by its content. When the height of the body element
   // is less than the
   // rich text area height the user can click outside of the body element, on the HTML element.
   // When this happens
   // the selection can be lost. To prevent this we give the focus back to the body element.
   if (Element.is(event.getEventTarget())
       && "html".equalsIgnoreCase(Element.as(event.getEventTarget()).getTagName())) {
     textArea.setFocus(true);
   }
 }
  public void moveTab(int index, int delta) {
    // do no work if we haven't been asked to move anywhere
    if (delta == 0) return;

    Element tabHost = getTabBarElement();

    // ignore moving left if the tab is already the leftmost tab (same for
    // right)
    int dest = index + delta;
    if (dest < 0 || dest >= tabHost.getChildCount()) return;

    // rearrange the DOM
    Element tab = Element.as(tabHost.getChild(index));
    Element prev = Element.as(tabHost.getChild(dest));
    tabHost.removeChild(tab);
    if (delta > 0) tabHost.insertAfter(tab, prev);
    else tabHost.insertBefore(tab, prev);

    // fire the tab reorder event (this syncs the editor state)
    TabReorderEvent event = new TabReorderEvent(index, dest);
    fireEvent(event);
  }
Beispiel #12
0
 /**
  * This function intercepts the user click on the map and call the method named
  * getCenterMapstraction
  *
  * @see com.google.gwt.user.client.ui.Composite#onBrowserEvent(com.google.gwt.user.client.Event)
  */
 @Override
 public void onBrowserEvent(Event event) {
   super.onBrowserEvent(event);
   Element targetElement = Element.as(((NativeEvent) event).getEventTarget());
   String targetTagName = targetElement.getTagName();
   if (targetTagName.equalsIgnoreCase("svg") || targetTagName.equalsIgnoreCase("path"))
     getCenterMapstraction(
         EUOSMEGWT.apiMapstraction,
         geoBoundsObj.newTextBoxNorth.getElement(),
         geoBoundsObj.newTextBoxEast.getElement(),
         geoBoundsObj.newTextBoxSouth.getElement(),
         geoBoundsObj.newTextBoxWest.getElement());
 }
Beispiel #13
0
  private Element findAppNameElement(Element parent) {
    for (int i = 0; i < parent.getChildCount(); i++) {
      Node childNode = parent.getChild(i);

      if (Element.is(childNode)) {
        Element child = Element.as(childNode);
        if (child.getAttribute("name").equalsIgnoreCase(appearance.download())) { // $NON-NLS-1$
          return child;
        }
      }
    }
    return null;
  }
Beispiel #14
0
  /**
   * Blurs the time box if the user clicks outside of it.
   *
   * <p>
   *
   * @param event the native preview event
   */
  protected void previewNativeEvent(NativePreviewEvent event) {

    Event nativeEvent = Event.as(event.getNativeEvent());
    if ((nativeEvent.getTypeInt() == Event.ONCLICK)) {
      EventTarget target = nativeEvent.getEventTarget();
      if (!Element.is(target)) {
        return;
      }
      Element element = Element.as(target);
      if (!m_time.getElement().isOrHasChild(element)) {
        m_time.blur();
      }
    }
  }
Beispiel #15
0
  /**
   * Does the event target one of the partner elements?
   *
   * @param event the native event
   * @return true if the event targets a partner
   */
  private boolean eventTargetsPartner(NativeEvent event) {
    if (autoHidePartners == null) {
      return false;
    }

    EventTarget target = event.getEventTarget();
    if (Element.is(target)) {
      for (Element elem : autoHidePartners) {
        if (elem.isOrHasChild(Element.as(target))) {
          return true;
        }
      }
    }
    return false;
  }
Beispiel #16
0
 @Override
 public void onBrowserEvent(
     Context context, Element parent, C value, NativeEvent event, ValueUpdater<C> valueUpdater) {
   super.onBrowserEvent(context, parent, value, event, valueUpdater);
   if (CLICK.equals(event.getType())) {
     EventTarget eventTarget = event.getEventTarget();
     if (!Element.is(eventTarget)) {
       return;
     }
     if (parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))) {
       // Ignore clicks that occur outside of the main element.
       onEnterKeyDown(context, parent, value, event, valueUpdater);
     }
   }
 }
  public void onMouseUp(MouseUpEvent event) {
    if (mouseMoveCanceled) {
      return;
    }

    Event.releaseCapture(getElement());
    setFocus(false);
    if (moveRegistration != null) {
      moveRegistration.removeHandler();
      moveRegistration = null;
    }
    int endX = event.getClientX();
    int endY = event.getClientY();
    int xDiff = startX - endX;
    int yDiff = startY - endY;
    startX = -1;
    startY = -1;
    mouseMoveStarted = false;
    Style s = getElement().getStyle();
    s.setZIndex(1);
    if (!clickTargetsResize()) {
      // check if mouse has moved over threshold of 3 pixels
      boolean mouseMoved = (xDiff < -3 || xDiff > 3 || yDiff < -3 || yDiff > 3);

      if (!weekGrid.getCalendar().isDisabledOrReadOnly() && mouseMoved) {
        // Event Move:
        // - calendar must be enabled
        // - calendar must not be in read-only mode
        weekGrid.eventMoved(this);
      } else if (!weekGrid.getCalendar().isDisabled()) {
        // Event Click:
        // - calendar must be enabled (read-only is allowed)
        EventTarget et = event.getNativeEvent().getEventTarget();
        Element e = Element.as(et);
        if (e == caption || e == eventContent || e.getParentElement() == caption) {
          if (weekGrid.getCalendar().getEventClickListener() != null) {
            weekGrid.getCalendar().getEventClickListener().eventClick(calendarEvent);
          }
        }
      }

    } else { // click targeted resize bar
      removeGlobalResizeStyle();
      if (weekGrid.getCalendar().getEventResizeListener() != null) {
        weekGrid.getCalendar().getEventResizeListener().eventResized(calendarEvent);
      }
    }
  }
 private void editEvent(
     Context context,
     Element parent,
     String value,
     ViewData viewData,
     NativeEvent event,
     ValueUpdater<String> valueUpdater) {
   String type = event.getType();
   boolean keyUp = KEYUP.equals(type);
   boolean keyDown = KEYDOWN.equals(type);
   if (keyUp || keyDown) {
     int keyCode = event.getKeyCode();
     if (keyUp
         && keyCode == KeyCodes.KEY_ENTER
         && (event.getCtrlKey() || event.getAltKey() || event.getShiftKey())) {
       // Commit the change.
       commit(context, parent, viewData, valueUpdater);
     } else if (keyUp && keyCode == KeyCodes.KEY_ESCAPE) {
       // Cancel edit mode.
       String originalText = viewData.getOriginal();
       if (viewData.isEditingAgain()) {
         viewData.setText(originalText);
         viewData.setEditing(false);
       } else {
         setViewData(context.getKey(), null);
       }
       cancel(context, parent, value);
     } else {
       // Update the text in the view data on each key.
       updateViewData(parent, viewData, true);
     }
   } else if (BLUR.equals(type)) {
     // Commit the change. Ensure that we are blurring the input element and
     // not the parent element itself.
     EventTarget eventTarget = event.getEventTarget();
     if (Element.is(eventTarget)) {
       Element target = Element.as(eventTarget);
       if ("input".equals(target.getTagName().toLowerCase())) {
         commit(context, parent, viewData, valueUpdater);
       }
     }
   }
 }
 @Override
 public void onBrowserEvent(Event event) {
   switch (DOM.eventGetType(event)) {
     case Event.ONCLICK:
       {
         // tabs can be closed by (a) middle mouse (anywhere), or (b)
         // left click on close element
         if (event.getButton() == Event.BUTTON_MIDDLE
             || (Element.as(event.getEventTarget()) == closeElement_
                 && event.getButton() == Event.BUTTON_LEFT)) {
           closeHandler_.onTabClose();
           event.stopPropagation();
           event.preventDefault();
         }
         break;
       }
   }
   super.onBrowserEvent(event);
 }
 @Override
 public void onBrowserEvent(
     com.google.gwt.cell.client.Cell.Context context,
     Element parent,
     SummaryDTO value,
     NativeEvent event,
     ValueUpdater<SummaryDTO> valueUpdater) {
   super.onBrowserEvent(context, parent, value, event, valueUpdater);
   EventTarget eventTarget = event.getEventTarget();
   if (Element.is(eventTarget)) {
     Element src = Element.as(eventTarget);
     String id = src.getId();
     if (id.startsWith(SEE_METADATA)) {
       presenter.displayMetadata(value.getUuid());
     }
     if (id.startsWith(PDF_METADATA)) {
       presenter.displayMetadataPDF(value.getUuid());
     }
   }
 }
  public void onMouseDown(MouseDownEvent event) {
    startX = event.getClientX();
    startY = event.getClientY();
    if (isDisabled() || event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
      return;
    }

    clickTarget = Element.as(event.getNativeEvent().getEventTarget());
    mouseMoveCanceled = false;

    if (weekGrid.getCalendar().isEventMoveAllowed() || clickTargetsResize()) {
      moveRegistration = addMouseMoveHandler(this);
      setFocus(true);
      try {
        startYrelative = (int) ((double) event.getRelativeY(caption) % slotHeight);
        startXrelative =
            (event.getRelativeX(weekGrid.getElement()) - weekGrid.timebar.getOffsetWidth())
                % getDateCellWidth();
      } catch (Exception e) {
        GWT.log("Exception calculating relative start position", e);
      }
      mouseMoveStarted = false;
      Style s = getElement().getStyle();
      s.setZIndex(1000);
      startDatetimeFrom = (Date) calendarEvent.getStartTime().clone();
      startDatetimeTo = (Date) calendarEvent.getEndTime().clone();
      Event.setCapture(getElement());
    }

    // make sure the right cursor is always displayed
    if (clickTargetsResize()) {
      addGlobalResizeStyle();
    }

    /*
     * We need to stop the event propagation or else the WeekGrid
     * range select will kick in
     */
    event.stopPropagation();
    event.preventDefault();
  }
Beispiel #22
0
  @Override
  public void onBrowserEvent(
      Cell.Context context,
      Element parent,
      MetadataTemplateInfo value,
      NativeEvent event,
      ValueUpdater<MetadataTemplateInfo> valueUpdater) {
    if (value == null) {
      return;
    }

    Element eventTarget = Element.as(event.getEventTarget());
    Element child = findAppNameElement(parent);
    if (child != null && child.isOrHasChild(eventTarget)) {
      switch (Event.as(event).getTypeInt()) {
        case Event.ONCLICK:
          doOnClick(eventTarget, value);
          break;
        default:
          break;
      }
    }
  }
  private void updatePOILayer(Element markerElement) {
    String markerImageSrc = Element.as(markerElement.getFirstChild()).getAttribute("src");
    String currentStyles = markerElement.getAttribute("style");

    if (markerImageSrc.equals("images/selected-DOWN.png")
        || markerImageSrc.equals("images/deselected-DOWN.png")) {
      markerElement.setAttribute("style", currentStyles.replace("z-index: 90", "z-index: 90"));
    } else if (markerImageSrc.equals("images/selected-DISCONNECTED.png")
        || markerImageSrc.equals("images/deselected-DISCONNECTED.png")) {
      markerElement.setAttribute("style", currentStyles.replace("z-index: 90", "z-index: 80"));
    } else if (markerImageSrc.equals("images/selected-MARGINAL.png")
        || markerImageSrc.equals("images/deselected-MARGINAL.png")) {
      markerElement.setAttribute("style", currentStyles.replace("z-index: 90", "z-index: 70"));
    } else if (markerImageSrc.equals("images/selected-UP.png")
        || markerImageSrc.equals("images/deselected-UP.png")) {
      markerElement.setAttribute("style", currentStyles.replace("z-index: 90", "z-index: 60"));
    } else if (markerImageSrc.equals("images/selected-STOPPED.png")
        || markerImageSrc.equals("images/deselected-STOPPED.png")) {
      markerElement.setAttribute("style", currentStyles.replace("z-index: 90", "z-index: 50"));
    } else if (markerImageSrc.equals("images/selected-UNKNOWN.png")
        || markerImageSrc.equals("images/deselected-UNKNOWN.png")) {
      markerElement.setAttribute("style", currentStyles.replace("z-index: 90", "z-index: 40"));
    }
  }
 /**
  * Detaches the XML tree from the DOM. Use with caution. {@link #getNode(String)} will not work
  * after this.
  */
 public void detach() {
   if (root != null) {
     Element.as(root).removeFromParent();
   }
 }
  public void ensureSelectedTabIsVisible(boolean animate) {
    if (currentAnimation_ != null) {
      currentAnimation_.cancel();
      currentAnimation_ = null;
    }

    Element selectedTab =
        (Element)
            DomUtils.findNode(
                getElement(),
                true,
                false,
                new NodePredicate() {
                  public boolean test(Node n) {
                    if (n.getNodeType() != Node.ELEMENT_NODE) return false;
                    return ((Element) n).getClassName().contains("gwt-TabLayoutPanelTab-selected");
                  }
                });
    if (selectedTab == null) {
      return;
    }
    selectedTab = selectedTab.getFirstChildElement().getFirstChildElement();

    Element tabBar = getTabBarElement();

    if (!isVisible() || !isAttached() || tabBar.getOffsetWidth() == 0) return; // not yet loaded

    final Element tabBarParent = tabBar.getParentElement();

    final int start = tabBarParent.getScrollLeft();
    int end =
        DomUtils.ensureVisibleHoriz(
            tabBarParent, selectedTab, padding_, padding_ + rightMargin_, true);

    // When tabs are closed, the overall width shrinks, and this can lead
    // to cases where there's too much empty space on the screen
    Node lastTab = getLastChildElement(tabBar);
    if (lastTab == null || lastTab.getNodeType() != Node.ELEMENT_NODE) return;
    int edge =
        DomUtils.getRelativePosition(tabBarParent, Element.as(lastTab)).x
            + Element.as(lastTab).getOffsetWidth();
    end = Math.min(end, Math.max(0, edge - (tabBarParent.getOffsetWidth() - rightMargin_)));

    if (edge <= tabBarParent.getOffsetWidth() - rightMargin_) end = 0;

    if (start != end) {
      if (!animate) {
        tabBarParent.setScrollLeft(end);
      } else {
        final int finalEnd = end;
        currentAnimation_ =
            new Animation() {
              @Override
              protected void onUpdate(double progress) {
                double delta = (finalEnd - start) * progress;
                tabBarParent.setScrollLeft((int) (start + delta));
              }

              @Override
              protected void onComplete() {
                if (this == currentAnimation_) {
                  tabBarParent.setScrollLeft(finalEnd);
                  currentAnimation_ = null;
                }
              }
            };
        currentAnimation_.run(Math.max(200, Math.min(1500, Math.abs(end - start) * 2)));
      }
    }
  }
    private void beginDrag(Event evt) {
      String docId = initDragParams_.getDocId();
      int dragTabWidth = initDragWidth_;

      // set drag element state
      dragTabsHost_ = getTabBarElement();
      dragScrollHost_ = dragTabsHost_.getParentElement();
      outOfBounds_ = 0;
      candidatePos_ = null;
      startPos_ = null;

      // attempt to determine which tab the cursor is over
      Point hostPos = DomUtils.getRelativePosition(Document.get().getBody(), dragTabsHost_);
      int dragX = evt.getClientX() - hostPos.getX();
      for (int i = 0; i < dragTabsHost_.getChildCount(); i++) {
        Node node = dragTabsHost_.getChild(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
          int left =
              DomUtils.leftRelativeTo(dragTabsHost_, Element.as(node))
                  - dragScrollHost_.getScrollLeft();
          int right = left + Element.as(node).getOffsetWidth();
          if (left <= dragX && dragX <= right) {
            candidatePos_ = i;
            break;
          }
        }
      }

      // let the rest of the IDE know we're dragging (this will enable us to
      // disable drag targets that might otherwise be happy to accept the
      // data)
      curState_ = STATE_DRAGGING;
      events_.fireEvent(
          new DocTabDragStateChangedEvent(DocTabDragStateChangedEvent.STATE_DRAGGING));

      // the relative position of the last node determines how far we
      // can drag
      dragMax_ =
          DomUtils.leftRelativeTo(dragTabsHost_, getLastChildElement(dragTabsHost_))
              + getLastChildElement(dragTabsHost_).getClientWidth();
      lastCursorX_ = evt.getClientX();

      // account for cursor starting out of bounds (e.g. dragging into
      // empty space on the right of the panel)
      if (lastCursorX_ > dragMax_ + (initDragParams_.getCursorOffset()))
        outOfBounds_ = (lastCursorX_ - dragMax_) - initDragParams_.getCursorOffset();

      // attempt to ascertain whether the element being dragged is one of
      // our own documents
      for (DocTab tab : docTabs_) {
        if (tab.getDocId() == docId) {
          dragElement_ = tab.getElement().getParentElement().getParentElement();
          break;
        }
      }

      // if we couldn't find the horizontal drag position in any tab, append
      // to the end
      if (candidatePos_ == null) {
        candidatePos_ = dragTabsHost_.getChildCount();
      }

      destPos_ = candidatePos_;

      // if we're dragging one of our own documents, figure out its physical
      // position
      if (dragElement_ != null) {
        for (int i = 0; i < dragTabsHost_.getChildCount(); i++) {
          if (dragTabsHost_.getChild(i) == dragElement_) {
            startPos_ = i;
            break;
          }
        }
      }

      // compute the start location for the drag
      if (candidatePos_ >= dragTabsHost_.getChildCount()) {
        Element lastTab = getLastChildElement(dragTabsHost_);
        lastElementX_ = DomUtils.leftRelativeTo(dragTabsHost_, lastTab) + lastTab.getOffsetWidth();
      } else {
        lastElementX_ =
            DomUtils.leftRelativeTo(
                dragTabsHost_, Element.as(dragTabsHost_.getChild(candidatePos_)));
      }

      // if we're dragging one of our own tabs, snap it out of the
      // tabset
      if (dragElement_ != null) {
        dragElement_.getStyle().setPosition(Position.ABSOLUTE);
        dragElement_.getStyle().setLeft(lastElementX_, Unit.PX);
        dragElement_.getStyle().setZIndex(100);
        Scheduler.get()
            .scheduleDeferred(
                new ScheduledCommand() {
                  @Override
                  public void execute() {
                    dragElement_.getStyle().setDisplay(Display.NONE);
                  }
                });
      }

      // create the placeholder that shows where this tab will go when the
      // mouse is released
      dragPlaceholder_ = Document.get().createDivElement();
      dragPlaceholder_.getStyle().setWidth(dragTabWidth - 4, Unit.PX);
      dragPlaceholder_.getStyle().setHeight(dragTabsHost_.getClientHeight() - 3, Unit.PX);
      dragPlaceholder_.getStyle().setDisplay(Display.INLINE_BLOCK);
      dragPlaceholder_.getStyle().setPosition(Position.RELATIVE);
      dragPlaceholder_.getStyle().setFloat(Float.LEFT);
      dragPlaceholder_.getStyle().setBorderStyle(BorderStyle.DOTTED);
      dragPlaceholder_.getStyle().setBorderColor("#A1A2A3");
      dragPlaceholder_.getStyle().setBorderWidth(1, Unit.PX);
      dragPlaceholder_.getStyle().setMarginLeft(1, Unit.PX);
      dragPlaceholder_.getStyle().setMarginRight(1, Unit.PX);
      dragPlaceholder_.getStyle().setProperty("borderTopLeftRadius", "4px");
      dragPlaceholder_.getStyle().setProperty("borderTopRightRadius", "4px");
      dragPlaceholder_.getStyle().setProperty("borderBottom", "0px");
      if (candidatePos_ < dragTabsHost_.getChildCount()) {
        dragTabsHost_.insertBefore(dragPlaceholder_, dragTabsHost_.getChild(candidatePos_));
      } else {
        dragTabsHost_.appendChild(dragPlaceholder_);
      }
    }
Beispiel #27
0
  private Element getTab(int index) {
    if (index >= getElement().getChildCount() - 1) return null;

    return Element.as(getElement().getChild(index)).cast();
  }