Search in sources :

Example 6 with SpanElement

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

the class CategoriesPageViewImpl method renderCategoryHeader.

private Element renderCategoryHeader(String category) {
    SpanElement categoryElement = Document.get().createSpanElement();
    categoryElement.setClassName(resources.defaultCategoriesListCss().headerText());
    SpanElement iconElement = Document.get().createSpanElement();
    categoryElement.appendChild(iconElement);
    SpanElement textElement = Document.get().createSpanElement();
    categoryElement.appendChild(textElement);
    textElement.setInnerText(category);
    Icon icon = iconRegistry.getIconIfExist(category + ".samples.category.icon");
    if (icon != null) {
        final SVGImage iconSVG = icon.getSVGImage();
        if (iconSVG != null) {
            iconElement.appendChild(iconSVG.getElement());
            return categoryElement;
        }
    }
    return categoryElement;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) Icon(org.eclipse.che.ide.api.icon.Icon) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 7 with SpanElement

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

the class ShellWidget method output.

private boolean output(String text, String className, boolean addToTop) {
    if (text.indexOf('\f') >= 0)
        clearOutput();
    Element outEl = output_.getElement();
    if (addToTop) {
        SpanElement leading = Document.get().createSpanElement();
        outEl.insertFirst(leading);
        VirtualConsole console = new VirtualConsole(leading);
        console.submit(text, className);
        lines_ += DomUtils.countLines(leading, true);
    } else {
        // create trailing output console if it doesn't already exist 
        if (virtualConsole_ == null) {
            SpanElement trailing = Document.get().createSpanElement();
            outEl.appendChild(trailing);
            virtualConsole_ = new VirtualConsole(trailing);
        }
        int oldLineCount = DomUtils.countLines(virtualConsole_.getParent(), true);
        virtualConsole_.submit(text, className);
        int newLineCount = DomUtils.countLines(virtualConsole_.getParent(), true);
        lines_ += newLineCount - oldLineCount;
    }
    boolean result = !trimExcess();
    resizeCommand_.nudge();
    return result;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) VirtualConsole(org.rstudio.core.client.VirtualConsole) Element(com.google.gwt.dom.client.Element) SpanElement(com.google.gwt.dom.client.SpanElement)

Example 8 with SpanElement

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

the class DomUtilsTests method testCountLinesRecursive.

public void testCountLinesRecursive() {
    PreElement pre = Document.get().createPreElement();
    SpanElement s1 = Document.get().createSpanElement();
    s1.setInnerText("Line1\nLine2\n");
    pre.appendChild(s1);
    SpanElement s2 = Document.get().createSpanElement();
    s2.setInnerText("Line3\n");
    pre.appendChild(s2);
    Assert.assertEquals(3, DomUtils.countLines(pre, true));
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) PreElement(com.google.gwt.dom.client.PreElement)

Example 9 with SpanElement

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

the class TargetsViewImpl method renderCategoryHeader.

private SpanElement renderCategoryHeader(final Category<Target> category) {
    SpanElement categoryHeaderElement = Document.get().createSpanElement();
    categoryHeaderElement.setClassName(commandResources.getCss().categoryHeader());
    categoryHeaderElement.appendChild(createMachineLabel(category.getTitle()));
    SpanElement textElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(textElement);
    textElement.setInnerText(category.getTitle());
    if (machineLocale.targetsViewCategorySsh().equalsIgnoreCase(category.getTitle())) {
        // Add button to create a target
        SpanElement buttonElement = Document.get().createSpanElement();
        buttonElement.appendChild(commandResources.addCommandButton().getSvg().getElement());
        categoryHeaderElement.appendChild(buttonElement);
        Event.sinkEvents(buttonElement, Event.ONCLICK);
        Event.setEventListener(buttonElement, new EventListener() {

            @Override
            public void onBrowserEvent(Event event) {
                event.stopPropagation();
                event.preventDefault();
                delegate.onAddTarget(category.getTitle());
            }
        });
    } else {
        // Add empty span for properly aligning items
        categoryHeaderElement.appendChild(Document.get().createSpanElement());
    }
    return categoryHeaderElement;
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Event(com.google.gwt.user.client.Event) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) KeyboardEvent(elemental.events.KeyboardEvent) EventListener(com.google.gwt.user.client.EventListener)

Example 10 with SpanElement

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

the class UiBinderWithWidgetsTest method uiObjectTag.

