Пример #1
0
 public void testWest() {
   Widget west = root.getWidget(1);
   assertEquals(com.google.gwt.user.client.ui.DockPanel.WEST, root.getWidgetDirection(west));
   assertEquals(HTML.class, west.getClass());
   String html = ((HTML) west).getHTML();
   assertTrue(html.contains("side bar"));
 }
Пример #2
0
 /**
  * Gets the layout direction of the given child widget.
  *
  * @param child the widget to be queried
  * @return the widget's layout direction, or <code>null</code> if it is not a child of this panel
  * @throws AssertionError if the widget is not a child and assertions are enabled
  */
 public Direction getWidgetDirection(Widget child) {
   assertIsChild(child);
   if (child.getParent() != this) {
     return null;
   }
   return ((LayoutData) child.getLayoutData()).direction;
 }
Пример #3
0
  @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);
  }
  @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;
    }
  }
Пример #5
0
  /**
   * This constructor allows to use an existing form panel.
   *
   * @param type file input to use
   * @param status Customized status widget to use
   * @param submitButton Customized button which submits the form
   * @param form Customized form panel
   */
  public SingleUploader(
      FileInputType type, IUploadStatus status, Widget submitButton, FormPanel form) {
    super(type, form);

    final Uploader thisInstance = this;

    if (status == null) {
      status = new BaseUploadStatus();
      super.add(status.getWidget());
    }
    super.setStatusWidget(status);

    this.button = submitButton;
    if (submitButton != null) {
      submitButton.addStyleName("submit");
      if (submitButton instanceof HasClickHandlers) {
        ((HasClickHandlers) submitButton)
            .addClickHandler(
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    thisInstance.submit();
                  }
                });
      }
      if (submitButton instanceof HasText) {
        ((HasText) submitButton).setText(I18N_CONSTANTS.uploaderSend());
      }
      // The user could have attached the button anywhere in the page.
      if (!submitButton.isAttached()) {
        super.add(submitButton);
      }
    }
  }
 @Override
 public void onResize(final ResizeEvent event) {
   if (!widget.isAttached()) {
     return;
   }
   widget.setHeight(getHeight() + "px");
 }
  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();
  }
Пример #8
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;
  }
Пример #9
0
  @Override
  protected void onDelayLoadSuccess(T obj) {
    super.onDelayLoadSuccess(obj);
    final Widget child = obj.asWidget();

    if (child instanceof HasEnsureVisibleHandlers) {
      ((HasEnsureVisibleHandlers) child)
          .addEnsureVisibleHandler(
              new EnsureVisibleHandler() {
                public void onEnsureVisible(EnsureVisibleEvent event) {
                  parentTab_.ensureVisible();
                }
              });
    }

    if (child instanceof HasEnsureHiddenHandlers) {
      ((HasEnsureHiddenHandlers) child)
          .addEnsureHiddenHandler(
              new EnsureHiddenHandler() {
                public void onEnsureHidden(EnsureHiddenEvent event) {
                  parentTab_.ensureHidden();
                }
              });
    }

    child.setSize("100%", "100%");
    parentTab_.getPanel().add(child);
  }
Пример #10
0
  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);
              }
            }
          }
        }
      }
    }
  }
Пример #11
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();
          }
        });
  }
  @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;
  }
Пример #13
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;
  }
Пример #14
0
  public String getInnerHTML() {
    // if this canvas is being redrawn, detach underlying gwt widget so that onDraw()
    // can correctly reassociate it with container div
    if (widget.isAttached()) widget.removeFromParent();

    return "<DIV STYLE='width:100%;height:100%' ID=" + this.getID() + "_widget></DIV>";
  }
Пример #15
0
  /* (non-Javadoc)
   * @see gwtupload.client.Uploader#onFinishUpload()
   */
  @Override
  protected void onFinishUpload() {
    super.onFinishUpload();
    if (getStatus() == Status.REPEATED) {
      getStatusWidget().setError(getI18NConstants().uploaderAlreadyDone());
    }
    getStatusWidget().setStatus(Status.UNINITIALIZED);
    reuse();
    assignNewNameToFileInput();
    for (Widget i : formWidgets) {
      if (i instanceof Hidden) {
        Hidden h = (Hidden) i;
        if (h.getValue().startsWith(fileInputPrefix)) {
          h.setValue(getInputName());
        }
      }
    }

    getFileInput().getWidget().setVisible(true);
    if (button != null) {
      setEnabledButton(true);
      button.removeStyleName("changed");
      if (!autoSubmit) {
        button.setVisible(true);
      }
    }
    if (autoSubmit) {
      getFileInput().setText(i18nStrs.uploaderBrowse());
    }
  }
