コード例 #1
0
 public void output(String text, String color) {
   DivElement div = Document.get().createDivElement();
   div.setInnerText(text);
   div.setAttribute("style", "color:" + color);
   messages.getElement().appendChild(div);
   scrollPanel.scrollToBottom();
 }
コード例 #2
0
ファイル: UiBinderTest.java プロジェクト: hammoum/gwt
 public void testDomAccessInHtml() {
   DivElement sideBar = widgetUi.sideBar;
   assertTrue(
       "sideBar should start: \"This could\"", sideBar.getInnerText().startsWith("This could"));
   assertTrue("sideBar should end: \"example:\"", sideBar.getInnerText().endsWith("like that..."));
   assertEquals("Should have no id", "", sideBar.getAttribute("id"));
 }
コード例 #3
0
 protected Widget getContent(AssetContentItem contentItem) {
   // Add the content
   HTML contentHTML = new HTML(contentItem.getContent());
   // So that lightbox centering in firefox works, enclose each sized <object>
   // with a div styled to exactly that size.
   NodeList<Element> objectElements = contentHTML.getElement().getElementsByTagName("object");
   Document document = Document.get();
   for (int i = 0, len = objectElements.getLength(); i < len; i++) {
     Element objectElement = objectElements.getItem(i);
     String width = objectElement.getAttribute("width");
     String height = objectElement.getAttribute("height");
     if (width.matches("[0-9]+%?") && height.matches("[0-9]+%?")) {
       DivElement div = document.createDivElement();
       div.getStyle().setProperty("width", width + (width.endsWith("%") ? "" : "px"));
       div.getStyle().setProperty("height", height + (height.endsWith("%") ? "" : "px"));
       objectElement.getParentElement().replaceChild(div, objectElement);
       div.appendChild(objectElement);
     }
   }
   // In case there are images within the content, we should fire a PopupImageLoadedEvent
   // so that any popup window displaying this view has a chance to reposition itself.
   NodeList<Element> imageElements = contentHTML.getElement().getElementsByTagName("img");
   for (int i = 0; i < imageElements.getLength(); i++) {
     ImageElement image = imageElements.getItem(i).cast();
     addImageLoadHandler(image);
   }
   return contentHTML;
 }
コード例 #4
0
  public void init(String title, ContentKind contentKind) {
    this.title.setInnerText(Strings.isNullOrEmpty(title) ? labels.untitled() : title);
    cardType.setInnerText(contentKind.toString());
    icon.addClassName(contentKind.getIcon());

    updateHeaderWidth(this.title);
  }
コード例 #5
0
  /**
   * Set the background colour properties for the foreground and background elements (using the
   * global {@link #fgCol} and {@link #bgCol}).
   *
   * @param updateWhat A constant to indicate if only the foreground colour, only the background
   *     colour or both should be updated.
   */
  protected void update(int updateWhat) {
    boolean updateBg = (updateWhat == UPDATE_BOTH || updateWhat == UPDATE_BG);
    boolean updateFg = (updateWhat == UPDATE_BOTH || updateWhat == UPDATE_FG);

    if (updateFg) {
      fgColEl.getStyle().setBackgroundColor(fgCol.toString());
    }
    if (updateBg) {
      bgColEl.getStyle().setBackgroundColor(bgCol.toString());
    }

    // There are two ToggleColourButtons, update both
    if (identifier.equals(TOGGLE_COLOUR)) {
      if (updateFg && !GuiState.toolMenuToggleColour.fgCol.equals(fgCol)) {
        GuiState.toolMenuToggleColour.setForegroundColour(fgCol);
      }
      if (updateBg && !GuiState.toolMenuToggleColour.bgCol.equals(bgCol)) {
        GuiState.toolMenuToggleColour.setBackgroundColour(bgCol);
      }
    } else {
      if (updateFg && !GuiState.toggleColour.fgCol.equals(fgCol)) {
        GuiState.toggleColour.setForegroundColour(fgCol);
      }
      if (updateBg && !GuiState.toggleColour.bgCol.equals(bgCol)) {
        GuiState.toggleColour.setBackgroundColour(bgCol);
      }
    }

    // Update the colours of the drawing tool buttons
    GuiState.squareDrawingTool.setColour(fgCol);
    GuiState.circleDrawingTool.setColour(fgCol);
  }
