@Override
  protected void onAttach() {
    super.onAttach();
    name = String.valueOf(hashCode());
    int col = 12 / tabPanel.getWidgetCount();
    int index = tabPanel.getWidgetCount();
    for (Widget w : tabPanel) {
      if (w instanceof ListItem) {
        if (!waves.isEmpty())
          ((ListItem) w).getWidget(0).getElement().addClassName("waves-effect waves-" + waves);
        if (!color.isEmpty()) w.getElement().addClassName(color);
        if (!textColor.isEmpty())
          ((ListItem) w).getWidget(0).getElement().addClassName(textColor + "-text");
        ((ListItem) w).getWidget(0).getElement().setAttribute("href", "#" + name + index);
        w.addStyleName("tab col s" + col);
        index--;
      }
    }

    int indexC = contentPanel.getWidgetCount();
    for (Widget w : contentPanel) {
      w.getElement().setAttribute("id", name + indexC);
      indexC--;
    }
    initTabs();
    changeIndicator(indicatorColor);
  }
  public void onMouseMove(@Nonnull final MouseMoveEvent event) {
    if (dragging) {
      // we don't want the widget to go off-screen, so the top/left
      // values should always remain be positive.
      //            int newX = Math.max(0, event.getRelativeX(widget.getElement()) +
      // widget.getAbsoluteLeft() - dragStartX);
      //            int newY = Math.max(0, event.getRelativeY(widget.getElement()) +
      // widget.getAbsoluteTop() - dragStartY);
      //            int newX =  event.getRelativeX(widget.getElement()) - dragStartX;
      delta = event.getY() - startY;
      //            DOM.setStyleAttribute(widget.getElement(), "left", "" + newX);
      //            DOM.setStyleAttribute(widget.getElement(), "top", "" + newY);
      //            widget.getElement().setAttribute("style",
      // widget.getElement().getAttribute("style") + ";border: white 2px solid;");

      widget
          .getElement()
          .setAttribute(
              "style",
              originalStyle
                  + "; -webkit-transition-property: -webkit-transform; -webkit-transition-duration: 0.1s;-webkit-transform:translate(0px,"
                  + (y + delta)
                  + "px);");
      DOM.setStyleAttribute(widget.getElement(), "border", "blue 2px solid");
      //            container.setWidgetPosition(widget, newX, newY);
      ClientLog.log("DRAG to " + y, null);
    }
    event.stopPropagation();
    event.preventDefault();
  }
 private void append(Widget widget, boolean floatLeft) {
   if (floatLeft) {
     widget.getElement().getStyle().setFloat(Float.LEFT);
   } else {
     widget.getElement().getStyle().setFloat(Float.RIGHT);
   }
   add(widget);
 }
Beispiel #4
0
 private void internalSetWidget(Widget widget) {
   // this.widget = widget;
   if (widget == null || widget == RootPanel.get()) {
     widgetLeft = 0;
     widgetTop = 0;
   } else {
     widgetLeft = widget.getAbsoluteLeft() - widget.getElement().getScrollLeft();
     widgetTop = widget.getAbsoluteTop() - widget.getElement().getScrollTop();
   }
 }
Beispiel #5
0
 private void internalSetReference(Widget reference) {
   // this.reference = reference;
   if (reference == null || reference == RootPanel.get()) {
     referenceAdjustLeft = 0;
     referenceAdjustTop = 0;
   } else {
     referenceAdjustLeft =
         reference.getAbsoluteLeft() + DOMUtil.getBorderLeft(reference.getElement());
     referenceAdjustTop =
         reference.getAbsoluteTop() + DOMUtil.getBorderTop(reference.getElement());
   }
 }
 @Override
 protected void insert(Widget child, Direction direction, double size, Widget before) {
   super.insert(child, direction, size, before);
   recalcMargins();
   child.getElement().getStyle().clearRight();
   child.getElement().getStyle().clearBottom();
   child.getElement().getStyle().setWidth(100, Style.Unit.PCT);
   child.getElement().getStyle().setHeight(100, Style.Unit.PCT);
   com.bearsoft.gwt.ui.CommonResources.INSTANCE.commons().ensureInjected();
   child
       .getElement()
       .addClassName(com.bearsoft.gwt.ui.CommonResources.INSTANCE.commons().borderSized());
 }