Пример #16
0
 /**
  * Gets the layout size of the given child widget.
  *
  * @param child the widget to be queried
  * @return the widget's layout size, or <code>null</code> if it is not a child of this panel
  * @throws AssertionError if the widget is not a child and assertions are enabled
  */
 public Double getWidgetSize(Widget child) {
   assertIsChild(child);
   if (child.getParent() != this) {
     return null;
   }
   return ((LayoutData) child.getLayoutData()).size;
 }
Пример #17
0
 private void addColumn(Object columnHeading) {
   Widget widget = createCellWidget(columnHeading);
   int cell = flexTable.getCellCount(HEADER_ROW_INDEX);
   widget.setWidth("100%");
   widget.addStyleName("FlexTable-ColumnLabel");
   flexTable.setWidget(HEADER_ROW_INDEX, cell, widget);
   flexTable.getCellFormatter().addStyleName(HEADER_ROW_INDEX, cell, "FlexTable-ColumnLabelCell");
 }
Пример #18
0
 private void closeParent() {
   for (Widget w = getParent(); w != null; w = w.getParent()) {
     if (w instanceof PopupPanel) {
       ((PopupPanel) w).hide(true);
       break;
     }
   }
 }
 private void append(Widget widget, boolean floatLeft) {
   if (floatLeft) {
     widget.getElement().getStyle().setFloat(Float.LEFT);
   } else {
     widget.getElement().getStyle().setFloat(Float.RIGHT);
   }
   add(widget);
 }
Пример #20
0
 public void setPreviewVisible(boolean v) {
   Widget w = getDisplay();
   if (w != null && v != w.isVisible()) {
     w.setVisible(v);
     if (v) onShow();
     else onShow();
   }
 }
Пример #21
0
  protected Toolbar getParentToolbar() {
    Widget parent = getParent();
    while (parent != null) {
      if (parent instanceof Toolbar) return (Toolbar) parent;
      parent = parent.getParent();
    }

    return null;
  }
Пример #22
0
 @Override
 public void onTransitionEnd() {
   for (int i = 0; i < _panel.getWidgetCount(); i++) {
     Widget w = _panel.getWidget(i);
     if (Utils.isSubclassOf(w.getClass(), WidgetBase.class)) {
       ((WidgetBase) w).onTransitionEnd();
     }
   }
 }
Пример #23
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();
  }
Пример #24
0
 private int getButtonIndex(String title) {
   for (int i = 0; i < buttons.size(); i++) {
     Widget w = buttons.get(i);
     if (w.getTitle().equals(title)) {
       return i;
     }
   }
   return -1;
 }
Пример #25
0
 @Override
 public void onResize() {
   // It is possible that the SplitterPanel is removed from the DOM before the resize is called
   if (isAttached()) {
     final Widget parent = getParent();
     setPixelSize(parent.getOffsetWidth(), parent.getOffsetHeight());
     super.onResize();
   }
 }
Пример #26
0
 public void setFocus(Widget panel) {
   if (panel.getClass().equals(databaseOptionsPanel.getClass())) {
     deploymentOptionsPanel.setFocus();
   } else if (panel.getClass().equals(appBrowserPanel.getClass())) {
     projectOptionsPanel.setFocus();
   } else if (panel.getClass().equals(projectOptionsPanel.getClass())) {
     databaseOptionsPanel.setFocus();
   }
 }
 Candidate(DropController dropController) {
   this.dropController = dropController;
   Widget target = dropController.getDropTarget();
   if (!target.isAttached()) {
     throw new IllegalStateException(
         "Unattached drop target. You must call DragController#unregisterDropController for all drop targets not attached to the DOM.");
   }
   targetArea = new WidgetArea(target, null);
 }
Пример #28
0
 /**
  * Show on the left of the provided widget
  *
  * @param widget
  */
 public void showWestOf(Widget widget, String text) {
   init(text);
   clearStyleDependentName();
   addStyleDependentName(EAST);
   show();
   int top = widget.getAbsoluteTop() - ((this.getOffsetHeight() - widget.getOffsetHeight()) / 2);
   int left = widget.getAbsoluteLeft() - 1;
   moveTo(top, left);
 }
Пример #29
0
 public void setButtonVisible(String name, boolean isVisible) {
   TabHolder th = tabs.get(name);
   if (th != null) {
     int idx = indexOf(th.tabBar, th.tab);
     Widget w = th.tabBar.getTabWrapper(idx);
     if (w != null) {
       w.setVisible(isVisible);
     }
   }
 }
Пример #30
0
 /* (non-Javadoc)
  * @see gwtupload.client.Uploader#onStartUpload()
  */
 @Override
 protected void onStartUpload() {
   super.onStartUpload();
   if (button != null) {
     setEnabledButton(false);
     button.removeStyleName("changed");
     button.setVisible(false);
   }
   getFileInput().getWidget().setVisible(false);
 }