/** 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);
 }
Esempio n. 2
0
  @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);
  }
 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;
 }
Esempio n. 4
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);
  }
Esempio n. 5
0
  private void displayTests() {
    final BodyElement body = Document.get().getBody();

    for (final Class<?> c : testClasses.keySet()) {
      final DivElement div = Document.get().createDivElement();
      div.getStyle().setDisplay(Display.INLINE_BLOCK);
      div.getStyle().setVerticalAlign(VerticalAlign.TOP);
      div.getStyle().setMarginRight(2, Unit.EM);
      div.getStyle().setProperty("maxHeight", "400px");
      div.getStyle().setOverflowY(Overflow.AUTO);

      StringBuilder b = new StringBuilder();
      final String id = toId(c);
      b.append("<h3><a id='" + id + "' href='#run:" + id + "'>")
          .append(c.getName())
          .append("</a></h3>")
          .append("<div class='results' id='" + TEST_RESULTS + id + "'> </div>");
      try {
        final String path = c.getProtectionDomain().getCodeSource().getLocation().getPath();
        b.append("<sup><a href='file://" + path + "'>").append(path).append("</a></sup>");
      } catch (final Exception ignored) {
      }
      div.setInnerHTML(b.toString());
      for (final Method m : testClasses.get(c)) {
        final String methodId = m.getName() + c.hashCode();
        b = new StringBuilder();
        b.append("<pre>");
        b.append("<a href='javascript:'>");
        b.append(m.getName());
        b.append("</a>");
        b.append('(');
        b.append(ReflectUtil.joinClasses(", ", m.getParameterTypes()));
        b.append(')');
        b.append("</pre>");
        b.append("<div id='" + methodId + "'> </div>");
        final Element el = Document.get().createDivElement().cast();
        el.setInnerHTML(b.toString());
        DOM.setEventListener(
            el,
            new EventListener() {
              @Override
              public void onBrowserEvent(final Event event) {
                if (event.getTypeInt() == Event.ONCLICK) {
                  runTest(m);
                }
              }
            });
        DOM.sinkEvents(el, Event.ONCLICK);
        div.appendChild(el);
      }
      body.appendChild(div);
      final Element anchor = Document.get().getElementById(id).cast();
      DOM.setEventListener(
          anchor,
          new EventListener() {
            @Override
            public void onBrowserEvent(final Event event) {
              final Map<Method, Boolean> res = testResults.get(c);

              for (final Method m : res.keySet().toArray(new Method[res.size()])) {
                res.put(m, null);
              }
              updateTestClass(c);

              for (final Method m : testClasses.get(c)) {
                Scheduler.get()
                    .scheduleDeferred(
                        new ScheduledCommand() {
                          @Override
                          public void execute() {
                            runTest(m);
                          }
                        });
              }
            }
          });
      DOM.sinkEvents(anchor, Event.ONCLICK);
    }
  }