コード例 #6
0
 /** Create a progress bar */
 public ProgressWidget() {
   PROGRESS_RESOURCES.css().ensureInjected();
   bar.setClassName(PROGRESS_RESOURCES.css().bar());
   groove.setClassName(PROGRESS_RESOURCES.css().groove());
   element.appendChild(bar);
   element.appendChild(groove);
   setElement(element);
   setValue(0.0);
 }
コード例 #7
0
  /**
   * Tunes splitter. Makes it wider and adds double border to seem rich.
   *
   * @param el element to tune
   */
  private void tuneSplitter(Element el) {
    /** Add Z-Index to move the splitter on the top and make content visible */
    el.getParentElement().getStyle().setProperty("zIndex", "1000");
    el.getParentElement().getStyle().setProperty("overflow", "visible");

    /** Tune splitter catch panel */
    el.getStyle().setProperty("boxSizing", "border-box");
    el.getStyle().setProperty("width", "5px");
    el.getStyle().setProperty("overflow", "hidden");
    el.getStyle().setProperty("marginLeft", "-3px");
    el.getStyle().setProperty("backgroundColor", "transparent");

    /** Add small border */
    DivElement smallBorder = Document.get().createDivElement();
    smallBorder.getStyle().setProperty("position", "absolute");
    smallBorder.getStyle().setProperty("width", "1px");
    smallBorder.getStyle().setProperty("height", "100%");
    smallBorder.getStyle().setProperty("left", "3px");
    smallBorder.getStyle().setProperty("top", "0px");
    smallBorder.getStyle().setProperty("backgroundColor", Style.getSplitterSmallBorderColor());
    el.appendChild(smallBorder);

    /** Add large border */
    DivElement largeBorder = Document.get().createDivElement();
    largeBorder.getStyle().setProperty("position", "absolute");
    largeBorder.getStyle().setProperty("width", "2px");
    largeBorder.getStyle().setProperty("height", "100%");
    largeBorder.getStyle().setProperty("left", "1px");
    largeBorder.getStyle().setProperty("top", "0px");
    largeBorder.getStyle().setProperty("opacity", "0.4");
    largeBorder.getStyle().setProperty("backgroundColor", Style.getSplitterLargeBorderColor());
    el.appendChild(largeBorder);
  }
コード例 #8
0
ファイル: GalleryPanel.java プロジェクト: ssinica/ssgallery
 private void setCurrentUser(String loggedInUser) {
   if (GWTUtils.isEmpty(loggedInUser)) {
     elLogged.setInnerHTML("");
     elLoggedWrapper.getStyle().setDisplay(Display.NONE);
     elLoginWrapper.getStyle().setDisplay(Display.BLOCK);
   } else {
     elLogged.setInnerHTML(GWTUtils.safeString(loggedInUser));
     elLoggedWrapper.getStyle().setDisplay(Display.BLOCK);
     elLoginWrapper.getStyle().setDisplay(Display.NONE);
   }
 }
コード例 #9
0
ファイル: CreateEventTest.java プロジェクト: hammoum/gwt
  @Override
  protected void gwtSetUp() throws Exception {
    parent = Document.get().createDivElement();
    child = Document.get().createTextInputElement();
    img = Document.get().createImageElement();

    Document.get().getBody().appendChild(parent);
    parent.appendChild(child);
    parent.appendChild(img);

    Event.sinkEvents(parent, ALL_EVENTS);
    Event.sinkEvents(child, ALL_EVENTS);
    Event.sinkEvents(img, ALL_EVENTS);
  }
