Search in sources :

Example 41 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project ArchCNL by Mari-Wie.

the class DefaultStatementComponent method initializeLayout.

private void initializeLayout() {
    createCondtionComponent();
    horizontalRowLayout = new HorizontalLayout();
    componentRuleLayout = new HorizontalLayout();
    initializeFirstCombobox();
    createRelationComboBox();
    three_secondCombobox = new ComboBox<String>("Modifier", secondModifierList);
    three_secondCombobox.setValue("a");
    three_secondCombobox.addValueChangeListener(e -> {
        determineState();
    });
    Set<String> regexSet = new HashSet<>();
    regexSet.add(CHAR_REGEX);
    regexSet.add(INTEGER_REGEX);
    four_secondVariable = new VariableTextfieldWidget(regexSet);
    four_secondVariable.setPlaceholder("+/- [0-9] / String");
    four_secondVariable.setLabel("Integer or String");
    createConceptComboBox();
    six_addConditionCheckbox = new Checkbox("that... (add condition)");
    six_addConditionCheckbox.addClickListener(e -> showConditionBlock(six_addConditionCheckbox.getValue()));
    componentRuleLayout.setVerticalComponentAlignment(Alignment.END, six_addConditionCheckbox);
    buildingBlock = new Component[6];
    buildingBlock[0] = one_firstCombobox;
    buildingBlock[1] = two_firstVariable;
    buildingBlock[2] = three_secondCombobox;
    buildingBlock[3] = four_secondVariable;
    buildingBlock[4] = five_thirdVariable;
    buildingBlock[5] = six_addConditionCheckbox;
    horizontalRowLayout.add(componentRuleLayout);
    initializeAndOrButtons();
    add(horizontalRowLayout);
}
Also used : VariableTextfieldWidget(org.archcnl.ui.inputview.rulesormappingeditorview.architectureruleeditor.components.textfieldwidgets.VariableTextfieldWidget) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) HashSet(java.util.HashSet)

Example 42 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project komunumo-server by komunumo.

the class EventDialog method createForm.

