Search in sources :

Example 1 with FlexItem

use of org.dominokit.domino.ui.grid.flex.FlexItem in project nalu-examples by NaluKit.

the class ErrorComponent method render.

@Override
public void render() {
    this.dialog = ModalDialog.create(">>To Be Set<<").large().setAutoClose(false);
    this.errorIcon = new Image(64, 64);
    this.errorIcon.setAttribute("src", "media/images/bug-128.png");
    this.route = DominoElement.div().element();
    this.message = DominoElement.div().styler(style -> {
        style.setMarginBottom("12px");
    }).element();
    DominoElement messageElement = DominoElement.div().styler(style -> {
        style.setWidth("100%");
    }).appendChild(DominoElement.div().styler(style -> style.setFloat("left")).appendChild(DominoElement.div().setTextContent("Route:").styler(style -> {
        style.setMarginBottom("6px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().appendChild(this.route).styler(style -> {
        style.setMarginBottom("24px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().setTextContent("Message:").styler(style -> {
        style.setMarginBottom("6px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().appendChild(this.message).styler(style -> {
        style.setMarginBottom("24px");
        style.setProperty("font-weight", "bold");
    })));
    FlexLayout flexLayout = FlexLayout.create().style().add("fill-height").get().setDirection(FlexDirection.LEFT_TO_RIGHT);
    FlexItem flexItemLeft = FlexItem.create().setAlignSelf(FlexAlign.START).setOrder(1).appendChild(this.errorIcon);
    flexLayout.appendChild(flexItemLeft);
    FlexItem flexItemRight = FlexItem.create().styler(style -> style.setMarginLeft("24px")).setAlignSelf(FlexAlign.START).setFlexGrow(1).setOrder(2).appendChild(messageElement);
    flexLayout.appendChild(flexItemRight);
    this.dialog.appendChild(flexLayout);
    this.dialog.appendFooterChild(Button.create("OK").addClickListener(e -> {
        this.hide();
        this.getController().doRouteHome();
    }));
}
Also used : FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) FlexDirection(org.dominokit.domino.ui.grid.flex.FlexDirection) ModalDialog(org.dominokit.domino.ui.modals.ModalDialog) DominoElement(org.dominokit.domino.ui.utils.DominoElement) AbstractErrorPopUpComponent(com.github.nalukit.nalu.client.component.AbstractErrorPopUpComponent) Image(elemental2.dom.Image) FlexAlign(org.dominokit.domino.ui.grid.flex.FlexAlign) HTMLDivElement(elemental2.dom.HTMLDivElement) Controller(com.github.nalukit.example.nalu.simpleapplication.client.ui.content.error.IErrorComponent.Controller) Map(java.util.Map) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) ErrorType(com.github.nalukit.nalu.client.event.model.ErrorInfo.ErrorType) Button(org.dominokit.domino.ui.button.Button) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) Image(elemental2.dom.Image) DominoElement(org.dominokit.domino.ui.utils.DominoElement)

Example 2 with FlexItem

use of org.dominokit.domino.ui.grid.flex.FlexItem in project nalu-examples by NaluKit.

the class ErrorComponent method render.