コード例 #10
0
  @Test
  public void checkGetElementByIdInBody() {
    // Setup
    AnchorElement a = Document.get().createAnchorElement();
    a.setId("myId");
    DivElement div = Document.get().createDivElement();
    div.appendChild(a);
    d.getBody().appendChild(div);

    // Test
    Element result = d.getElementById("myId");

    // Assert
    Assert.assertEquals(a, result);
  }
コード例 #11
0
  private void openRawTab() {
    if (currentTab.equals(TABS.RAW)) return;

    String tabHandlercurrent = "inlineButtonChecked";
    String tabsContent = "tabsContent";
    String cssTabContent = "tabContent";
    String tabContentCurrent = "tabContentCurrent";

    HTML5Element tab = (HTML5Element) rawTab.getElement().cast();
    ((HTML5Element) tab.getParentElement())
        .querySelector("." + tabHandlercurrent)
        .getClassList()
        .remove(tabHandlercurrent);
    tab.getClassList().add(tabHandlercurrent);

    HTML5Element contentParent = (HTML5Element) tabContent.getParentElement();
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "." + tabContentCurrent)
        .getClassList()
        .remove(tabContentCurrent);
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "[data-tab=\"raw\"]")
        .getClassList()
        .add(tabContentCurrent);

    currentTab = TABS.RAW;

    if (headersCodeMirror != null) {
      headersCodeMirror.refresh();
    }
    GoogleAnalytics.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Raw tab");
    GoogleAnalyticsApp.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Raw tab");
  }
コード例 #12
0
  private void openFormTab() {
    if (currentTab.equals(TABS.FORM)) return;

    updateForm();
    ensureFormHasRow();

    String tabHandlercurrent = "inlineButtonChecked";
    String tabsContent = "tabsContent";
    String cssTabContent = "tabContent";
    String tabContentCurrent = "tabContentCurrent";

    HTML5Element tab = (HTML5Element) formTab.getElement().cast();
    ((HTML5Element) tab.getParentElement())
        .querySelector("." + tabHandlercurrent)
        .getClassList()
        .remove(tabHandlercurrent);
    tab.getClassList().add(tabHandlercurrent);

    HTML5Element contentParent = (HTML5Element) tabContent.getParentElement();
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "." + tabContentCurrent)
        .getClassList()
        .remove(tabContentCurrent);
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "[data-tab=\"form\"]")
        .getClassList()
        .add(tabContentCurrent);

    currentTab = TABS.FORM;
    GoogleAnalytics.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Form tab");
    GoogleAnalyticsApp.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Form tab");
  }
コード例 #13
0
ファイル: IndexPanel.java プロジェクト: larrytin/cloudlet
  private void initPostion() {
    if (pns == null) {
      pns = new ArrayList<PositionNav>();
    }
    NodeList<Node> nodes = content.getChildNodes();
    for (int i = 1; i < nodes.getLength(); i = i + 2) {
      Element elm = nodes.getItem(i).<Element>cast();

      final int absoluteTop = elm.getAbsoluteTop() - OFFSET;

      LIElement li = Document.get().createLIElement().cast();
      li.setInnerHTML(elm.getId());
      EventGenerator.onClick(
          li,
          new Function() {
            @Override
            public void f(Event e) {
              root.getElement().setScrollTop(absoluteTop);
            }
          });
      ul.appendChild(li);

      pns.add(new PositionNav(absoluteTop, li));
    }
    currentli = pns.get(0).getElm();
    currentli.addClassName(style.active());
  }
コード例 #14
0
  /** Default constructor. */
  public PagerComposite() {
    initWidget(binder.createAndBindUi(this));
    buttonContainer.setVisible(false);
    headerText.getStyle().setDisplay(Display.NONE);

    buildPage();
  }
