Search in sources :

Example 1 with CheckBox

use of org.dominokit.domino.ui.forms.CheckBox in project domino-ui-demo by DominoKit.

the class FormsValidationsViewImpl method initValidations.

@SampleMethod
private void initValidations() {
    FieldsGrouping fieldsGrouping = FieldsGrouping.create();
    TextBox name = TextBox.create("Name").groupBy(fieldsGrouping);
    TextBox surename = TextBox.create("Surename").groupBy(fieldsGrouping);
    TextBox email = TextBox.create("Email").groupBy(fieldsGrouping);
    RadioGroup<String> gender = RadioGroup.<String>create("gender", "Gender").appendChild(Radio.create("male", "Male")).appendChild(Radio.create("female", "Female")).horizontal().setShowRequiredIndicator(false).groupBy(fieldsGrouping);
    TextArea description = TextArea.create("Description").groupBy(fieldsGrouping);
    TextBox password = TextBox.password("Password").groupBy(fieldsGrouping);
    CheckBox termsAndConditions = CheckBox.create("I have read and accept the terms").groupBy(fieldsGrouping);
    Select language = Select.create("Language").appendChild(SelectOption.create("english", "English")).appendChild(SelectOption.create("france", "France")).appendChild(SelectOption.create("arabic", "Arabic")).groupBy(fieldsGrouping);
    fieldsGrouping.setAutoValidation(true).setRequired(true);
    validationsCard.appendChild(Row.create().addColumn(Column.span12().appendChild(name))).appendChild(Row.create().addColumn(Column.span12().appendChild(surename))).appendChild(Row.create().addColumn(Column.span12().appendChild(email))).appendChild(Row.create().addColumn(Column.span12().appendChild(gender))).appendChild(Row.create().addColumn(Column.span12().appendChild(description))).appendChild(Row.create().addColumn(Column.span12().appendChild(password))).appendChild(Row.create().addColumn(Column.span12().appendChild(language))).appendChild(Row.create().addColumn(Column.span12().appendChild(termsAndConditions))).appendChild(Row.create().addColumn(Column.span12().appendChild(Button.createPrimary("REGISTER").addClickListener(evt -> {
        ValidationResult validationResult = fieldsGrouping.validate();
        if (validationResult.isValid()) {
            fieldsGrouping.clear();
        } else {
            Notification.createDanger("Error " + validationResult.getErrorMessage()).show();
        }
    }))));
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) SampleClass(org.dominokit.domino.SampleClass) SampleMethod(org.dominokit.domino.SampleMethod) ValidationResult(org.dominokit.domino.ui.forms.validations.ValidationResult) RadioGroup(org.dominokit.domino.ui.forms.RadioGroup) UiView(org.dominokit.domino.api.client.annotations.UiView) FormsValidationsView(org.dominokit.domino.formsvalidations.client.views.FormsValidationsView) CodeCard(org.dominokit.domino.componentcase.client.ui.views.CodeCard) Elements(org.jboss.elemento.Elements) Column(org.dominokit.domino.ui.grid.Column) Radio(org.dominokit.domino.ui.forms.Radio) Notification(org.dominokit.domino.ui.notifications.Notification) Icon(org.dominokit.domino.ui.icons.Icon) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) LinkToSourceCode(org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode) FormsValidationsProxy(org.dominokit.domino.formsvalidations.client.presenters.FormsValidationsProxy) Tooltip(org.dominokit.domino.ui.popover.Tooltip) HTMLElement(elemental2.dom.HTMLElement) Row(org.dominokit.domino.ui.grid.Row) SwitchButton(org.dominokit.domino.ui.forms.SwitchButton) Card(org.dominokit.domino.ui.cards.Card) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextBox(org.dominokit.domino.ui.forms.TextBox) BaseDemoView(org.dominokit.domino.componentcase.client.ui.views.BaseDemoView) FieldsGrouping(org.dominokit.domino.ui.forms.FieldsGrouping) TextArea(org.dominokit.domino.ui.forms.TextArea) Select(org.dominokit.domino.ui.forms.Select) HTMLDivElement(elemental2.dom.HTMLDivElement) CheckBox(org.dominokit.domino.ui.forms.CheckBox) Button(org.dominokit.domino.ui.button.Button) TextArea(org.dominokit.domino.ui.forms.TextArea) CheckBox(org.dominokit.domino.ui.forms.CheckBox) FieldsGrouping(org.dominokit.domino.ui.forms.FieldsGrouping) Select(org.dominokit.domino.ui.forms.Select) TextBox(org.dominokit.domino.ui.forms.TextBox) ValidationResult(org.dominokit.domino.ui.forms.validations.ValidationResult) SampleMethod(org.dominokit.domino.SampleMethod)

