Search in sources :

Example 1 with Element

use of elemental2.dom.Element in project kie-wb-common by kiegroup.

the class KieEnumSelectElementTest method testSetup.

@Test
public void testSetup() {
    final Element container = spy(new Element());
    final List<Option> options = Arrays.asList(new Option("FOO", "foo"), new Option("Bar", "bar"));
    doReturn(options).when(kieEnumSelectElement).buildOptions(any());
    kieEnumSelectElement.setup(container, TestEnum.values(), TestEnum.FOO, value -> {
    });
    assertEquals(TestEnum.class, kieEnumSelectElement.componentType);
    verify(kieSelectElement).setup(eq(container), eq(options), eq("FOO"), any());
}
Also used : Element(elemental2.dom.Element) Option(org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option) Test(org.junit.Test)

Example 2 with Element

use of elemental2.dom.Element in project kie-wb-common by kiegroup.

the class KieSelectElementTest method testSetup.

@Test
public void testSetup() {
    final HTMLElement viewRoot = spy(new HTMLElement());
    viewRoot.innerHTML = "bar";
    doReturn(viewRoot).when(view).getElement();
    final HTMLSelectElement selectElement = spy(new HTMLSelectElement());
    doReturn(selectElement).when(view).getSelect();
    final Element container = spy(new Element() {

        @Override
        public Node appendChild(final Node node) {
            if (node instanceof HTMLElement) {
                this.innerHTML += ((HTMLElement) node).innerHTML;
            }
            return node;
        }
    });
    container.innerHTML = "";
    final List<Option> options = singletonList(new Option("Label", "Value"));
    kieSelectElement.setup(container, options, "Value", value -> {
    });
    verify(view).setValue(eq("Value"));
    verify(view).initSelect();
    verify(optionsListPresenter).setup(eq(selectElement), eq(options), any());
    assertEquals("bar", container.innerHTML);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) HTMLSelectElement(elemental2.dom.HTMLSelectElement) Node(elemental2.dom.Node) Option(org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option) HTMLSelectElement(elemental2.dom.HTMLSelectElement) Test(org.junit.Test)

Example 3 with Element

use of elemental2.dom.Element in project mvp4g2-examples by mvp4g.

the class ShellView method setCenter.

@Override
public void setCenter(Element element) {
    if (content.childElementCount > 0) {
        for (int i = 0; i < content.childNodes.length; i++) {
            Node oldChild = content.childNodes.item(i);
            content.removeChild(oldChild);
        }
    }
    content.appendChild(element);
}
Also used : Node(elemental2.dom.Node)

Example 4 with Element

use of elemental2.dom.Element in project domino-ui-demo by DominoKit.

the class ButtonsViewImpl method initDropUp.