// just a lot of fields for the form
@SuppressWarnings("checkstyle:MethodLength")
@Override
public void createForm(@NotNull final FormLayout formLayout, @NotNull final Binder<Event> binder) {
    final var type = new Select<>(EventType.values());
    final var title = new TextField("Title");
    final var subtitle = new TextField("Subtitle");
    final var speaker = new MultiselectComboBox<EventSpeakerEntity>("Speaker");
    final var organizer = new MultiselectComboBox<Member>("Organizer");
    final var description = new RichTextEditor();
    final var keyword = new MultiselectComboBox<KeywordEntity>("Keyword");
    final var agenda = new RichTextEditor();
    final var level = new Select<>(EventLevel.values());
    final var language = new Select<>(EventLanguage.values());
    final var room = new TextField("Room");
    final var travelInstructions = new TextField("Travel instructions");
    final var location = new ComboBox<String>("Location");
    final var webinarUrl = new TextField("Webinar URL");
    final var youtTube = new TextField("YouTube");
    final var date = new DateTimePicker("Date & Time");
    final var duration = new TimePicker("Duration");
    final var eventUrl = new TextField("Event URL");
    final var attendeeLimit = new IntegerField("Attendee limit (0 = no limit)");
    final var membersOnly = new Checkbox("Members only");
    final var published = new Checkbox("Published");
    type.setLabel("Type");
    type.setRequiredIndicatorVisible(true);
    title.setRequiredIndicatorVisible(true);
    title.setValueChangeMode(EAGER);
    title.addValueChangeListener(changeEvent -> {
        if (eventUrl.getValue().equals(URLUtil.createReadableUrl(changeEvent.getOldValue()))) {
            eventUrl.setValue(URLUtil.createReadableUrl(changeEvent.getValue()));
        }
    });
    subtitle.setValueChangeMode(EAGER);
    speaker.setOrdered(true);
    speaker.setItemLabelGenerator(EventSpeakerEntity::fullName);
    speaker.setItems(databaseService.getAllEventSpeakers());
    organizer.setOrdered(true);
    organizer.setItemLabelGenerator(value -> String.format("%s %s", value.getFirstName(), value.getLastName()));
    organizer.setItems(databaseService.getAllAdmins());
    organizer.setRequiredIndicatorVisible(true);
    keyword.setOrdered(true);
    keyword.setItemLabelGenerator(KeywordEntity::keyword);
    keyword.setItems(databaseService.getAllKeywords());
    level.setLabel("Level");
    language.setLabel("Language");
    location.setItems(databaseService.getAllEventLocations());
    location.setAllowCustomValue(true);
    location.addValueChangeListener(changeEvent -> {
        final var value = changeEvent.getValue();
        final var isOnline = "Online".equalsIgnoreCase(value);
        webinarUrl.setEnabled(isOnline);
        webinarUrl.setRequiredIndicatorVisible(published.getValue() && isOnline);
        room.setRequiredIndicatorVisible(!isOnline);
        updateEventUrlPrefix(location, date, eventUrl);
        binder.validate();
    });
    room.setValueChangeMode(EAGER);
    travelInstructions.setValueChangeMode(EAGER);
    webinarUrl.setValueChangeMode(EAGER);
    date.setMin(LocalDateTime.now());
    date.addValueChangeListener(changeEvent -> updateEventUrlPrefix(location, date, eventUrl));
    duration.setStep(Duration.ofMinutes(15));
    duration.setMin(LocalTime.of(1, 0));
    duration.setMax(LocalTime.of(3, 0));
    eventUrl.setValueChangeMode(EAGER);
    updateEventUrlPrefix(location, date, eventUrl);
    attendeeLimit.setMin(0);
    attendeeLimit.setMax(500);
    attendeeLimit.setStep(10);
    attendeeLimit.setHasControls(true);
    published.addValueChangeListener(changeEvent -> {
        final var value = changeEvent.getValue();
        speaker.setRequiredIndicatorVisible(value);
        level.setRequiredIndicatorVisible(value);
        description.setRequiredIndicatorVisible(value);
        language.setRequiredIndicatorVisible(value);
        location.setRequiredIndicatorVisible(value);
        room.setRequiredIndicatorVisible(!"Online".equalsIgnoreCase(location.getValue()));
        date.setRequiredIndicatorVisible(value);
        duration.setRequiredIndicatorVisible(value);
        eventUrl.setRequiredIndicatorVisible(value);
        binder.validate();
    });
    formLayout.add(type, title, subtitle, speaker, organizer, level, new CustomLabel("Description"), description, keyword, new CustomLabel("Agenda"), agenda, language, location, room, travelInstructions, webinarUrl, youtTube, date, duration, eventUrl, attendeeLimit, membersOnly, published);
    binder.forField(type).withValidator(value -> !published.getValue() || value != null, "Please select a type").bind(Event::getType, Event::setType);
    binder.forField(title).withValidator(new StringLengthValidator("Please enter a title (max. 255 chars)", 1, 255)).bind(Event::getTitle, Event::setTitle);
    binder.forField(subtitle).withValidator(new StringLengthValidator("The subtitle is too long (max. 255 chars)", 0, 255)).bind(Event::getSubtitle, Event::setSubtitle);
    binder.forField(speaker).withValidator(value -> !published.getValue() || !value.isEmpty(), "Please select at least one speaker").bind(this::getSpeakers, this::setSpeakers);
    binder.forField(organizer).withValidator(value -> !value.isEmpty(), "Please select at least one organizer").bind(this::getOrganizer, this::setOrganizer);
    binder.forField(level).withValidator(value -> !published.getValue() || value != null, "Please select a level").bind(Event::getLevel, Event::setLevel);
    binder.forField(description.asHtml()).withValidator(value -> !published.getValue() || value != null && !value.isBlank(), "Please enter a description").bind(Event::getDescription, Event::setDescription);
    binder.forField(keyword).bind(this::getKeyword, this::setKeyword);
    binder.forField(agenda.asHtml()).bind(Event::getAgenda, Event::setAgenda);
    binder.forField(language).withValidator(value -> !published.getValue() || value != null, "Please select a language").bind(Event::getLanguage, Event::setLanguage);
    binder.forField(location).withValidator(value -> !published.getValue() || value != null, "Please select a location").bind(Event::getLocation, Event::setLocation);
    binder.forField(room).withValidator(value -> !published.getValue() || "Online".equalsIgnoreCase(location.getValue()) || !value.isBlank(), "Please enter a room").bind(Event::getRoom, Event::setRoom);
    binder.forField(travelInstructions).withValidator(value -> value.isBlank() || URLUtil.isValid(value), "Please enter a valid URL").bind(Event::getTravelInstructions, Event::setTravelInstructions);
    binder.forField(webinarUrl).withValidator(value -> !published.getValue() || !"Online".equalsIgnoreCase(location.getValue()) || URLUtil.isValid(value), "Please enter a valid URL").bind(Event::getWebinarUrl, Event::setWebinarUrl);
    binder.forField(youtTube).bind(Event::getYoutube, Event::setYoutube);
    binder.forField(date).withValidator(value -> isPastEvent(date) || !published.getValue() && (value == null || value.isAfter(LocalDateTime.now())) || value != null && value.isAfter(LocalDateTime.now()), "Please enter a date and time in the future").bind(Event::getDate, Event::setDate);
    binder.forField(duration).withValidator(value -> !published.getValue() || (value != null && value.isAfter(LocalTime.MIN) && value.isBefore(LocalTime.MAX)), "Please enter a duration").bind(Event::getDuration, Event::setDuration);
    // TODO check for duplicates
    binder.forField(eventUrl).withValidator(value -> !published.getValue() || value != null && !value.isBlank(), "Please enter a valid event URL").bind(Event::getEventUrl, Event::setEventUrl);
    binder.forField(attendeeLimit).bind(Event::getAttendeeLimit, Event::setAttendeeLimit);
    binder.forField(membersOnly).bind(Event::getMembersOnly, Event::setMembersOnly);
    binder.forField(published).bind(Event::getPublished, Event::setPublished);
    afterOpen = () -> {
        webinarUrl.setEnabled("Online".equalsIgnoreCase(location.getValue()));
        if (isPastEvent(date)) {
            binder.setReadOnly(true);
            binder.setValidatorsDisabled(true);
            youtTube.setReadOnly(false);
        }
    };
}
Also used : Member(org.komunumo.data.entity.Member) EventLevel(org.komunumo.data.db.enums.EventLevel) Event(org.komunumo.data.entity.Event) CustomLabel(org.komunumo.ui.component.CustomLabel) Select(com.vaadin.flow.component.select.Select) Binder(com.vaadin.flow.data.binder.Binder) LocalDateTime(java.time.LocalDateTime) ComboBox(com.vaadin.flow.component.combobox.ComboBox) EditDialog(org.komunumo.ui.component.EditDialog) KeywordEntity(org.komunumo.data.entity.KeywordEntity) EventLanguage(org.komunumo.data.db.enums.EventLanguage) AuthenticatedUser(org.komunumo.security.AuthenticatedUser) MultiselectComboBox(org.vaadin.gatanaso.MultiselectComboBox) IntegerField(com.vaadin.flow.component.textfield.IntegerField) Duration(java.time.Duration) LocalTime(java.time.LocalTime) TextField(com.vaadin.flow.component.textfield.TextField) EAGER(com.vaadin.flow.data.value.ValueChangeMode.EAGER) URLUtil(org.komunumo.util.URLUtil) Set(java.util.Set) TimePicker(com.vaadin.flow.component.timepicker.TimePicker) EventSpeakerEntity(org.komunumo.data.entity.EventSpeakerEntity) Collectors(java.util.stream.Collectors) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) Nullable(org.jetbrains.annotations.Nullable) DatabaseService(org.komunumo.data.service.DatabaseService) RichTextEditor(com.vaadin.flow.component.richtexteditor.RichTextEditor) Year(java.time.Year) NotNull(org.jetbrains.annotations.NotNull) Callback(org.komunumo.Callback) DateTimePicker(org.komunumo.ui.component.DateTimePicker) Span(com.vaadin.flow.component.html.Span) EventType(org.komunumo.data.db.enums.EventType) TimePicker(com.vaadin.flow.component.timepicker.TimePicker) DateTimePicker(org.komunumo.ui.component.DateTimePicker) CustomLabel(org.komunumo.ui.component.CustomLabel) MultiselectComboBox(org.vaadin.gatanaso.MultiselectComboBox) EventSpeakerEntity(org.komunumo.data.entity.EventSpeakerEntity) ComboBox(com.vaadin.flow.component.combobox.ComboBox) MultiselectComboBox(org.vaadin.gatanaso.MultiselectComboBox) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) IntegerField(com.vaadin.flow.component.textfield.IntegerField) DateTimePicker(org.komunumo.ui.component.DateTimePicker) KeywordEntity(org.komunumo.data.entity.KeywordEntity) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Select(com.vaadin.flow.component.select.Select) TextField(com.vaadin.flow.component.textfield.TextField) Event(org.komunumo.data.entity.Event) RichTextEditor(com.vaadin.flow.component.richtexteditor.RichTextEditor)