Beispiel #7
0
  public void reconfigure() {
    // First destroy the old tooltip
    destroy();

    // Setup the new tooltip
    if (container != null && selector != null) {
      tooltip(
          widget.getElement(),
          isAnimated,
          isHTML,
          placement.getCssName(),
          selector,
          title,
          trigger.getCssName(),
          showDelayMs,
          hideDelayMs,
          container);
    } else if (container != null) {
      tooltip(
          widget.getElement(),
          isAnimated,
          isHTML,
          placement.getCssName(),
          title,
          trigger.getCssName(),
          showDelayMs,
          hideDelayMs,
          container);
    } else if (selector != null) {
      tooltip(
          widget.getElement(),
          isAnimated,
          isHTML,
          placement.getCssName(),
          selector,
          title,
          trigger.getCssName(),
          showDelayMs,
          hideDelayMs);
    } else {
      tooltip(
          widget.getElement(),
          isAnimated,
          isHTML,
          placement.getCssName(),
          title,
          trigger.getCssName(),
          showDelayMs,
          hideDelayMs);
    }
  }
 public WidgetCanvas(Widget widget) {
   this.widget = widget;
   setRedrawOnResize(false);
   setAttribute("_redrawWithParent", false, false);
   setAttribute("_clearWithRemoveChild", true, false);
   setOverflow(Overflow.VISIBLE);
   String width = DOM.getStyleAttribute(widget.getElement(), "width");
   String height = DOM.getStyleAttribute(widget.getElement(), "height");
   if (width != null && !width.equals("")) {
     setWidth(width);
   }
   if (height != null && !height.equals("")) {
     setHeight(height);
   }
 }
 @Override
 public void add(Widget widget) {
   widget.getElement().getStyle().clearWidth();
   widget.getElement().getStyle().clearHeight();
   super.add(widget);
   AddEvent.fire(this, widget);
 }
 public Widget getFootCellWidget(int index) {
   Object cellValue;
   try {
     cellValue = getFootCellValue(index);
   } catch (Exception ex) {
     log.error(
         Str.getSimpleName(getClass()) + ".getCellValue() (for column " + index + ") failed.",
         ex);
     cellValue = "ERROR: " + Str.formatException(ex);
   }
   Widget cellWidget = Widgets.widget(cellValue);
   if (cellWidget == null) return null;
   if (isNoWrap()) cellWidget.getElement().getStyle().setWhiteSpace(WhiteSpace.NOWRAP);
   cellWidget.getElement().getStyle().setColor(getFootCellColor(index));
   return isPadded() ? Widgets.frame(cellWidget) : cellWidget;
 }
Beispiel #11
0
 @Override
 public void setId(final String id) {
   this.id = id;
   if (widget != null) {
     widget.getElement().setId(id);
   }
 }
Beispiel #12
0
  @Override
  public void toggleMenu() {

    if (!this.menuShowing) {
      this.menuShowing = true;
      boolean needsUpdate = menuInited;
      if (!menuInited) {
        frame.getMenuBar(this).init(this);
        this.menuInited = true;
      }
      this.splitPanelWrapper.add(frame.getMenuBar(this));
      this.oldSplitLayoutPanel.setPixelSize(
          this.oldSplitLayoutPanel.getOffsetWidth() - GLookAndFeel.MENUBAR_WIDTH,
          this.oldSplitLayoutPanel.getOffsetHeight());
      frame
          .getMenuBar(this)
          .setPixelSize(GLookAndFeel.MENUBAR_WIDTH, this.oldSplitLayoutPanel.getOffsetHeight());
      if (needsUpdate) {
        frame.getMenuBar(this).getMenubar().updateMenubar();
      }
      this.getGuiManager().refreshDraggingViews();
      oldSplitLayoutPanel.getElement().getStyle().setOverflow(Overflow.HIDDEN);
      getGuiManager().updateStyleBarPositions(true);
      frame.getMenuBar(this).getMenubar().dispatchOpenEvent();
    } else {
      hideMenu();
    }
  }
Beispiel #13
0
  @Override
  public void setWidget(final Widget w) {
    // Validate
    if (w == widget) {
      return;
    }

    // Detach new child
    if (w != null) {
      w.removeFromParent();
    }

    // Remove old child
    if (widget != null) {
      remove(widget);
    }

    // Logical attach, but don't physical attach; done by jquery.
    widget = w;
    if (widget == null) {
      return;
    }

    // Bind jquery events
    bindJavaScriptEvents(widget.getElement());

    // When we attach it, configure the tooltip
    widget.addAttachHandler(
        new AttachEvent.Handler() {
          @Override
          public void onAttachOrDetach(final AttachEvent event) {
            reconfigure();
          }
        });
  }
  public void setWave(String wave) {
    this.wave = wave;
    for (Widget w : navigation) {
      if (w instanceof ListItem) {
        w.addStyleName("waves-effect waves-" + wave);
      }
    }

    for (Widget w : mobileNav) {
      if (w instanceof ListItem) {
        ListItem item = (ListItem) w;
        for (Widget child : item) {
          if (!(child instanceof MaterialCollapsible)) {
            w.addStyleName("waves-effect waves-" + wave);
            w.getElement().getStyle().setDisplay(Display.BLOCK);
          } else {
            MaterialCollapsible col = (MaterialCollapsible) child;
            for (Widget colItem : col) {
              if (colItem instanceof MaterialCollapsibleItem) {
                ((MaterialCollapsibleItem) colItem)
                    .getHeader()
                    .addStyleName("waves-effect waves-" + wave);
              }
            }
          }
        }
      }
    }
  }