private void initDropUp() {
    Card card = Card.create("DROPUP VARIATION", "Trigger dropdown menus above elements.");
    HTMLElement element = DropdownButton.createDefault("DEFAULT").addAction(DropdownAction.create("Action")).addAction(DropdownAction.create("Another action")).dropup().asElement();
    HTMLElement primary = DropdownButton.createPrimary("PRIMARY").addAction(DropdownAction.create("Action")).addAction(DropdownAction.create("Another action")).dropup().asElement();
    HTMLElement success = DropdownButton.createSuccess("SUCCESS").addAction(DropdownAction.create("Action")).addAction(DropdownAction.create("Another action")).dropup().asElement();
    HTMLElement info = DropdownButton.createInfo("INFO").addAction(DropdownAction.create("Action")).addAction(DropdownAction.create("Another action")).dropup().asElement();
    DropdownButton danger = DropdownButton.createDanger("Dropdown").addAction(DropdownAction.create("Action")).addAction(DropdownAction.create("Another action")).dropup();
    HTMLElement group = ButtonsGroup.create().addButton(Button.createDanger("DANGER")).addDropDown(danger).asElement();
    element.style.margin = CSSProperties.MarginUnionType.of("5px");
    primary.style.margin = CSSProperties.MarginUnionType.of("5px");
    success.style.margin = CSSProperties.MarginUnionType.of("5px");
    info.style.margin = CSSProperties.MarginUnionType.of("5px");
    group.style.margin = CSSProperties.MarginUnionType.of("5px");
    card.appendContent(element);
    card.appendContent(primary);
    card.appendContent(success);
    card.appendContent(info);
    card.appendContent(group);
    this.element.appendChild(card.asElement());
    this.element.appendChild(Card.createCodeCard(CodeResource.INSTANCE.initDropUp()).asElement());
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Card(org.dominokit.domino.ui.cards.Card)

Example 5 with Element

use of elemental2.dom.Element in project domino-ui-demo by DominoKit.

the class CollapseViewImpl method example.

private void example() {
    Collapsible collapsible = Collapsible.create(Elements.div().add(Elements.div().css("well").textContent(SAMPLE_CONTENT).asElement()).asElement());
    EventListener collapsibleListener = evt -> {
        if (collapsible.isCollapsed())
            collapsible.expand();
        else
            collapsible.collapse();
    };
    Button anchorButton = Button.create("LINK WITH HREF");
    anchorButton.justify();
    anchorButton.getClickableElement().addEventListener("click", collapsibleListener);
    Button button = Button.create("BUTTON");
    button.getClickableElement().addEventListener("click", collapsibleListener);
    element.appendChild(Row.create().addColumn(column.copy().addElement(Card.create("EXAMPLE", "click the buttons below to show and hide another element via class changes.").appendContent(anchorButton.htmlBuilder().css(CssStyles.M_B_15).component().setBackground(Background.PINK).asElement()).appendContent(new Text("\n")).appendContent(button.htmlBuilder().css(CssStyles.M_B_15).component().setBackground(Background.CYAN).asElement()).appendContent(collapsible.asElement()).asElement())).asElement());
    element.appendChild(Card.createCodeCard(CodeResource.INSTANCE.example()).asElement());
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) Accordion(org.dominokit.domino.ui.collapsible.Accordion) UiView(org.dominokit.domino.api.client.annotations.UiView) ComponentView(org.dominokit.domino.componentcase.shared.extension.ComponentView) AccordionPanel(org.dominokit.domino.ui.collapsible.AccordionPanel) CssStyles(org.dominokit.domino.ui.style.CssStyles) Column(org.dominokit.domino.ui.column.Column) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) EventListener(elemental2.dom.EventListener) Color(org.dominokit.domino.ui.style.Color) Row(org.dominokit.domino.ui.row.Row) HTMLDivElement(elemental2.dom.HTMLDivElement) Text(elemental2.dom.Text) CollapseView(org.dominokit.domino.collapse.client.views.CollapseView) Collapsible(org.dominokit.domino.ui.collapsible.Collapsible) CodeResource(org.dominokit.domino.collapse.client.views.CodeResource) Card(org.dominokit.domino.ui.cards.Card) CollapsePresenter(org.dominokit.domino.collapse.client.presenters.CollapsePresenter) Button(org.dominokit.domino.ui.button.Button) Elements(org.jboss.gwt.elemento.core.Elements) Background(org.dominokit.domino.ui.style.Background) Button(org.dominokit.domino.ui.button.Button) Text(elemental2.dom.Text) Collapsible(org.dominokit.domino.ui.collapsible.Collapsible) EventListener(elemental2.dom.EventListener)

Aggregations

Element (elemental2.dom.Element)3 Node (elemental2.dom.Node)3 HTMLElement (elemental2.dom.HTMLElement)2 Card (org.dominokit.domino.ui.cards.Card)2 Test (org.junit.Test)2 Option (org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option)2 Autorun (arez.annotations.Autorun)1 EventListener (elemental2.dom.EventListener)1 HTMLDivElement (elemental2.dom.HTMLDivElement)1 HTMLSelectElement (elemental2.dom.HTMLSelectElement)1 Text (elemental2.dom.Text)1 UiView (org.dominokit.domino.api.client.annotations.UiView)1 CollapsePresenter (org.dominokit.domino.collapse.client.presenters.CollapsePresenter)1 CodeResource (org.dominokit.domino.collapse.client.views.CodeResource)1 CollapseView (org.dominokit.domino.collapse.client.views.CollapseView)1 ComponentView (org.dominokit.domino.componentcase.shared.extension.ComponentView)1 Button (org.dominokit.domino.ui.button.Button)1 Accordion (org.dominokit.domino.ui.collapsible.Accordion)1 AccordionPanel (org.dominokit.domino.ui.collapsible.AccordionPanel)1 Collapsible (org.dominokit.domino.ui.collapsible.Collapsible)1