@Override
public void render() {
    this.dialog = ModalDialog.create(">>To Be Set<<").large().setAutoClose(false);
    this.errorIcon = new Image(64, 64);
    this.errorIcon.setAttribute("src", "media/images/bug-128.png");
    this.route = DominoElement.div().element();
    this.message = DominoElement.div().styler(style -> {
        style.setMarginBottom("12px");
    }).element();
    DominoElement messageElement = DominoElement.div().styler(style -> {
        style.setWidth("100%");
    }).appendChild(DominoElement.div().styler(style -> style.setFloat("left")).appendChild(DominoElement.div().setTextContent("Route:").styler(style -> {
        style.setMarginBottom("6px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().appendChild(this.route).styler(style -> {
        style.setMarginBottom("24px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().setTextContent("Message:").styler(style -> {
        style.setMarginBottom("6px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().appendChild(this.message).styler(style -> {
        style.setMarginBottom("24px");
        style.setProperty("font-weight", "bold");
    })));
    FlexLayout flexLayout = FlexLayout.create().style().add("fill-height").get().setDirection(FlexDirection.LEFT_TO_RIGHT);
    FlexItem flexItemLeft = FlexItem.create().setAlignSelf(FlexAlign.START).setOrder(1).setFlexGrow(1).appendChild(this.errorIcon);
    flexLayout.appendChild(flexItemLeft);
    FlexItem flexItemRight = FlexItem.create().styler(style -> style.setMarginLeft("24px")).setAlignSelf(FlexAlign.START).setOrder(2).appendChild(messageElement);
    flexLayout.appendChild(flexItemRight);
    this.dialog.appendChild(flexLayout);
    this.dialog.appendFooterChild(Button.create("OK").addClickListener(e -> {
        this.hide();
        this.getController().doRouteHome();
    }));
}
Also used : FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) FlexDirection(org.dominokit.domino.ui.grid.flex.FlexDirection) ModalDialog(org.dominokit.domino.ui.modals.ModalDialog) DominoElement(org.dominokit.domino.ui.utils.DominoElement) AbstractErrorPopUpComponent(com.github.nalukit.nalu.client.component.AbstractErrorPopUpComponent) Image(elemental2.dom.Image) FlexAlign(org.dominokit.domino.ui.grid.flex.FlexAlign) HTMLDivElement(elemental2.dom.HTMLDivElement) Map(java.util.Map) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) Controller(com.github.nalukit.example.nalu.loginapplication.client.ui.error.IErrorComponent.Controller) ErrorType(com.github.nalukit.nalu.client.event.model.ErrorInfo.ErrorType) Button(org.dominokit.domino.ui.button.Button) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) Image(elemental2.dom.Image) DominoElement(org.dominokit.domino.ui.utils.DominoElement)

Example 3 with FlexItem

use of org.dominokit.domino.ui.grid.flex.FlexItem in project domino-ui-demo by DominoKit.

the class FlexLayoutViewImpl method initFlexItems.