Example 43 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project komunumo-server by komunumo.

the class MemberDialog method createForm.

@Override
public void createForm(@NotNull final FormLayout formLayout, @NotNull final Binder<Member> binder) {
    final var firstName = new TextField("First name");
    final var lastName = new TextField("Last name");
    final var company = new TextField("Company");
    final var email = new EmailField("Email");
    final var active = new Checkbox("Active");
    final var address = new TextField("Address");
    final var zipCode = new TextField("Zip code");
    final var city = new TextField("City");
    final var state = new TextField("State");
    final var country = new TextField("Country");
    final var admin = new Checkbox("Member is Admin");
    final var blocked = new Checkbox("Account Blocked");
    final var blockedReason = new TextField("Reason");
    final var comment = new TextArea("Comment");
    firstName.setRequiredIndicatorVisible(true);
    firstName.setValueChangeMode(EAGER);
    lastName.setRequiredIndicatorVisible(true);
    lastName.setValueChangeMode(EAGER);
    blocked.addValueChangeListener(event -> {
        final var isBlocked = event.getValue();
        blockedReason.setEnabled(isBlocked);
        blockedReason.setRequiredIndicatorVisible(isBlocked);
        if (isBlocked) {
            blockedReason.focus();
        } else {
            blockedReason.setValue("");
        }
        binder.validate();
    });
    blockedReason.setValueChangeMode(EAGER);
    blockedReason.setEnabled(false);
    formLayout.add(firstName, lastName, company, email, active, address, zipCode, city, state, country, admin, blocked, blockedReason, comment);
    binder.forField(firstName).withValidator(new StringLengthValidator("Please enter the first name of the member (max. 255 chars)", 1, 255)).bind(Member::getFirstName, Member::setFirstName);
    binder.forField(lastName).withValidator(new StringLengthValidator("Please enter the last name of the member (max. 255 chars)", 1, 255)).bind(Member::getLastName, Member::setLastName);
    binder.forField(company).bind(Member::getCompany, Member::setCompany);
    binder.forField(email).withValidator(new EmailValidator("Please enter a correct email address or leave this field empty", true)).withValidator(new StringLengthValidator("The email address is too long (max. 255 chars)", 0, 255)).bind(Member::getEmail, Member::setEmail);
    binder.forField(active).bind(Member::getAccountActive, Member::setAccountActive);
    binder.forField(address).withValidator(new StringLengthValidator("The address is too long (max. 255 chars)", 0, 255)).bind(Member::getAddress, Member::setAddress);
    binder.forField(zipCode).withValidator(new StringLengthValidator("The zip code is too long (max. 255 chars)", 0, 255)).bind(Member::getZipCode, Member::setZipCode);
    binder.forField(city).withValidator(new StringLengthValidator("The city is too long (max. 255 chars)", 0, 255)).bind(Member::getCity, Member::setCity);
    binder.forField(state).withValidator(new StringLengthValidator("The state is too long (max. 255 chars)", 0, 255)).bind(Member::getState, Member::setState);
    binder.forField(country).withValidator(new StringLengthValidator("The country is too long (max. 255 chars)", 0, 255)).bind(Member::getCountry, Member::setCountry);
    binder.forField(admin).bind(Member::getAdmin, Member::setAdmin);
    binder.forField(blocked).bind(Member::getAccountBlocked, Member::setAccountBlocked);
    binder.forField(blockedReason).withValidator(value -> !blocked.getValue() || blocked.getValue() && !value.isBlank(), "If you want to block this member, you must enter a reason").withValidator(new StringLengthValidator("The reason is too long (max. 255 chars)", 0, 255)).bind(Member::getAccountBlockedReason, Member::setAccountBlockedReason);
    binder.forField(comment).bind(Member::getComment, Member::setComment);
}
Also used : EmailValidator(com.vaadin.flow.data.validator.EmailValidator) TextArea(com.vaadin.flow.component.textfield.TextArea) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) EmailField(com.vaadin.flow.component.textfield.EmailField) TextField(com.vaadin.flow.component.textfield.TextField) Member(org.komunumo.data.entity.Member)