Beispiel #15
0
  private Widget addPopupMenu(
      final MenuLabel menuLabel, final MenuSource menuSource, boolean left) {
    final Widget label = menuLabel.asWidget();
    label.setStylePrimaryName("rstudio-StrongLabel");
    label.getElement().getStyle().setCursor(Style.Cursor.DEFAULT);
    label.getElement().getStyle().setOverflow(Overflow.HIDDEN);
    if (left) addLeftWidget(label);
    else addRightWidget(label);
    Image image = new Image(ThemeResources.INSTANCE.menuDownArrow());
    image.getElement().getStyle().setMarginLeft(5, Unit.PX);
    image.getElement().getStyle().setMarginRight(8, Unit.PX);
    image.getElement().getStyle().setMarginBottom(2, Unit.PX);
    if (left) addLeftWidget(image);
    else addRightWidget(image);

    final ClickHandler clickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            ToolbarPopupMenu menu = menuSource.getMenu();
            menu.showRelativeTo(label);
            menu.getElement().getStyle().setPaddingTop(3, Style.Unit.PX);
          }
        };
    menuLabel.addClickHandler(clickHandler);
    image.addClickHandler(clickHandler);

    return image;
  }
  @Override
  public void setErrors(Set<ErrorDisplay> errors) {
    HashSet<ErrorDisplay> errorsToRemove = new HashSet<ErrorDisplay>(containedErrros);
    errorsToRemove.removeAll(errors);
    for (ErrorDisplay errorDisplay : errorsToRemove) {
      Widget widget = widgets.get(errorDisplay);
      errorsList.remove(widget);
      widgets.remove(widget);
    }

    HashSet<ErrorDisplay> errorsToAdd = new HashSet<ErrorView.ErrorDisplay>(errors);
    errorsToAdd.removeAll(containedErrros);
    String errorViewItemClass = ApplicationResources.INSTANCE.css().errorViewItemClass();
    String errorViewImageClass = ApplicationResources.INSTANCE.css().errorViewImageClass();
    for (ErrorDisplay errorDisplay : errorsToAdd) {
      SafeHtml html =
          template.errorDisplayTemplate(
              errorImageSafeUri, errorDisplay.getErrorInfo(), errorViewImageClass);
      HTML widget = new HTML(html);
      widget.setStyleName(errorViewItemClass);
      widgets.put(errorDisplay, widget);
      errorsList.add(widget);
    }
    containedErrros = new HashSet<ErrorView.ErrorDisplay>(errors);
    int height = 0;
    for (int i = 0; i < errorsList.getWidgetCount(); ++i) {
      Widget widget = errorsList.getWidget(i);
      widget.getElement().getStyle().setTop(height, Unit.PX);
      height += widget.getOffsetHeight() + 5;
    }
  }
Beispiel #17
0
  public Widget asWidget() {

    HorizontalPanel layout = new HorizontalPanel();
    layout.getElement().setAttribute("style", "padding:4px;");

    server = new ComboBox();
    server.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(final ValueChangeEvent<String> event) {

            Scheduler.get()
                .scheduleEntry(
                    new Scheduler.ScheduledCommand() {
                      @Override
                      public void execute() {
                        // Console.MODULES.getEventBus().fireEvent(new
                        // ServerSelectionEvent(event.getValue()));
                      }
                    });
          }
        });

    Label hostLabel = new Label("Server:");
    hostLabel.setStyleName("header-label");
    layout.add(hostLabel);
    Widget hWidget = server.asWidget();
    layout.add(hWidget);

    // combo box use all available space
    hWidget.getElement().getParentElement().setAttribute("width", "100%");

    return layout;
  }
 protected void onDraw() {
   // a GWT widget must be attached to a GWT Panel for its events to fire.
   boolean attached = widget.isAttached();
   if (!attached) {
     RootPanel rp = RootPanel.get(this.getID() + "_widget");
     rp.add(widget);
     String width = DOM.getStyleAttribute(widget.getElement(), "width");
     if (width != null && !width.equals("")) {
       setWidth(width);
     }
     String height = DOM.getStyleAttribute(widget.getElement(), "height");
     if (height != null && !height.equals("")) {
       setHeight(height);
     }
   }
 }