Example 2 with CheckBox

use of org.dominokit.domino.ui.forms.CheckBox in project domino-ui-demo by DominoKit.

the class GridLayoutViewImpl method initLayoutSamples.

private void initLayoutSamples() {
    GridLayout gridLayout = GridLayout.create().style().setHeight("500px").get();
    gridLayout.getContentElement().style().addCss("demo-layout-section", "demo-content");
    gridLayout.getHeaderElement().style().addCss("demo-layout-section", "demo-header");
    gridLayout.getFooterElement().style().addCss("demo-layout-section", "demo-l-footer");
    gridLayout.getLeftElement().style().addCss("demo-layout-section", "demo-left");
    gridLayout.getRightElement().style().addCss("demo-layout-section", "demo-right");
    gridLayout.getContentElement().appendChild(span().textContent("Content").element());
    gridLayout.getHeaderElement().appendChild(span().textContent("Header").element());
    gridLayout.getFooterElement().appendChild(span().textContent("Footer").element());
    gridLayout.getLeftElement().appendChild(span().textContent("Left").element());
    gridLayout.getRightElement().appendChild(span().textContent("Right").element());
    Slider headerSlider = Slider.create(6, 0, 0).withThumb().setStep(1);
    headerSlider.addChangeHandler(value -> {
        if (value == 0) {
            gridLayout.hideHeader();
        } else {
            gridLayout.setHeaderSpan(SectionSpan.valueOf("_" + value));
        }
    });
    Slider leftSlider = Slider.create(6, 0, 0).withThumb().setStep(1);
    CheckBox leftSpanUpCheck = CheckBox.create("Span Up");
    CheckBox leftSpanDownCheck = CheckBox.create("Span Down");
    leftSpanUpCheck.addChangeHandler(value -> {
        if (leftSlider.getValue() > 0) {
            gridLayout.setLeftSpan(SectionSpan.valueOf("_" + leftSlider.getValue()), value, leftSpanDownCheck.getValue());
        }
    });
    leftSpanDownCheck.addChangeHandler(value -> {
        if (leftSlider.getValue() > 0) {
            gridLayout.setLeftSpan(SectionSpan.valueOf("_" + leftSlider.getValue()), leftSpanUpCheck.getValue(), value);
        }
    });
    leftSlider.addChangeHandler(value -> {
        if (value == 0) {
            gridLayout.hideLeft();
        } else {
            gridLayout.setLeftSpan(SectionSpan.valueOf("_" + value), leftSpanUpCheck.getValue(), leftSpanDownCheck.getValue());
        }
    });
    Slider rightSlider = Slider.create(6, 0, 0).withThumb().setStep(1);
    CheckBox rightSpanUpCheck = CheckBox.create("Span Up");
    CheckBox rightSpanDownCheck = CheckBox.create("Span Down");
    rightSpanUpCheck.addChangeHandler(value -> {
        if (rightSlider.getValue() > 0) {
            gridLayout.setRightSpan(SectionSpan.valueOf("_" + rightSlider.getValue()), value, rightSpanDownCheck.getValue());
        }
    });
    rightSpanDownCheck.addChangeHandler(value -> {
        if (rightSlider.getValue() > 0) {
            gridLayout.setRightSpan(SectionSpan.valueOf("_" + rightSlider.getValue()), rightSpanUpCheck.getValue(), value);
        }
    });
    rightSlider.addChangeHandler(value -> {
        if (value == 0) {
            gridLayout.hideRight();
        } else {
            gridLayout.setRightSpan(SectionSpan.valueOf("_" + value), rightSpanUpCheck.getValue(), rightSpanDownCheck.getValue());
        }
    });
    Slider footerSlider = Slider.create(6, 0, 0).withThumb().setStep(1);
    footerSlider.addChangeHandler(value -> {
        if (value == 0) {
            gridLayout.hideFooter();
        } else {
            gridLayout.setFooterSpan(SectionSpan.valueOf("_" + value));
        }
    });
    Slider gapSlider = Slider.create(10, 0, 0).withThumb().setStep(1).addChangeHandler(value -> gridLayout.setGap(value + "px"));
    element.appendChild(Card.create().appendChild(Row.create().addColumn(Column.span2().appendChild(headerSlider).appendChild(h(5).textContent("Header"))).addColumn(Column.span2().appendChild(leftSlider).appendChild(h(5).textContent("Left")).appendChild(leftSpanUpCheck).appendChild(leftSpanDownCheck)).addColumn(Column.span2().appendChild(rightSlider).appendChild(h(5).textContent("Right")).appendChild(rightSpanUpCheck).appendChild(rightSpanDownCheck)).addColumn(Column.span2().appendChild(footerSlider).appendChild(h(5).textContent("Footer"))).addColumn(Column.span2().appendChild(gapSlider).appendChild(h(5).textContent("Gap")))).appendChild(gridLayout).element());
    element.appendChild(Card.create("USAGE").appendChild(BlockHeader.create("Basic", "Grid layout is a 12 columns grid based layout with a content section and another 4 optional sections: Header. Footer, Left and Right. ").appendChild(a().attr("href", "https://developer.mozilla.org/en-US/docs/Web/CSS/grid").textContent("Please checkout css grid on MDN")).appendChild(br())).appendChild(h(5).textContent("The GridLayout is a single div element that can hold up to 5 other divs for each section")).appendChild(br()).appendChild(h(5).textContent("The Content")).appendChild(h(6).textContent("Content section is the only section in the GridLayout by default, it covers all 12 rows and columns of the grid by default.")).appendChild(br()).appendChild(h(5).textContent("Creating a grid layout")).appendChild(CodeCard.preBlock("GridLayout gridLayout = GridLayout.create()\n" + "                .style()\n" + "                .setHeight(\"500px\").get();")).appendChild(h(6).textContent("This will create a gridlayout of 500px.")).appendChild(br()).appendChild(h(5).textContent("Changing a section size")).appendChild(CodeCard.preBlock("gridLayout.setHeaderSpan(SectionSpan._2);\n" + "gridLayout.setLeftSpan(SectionSpan._3);\n" + "gridLayout.setRightSpan(SectionSpan._4);\n" + "gridLayout.setFooterSpan(SectionSpan._2);")).appendChild(h(6).textContent("You can span a section to cover up to 6 rows or columns.")).appendChild(br()).appendChild(h(4).textContent("Adding elements to the gridLayout sections")).appendChild(br()).appendChild(CodeCard.preBlock("gridLayout.getContentElement().appendChild(otherElement);\n" + "gridLayout.getHeaderElement().appendChild(otherElement);\n" + "gridLayout.getLeftElement().appendChild(otherElement);\n" + "gridLayout.getRightElement().appendChild(otherElement);\n" + "gridLayout.getFooterElement().appendChild(otherElement);\n")).appendChild(h(6).textContent("You have to span a section to make the appended elements show up.")).appendChild(br()).appendChild(h(5).textContent("Hiding a section")).appendChild(CodeCard.preBlock("gridLayout.hideHeader();\n" + "gridLayout.hideLeft();\n" + "gridLayout.hideRight();\n" + "gridLayout.hideFooter();\n")).appendChild(h(6).textContent("You can hide all sections except the content section.")).appendChild(br()).element());
}
Also used : GridLayout(org.dominokit.domino.ui.grid.GridLayout) Slider(org.dominokit.domino.ui.sliders.Slider) CheckBox(org.dominokit.domino.ui.forms.CheckBox)