コード例 #15
0
  /** Check the post box. */
  private void checkPostBox() {
    postCharCount.setInnerText(Integer.toString(POST_MAX - postBox.getText().length()));

    if (POST_MAX - postBox.getText().length() < 0) {
      postCharCount.addClassName(style.postCharCountOverLimit());
    } else {
      postCharCount.removeClassName(style.postCharCountOverLimit());
    }

    if ((postBox.getText().length() > 0 && POST_MAX - postBox.getText().length() >= 0)
        || attachment != null) {
      postButton.removeStyleName(style.postButtonInactive());
    } else {
      postButton.addStyleName(style.postButtonInactive());
    }
  }
コード例 #16
0
  /**
   * Load CodeMirror library into editor. TODO: Switching off CodeMirror support will be removed in
   * Q2 2016. Targeting for R8.
   */
  private void loadCodeMirrorForHeaders() {
    if (SyncAdapter.codeMirrorHeaders) {
      tabContent.addClassName("codeMirror");

      if (headersCodeMirror != null) {
        headersCodeMirror.refresh();
        return;
      }

      CodeMirrorOptions opt = CodeMirrorOptions.create();
      opt.setMode("message/http");
      //			opt.setTheme("headers");
      opt.setAutoClearEmptyLines(true);
      opt.setLineWrapping(true);

      CodeMirrorKeyMap extraKey = CodeMirrorKeyMap.create();
      extraKey.add("Ctrl-Space", "autocompleteHeaders");
      opt.setExtraKeys(extraKey);

      setHeadersEditor();

      if (!(headersData == null || headersData.isEmpty())) {
        opt.setValue(headersData);
      }
      headersCodeMirror =
          CodeMirror.fromTextArea(
              headersRawInput.getElement(),
              opt,
              new CodeMirrorChangeHandler() {
                @Override
                public void onChage() {
                  headersData = headersCodeMirror.getValue();
                  headersRawInput.setValue(headersData);
                  Log.info("Code mirror change fired actually now::" + headersData);
                }
              });
      setHeadersEditorCallback(headersCodeMirror.getInstance());
      headersCodeMirror.refresh();
      // RestClient.fixChromeLayout();
    } else {
      if (headersCodeMirror != null) {
        headersCodeMirror.toTextArea();
        headersCodeMirror = null;
      }
      tabContent.removeClassName("codeMirror");
    }
  }
コード例 #17
0
  /**
   * The default implementation will display, but not consume, received errors whose {@link
   * EditorError#getEditor() getEditor()} method returns the Editor passed into {@link #setEditor}.
   *
   * @param errors a List of {@link EditorError} instances
   */
  @Override
  public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
      if (error.getEditor().equals(editor)) {
        sb.append("\n").append(error.getMessage());
      }
    }

    if (sb.length() == 0) {
      errorLabel.setInnerText("");
      errorLabel.getStyle().setDisplay(Display.NONE);
      return;
    }

    errorLabel.setInnerText(sb.substring(1));
    errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK);
  }
コード例 #18
0
ファイル: RStudio.java プロジェクト: themel/rstudio
  private Command showProgress() {
    String progressUrl = ProgressImages.createLargeGray().getUrl();
    final DivElement div = Document.get().createDivElement();
    div.setInnerHTML("<img src=\"" + progressUrl + "\"/>");
    div.getStyle().setWidth(100, Style.Unit.PCT);
    div.getStyle().setMarginTop(200, Style.Unit.PX);
    div.getStyle().setProperty("textAlign", "center");
    div.getStyle().setZIndex(1000);
    Document.get().getBody().appendChild(div);

    return new Command() {
      public void execute() {
        try {
          Document.get().getBody().removeChild(div);
        } catch (Exception e) {
          Debug.log(e.toString());
        }
      }
    };
  }
