Search in sources :

Example 11 with DivElement

use of com.google.gwt.dom.client.DivElement in project rstudio by rstudio.

the class NineUpBorder method addBgPanel.

private void addBgPanel(String className) {
    DivElement div = Document.get().createDivElement();
    div.setClassName(className);
    panel_.getElement().appendChild(div);
}
Also used : DivElement(com.google.gwt.dom.client.DivElement)

Example 12 with DivElement

use of com.google.gwt.dom.client.DivElement in project rstudio by rstudio.

the class PdfJsWindow method navigateTo.

public static void navigateTo(final PdfJsWindow win, final PdfLocation pdfLocation) {
    double factor = win.getCurrentScale() * 96 / 72;
    final double x = pdfLocation.getX() * factor;
    final double y = pdfLocation.getY() * factor;
    final double w = pdfLocation.getWidth() * factor;
    final double h = pdfLocation.getHeight() * factor;
    final Value<Integer> retries = new Value<Integer>(0);
    // Sometimes pageContainer is null during load, so retry every 100ms
    // until it's not, or we've tried 40 times.
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            Element pageContainer = win.getDocument().getElementById("pageContainer" + pdfLocation.getPage());
            if (pageContainer == null) {
                retries.setValue(retries.getValue() + 1);
                return retries.getValue() < 40;
            }
            if (pdfLocation.isFromClick()) {
                final DivElement div = win.getDocument().createDivElement();
                div.getStyle().setPosition(Style.Position.ABSOLUTE);
                div.getStyle().setTop(y, Unit.PX);
                div.getStyle().setLeft(x, Unit.PX);
                div.getStyle().setWidth(w, Unit.PX);
                div.getStyle().setHeight(h, Unit.PX);
                div.getStyle().setBackgroundColor("rgba(0, 126, 246, 0.1)");
                div.getStyle().setProperty("transition", "opacity 4s");
                // use DomUtils to set transition styles so gwt doesn't assert
                // an invalid style name (no camelCase) in debug mode
                DomUtils.setStyle(div, "-moz-transition", "opacity 4s");
                DomUtils.setStyle(div, "-webkit-transition", "opacity 4s");
                pageContainer.appendChild(div);
                Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {

                    @Override
                    public boolean execute() {
                        div.getStyle().setOpacity(0.0);
                        return false;
                    }
                }, 2000);
            }
            // scroll to the page
            win.goToPage(pdfLocation.getPage());
            // if the target isn't on-screen then scroll to it
            SyncTexCoordinates boundary = getBoundaryCoordinates(win, false);
            if (boundary != null && pdfLocation.getY() > boundary.getY()) {
                Element container = getViewerContainer(win);
                container.setScrollTop(Math.max(0, DomUtils.topRelativeTo(getViewerContainer(win), pageContainer) + (int) y - 180));
            }
            win.focus();
            return false;
        }
    }, 100);
}
Also used : DivElement(com.google.gwt.dom.client.DivElement) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) DivElement(com.google.gwt.dom.client.DivElement) Element(com.google.gwt.dom.client.Element) Value(org.rstudio.studio.client.common.Value)

Example 13 with DivElement

use of com.google.gwt.dom.client.DivElement in project gwt-test-utils by gwt-test-utils.

the class LabelTest method wrap.

@Test
public void wrap() {
    // Given
    // Element.setInnerHTML & Document.get().getElementById are supposed to
    // work
    Document.get().getBody().setInnerHTML("<div id=\"anId\"></div>");
    DivElement div = Document.get().getElementById("anId").cast();
    // When
    Label label = Label.wrap(div);
    label.setText("My wrapped label !");
    // Then
    assertThat(label.getElement()).isEqualTo(div);
    assertThat(div.getInnerText()).isEqualTo("My wrapped label !");
}
Also used : DivElement(com.google.gwt.dom.client.DivElement) Label(com.google.gwt.user.client.ui.Label) Test(org.junit.Test)

Example 14 with DivElement

use of com.google.gwt.dom.client.DivElement in project che by eclipse.

the class PerspectiveViewImpl method tuneRightSplitter.

/**
     * Tunes left splitter. Makes it wider and adds double border to seem rich.
     *
     * @param el
     *         element to tune
     */
private void tuneRightSplitter(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", "-1px");
    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", "1px");
    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", "2px");
    largeBorder.getStyle().setProperty("top", "0px");
    largeBorder.getStyle().setProperty("opacity", "0.4");
    largeBorder.getStyle().setProperty("backgroundColor", Style.getSplitterLargeBorderColor());
    el.appendChild(largeBorder);
}
Also used : DivElement(com.google.gwt.dom.client.DivElement)

Example 15 with DivElement

use of com.google.gwt.dom.client.DivElement in project che by eclipse.

the class LibEntryViewImpl method createNameOfElement.

private Element createNameOfElement(String fullPath) {
    DivElement textElement = Document.get().createDivElement();
    int lastSeparator = fullPath.lastIndexOf('/');
    if (lastSeparator < 0 || !fullPath.endsWith(".jar")) {
        textElement.setInnerText(fullPath);
        return textElement;
    }
    String name = fullPath.substring(lastSeparator + 1);
    String path = fullPath.substring(0, lastSeparator);
    textElement.setInnerText(name + " - " + path);
    return textElement;
}
Also used : DivElement(com.google.gwt.dom.client.DivElement)

Aggregations

DivElement (com.google.gwt.dom.client.DivElement)25 Element (com.google.gwt.dom.client.Element)2 Test (org.junit.Test)2 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 ImageElement (com.google.gwt.dom.client.ImageElement)1 Style (com.google.gwt.dom.client.Style)1 HTMLPanel (com.google.gwt.user.client.ui.HTMLPanel)1 Label (com.google.gwt.user.client.ui.Label)1 Element (elemental.dom.Element)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 LIElement (elemental.html.LIElement)1 SpanElement (elemental.html.SpanElement)1 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)1 Presentation (org.eclipse.che.ide.api.action.Presentation)1 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)1 Value (org.rstudio.studio.client.common.Value)1 OMSVGSVGElement (org.vectomatic.dom.svg.OMSVGSVGElement)1