@SampleMethod
private void initFlexItems() {
    Slider orderSlider = Slider.create(6);
    Slider flexGrowSlider = Slider.create(10);
    Slider flexShrinkSlider = Slider.create(10);
    TextBox flexBasisTextBox = TextBox.create("Flex Basis").setHelperText("Default size of an element before the remaining space is distributed");
    RadioGroup<String> targetBlockRadioGroup = RadioGroup.create("target-block", "Target block # to play with");
    RadioGroup<String> alignSelfRadioGroup = RadioGroup.create("align-self", "Align self");
    flexItemsCard.setBodyPaddingTop("40px").appendChild(Row.create().appendChild(Column.span4().appendChild(targetBlockRadioGroup.appendChild(Radio.create("0", "1")).appendChild(Radio.create("1", "2")).appendChild(Radio.create("2", "3")).appendChild(Radio.create("3", "4")).appendChild(Radio.create("4", "5")).horizontal()))).appendChild(Row.create().appendChild(Column.span4().appendChild(orderSlider.withThumb()).appendChild(h(5).textContent("Order"))).appendChild(Column.span4().appendChild(flexGrowSlider.withThumb()).appendChild(h(5).textContent("Flex Grow"))).appendChild(Column.span4().appendChild(flexShrinkSlider.withThumb()).appendChild(h(5).textContent("Flex Shrink")))).appendChild(Row.create().appendChild(Column.span6().appendChild(flexBasisTextBox)).appendChild(Column.span6().appendChild(alignSelfRadioGroup.appendChild(Radio.create(FlexAlign.START.name(), "Start")).appendChild(Radio.create(FlexAlign.END.name(), "End")).appendChild(Radio.create(FlexAlign.CENTER.name(), "Center")).appendChild(Radio.create(FlexAlign.STRETCH.name(), "Stretch")).appendChild(Radio.create(FlexAlign.BASE_LINE.name(), "Base line")).horizontal())));
    FlexLayout flexLayout = FlexLayout.create().style().addCss("demo-flex-layout-container").addCss("fill-height").get().setDirection(FlexDirection.LEFT_TO_RIGHT);
    Map<String, FlexItem<HTMLDivElement>> items = new HashMap<>();
    for (int i = 0; i < 5; i++) {
        FlexItem<HTMLDivElement> item = FlexItem.create().style().addCss("demo-flex-layout-block").addCss(colorOf(i + 1).getBackground()).get().setAlignSelf(FlexAlign.START).setOrder(i + 1).appendChild(h(4));
        items.put(i + "", item);
        flexLayout.appendChild(item);
    }
    flexItemsCard.appendChild(div().css("demo-flex-layout-result-container").add(flexLayout).element());
    orderSlider.addSlideHandler(value -> items.get(targetBlockRadioGroup.getValue()).setOrder((int) value));
    flexGrowSlider.addSlideHandler(value -> items.get(targetBlockRadioGroup.getValue()).setFlexGrow((int) value));
    flexShrinkSlider.addSlideHandler(value -> items.get(targetBlockRadioGroup.getValue()).setFlexShrink((int) value));
    alignSelfRadioGroup.addChangeHandler(value -> items.get(targetBlockRadioGroup.getValue()).setAlignSelf(FlexAlign.valueOf(value)));
    flexBasisTextBox.addChangeHandler(value -> items.get(targetBlockRadioGroup.getValue()).setFlexBasis(value));
    targetBlockRadioGroup.addChangeHandler(value -> {
        FlexItem flexItem = items.get(targetBlockRadioGroup.getValue());
        flexGrowSlider.setValue(flexItem.getFlexGrow());
        orderSlider.setValue(flexItem.getOrder());
        flexShrinkSlider.setValue(flexItem.getFlexShrink());
        flexBasisTextBox.setValue(isNull(flexItem.getFlexBasis()) ? "" : flexItem.getFlexBasis());
        alignSelfRadioGroup.setValue(flexItem.getAlignSelf().name());
    });
    targetBlockRadioGroup.setValue("2");
}
Also used : Slider(org.dominokit.domino.ui.sliders.Slider) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) HashMap(java.util.HashMap) FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) HTMLDivElement(elemental2.dom.HTMLDivElement) TextBox(org.dominokit.domino.ui.forms.TextBox) SampleMethod(org.dominokit.domino.SampleMethod)

Example 4 with FlexItem

use of org.dominokit.domino.ui.grid.flex.FlexItem in project domino-ui-demo by DominoKit.

the class FlexLayoutViewImpl method initLayoutPlayground.