コード例 #19
0
  /**
   * Construct a new button that can be used to toggle between black and white.
   *
   * @param appState Reference to the model, used to change drawing colour.
   * @param identifier Identifier for this object.
   */
  public ToggleColourButton(ApplicationState appState, String identifier) {
    super();
    this.as = appState;
    this.identifier = identifier;
    this.fgCol = Colour.BLACK;
    this.bgCol = Colour.WHITE;

    addPressHandler(this);

    // Set class of button element
    setStyleName(STYLENAME);

    // Create element that shows foreground colour, set it up and add it
    fgColEl = DivElement.as(DOM.createElement("div"));
    fgColEl.setPropertyString("className", STYLENAME_FG_EL);
    fgColEl.getStyle().setBackgroundColor(fgCol.toString());
    getElement().appendChild(fgColEl);

    // Create element that shows background colour, set it up and add it
    bgColEl = DivElement.as(DOM.createElement("div"));
    bgColEl.setPropertyString("className", STYLENAME_BG_EL);
    bgColEl.getStyle().setBackgroundColor(bgCol.toString());
    getElement().appendChild(bgColEl);

    // Set the debug ID for the toggle colour button.
    ensureDebugId("toggleColor");
  }
コード例 #20
0
ファイル: PercentageBar.java プロジェクト: carlosmunoz/guvnor
  public void setValue(Integer value, boolean fireEvents) {

    percent = value;

    setColor();

    percentage.setText(Integer.toString(value) + " %");
    bar.getStyle().setWidth(value, Unit.PCT);

    if (fireEvents) {
      ValueChangeEvent.fire(this, value);
    }
  }
コード例 #21
0
  private DivElement addPanel(String styleName, int halign, int valign) {
    DivElement div = Document.get().createDivElement();
    div.setClassName(styleName);

    Style style = div.getStyle();
    style.setPosition(Style.Position.ABSOLUTE);

    switch (halign) {
      case LEFT:
        style.setPropertyPx("left", 0);
        style.setPropertyPx("width", 10);
        break;
      case CENTER:
        style.setPropertyPx("left", 10);
        style.setPropertyPx("right", 10);
        break;
      case RIGHT:
        style.setPropertyPx("right", 0);
        style.setPropertyPx("width", 10);
        break;
    }
    switch (valign) {
      case TOP:
        style.setPropertyPx("top", 0);
        style.setPropertyPx("height", 26);
        break;
      case MIDDLE:
        style.setPropertyPx("top", 26);
        style.setPropertyPx("bottom", 26);
        break;
      case BOTTOM:
        style.setPropertyPx("bottom", 0);
        style.setPropertyPx("height", 26);
    }

    layout_.getElement().appendChild(div);
    return div;
  }
コード例 #22
0
ファイル: NodeTest.java プロジェクト: MaxDhn/gwt-test-utils
  @Test
  public void clone_NotDeep() {
    // Arrange
    Element e = n.cast();
    e.setInnerText("text");
    e.getStyle().setBackgroundColor("black");

    AnchorElement child = Document.get().createAnchorElement();
    child.setInnerText("child inner text");
    n.appendChild(child);

    // Act
    DivElement newNode = n.cloneNode(false).cast();

    // Assert
    assertEquals(Node.ELEMENT_NODE, newNode.getNodeType());
    assertTrue(e.getStyle() != newNode.getStyle());
    assertEquals("black", newNode.getStyle().getBackgroundColor());
    assertEquals("text", newNode.getInnerText());
    assertNull(newNode.getParentNode());
    assertEquals(2, n.getChildNodes().getLength());
    assertEquals(1, newNode.getChildNodes().getLength());
  }