Beispiel #19
0
    private void removeUncheckedPlots(Set<String> selectedTaskIds) {

      List<Widget> toRemove = new ArrayList<Widget>();
      for (int i = 0; i < plotPanel.getWidgetCount(); i++) {
        Widget widget = plotPanel.getWidget(i);
        String widgetId = widget.getElement().getId();
        if ((!isSessionScopePlotId(widgetId)) || selectedTaskIds.contains(widgetId)) {
          continue;
        }
        toRemove.add(widget);
      }
      for (Widget widget : toRemove) {
        plotPanel.remove(widget);
        chosenPlots.remove(widget.getElement().getId());
      }
    }
 private void show(Widget widget, boolean isShow) {
   Element divParent = widget.getElement().getParentElement();
   if (divParent.hasClassName("select-wrapper")) {
     divParent = divParent.getParentElement();
   }
   show(divParent, isShow);
 }
 public KeepThisDraggableMouseListener(
     final AbsolutePanel container, @Nonnull final Widget widget) {
   this.container = container;
   this.widget = widget;
   originalStyle = widget.getElement().getAttribute("style");
   y = 0;
   delta = 0;
 }
 protected void onTargetOver(Event ce) {
   if (disabled || !target.getElement().isOrHasChild(ce.getEventTarget().<Element>cast())) {
     return;
   }
   clearTimer("hide");
   targetXY = new Point(ce.getClientX(), ce.getClientY());
   delayShow();
 }
  /** Force the Tooltip to be destroyed */
  public void destroy() {
    call(widget.getElement(), DESTROY);

    if (clickHandler != null) {
      clickHandler.removeHandler();
      clickHandler = null;
    }
  }
Beispiel #24
0
 /**
  * @param e
  * @param animated
  * @param placement
  * @param trigger
  * @param showDelay
  * @param hideDelay
  */
 public static void configure(
     Widget e,
     boolean animated,
     Placement placement,
     Trigger trigger,
     int showDelay,
     int hideDelay) {
   configure(e.getElement(), animated, placement.get(), trigger.get(), showDelay, hideDelay);
 }
Beispiel #25
0
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (focusWidget != null) {
       El.fly(focusWidget.getElement()).focus();
     }
   }
 }
Beispiel #26
0
  @Override
  public Widget asWidget() {
    Widget widgetPanel = controller.getView();
    widgetPanel.getElement().getStyle().setMargin(0, Unit.PX);
    widgetPanel.getElement().getStyle().setProperty("border", "0px");

    controller.setFrameSize(300, 300);
    return controller.getViewAsScrollPanel();
  }
Beispiel #27
0
  private void display(Widget panel, Element underlyingMarker) {
    // Bail if the underlying marker isn't wide enough
    if (underlyingMarker.getOffsetWidth() < 250) return;

    // Get the 'virtual' parent -- this is the Ace scroller that houses all
    // of the Ace content, where we want our icons to live. We need them
    // to live here so that they properly hide when the user scrolls and
    // e.g. markers are only partially visible.
    Element virtualParent = DomUtils.getParent(underlyingMarker, 3);

    // We'd prefer to use 'getOffsetTop()' here, but that seems to give
    // some janky dimensions due to how the Ace layers are ... layered,
    // so we manually compute it.
    int top = underlyingMarker.getAbsoluteTop() - virtualParent.getAbsoluteTop();

    panel.getElement().getStyle().setTop(top, Unit.PX);
    virtualParent.appendChild(panel.getElement());
  }
Beispiel #28
0
 protected void doFocus() {
   if (focusWidget != null) {
     if (focusWidget instanceof Component) {
       ((Component) focusWidget).focus();
     } else {
       fly(focusWidget.getElement()).focus();
     }
   } else {
     Window.super.focus();
   }
 }
  public void onMouseDown(@Nonnull final MouseDownEvent event) {
    dragging = true;

    // capturing the mouse to the dragged widget.
    DOM.setCapture(container.getElement());
    startY = event.getY();
    ClientLog.log("DOWN", null);
    event.stopPropagation();
    event.preventDefault();
    originalStyle = widget.getElement().getAttribute("style");
  }
  public void onMouseUp(@Nonnull final MouseUpEvent event) {
    dragging = false;
    DOM.releaseCapture(container.getElement());
    ClientLog.log("UP", null);
    event.stopPropagation();
    event.preventDefault();
    DOM.setStyleAttribute(widget.getElement(), "border", "red 2px solid");
    y += delta;

    //        widget.getElement().setAttribute("style", originalStyle);
  }