@SampleMethod
private void initLayoutPlayground() {
    RadioGroup<String> alignItemsRadioGroup = RadioGroup.<String>create("align-items").hide();
    CheckBox fillHeightCheckBox = CheckBox.create("Fill height");
    RadioGroup<String> directionsRadioGroup = RadioGroup.create("direction");
    RadioGroup<String> justifyContentRadioGroup = RadioGroup.create("justify-content");
    // ********* settings part ********* //
    Button addBlockButton = Button.create("ADD BLOCK");
    Button resetButton = Button.create("RESET");
    RadioGroup<String> wrapRadioGroup = RadioGroup.create("wrap", "Wrap");
    layoutPlaygroundCard.setBodyPaddingTop("40px").appendChild(Row.create().appendChild(Column.span6().appendChild(directionsRadioGroup.setHelperText("Containers inside Flex Layout can have different directions").setLabel("Directions").appendChild(Radio.create(FlexDirection.LEFT_TO_RIGHT.name(), "Left to right").check()).appendChild(Radio.create(FlexDirection.RIGHT_TO_LEFT.name(), "Right to left")).appendChild(Radio.create(FlexDirection.TOP_TO_BOTTOM.name(), "Top to bottom")).appendChild(Radio.create(FlexDirection.BOTTOM_TO_TOP.name(), "Bottom to top")).horizontal())).appendChild(Column.span2().appendChild(fillHeightCheckBox)).appendChild(Column.span4().appendChild(wrapRadioGroup.appendChild(Radio.create(FlexWrap.NO_WRAP.name(), "No wrap").check()).appendChild(Radio.create(FlexWrap.WRAP_TOP_TO_BOTTOM.name(), "Wrap top to bottom")).appendChild(Radio.create(FlexWrap.WRAP_BOTTOM_TO_TOP.name(), "Wrap bottom to top")).horizontal()))).appendChild(Row.create().appendChild(Column.span6().appendChild(justifyContentRadioGroup.setHelperText("Containers inside Flex Layout can be placed in different ways").setLabel("Justify Content").appendChild(Radio.create(FlexJustifyContent.START.name(), "Start").check()).appendChild(Radio.create(FlexJustifyContent.END.name(), "End")).appendChild(Radio.create(FlexJustifyContent.CENTER.name(), "Center")).appendChild(Radio.create(FlexJustifyContent.SPACE_BETWEEN.name(), "Space between")).appendChild(Radio.create(FlexJustifyContent.SPACE_AROUND.name(), "Space around")).appendChild(Radio.create(FlexJustifyContent.SPACE_EVENLY.name(), "Space evenly")).horizontal())).appendChild(Column.span6().appendChild(alignItemsRadioGroup.setHelperText("Containers inside Flex Layout can be aligned in different ways").setLabel("Align items").appendChild(Radio.create(FlexAlign.START.name(), "Start")).appendChild(Radio.create(FlexAlign.END.name(), "End")).appendChild(Radio.create(FlexAlign.CENTER.name(), "Center")).appendChild(Radio.create(FlexAlign.STRETCH.name(), "Stretch").check()).appendChild(Radio.create(FlexAlign.BASE_LINE.name(), "Base line")).horizontal()))).appendChild(Row.create().fullSpan(column -> column.appendChild(resetButton.linkify().style().addCss(Styles.pull_right)).appendChild(addBlockButton.linkify().style().addCss(Styles.pull_right))));
    // ********* flex layout part ********* //
    FlexLayout flexLayout = FlexLayout.create().style().addCss("demo-flex-layout-container").get().appendChild(FlexItem.create().style().addCss("demo-flex-layout-block").get().appendChild(h(4))).appendChild(FlexItem.create().style().addCss("demo-flex-layout-block").get().appendChild(h(4))).appendChild(FlexItem.create().style().addCss("demo-flex-layout-block").get().appendChild(h(4))).setDirection(FlexDirection.LEFT_TO_RIGHT);
    layoutPlaygroundCard.appendChild(div().css("demo-flex-layout-result-container").add(flexLayout).element());
    // ********* listeners part ********* //
    directionsRadioGroup.addChangeHandler(direction -> {
        FlexDirection flexDirection = FlexDirection.valueOf(direction);
        if (fillHeightCheckBox.isChecked() || isVerticalDirection(flexDirection)) {
            flexLayout.style().addCss("fill-height");
        } else {
            flexLayout.style().removeCss("fill-height");
        }
        flexLayout.setDirection(flexDirection);
    });
    fillHeightCheckBox.addChangeHandler(value -> {
        if (value) {
            alignItemsRadioGroup.show();
            flexLayout.style().addCss("fill-height");
        } else {
            alignItemsRadioGroup.hide();
            flexLayout.style().removeCss("fill-height");
        }
    });
    justifyContentRadioGroup.addChangeHandler(direction -> flexLayout.setJustifyContent(FlexJustifyContent.valueOf(direction)));
    alignItemsRadioGroup.addChangeHandler(direction -> flexLayout.setAlignItems(FlexAlign.valueOf(direction)));
    wrapRadioGroup.addChangeHandler(value -> flexLayout.setWrap(FlexWrap.valueOf(value)));
    List<FlexItem<HTMLDivElement>> dynamicAddedItems = new ArrayList<>();
    addBlockButton.addClickListener(evt -> {
        FlexItem<HTMLDivElement> item = FlexItem.create().style().addCss("demo-flex-layout-block").get().appendChild(h(4));
        flexLayout.appendChild(item);
        dynamicAddedItems.add(item);
    });
    resetButton.addClickListener(evt -> {
        for (FlexItem<HTMLDivElement> dynamicAddedItem : dynamicAddedItems) {
            dynamicAddedItem.remove();
        }
        dynamicAddedItems.clear();
    });
}
Also used : SampleClass(org.dominokit.domino.SampleClass) FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) SampleMethod(org.dominokit.domino.SampleMethod) RadioGroup(org.dominokit.domino.ui.forms.RadioGroup) Elements.a(org.jboss.elemento.Elements.a) UiView(org.dominokit.domino.api.client.annotations.UiView) CodeCard(org.dominokit.domino.componentcase.client.ui.views.CodeCard) FlexDirection(org.dominokit.domino.ui.grid.flex.FlexDirection) Column(org.dominokit.domino.ui.grid.Column) HashMap(java.util.HashMap) Elements.h(org.jboss.elemento.Elements.h) Radio(org.dominokit.domino.ui.forms.Radio) FlexAlign(org.dominokit.domino.ui.grid.flex.FlexAlign) ArrayList(java.util.ArrayList) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) Elements.p(org.jboss.elemento.Elements.p) LinkToSourceCode(org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode) FlexWrap(org.dominokit.domino.ui.grid.flex.FlexWrap) Styles(org.dominokit.domino.ui.style.Styles) Elements.div(org.jboss.elemento.Elements.div) Map(java.util.Map) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) Row(org.dominokit.domino.ui.grid.Row) Objects.isNull(java.util.Objects.isNull) Card(org.dominokit.domino.ui.cards.Card) TextNode(org.dominokit.domino.ui.utils.TextNode) TextBox(org.dominokit.domino.ui.forms.TextBox) BaseDemoView(org.dominokit.domino.componentcase.client.ui.views.BaseDemoView) FlexJustifyContent(org.dominokit.domino.ui.grid.flex.FlexJustifyContent) List(java.util.List) Color(org.dominokit.domino.ui.style.Color) HTMLDivElement(elemental2.dom.HTMLDivElement) Slider(org.dominokit.domino.ui.sliders.Slider) FlexLayoutProxy(org.dominokit.domino.flexlayout.client.presenters.FlexLayoutProxy) CheckBox(org.dominokit.domino.ui.forms.CheckBox) FlexLayoutView(org.dominokit.domino.flexlayout.client.views.FlexLayoutView) Button(org.dominokit.domino.ui.button.Button) Button(org.dominokit.domino.ui.button.Button) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) CheckBox(org.dominokit.domino.ui.forms.CheckBox) FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) ArrayList(java.util.ArrayList) FlexDirection(org.dominokit.domino.ui.grid.flex.FlexDirection) HTMLDivElement(elemental2.dom.HTMLDivElement) SampleMethod(org.dominokit.domino.SampleMethod)