コード例 #23
0
  /** Build page. */
  private void buildPage() {
    posterAvatar.add(
        avatarRenderer.render(
            Session.getInstance().getCurrentPerson().getEntityId(),
            Session.getInstance().getCurrentPerson().getAvatarId(),
            EntityType.PERSON,
            Size.Small));
    postCharCount.setInnerText(POST_MAX.toString());
    checkPostBox();
    postBox.setLabel("Post to your stream...");
    postBox.reset();

    addEvents();

    postBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(final KeyUpEvent event) {
            checkPostBox();
          }
        });

    postBox.addFocusHandler(
        new FocusHandler() {
          public void onFocus(final FocusEvent event) {
            postOptions.addClassName(style.visiblePostBox());
          }
        });

    postBox.addBlurHandler(
        new BlurHandler() {
          public void onBlur(final BlurEvent event) {

            timerFactory.runTimer(
                BLUR_DELAY,
                new TimerHandler() {
                  public void run() {
                    if (postBox.getText().trim().length() == 0
                        && !addLinkComposite.inAddMode()
                        && attachment == null) {
                      postOptions.removeClassName(style.visiblePostBox());
                      postBox.getElement().getStyle().clearHeight();
                      postBox.reset();
                    }
                  }
                });
          }
        });

    setupPostButtonClickHandler();

    postBox.addKeyDownHandler(
        new KeyDownHandler() {
          public void onKeyDown(final KeyDownEvent event) {
            if ((event.getNativeKeyCode() == KeyCodes.KEY_TAB
                    || event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                && !event.isAnyModifierKeyDown()
                && activeItemIndex != null) {
              hashTags
                  .getWidget(activeItemIndex)
                  .getElement()
                  .dispatchEvent(
                      Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false));
              event.preventDefault();
              event.stopPropagation();
              // clearSearch();

            } else if (event.getNativeKeyCode() == KeyCodes.KEY_DOWN && activeItemIndex != null) {
              if (activeItemIndex + 1 < hashTags.getWidgetCount()) {
                selectItem((Label) hashTags.getWidget(activeItemIndex + 1));
              }
              event.preventDefault();
              event.stopPropagation();
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_UP && activeItemIndex != null) {
              if (activeItemIndex - 1 >= 0) {
                selectItem((Label) hashTags.getWidget(activeItemIndex - 1));
              }
              event.preventDefault();
              event.stopPropagation();
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER && event.isControlKeyDown()) {
              postButton
                  .getElement()
                  .dispatchEvent(
                      Document.get().createClickEvent(1, 0, 0, 0, 0, false, false, false, false));
              event.preventDefault();
              event.stopPropagation();
            }
          }
        });

    postBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(final KeyUpEvent event) {
            int tagsAdded = 0;

            String postText = postBox.getText();
            if (!postText.endsWith(" ")) {
              String[] words = postText.split("\\s");
              if (words.length >= 1) {
                final String lastWord = words[words.length - 1];
                if (lastWord.startsWith("#")) {
                  boolean activeItemSet = false;
                  Label firstItem = null;

                  for (String hashTag : allHashTags) {
                    if (hashTag.startsWith(lastWord)) {
                      // get list ready on first tag added
                      if (tagsAdded == 0) {
                        hashTags.clear();

                        String boxHeight =
                            postBox.getElement().getStyle().getHeight().replace("px", "");
                        if (boxHeight.isEmpty()) {
                          boxHeight = "44";
                        }
                        hashTags
                            .getElement()
                            .getStyle()
                            .setTop(
                                Integer.parseInt(boxHeight) + HASH_TAG_DROP_DOWN_PADDING, Unit.PX);
                        hashTags.setVisible(true);
                      }

                      final String hashTagFinal = hashTag;
                      final Label tagLbl = new Label(hashTagFinal);
                      tagLbl.addClickHandler(
                          new ClickHandler() {
                            public void onClick(final ClickEvent event) {
                              String postText = postBox.getText();
                              postText =
                                  postText.substring(0, postText.length() - lastWord.length())
                                      + hashTagFinal
                                      + " ";
                              postBox.setText(postText);
                              hashTags.setVisible(false);
                              hashTags.clear();
                              activeItemIndex = null;
                            }
                          });
                      tagLbl.addMouseOverHandler(
                          new MouseOverHandler() {
                            public void onMouseOver(final MouseOverEvent arg0) {
                              selectItem(tagLbl);
                            }
                          });
                      hashTags.add(tagLbl);

                      if (firstItem == null) {
                        firstItem = tagLbl;
                      }

                      if (activeItemIndex != null
                          && activeItemIndex.equals(hashTags.getWidgetCount() - 1)) {
                        activeItemIndex = null;
                        activeItemSet = true;
                        selectItem(tagLbl);
                      }

                      tagsAdded++;
                      if (tagsAdded >= MAX_HASH_TAG_AUTOCOMPLETE_ENTRIES) {
                        break;
                      }
                    }
                  }

                  if (!activeItemSet && firstItem != null) {
                    activeItemIndex = null;
                    selectItem(firstItem);
                  }
                }
              }
            }

            if (tagsAdded == 0) {
              hashTags.setVisible(false);
              activeItemIndex = null;
            }
          }
        });

    AllPopularHashTagsModel.getInstance().fetch(null, true);
    SystemSettingsModel.getInstance().fetch(null, true);

    hashTags.setVisible(false);
  }