@Test
public void uiObjectTag() {
    // Given
    UiBinderWithWidgets w = new UiBinderWithWidgets("gael", "eric");
    // When
    RootPanel.get().add(w);
    // Then
    assertThat(w.listBox.getVisibleItemCount()).isEqualTo(1);
    HTMLPanel wrappedPanel = GwtReflectionUtils.callPrivateMethod(w, "getWidget");
    assertThat(wrappedPanel.getWidget(0)).isEqualTo(w.listBox);
    assertThat(w.radioButton1.getText()).isEqualTo("Test radio 1");
    assertThat(w.radioButton1.getName()).isEqualTo("MyRadioGroup");
    assertThat(w.radioButton1.getValue()).isTrue();
    assertThat(w.radioButton2.getText()).isEqualTo("Test radio 2");
    assertThat(w.radioButton2.getName()).isEqualTo("MyRadioGroup");
    assertThat(w.radioButton2.getValue()).isFalse();
    assertThat(w.image.getUrl()).isEqualTo(MyClientBundle.INSTANCE.cellTableLoading().getSafeUri().asString());
    assertThat(w.image.getAltText()).isEqualTo("Loading...");
    assertThat(w.image.getStyleName()).isEqualTo("pretty");
    assertThat(w.imageWithUrl.getUrl()).isEqualTo("http://slazzer.com/image.jpg");
    assertThat(w.providedLabel.getText()).isEqualTo("my provided label");
    assertThat(w.providedLabel.getCustomText()).isEqualTo("custom text setup in ui.xml");
    assertThat(w.providedLabel.providedString).isEqualTo("my provided string");
    assertThat(w.providedLabel.getStyleName()).isEqualTo("disabled");
    assertThat(w.uiFactoryLabel.getText()).isEqualTo("my UiFactory label");
    assertThat(w.uiFactoryLabel.getCustomText()).isEqualTo("custom text setup in ui.xml");
    assertThat(w.uiFactoryLabel.uiFactoryString).isEqualTo("gael");
    assertThat(w.uiConstructorLabel.getText()).isEqualTo("my UiConstructor label");
    assertThat(w.uiConstructorLabel.getCustomText()).isEqualTo("custom text setup in ui.xml");
    assertThat(w.uiConstructorLabel.uiConstructorLabel).isEqualTo("uiConstructor property");
    Label label = (Label) wrappedPanel.getWidget(1);
    assertThat(label).isNotNull();
    assertThat(label.getText()).isEqualTo("Keep your ducks");
    SpanElement spanElement = Document.get().getElementById("mySpan").cast();
    assertThat(spanElement.getInnerText()).isEqualTo("some span for testing");
    assertThat(spanElement.getClassName()).isEqualTo("pretty");
    assertThat(w.msgLabel.getText()).isEqualTo("We strongly urge you to reconsider.");
    assertThat(w.msgInnerWidget.getText()).isEqualTo("9'00");
    assertThat(wrappedPanel.getWidget(5)).isEqualTo(w.msgInnerWidget);
    assertThat(w.verticalPanel.getHorizontalAlignment()).isEqualTo(HasHorizontalAlignment.ALIGN_LEFT);
    assertThat(w.verticalPanel.getVerticalAlignment()).isEqualTo(HasVerticalAlignment.ALIGN_MIDDLE);
    // Thenion on specific style
    assertThat(w.style.getName()).isEqualTo("style");
    assertThat(w.style.disabled()).isEqualTo("disabled");
    assertThat(w.style.getText()).isEqualTo(".redBox {background-color: pink;border: 1px solid red;}.enabled {color: black;}.disabled {color: gray;}");
    // Thenion on inner style
    assertThat(w.pushButton.getStyleName()).isEqualTo("gwt-PushButton testStyle pretty gwt-PushButton-up");
    // Thenion on inner image
    assertThat(w.img.getName()).isEqualTo("img");
    assertThat(w.img.getSafeUri().asString()).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/img.jpg");
    // Thenion on inner data
    assertThat(w.data.getName()).isEqualTo("data");
    assertThat(w.data.getSafeUri().asString()).isEqualTo("http://127.0.0.1:8888/gwt_test_utils_module/MyChildConstants.properties");
    // Thenion on "IsWidget
    assertThat(w.isWidgetLabel.getText()).isEqualTo("isWidget Label");
    assertThat(DOM.getStyleAttribute(w.textBox.getElement(), "textAlign")).isEqualTo("justify");
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) GwtTestTest(com.googlecode.gwt.test.GwtTestTest) Test(org.junit.Test)

Aggregations

SpanElement (com.google.gwt.dom.client.SpanElement)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)5 Event (com.google.gwt.user.client.Event)5 EventListener (com.google.gwt.user.client.EventListener)5 KeyboardEvent (elemental.events.KeyboardEvent)5 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 Icon (org.eclipse.che.ide.api.icon.Icon)4 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)3 Element (com.google.gwt.dom.client.Element)1 PreElement (com.google.gwt.dom.client.PreElement)1 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)1 CommandType (org.eclipse.che.ide.api.command.CommandType)1 DebugConfigurationType (org.eclipse.che.ide.api.debug.DebugConfigurationType)1 Test (org.junit.Test)1 Rectangle (org.rstudio.core.client.Rectangle)1 VirtualConsole (org.rstudio.core.client.VirtualConsole)1 ElementEx (org.rstudio.core.client.dom.ElementEx)1