Example 44 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project SODevelopment by syampillai.

the class ProcessCheckList method process.

@Override
protected boolean process() {
    ArrayList<AbstractCheckList> modified = new ArrayList<>();
    AbstractCheckList node;
    Date date;
    boolean completed;
    for (Object[] row : items) {
        if (((DateField) row[1]).isReadOnly()) {
            continue;
        }
        node = (AbstractCheckList) row[0];
        completed = ((Checkbox) row[2]).getValue();
        date = ((DateField) row[1]).getValue();
        if (node.getCompleted() == completed && date.compareTo(node.getCompletedOn()) == 0) {
            continue;
        }
        node.setCompletedOn(date);
        node.setCompleted(completed);
        modified.add(node);
    }
    if (modified.isEmpty()) {
        message("No changes done");
        return true;
    }
    completed = transact(t -> {
        for (AbstractCheckList m : modified) {
            m.save(t);
        }
    });
    if (!completed) {
        return true;
    }
    // noinspection SuspiciousMethodCalls
    items.removeIf(r -> modified.contains(r[0]));
    modified.clear();
    items.removeIf(r -> {
        AbstractCheckList item = (AbstractCheckList) r[0];
        if (item.getCompleted() == item.checkCompleteness()) {
            return true;
        }
        modified.add(item);
        return false;
    });
    transact(t -> {
        for (AbstractCheckList m : modified) {
            m.save(t);
        }
    });
    return true;
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox) DateUtility(com.storedobject.core.DateUtility) com.storedobject.ui(com.storedobject.ui) DateField(com.storedobject.vaadin.DateField) GridLayout(com.storedobject.vaadin.GridLayout) AbstractCheckList(com.storedobject.core.AbstractCheckList) HasComponents(com.vaadin.flow.component.HasComponents) DataForm(com.storedobject.vaadin.DataForm) Date(java.sql.Date) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) DateField(com.storedobject.vaadin.DateField) AbstractCheckList(com.storedobject.core.AbstractCheckList) Date(java.sql.Date)