コード例 #24
0
 /**
  * Shows the given error message.
  *
  * @param errorMessage
  */
 public void showError(String errorMessage) {
   errorLabel.setInnerText(errorMessage);
   errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK);
 }
コード例 #25
0
 /** @param string */
 public void setError(String string) {
   error.setInnerText(string);
 }
コード例 #26
0
ファイル: NodeTest.java プロジェクト: MaxDhn/gwt-test-utils
  @Test
  public void clone_Deep() {
    // Arrange
    AnchorElement child = Document.get().createAnchorElement();
    child.setInnerText("child inner text");
    child.getStyle().setBackgroundColor("black");
    n.appendChild(child);

    // Act
    DivElement newNode = n.cloneNode(true).cast();

    // Assert
    assertEquals(Node.ELEMENT_NODE, newNode.getNodeType());
    DivElement source = n.cast();
    assertEquals(source.getInnerText(), newNode.getInnerText());
    assertEquals(source.getInnerHTML(), newNode.getInnerHTML());
    assertEquals(source.toString(), newNode.toString());

    assertNull(newNode.getParentNode());
    assertEquals(n.getChildNodes().getLength(), newNode.getChildNodes().getLength());

    assertEquals(Node.ELEMENT_NODE, newNode.getChildNodes().getItem(0).getNodeType());
    AnchorElement childElement = newNode.getChildNodes().getItem(0).cast();
    assertEquals("child inner text", childElement.getInnerText());

    Style newStyle = childElement.getStyle();
    assertTrue(newStyle != child.getStyle());
    assertEquals("black", newStyle.getBackgroundColor());
  }
コード例 #27
0
 private void log(String log) {
   String innerHtml = $(logEventWindow).html();
   innerHtml += log + "<br />";
   $(logEventWindow).html(innerHtml);
   logEventWindow.setScrollTop(logEventWindow.getScrollHeight());
 }
コード例 #28
0
 /**
  * Update the current progress displayed in the progress bar.
  *
  * @param value Must be a number between 0 and 1.
  */
 public void setValue(double value) {
   currentProgress = Math.max(0, Math.min(value, 1));
   bar.getStyle().setWidth(currentProgress * 100, Style.Unit.PCT);
   groove.getStyle().setWidth((1 - currentProgress) * 100, Style.Unit.PCT);
 }
コード例 #29
0
ファイル: VPopupButton.java プロジェクト: qwasli/PopupButton
 public VPopupButton() {
   super();
   DivElement e = Document.get().createDivElement();
   e.setClassName(POPUP_INDICATOR_CLASSNAME);
   getElement().getFirstChildElement().appendChild(e);
 }
コード例 #30
0
 @UiHandler(value = {"clearLogButton"})
 public void onClearLogClicked(ClickEvent e) {
   $(logEventWindow).html("");
   logEventWindow.setScrollTop(0);
 }