Example 3 with CheckBox

use of org.dominokit.domino.ui.forms.CheckBox in project domino-ui-demo by DominoKit.

the class DataTableViewImpl method editableTable.

@SampleMethod
private void editableTable() {
    TableConfig<Contact> tableConfig = new TableConfig<>();
    tableConfig.addColumn(ColumnConfig.<Contact>create("edit_save", "").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> Icons.ALL.pencil_mdi().clickable().setTooltip("Edit").addClickListener(evt -> cell.getTableRow().edit()).element()).setEditableCellRenderer(cell -> Icons.ALL.content_save_mdi().clickable().setTooltip("Save").addClickListener(evt -> {
        if (cell.getTableRow().validate().isValid()) {
            cell.getTableRow().save();
        }
    }).element())).addColumn(ColumnConfig.<Contact>create("id", "#").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getIndex() + 1 + ""))).addColumn(ColumnConfig.<Contact>create("status", "Status").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).textAlign("center").setCellRenderer(cell -> {
        if (cell.getTableRow().getRecord().isActive()) {
            return Style.of(Icons.ALL.check_circle()).setColor(Color.GREEN_DARKEN_3.getHex()).element();
        } else {
            return Style.of(Icons.ALL.highlight_off()).setColor(Color.RED_DARKEN_3.getHex()).element();
        }
    }).setEditableCellRenderer(cell -> {
        CheckBox activeCheckBox = CheckBox.create("").setFieldStyle(FieldStyle.ROUNDED).value(cell.getRecord().isActive());
        cell.setDirtyRecordHandler(dirty -> dirty.setActive(activeCheckBox.getValue()));
        return activeCheckBox.element();
    })).addColumn(ColumnConfig.<Contact>create("firstName", "First name").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getName())).setEditableCellRenderer(cell -> {
        TextBox nameBox = TextBox.create().setFieldStyle(FieldStyle.ROUNDED).value(cell.getRecord().getName());
        cell.setDirtyRecordHandler(dirty -> dirty.setName(nameBox.getValue()));
        return nameBox.element();
    })).addColumn(ColumnConfig.<Contact>create("gender", "Gender").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> ContactUiUtils.getGenderElement(cell.getRecord())).setEditableCellRenderer(cell -> {
        Select<Gender> genderSelect = Select.<Gender>create().styler(style -> style.setMinWidth("100px")).setFieldStyle(FieldStyle.ROUNDED).appendChild(SelectOption.create(Gender.male, "Male", "Male")).appendChild(SelectOption.create(Gender.female, "female", "female")).value(cell.getRecord().getGender());
        cell.setDirtyRecordHandler(dirty -> dirty.setGender(genderSelect.getValue()));
        return genderSelect.element();
    }).textAlign("center")).addColumn(ColumnConfig.<Contact>create("eyeColor", "Eye color").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> ContactUiUtils.getEyeColorElement(cell.getRecord())).setEditableCellRenderer(cell -> {
        Select<EyeColor> eyeColorSelect = Select.<EyeColor>create().setFieldStyle(FieldStyle.ROUNDED).appendChild(SelectOption.create(EyeColor.blue, "Blue", "Blue")).appendChild(SelectOption.create(EyeColor.brown, "Brown", "Brown")).appendChild(SelectOption.create(EyeColor.green, "Green", "Green")).value(cell.getRecord().getEyeColor());
        cell.setDirtyRecordHandler(dirty -> dirty.setEyeColor(eyeColorSelect.getValue()));
        return eyeColorSelect.element();
    }).textAlign("center")).addColumn(ColumnConfig.<Contact>create("balance", "Balance").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> ContactUiUtils.getBalanceElement(cell.getRecord())).setEditableCellRenderer(cell -> {
        DoubleBox doubleBox = DoubleBox.create().setFieldStyle(FieldStyle.ROUNDED).setMaxValue(4000.0).value(cell.getRecord().getBalance());
        cell.setDirtyRecordHandler(dirty -> dirty.setBalance(doubleBox.getValue().doubleValue()));
        cell.setCellValidator(doubleBox::validate);
        return doubleBox.element();
    })).addColumn(ColumnConfig.<Contact>create("email", "Email").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getEmail())).setEditableCellRenderer(cell -> {
        EmailBox emailBox = EmailBox.create().setFieldStyle(FieldStyle.ROUNDED).value(cell.getRecord().getEmail());
        cell.setDirtyRecordHandler(dirty -> dirty.setEmail(emailBox.getValue()));
        return emailBox.element();
    })).addColumn(ColumnConfig.<Contact>create("phone", "Phone").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().getPhone())).setEditableCellRenderer(cell -> {
        TelephoneBox telephoneBox = TelephoneBox.create().setFieldStyle(FieldStyle.ROUNDED).value(cell.getRecord().getPhone());
        cell.setDirtyRecordHandler(dirty -> dirty.setPhone(telephoneBox.getValue()));
        return telephoneBox.element();
    })).addColumn(ColumnConfig.<Contact>create("badges", "Badges").styleCell(element -> {
        element.style.setProperty("vertical-align", "top");
    }).setCellRenderer(cell -> {
        if (cell.getTableRow().getRecord().getAge() < 35) {
            return Badge.create("Young").setBackground(ColorScheme.GREEN.color()).element();
        }
        return TextNode.of("");
    })).setDirtyRecordHandlers(Contact::new, (originalRecord, dirtyRecord) -> {
        originalRecord.setActive(dirtyRecord.isActive());
        originalRecord.setPhone(dirtyRecord.getPhone());
        originalRecord.setEmail(dirtyRecord.getEmail());
        originalRecord.setBalance(dirtyRecord.getBalance());
        originalRecord.setEyeColor(dirtyRecord.getEyeColor());
        originalRecord.setGender(dirtyRecord.getGender());
        originalRecord.setName(dirtyRecord.getName());
    });
    LocalListDataStore<Contact> localListDataStore = new LocalListDataStore<>();
    DataTable<Contact> table = new DataTable<>(tableConfig, localListDataStore);
    element.appendChild(Card.create("EDITABLE TABLE", "Render cells as editable fields and save the row data.").setCollapsible().appendChild(new TableStyleActions(table)).appendChild(table).element());
    contactListParseHandlers.add(contacts -> {
        localListDataStore.setData(subList(contacts));
    });
}
Also used : SampleClass(org.dominokit.domino.SampleClass) JsonResource(org.dominokit.domino.datatable.client.views.JsonResource) SampleMethod(org.dominokit.domino.SampleMethod) SelectionPlugin(org.dominokit.domino.ui.datatable.plugins.SelectionPlugin) UiView(org.dominokit.domino.api.client.annotations.UiView) Date(java.util.Date) CodeCard(org.dominokit.domino.componentcase.client.ui.views.CodeCard) DoubleBox(org.dominokit.domino.ui.forms.DoubleBox) Style(org.dominokit.domino.ui.style.Style) TreeGridSample(org.dominokit.domino.datatable.client.views.model.TreeGridSample) Paragraph(org.dominokit.domino.ui.Typography.Paragraph) Random(java.util.Random) HTMLTableCellElement(elemental2.dom.HTMLTableCellElement) ContactSearchFilter(org.dominokit.domino.datatable.client.views.model.ContactSearchFilter) Notification(org.dominokit.domino.ui.notifications.Notification) Icon(org.dominokit.domino.ui.icons.Icon) EmailBox(org.dominokit.domino.ui.forms.EmailBox) HTMLElement(elemental2.dom.HTMLElement) TextHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter) HeaderBarPlugin(org.dominokit.domino.ui.datatable.plugins.HeaderBarPlugin) SimplePaginationPlugin(org.dominokit.domino.ui.datatable.plugins.SimplePaginationPlugin) Card(org.dominokit.domino.ui.cards.Card) ResourceException(com.google.gwt.resources.client.ResourceException) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) TextResource(com.google.gwt.resources.client.TextResource) BaseDemoView(org.dominokit.domino.componentcase.client.ui.views.BaseDemoView) DominoElement(org.dominokit.domino.ui.utils.DominoElement) RecordDetailsPlugin(org.dominokit.domino.ui.datatable.plugins.RecordDetailsPlugin) BooleanHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.BooleanHeaderFilter) Collectors(java.util.stream.Collectors) SortPlugin(org.dominokit.domino.ui.datatable.plugins.SortPlugin) List(java.util.List) Select(org.dominokit.domino.ui.forms.Select) Color(org.dominokit.domino.ui.style.Color) Unit.px(org.dominokit.domino.ui.style.Unit.px) ColumnHeaderFilterPlugin(org.dominokit.domino.ui.datatable.plugins.ColumnHeaderFilterPlugin) ScrollingPaginationPlugin(org.dominokit.domino.ui.datatable.plugins.ScrollingPaginationPlugin) Optional(java.util.Optional) GroupingPlugin(org.dominokit.domino.ui.datatable.plugins.GroupingPlugin) CheckBox(org.dominokit.domino.ui.forms.CheckBox) ContactList(org.dominokit.domino.datatable.client.views.model.ContactList) EyeColor(org.dominokit.domino.datatable.client.views.model.EyeColor) DatatableProxy(org.dominokit.domino.datatable.client.presenters.DatatableProxy) Icons(org.dominokit.domino.ui.icons.Icons) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) RowCell(org.dominokit.domino.ui.datatable.RowCell) TreeGridPlugin(org.dominokit.domino.ui.datatable.plugins.TreeGridPlugin) Elements.a(org.jboss.elemento.Elements.a) Elements.td(org.jboss.elemento.Elements.td) Badge(org.dominokit.domino.ui.badges.Badge) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) TopPanelPlugin(org.dominokit.domino.ui.datatable.plugins.TopPanelPlugin) DoubleHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.DoubleHeaderFilter) DatatableView(org.dominokit.domino.datatable.client.views.DatatableView) AdvancedPaginationPlugin(org.dominokit.domino.ui.datatable.plugins.AdvancedPaginationPlugin) TableEvent(org.dominokit.domino.ui.datatable.events.TableEvent) DataTable(org.dominokit.domino.ui.datatable.DataTable) ArrayList(java.util.ArrayList) BlockHeader(org.dominokit.domino.ui.header.BlockHeader) LinkToSourceCode(org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode) Elements.div(org.jboss.elemento.Elements.div) SelectHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter) Gender(org.dominokit.domino.datatable.client.views.model.Gender) BodyScrollPlugin(org.dominokit.domino.ui.datatable.plugins.BodyScrollPlugin) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) TextBox(org.dominokit.domino.ui.forms.TextBox) ContactSorter(org.dominokit.domino.datatable.client.views.model.ContactSorter) CellRenderer(org.dominokit.domino.ui.datatable.CellRenderer) LocalListScrollingDataSource(org.dominokit.domino.ui.datatable.store.LocalListScrollingDataSource) ResourceCallback(com.google.gwt.resources.client.ResourceCallback) ColorScheme(org.dominokit.domino.ui.style.ColorScheme) EnumHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.EnumHeaderFilter) Contact(org.dominokit.domino.datatable.client.views.model.Contact) DomGlobal(elemental2.dom.DomGlobal) TableDataUpdatedEvent(org.dominokit.domino.ui.datatable.events.TableDataUpdatedEvent) HTMLDivElement(elemental2.dom.HTMLDivElement) FieldStyle(org.dominokit.domino.ui.forms.FieldStyle) TelephoneBox(org.dominokit.domino.ui.forms.TelephoneBox) Comparator(java.util.Comparator) RowMarkerPlugin(org.dominokit.domino.ui.datatable.plugins.RowMarkerPlugin) Collections(java.util.Collections) DataTable(org.dominokit.domino.ui.datatable.DataTable) TextBox(org.dominokit.domino.ui.forms.TextBox) Gender(org.dominokit.domino.datatable.client.views.model.Gender) Contact(org.dominokit.domino.datatable.client.views.model.Contact) EyeColor(org.dominokit.domino.datatable.client.views.model.EyeColor) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) TelephoneBox(org.dominokit.domino.ui.forms.TelephoneBox) CheckBox(org.dominokit.domino.ui.forms.CheckBox) EmailBox(org.dominokit.domino.ui.forms.EmailBox) Select(org.dominokit.domino.ui.forms.Select) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) DoubleBox(org.dominokit.domino.ui.forms.DoubleBox) SampleMethod(org.dominokit.domino.SampleMethod)