Example 5 with FlexItem

use of org.dominokit.domino.ui.grid.flex.FlexItem in project nalu-examples by NaluKit.

the class ErrorComponent method render.

@Override
public void render() {
    dialog = ModalDialog.create("to be set").large().setAutoClose(false);
    Image errorIcon = new Image(64, 64);
    route = DominoElement.div().styler(style -> style.setMarginBottom("12px")).element();
    message = DominoElement.div().styler(style -> style.setMarginBottom("12px")).element();
    content = DominoElement.div();
    DominoElement<HTMLDivElement> messageElement = DominoElement.div().styler(style -> style.setWidth("100%")).appendChild(DominoElement.div().styler(style -> style.setFloat("left")).appendChild(DominoElement.div().setTextContent("Route:").styler(style -> {
        style.setMarginBottom("6px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().appendChild(route).styler(style -> {
        style.setMarginBottom("24px");
        style.setProperty("font-weight", "normal");
    })).appendChild(DominoElement.div().setTextContent("Message:").styler(style -> {
        style.setMarginBottom("6px");
        style.setProperty("font-weight", "bold");
    })).appendChild(DominoElement.div().appendChild(message).styler(style -> {
        style.setMarginBottom("24px");
        style.setProperty("font-weight", "normal");
    })).appendChild(content));
    FlexLayout flexLayout = FlexLayout.create().style().add("fill-height").get().setDirection(FlexDirection.LEFT_TO_RIGHT);
    FlexItem flexItemLeft = FlexItem.create().setAlignSelf(FlexAlign.START).setOrder(1).appendChild(errorIcon);
    flexLayout.appendChild(flexItemLeft);
    FlexItem flexItemRight = FlexItem.create().styler(style -> style.setMarginLeft("24px")).setAlignSelf(FlexAlign.START).setFlexGrow(1).setOrder(2).appendChild(messageElement);
    flexLayout.appendChild(flexItemRight);
    dialog.appendChild(flexLayout);
    this.dialog.appendFooterChild(Button.create("OK").large().linkify().styler(style -> style.setWidth("128px")).addClickListener(e -> {
        this.hide();
        this.getController().doRouteHome();
    }));
}
Also used : FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) HTMLDivElement(elemental2.dom.HTMLDivElement) Map(java.util.Map) FlexDirection(org.dominokit.domino.ui.grid.flex.FlexDirection) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) ModalDialog(org.dominokit.domino.ui.modals.ModalDialog) ErrorInfo(com.github.nalukit.nalu.client.event.model.ErrorInfo) DominoElement(org.dominokit.domino.ui.utils.DominoElement) AbstractErrorPopUpComponent(com.github.nalukit.nalu.client.component.AbstractErrorPopUpComponent) Image(elemental2.dom.Image) Button(org.dominokit.domino.ui.button.Button) FlexAlign(org.dominokit.domino.ui.grid.flex.FlexAlign) FlexLayout(org.dominokit.domino.ui.grid.flex.FlexLayout) FlexItem(org.dominokit.domino.ui.grid.flex.FlexItem) HTMLDivElement(elemental2.dom.HTMLDivElement) Image(elemental2.dom.Image)

