@Override
  protected Widget newPositioner(DragContext context) {
    // Use two widgets so that setPixelSize() consistently affects dimensions
    // excluding positioner border in quirks and strict modes
    SimplePanel outer = new SimplePanel();
    outer.addStyleName(DragClientBundle.INSTANCE.css().positioner());

    // place off screen for border calculation
    RootPanel.get().add(outer, -500, -500);

    // Ensure IE quirks mode returns valid outer.offsetHeight, and thus valid
    // DOMUtil.getVerticalBorders(outer)
    outer.setWidget(DUMMY_LABEL_IE_QUIRKS_MODE_OFFSET_HEIGHT);

    int width = 0;
    int height = 0;
    for (Widget widget : context.selectedWidgets) {
      width = Math.max(width, widget.getOffsetWidth());
      height += widget.getOffsetHeight();
    }

    SimplePanel inner = new SimplePanel();
    inner.setPixelSize(
        width - DOMUtil.getHorizontalBorders(outer), height - DOMUtil.getVerticalBorders(outer));

    outer.setWidget(inner);

    return outer;
  }
コード例 #2
0
 protected void configurePostionerSlot(DragContext context, PortletSlot slot) {
   positionerSlot = slot;
   int targetIndex =
       DOMUtil.findIntersect(
           panel,
           new CoordinateLocation(context.mouseX, context.mouseY),
           getLocationWidgetComparator());
   panel.insert(positionerSlot, targetIndex);
   positionerSlot.addStyleName("v-portallayout-positioner");
 }
コード例 #3
0
  @Override
  public void onMove(DragContext context) {
    super.onMove(context);
    int targetIndex =
        DOMUtil.findIntersect(
            panel,
            new CoordinateLocation(context.mouseX, context.mouseY),
            getLocationWidgetComparator());

    // check that positioner not already in the correct location
    int positionerIndex = panel.getWidgetIndex(positionerSlot);
    if (positionerIndex != targetIndex
        && (positionerIndex != targetIndex - 1 || targetIndex == 0)) {
      if (positionerIndex == 0 && panel.getWidgetCount() == 1) {
      } else if (targetIndex == -1) {
      } else {
        panel.insert(positionerSlot, targetIndex);
      }
    }
  }