Example 45 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project SODevelopment by syampillai.

the class TransferMaterial method addExtraButtons.

@Override
protected void addExtraButtons() {
    super.addExtraButtons();
    Checkbox h = new Checkbox("Include History");
    h.addValueChangeListener(e -> setFixedFilter(e.getValue() ? null : "Status<2"));
    buttonPanel.add(h);
    setFixedFilter("Status<2");
}
Also used : Checkbox(com.vaadin.flow.component.checkbox.Checkbox)

Aggregations

Checkbox (com.vaadin.flow.component.checkbox.Checkbox)68 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)16 Div (com.vaadin.flow.component.html.Div)14 TextField (com.vaadin.flow.component.textfield.TextField)14 Route (com.vaadin.flow.router.Route)14 Button (com.vaadin.flow.component.button.Button)12 Grid (com.vaadin.flow.component.grid.Grid)12 Label (com.vaadin.flow.component.html.Label)12 Collectors (java.util.stream.Collectors)10 Component (com.vaadin.flow.component.Component)8 NativeButton (com.vaadin.flow.component.html.NativeButton)8 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)8 Optional (java.util.Optional)8 Binder (com.vaadin.flow.data.binder.Binder)7 EmailValidator (com.vaadin.flow.data.validator.EmailValidator)7 Set (java.util.Set)7 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)6 PageTitle (io.imunity.furms.ui.components.PageTitle)6 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)6 DateTimeFormatter (java.time.format.DateTimeFormatter)6