Aggregations

HTMLDivElement (elemental2.dom.HTMLDivElement)8 FlexItem (org.dominokit.domino.ui.grid.flex.FlexItem)8 FlexLayout (org.dominokit.domino.ui.grid.flex.FlexLayout)8 Map (java.util.Map)7 Button (org.dominokit.domino.ui.button.Button)7 FlexAlign (org.dominokit.domino.ui.grid.flex.FlexAlign)7 FlexDirection (org.dominokit.domino.ui.grid.flex.FlexDirection)7 AbstractErrorPopUpComponent (com.github.nalukit.nalu.client.component.AbstractErrorPopUpComponent)6 Image (elemental2.dom.Image)6 ModalDialog (org.dominokit.domino.ui.modals.ModalDialog)6 DominoElement (org.dominokit.domino.ui.utils.DominoElement)6 ErrorType (com.github.nalukit.nalu.client.event.model.ErrorInfo.ErrorType)4 ErrorInfo (com.github.nalukit.nalu.client.event.model.ErrorInfo)2 HashMap (java.util.HashMap)2 SampleMethod (org.dominokit.domino.SampleMethod)2 TextBox (org.dominokit.domino.ui.forms.TextBox)2 Slider (org.dominokit.domino.ui.sliders.Slider)2 Controller (com.github.nalukit.example.nalu.loginapplication.client.ui.error.IErrorComponent.Controller)1 Controller (com.github.nalukit.example.nalu.loginapplication.ui.error.popup.IErrorComponent.Controller)1 Controller (com.github.nalukit.example.nalu.simpleapplication.client.ui.content.error.IErrorComponent.Controller)1