Example 4 with CheckBox

use of org.dominokit.domino.ui.forms.CheckBox 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)

Aggregations

CheckBox (org.dominokit.domino.ui.forms.CheckBox)4 HTMLDivElement (elemental2.dom.HTMLDivElement)3 SampleClass (org.dominokit.domino.SampleClass)3 SampleMethod (org.dominokit.domino.SampleMethod)3 UiView (org.dominokit.domino.api.client.annotations.UiView)3 BaseDemoView (org.dominokit.domino.componentcase.client.ui.views.BaseDemoView)3 CodeCard (org.dominokit.domino.componentcase.client.ui.views.CodeCard)3 LinkToSourceCode (org.dominokit.domino.componentcase.client.ui.views.LinkToSourceCode)3 Card (org.dominokit.domino.ui.cards.Card)3 TextBox (org.dominokit.domino.ui.forms.TextBox)3 BlockHeader (org.dominokit.domino.ui.header.BlockHeader)3 HTMLElement (elemental2.dom.HTMLElement)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Button (org.dominokit.domino.ui.button.Button)2 Radio (org.dominokit.domino.ui.forms.Radio)2 RadioGroup (org.dominokit.domino.ui.forms.RadioGroup)2 Select (org.dominokit.domino.ui.forms.Select)2 SelectOption (org.dominokit.domino.ui.forms.SelectOption)2 Column (org.dominokit.domino.ui.grid.Column)2