Example usage for com.vaadin.ui CheckBox CheckBox

List of usage examples for com.vaadin.ui CheckBox CheckBox

Introduction

In this page you can find the example usage for com.vaadin.ui CheckBox CheckBox.

Prototype

public CheckBox() 

Source Link

Document

Creates a new checkbox.

Usage

From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java

private void refreshProfiles(Group g, Layout layoutProfiles) {
    layoutProfiles.removeAllComponents();
    GroupUtils.getAllInterestProfiles(g, UserUtils.getCurrent()).forEach((p, enabled) -> {
        HorizontalLayout layoutProfile = new HorizontalLayout();
        layoutProfile.setWidth("100%");

        CheckBox checkBoxEnabled = new CheckBox();
        checkBoxEnabled.setValue(enabled);
        checkBoxEnabled.addValueChangeListener(v -> {
            GroupInterestProfileUtils.changeEnabled(p, UserUtils.getCurrent(), v.getValue());
            refreshAll(g);//from   w  w  w  .ja  v  a 2 s  .c om
        });

        long subscribers = p.getEnabledUsers().values().stream().filter(v -> v).count();
        Label labelProfileInfo = new Label();
        Language.setCustom(Word.SUBSCRIBERS, s -> {
            String info = p.getName() + " (" + subscribers + " ";
            info += subscribers == 1 ? Language.get(Word.SUBSCRIBER) + ")"
                    : Language.get(Word.SUBSCRIBERS) + ")";
            labelProfileInfo.setValue(info);
        });

        boolean isAdmin = g.getUsers().getOrDefault(UserUtils.getCurrent(), false);

        Button buttonOpen = new Button(VaadinIcons.EXTERNAL_LINK);
        buttonOpen.addClickListener(ce -> {
            UI.getCurrent().addWindow(GroupProfileWindow.show(p, isAdmin, () -> {
            }));
        });

        if (isAdmin) {
            Button buttonRemove = new Button(VaadinIcons.MINUS);
            buttonRemove.addStyleName(ValoTheme.BUTTON_DANGER);
            buttonRemove.addClickListener(ce -> {
                ConfirmationDialog.show(
                        Language.get(Word.REALLY_DELETE_PROFILE).replace("[PROFILE]", p.getName()), () -> {
                            GroupInterestProfileUtils.delete(p);
                            refreshAll(g);
                        });
            });

            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen, buttonRemove);
        } else {
            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen);
        }

        layoutProfile.setExpandRatio(labelProfileInfo, 5);
        layoutProfile.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
        layoutProfile.setComponentAlignment(labelProfileInfo, Alignment.MIDDLE_LEFT);

        layoutProfiles.addComponent(layoutProfile);
    });
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public VerticalLayout createTab(InterestProfile profile) {
    VerticalLayout profileSettingsLayout = new VerticalLayout();
    GridLayout tabContent = new GridLayout(3, 3);

    TextField textFieldName = new TextField();
    Language.set(Word.NAME, textFieldName);
    textFieldName.setWidth("100%");
    textFieldName.setValue(profile.getName());
    textFieldName.setMaxLength(255);//from w w w  .  j  av a 2 s  .  co  m
    CheckBox checkBoxEnabled = new CheckBox();
    checkBoxEnabled.setValue(profile.isEnabled());
    Language.setCustom(Word.ENABLED, s -> checkBoxEnabled.setCaption(s));

    Button buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        InterestProfileUtils.delete(profile);
        accordion.removeTab(accordion.getTab(profileSettingsLayout));
    });

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        InterestProfileUtils.changeName(profile, textFieldName.getValue());
        accordion.getTab(profileSettingsLayout).setCaption(textFieldName.getValue());
        InterestProfileUtils.changeEnabled(profile, checkBoxEnabled.getValue());
        InterestProfileUtils.changeSources(profile, profile.getSources());
        InterestProfileUtils.changeCategories(profile, profile.getCategories());
        InterestProfileUtils.changeAllTags(profile, profile.getTags());
        VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    Label placeholder = new Label();
    Label placeholder2 = new Label();
    placeholder2.setWidth("100%");

    Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML);
    Language.setCustom(Word.HELP_TEXT, s -> labelHelp.setValue(s));
    labelHelp.setWidth("500px");
    PopupView popupHelp = new PopupView(null, labelHelp);

    Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION);
    buttonHelp.addClickListener(ce -> {
        popupHelp.setPopupVisible(true);
    });

    GridLayout footer = new GridLayout(5, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.addComponents(buttonHelp, popupHelp, placeholder, buttonDelete, buttonSave);
    footer.setColumnExpandRatio(2, 5);
    footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    tabContent.addComponents(textFieldName, checkBoxEnabled, placeholder2);
    tabContent.addComponent(getSources(profile), 0, 1, 1, 1);
    tabContent.addComponent(getCategories(profile), 2, 1);
    tabContent.addComponent(getTags(profile), 0, 2, 2, 2);
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    tabContent.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
    profileSettingsLayout.addComponents(tabContent, footer);
    profileSettingsLayout.setMargin(false);
    profileSettingsLayout.setSpacing(false);
    profileSettingsLayout.setWidth("100%");
    return profileSettingsLayout;
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public Component getSources(InterestProfile profile) {
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setWidth("100%");
    VerticalLayout sourcesLayout = new VerticalLayout();
    sourcesLayout.setWidth("100%");
    Panel sourcesPanel = new Panel(sourcesLayout);

    List<CheckBox> checkBoxes = new ArrayList<>();
    HashMap<String, GridLayout> sourceLayouts = new HashMap<>();
    profile.getSources().entrySet().stream()
            .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> {
                Source source = e.getKey();
                boolean enabled = e.getValue();
                GridLayout sourceLayout = new GridLayout(5, 1);
                sourceLayout.setSizeFull();

                CheckBox sourceSelected = new CheckBox();
                sourceSelected.setValue(enabled);
                sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue()));
                checkBoxes.add(sourceSelected);

                Image sourceLogo = new Image();
                sourceLogo.addStyleName("logosmall");
                sourceLogo.setSource(new ExternalResource(source.getLogo()));
                sourceLogo.addClickListener(c -> {
                    sourceSelected.setValue(!sourceSelected.getValue());
                    profile.getSources().replace(source, sourceSelected.getValue());
                });/*from   w  w w . j  a va  2  s. c  o m*/
                VerticalLayout layoutLogo = new VerticalLayout(sourceLogo);
                layoutLogo.setWidth("150px");
                layoutLogo.setHeight("50px");
                layoutLogo.setMargin(false);
                layoutLogo.setSpacing(false);
                layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT);

                Label labelHeadLine = new Label(
                        source.getCategory().getIcon().getHtml() + "  " + source.getName(), ContentMode.HTML);
                labelHeadLine.addStyleName(ValoTheme.LABEL_H3);

                Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                labelDescription.setWidth("300px");
                PopupView popup = new PopupView(null, labelDescription);

                Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O);
                buttonDescription.addClickListener(ce -> {
                    popup.setPopupVisible(true);
                });

                sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription);
                sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER);
                sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER);
                sourceLayout.setColumnExpandRatio(2, 5);
                sourceLayout.setSpacing(true);

                sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                        .replaceAll("_", ""), sourceLayout);
                sourcesLayout.addComponent(sourceLayout);
            });

    sourcesPanel.setContent(sourcesLayout);
    sourcesPanel.setHeight("100%");
    sourcesPanel.setCaption(Language.get(Word.SOURCES));
    Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s));
    windowLayout.addComponent(sourcesPanel);
    windowLayout.setExpandRatio(sourcesPanel, 1);
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);

    CheckBox checkBoxSelectAll = new CheckBox();
    Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s));
    checkBoxSelectAll.setWidth("100%");
    checkBoxSelectAll.addValueChangeListener(e -> {
        profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue());
        checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue()));
    });

    TextField textFieldSearch = new TextField();
    Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s));
    textFieldSearch.setWidth("100%");
    textFieldSearch.setMaxLength(255);
    textFieldSearch.setPlaceholder(Language.get(Word.SEARCH));
    textFieldSearch.addValueChangeListener(searchValue -> {
        sourceLayouts.forEach((sourceName, sourceLayout) -> {
            if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "")
                    .replaceAll("-", "").replaceAll("_", ""))) {
                sourcesLayout.removeComponent(sourceLayout);
            } else {
                sourcesLayout.addComponent(sourceLayout);
            }
        });
    });

    Label placeholder = new Label();
    placeholder.setWidth("100%");

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.addStyleName("menubar");
    footer.setWidth("100%");
    footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder);
    footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT);
    footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(footer);
    windowLayout.setHeight("350px");
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public Component getCategories(InterestProfile profile) {
    Map<Category, Boolean> categories = profile.getCategories();
    VerticalLayout categoriesLayout = new VerticalLayout();
    categoriesLayout.setWidth("100%");
    Panel categoriesPanel = new Panel(categoriesLayout);

    categories.entrySet().stream().sorted((e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName()))
            .forEach(e -> {/*from   w  w w  .j a v a 2 s .  com*/
                Category category = e.getKey();
                boolean enabled = e.getValue();
                GridLayout categoryLayout = new GridLayout(3, 1);
                categoryLayout.setWidth("100%");

                CheckBox categorySelected = new CheckBox();
                categorySelected.setValue(enabled);
                categorySelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                categorySelected.addValueChangeListener(v -> categories.replace(category, v.getValue()));

                Label categoryIcon = new Label(category.getIcon().getHtml(), ContentMode.HTML);
                categoryIcon.addStyleName(ValoTheme.LABEL_H3);
                categoryIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                Label categoryName = new Label(category.getName(), ContentMode.HTML);
                Language.setCustom(null, s -> categoryName.setValue(category.getName()));
                categoryName.addStyleName(ValoTheme.LABEL_H3);
                categoryName.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                categoryLayout.addComponents(categorySelected, categoryIcon, categoryName);
                categoryLayout.setComponentAlignment(categorySelected, Alignment.MIDDLE_CENTER);
                categoryLayout.setComponentAlignment(categoryIcon, Alignment.MIDDLE_LEFT);
                categoryLayout.setComponentAlignment(categoryName, Alignment.MIDDLE_LEFT);
                categoryLayout.setColumnExpandRatio(2, 5);
                categoryLayout.setSpacing(true);

                categoriesLayout.addComponent(categoryLayout);
            });

    categoriesPanel.setContent(categoriesLayout);
    categoriesPanel.setHeight("100%");
    categoriesPanel.setCaption(Language.get(Word.CATEGORIES));
    Language.setCustom(Word.CATEGORIES, s -> categoriesPanel.setCaption(s));

    return categoriesPanel;
}

From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java

public Component getSources(GroupInterestProfile profile, boolean isAdmin) {
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setWidth("100%");
    VerticalLayout sourcesLayout = new VerticalLayout();
    sourcesLayout.setWidth("100%");
    Panel sourcesPanel = new Panel(sourcesLayout);

    List<CheckBox> checkBoxes = new ArrayList<>();
    HashMap<String, GridLayout> sourceLayouts = new HashMap<>();
    profile.getSources().entrySet().stream()
            .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> {
                Source source = e.getKey();
                boolean enabled = e.getValue();
                GridLayout sourceLayout = new GridLayout(5, 1);
                sourceLayout.setSizeFull();

                CheckBox sourceSelected = new CheckBox();
                sourceSelected.setValue(enabled);
                sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue()));
                sourceSelected.setEnabled(isAdmin);
                checkBoxes.add(sourceSelected);

                Image sourceLogo = new Image();
                sourceLogo.addStyleName("logosmall");
                sourceLogo.setSource(new ExternalResource(source.getLogo()));
                if (isAdmin) {
                    sourceLogo.addClickListener(c -> {
                        sourceSelected.setValue(!sourceSelected.getValue());
                        profile.getSources().replace(source, sourceSelected.getValue());
                    });/* w w w.  j  a  v a 2s  .  co  m*/
                }
                VerticalLayout layoutLogo = new VerticalLayout(sourceLogo);
                layoutLogo.setWidth("150px");
                layoutLogo.setHeight("50px");
                layoutLogo.setMargin(false);
                layoutLogo.setSpacing(false);
                layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT);

                Label labelHeadLine = new Label(
                        source.getCategory().getIcon().getHtml() + "  " + source.getName(), ContentMode.HTML);
                labelHeadLine.addStyleName(ValoTheme.LABEL_H3);

                Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                labelDescription.setWidth("300px");
                PopupView popup = new PopupView(null, labelDescription);

                Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O);
                buttonDescription.addClickListener(ce -> {
                    popup.setPopupVisible(true);
                });

                sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription);
                sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER);
                sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER);
                sourceLayout.setColumnExpandRatio(2, 5);
                sourceLayout.setSpacing(true);

                sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                        .replaceAll("_", ""), sourceLayout);
                sourcesLayout.addComponent(sourceLayout);
            });

    sourcesPanel.setContent(sourcesLayout);
    sourcesPanel.setHeight("100%");
    sourcesPanel.setCaption(Language.get(Word.SOURCES));
    Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s));
    windowLayout.addComponent(sourcesPanel);
    windowLayout.setExpandRatio(sourcesPanel, 1);
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);

    CheckBox checkBoxSelectAll = new CheckBox();
    Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s));
    checkBoxSelectAll.setWidth("100%");
    checkBoxSelectAll.addValueChangeListener(e -> {
        profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue());
        checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue()));
    });
    checkBoxSelectAll.setEnabled(isAdmin);

    TextField textFieldSearch = new TextField();
    Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s));
    textFieldSearch.setWidth("100%");
    textFieldSearch.setMaxLength(255);
    textFieldSearch.setPlaceholder(Language.get(Word.SEARCH));
    textFieldSearch.addValueChangeListener(searchValue -> {
        sourceLayouts.forEach((sourceName, sourceLayout) -> {
            if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "")
                    .replaceAll("-", "").replaceAll("_", ""))) {
                sourcesLayout.removeComponent(sourceLayout);
            } else {
                sourcesLayout.addComponent(sourceLayout);
            }
        });
    });

    Label placeholder = new Label();
    placeholder.setWidth("100%");

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.addStyleName("menubar");
    footer.setWidth("100%");
    footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder);
    footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT);
    footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(footer);
    windowLayout.setHeight("350px");
    return windowLayout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.GroupProfileWindow.java

public Component getCategories(GroupInterestProfile profile, boolean isAdmin) {
    Map<Category, Boolean> categories = profile.getCategories();
    VerticalLayout categoriesLayout = new VerticalLayout();
    categoriesLayout.setWidth("100%");
    Panel categoriesPanel = new Panel(categoriesLayout);

    categories.entrySet().stream().sorted((e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName()))
            .forEach(e -> {//from   ww w. j  av  a  2s .co  m
                Category category = e.getKey();
                boolean enabled = e.getValue();
                GridLayout categoryLayout = new GridLayout(3, 1);
                categoryLayout.setWidth("100%");

                CheckBox categorySelected = new CheckBox();
                categorySelected.setValue(enabled);
                categorySelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                categorySelected.addValueChangeListener(v -> categories.replace(category, v.getValue()));
                categorySelected.setEnabled(isAdmin);

                Label categoryIcon = new Label(category.getIcon().getHtml(), ContentMode.HTML);
                categoryIcon.addStyleName(ValoTheme.LABEL_H3);
                categoryIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                Label categoryName = new Label(category.getName(), ContentMode.HTML);
                Language.setCustom(null, s -> categoryName.setValue(category.getName()));
                categoryName.addStyleName(ValoTheme.LABEL_H3);
                categoryName.addStyleName(ValoTheme.LABEL_NO_MARGIN);

                categoryLayout.addComponents(categorySelected, categoryIcon, categoryName);
                categoryLayout.setComponentAlignment(categorySelected, Alignment.MIDDLE_CENTER);
                categoryLayout.setComponentAlignment(categoryIcon, Alignment.MIDDLE_LEFT);
                categoryLayout.setComponentAlignment(categoryName, Alignment.MIDDLE_LEFT);
                categoryLayout.setColumnExpandRatio(2, 5);
                categoryLayout.setSpacing(true);

                categoriesLayout.addComponent(categoryLayout);
            });

    categoriesPanel.setContent(categoriesLayout);
    categoriesPanel.setHeight("100%");
    categoriesPanel.setCaption(Language.get(Word.CATEGORIES));
    Language.setCustom(Word.CATEGORIES, s -> categoriesPanel.setCaption(s));

    return categoriesPanel;
}

From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java

private Component buildClippingsTab(User user) {
    HorizontalLayout root = new HorizontalLayout();
    root.setCaption(Language.get(Word.CLIPPINGS));
    root.setIcon(VaadinIcons.NEWSPAPER);
    root.setWidth("100%");
    root.setSpacing(true);/*from   w ww.j  ava 2 s .  c o  m*/
    root.setMargin(true);

    FormLayout formLayoutClippingDetails = new FormLayout();
    formLayoutClippingDetails.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    root.addComponent(formLayoutClippingDetails);

    CheckBox checkBoxReceiveEmails = new CheckBox();
    checkBoxReceiveEmails.setValue(UserUtils.getEmailNewsletter(user));
    checkBoxReceiveEmails.addValueChangeListener(v -> UserUtils.setEmailNewsletter(user, v.getValue()));
    HorizontalLayout layoutCheckBoxReceiveEmails = new HorizontalLayout(checkBoxReceiveEmails);
    layoutCheckBoxReceiveEmails.setCaption(Language.get(Word.EMAIL_SUBSCRIPTION));
    layoutCheckBoxReceiveEmails.setMargin(false);
    layoutCheckBoxReceiveEmails.setSpacing(false);

    HorizontalLayout layoutAddNewClippingTime = new HorizontalLayout();
    layoutAddNewClippingTime.setMargin(false);
    layoutAddNewClippingTime.setCaption(Language.get(Word.ADD_CLIPPING_TIME));
    layoutAddNewClippingTime.setWidth("100%");

    InlineDateTimeField dateFieldNewClippingTime = new InlineDateTimeField();
    LocalDateTime value = LocalDateTime.now(ZoneId.of("Europe/Berlin"));
    dateFieldNewClippingTime.setValue(value);
    dateFieldNewClippingTime.setLocale(VaadinSession.getCurrent().getLocale());
    dateFieldNewClippingTime.setResolution(DateTimeResolution.MINUTE);
    dateFieldNewClippingTime.addStyleName("time-only");

    Button buttonAddClippingTime = new Button();
    buttonAddClippingTime.setIcon(VaadinIcons.PLUS);
    buttonAddClippingTime.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonAddClippingTime.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttonAddClippingTime.addClickListener(e -> {
        LocalTime generalTime = dateFieldNewClippingTime.getValue().toLocalTime();
        layoutClippingTimes.addComponent(getTimeRow(user, generalTime));
        UserUtils.addClippingSendTime(user, generalTime);
    });
    layoutAddNewClippingTime.addComponents(dateFieldNewClippingTime, buttonAddClippingTime);
    layoutAddNewClippingTime.setComponentAlignment(dateFieldNewClippingTime, Alignment.MIDDLE_LEFT);
    layoutAddNewClippingTime.setComponentAlignment(buttonAddClippingTime, Alignment.MIDDLE_CENTER);
    layoutAddNewClippingTime.setExpandRatio(dateFieldNewClippingTime, 5);

    layoutClippingTimes = new VerticalLayout();
    layoutClippingTimes.setMargin(new MarginInfo(true, false, false, true));
    layoutClippingTimes.setCaption(Language.get(Word.CLIPPING_TIMES));
    layoutClippingTimes.setWidth("100%");
    layoutClippingTimes.addStyleName("times");

    Set<LocalTime> userTimes = user.getClippingTime();
    userTimes.forEach(t -> layoutClippingTimes.addComponent(getTimeRow(user, t)));

    formLayoutClippingDetails.addComponents(layoutCheckBoxReceiveEmails, layoutAddNewClippingTime,
            layoutClippingTimes);

    return root;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterViewImpl.java

License:Open Source License

private void generateUi() {

    setMargin(true);//from w  ww  . j  a va  2  s.  c o  m
    //setSizeFull();
    setLocked(true);
    setStyleName("small");

    // TODO: Zeilenanzahl anpassen
    gridLayout = new GridLayout(3, 30);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    //gridLayout.setSizeFull();

    VerticalLayout infoBox = new VerticalLayout();
    infoBox.setMargin(true);
    Label infoText1 = new Label("<h3>Deterministische Parameter:</h3>");
    infoText1.setContentMode(Label.CONTENT_XHTML);
    Label infoText2 = new Label(
            "Hier geben Sie das Basisjahr an, auf welches die knftigen Cashflows abgezinst werden. "
                    + "Zustzlich mssen Sie auch die Anzahl der einzubeziehenden zuknftigen Perioden ange-ben. "
                    + "Beachten Sie hierbei, dass Sie nur so viele Perioden angeben, "
                    + "wie Sie Daten ber die Cashflows des Unternehmens haben.");
    Label infoText3 = new Label("<h3>Stochastische Parameter:</h3>");
    infoText3.setContentMode(Label.CONTENT_XHTML);
    Label infoText4 = new Label(
            "Hier geben Sie das Basisjahr an, auf welches die knftigen Cashflows abgezinst werden. "
                    + "Zustzlich mssen Sie auch die Anzahl der zu prognostizierenden Perioden angeben. "
                    + "Die Prognose erfolgt auf Basis vergangener Werte, daher mssen Sie auch die Anzahl der ver-gangenen Perioden angeben. "
                    + "Beachten Sie hierbei, dass Sie nur so viele Perioden angeben, wie Sie Daten ber die Cashflows des Unternehmens haben. "
                    + "Des Weiteren haben Sie die Mglichkeit die Anzahl der Wiederholungen anzugeben. "
                    + "Info: Je mehr Iterationen Sie durchfhren lassen, desto genauer werden die Prognosewerte, aber desto lnger dauert die Berechnung.");

    infoBox.addComponent(infoText1);
    infoBox.addComponent(infoText2);
    infoBox.addComponent(infoText3);
    infoBox.addComponent(infoText4);

    setFirstComponent(gridLayout);
    setSecondComponent(infoBox);

    // Heading 1
    labelHeadingCommon = new Label("Allgemein");
    //gridLayout.addComponent(labelHeadingCommon, 0, 0);

    labelBasisYear = new Label("Basisjahr");
    gridLayout.addComponent(labelBasisYear, 0, 1);

    textfieldBasisYear = new TextField();
    textfieldBasisYear.setImmediate(true);
    textfieldBasisYear.setDescription(toolTipBasisYear);
    textfieldBasisYear.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.basisYearChosen((String) textfieldBasisYear.getValue());
        }
    });
    gridLayout.addComponent(textfieldBasisYear, 1, 1);

    // Heading 2
    labelHeadingMethDet = new Label("Stochastische Parameter:");
    gridLayout.addComponent(labelHeadingMethDet, 0, 3);

    labelNumPeriods = new Label("Anzahl zu prognostizierender Perioden");
    gridLayout.addComponent(labelNumPeriods, 0, 4);

    textfieldNumPeriodsToForecast = new TextField();
    textfieldNumPeriodsToForecast.setImmediate(true);
    textfieldNumPeriodsToForecast.setDescription(toolTipNumPeriodsToForecast);
    textfieldNumPeriodsToForecast.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.numberPeriodsToForecastChosen((String) textfieldNumPeriodsToForecast.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPeriodsToForecast, 1, 4);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 4);

    labelIterations = new Label("Durchlufe / Iterationen");
    gridLayout.addComponent(labelIterations, 0, 5);

    textfieldIterations = new TextField();
    textfieldIterations.setImmediate(true);
    // textfieldIterations.setValue(10000);
    textfieldIterations.setDescription(toolTipIterations);
    textfieldIterations.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            logger.debug(textfieldIterations.getValue());
            presenter.iterationChosen((String) textfieldIterations.getValue());
        }
    });
    gridLayout.addComponent(textfieldIterations, 1, 5);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 5);

    labelNumSpecifiedPastPeriods = new Label("Anzahl anzugebender, vergangener Perioden");
    gridLayout.addComponent(labelNumSpecifiedPastPeriods, 0, 6);

    textfieldNumSpecifiedPastPeriods = new TextField();
    textfieldNumSpecifiedPastPeriods.setImmediate(true);
    // textfieldIterations.setValue(10000);
    textfieldNumSpecifiedPastPeriods.setDescription(toolTipNumSpecifiedPastPeriods);
    textfieldNumSpecifiedPastPeriods.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            logger.debug(textfieldNumSpecifiedPastPeriods.getValue());
            presenter.specifiedPastPeriodsChosen((String) textfieldNumSpecifiedPastPeriods.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumSpecifiedPastPeriods, 1, 6);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 6);

    /**
     * Auskommentiert, da nicht fr Zeitreihenanalyse bentigt
     * 
    labelStepsPerPeriod = new Label("Schritte pro Periode");
    gridLayout.addComponent(labelStepsPerPeriod, 0, 6);
            
            
    textfieldStepsPerPeriod = new TextField();
    textfieldStepsPerPeriod.setImmediate(true);
    textfieldStepsPerPeriod.setDescription(toolTipStepsPerPeriod);
    textfieldStepsPerPeriod.addListener(new Property.ValueChangeListener() {
       private static final long serialVersionUID = 1L;
            
       public void valueChange(ValueChangeEvent event) {
    presenter.stepsPerPeriodChosen((String) textfieldStepsPerPeriod
          .getValue());
       }
    });
    gridLayout.addComponent(textfieldStepsPerPeriod, 1, 6);
            
    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 6);
     */
    // Heading 3

    labelHeadingTimeSeries = new Label("Stochastisch: Zeitreihenanalyse");
    //gridLayout.addComponent(labelHeadingTimeSeries, 0, 8);

    labelNumPastPeriods = new Label("Anzahl einbezogener, vergangener Perioden");
    gridLayout.addComponent(labelNumPastPeriods, 0, 9);

    textfieldNumPastPeriods = new TextField();
    textfieldNumPastPeriods.setImmediate(true);
    // textfieldNumPastPeriods: Wert darf hier nicht gesetzt werden
    // -> ber Event, sodass der Wert ins Projekt bernommen wird und nicht
    // nur einfach angezeigt wird ohne ausgewertet werden zu knnen
    // textfieldNumPastPeriods.setValue(5);
    textfieldNumPastPeriods.setDescription(toolTipNumPastPeriods
            + " Bitte beachten Sie, dass in dem Reiter Perioden immer eine Periode mehr angegeben werden muss. Diese zustzliche Periode wird bei einem Berechnungsverfahren der Zeitreihenanalyse bentigt.");
    textfieldNumPastPeriods.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.relevantPastPeriodsChosen((String) textfieldNumPastPeriods.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPastPeriods, 1, 9);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 9);

    checkboxIndustryRepresentative = new CheckBox();
    checkboxIndustryRepresentative.setCaption("Branchenstellvertreter einbeziehen");
    checkboxIndustryRepresentative.setDescription(toolTipIndustryRepresentatives);
    checkboxIndustryRepresentative.addListener(new ClickListener() {
        /**
         * Derzeit unbenutzt, da die Funkionalitaet in der Berechnung noch
         * nicht hinterlegt ist.
         * 
         * @see init()-Methode dieser Klasse
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.industryRepresentativeCheckBoxSelected(checkboxIndustryRepresentative.booleanValue());
        }
    });
    gridLayout.addComponent(checkboxIndustryRepresentative, 0, 10);

    comboBoxRepresentatives = new ComboBox();
    comboBoxRepresentatives.setImmediate(true);
    comboBoxRepresentatives.setInputPrompt("Branche ausw\u00e4hlen");
    comboBoxRepresentatives.setNullSelectionAllowed(false);
    comboBoxRepresentatives.addListener(new Property.ValueChangeListener() {
        /**
         * Derzeit unbenutzt, da die Funkionalitaet in der Berechnung auf
         * Basis von Branchenverreter in dieser Softareversion noch nicht
         * hinterlegt ist.
         * 
         * @see init()-Methode dieser Klasse
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            presenter.industryRepresentativeListItemChosen((String) event.getProperty().getValue());
            logger.debug("Branche " + event + " gewaehlt");
        }
    });

    gridLayout.addComponent(comboBoxRepresentatives, 1, 10);

    // Heading 4

    // Heading 6
    labelHeadingMethDet = new Label("Deterministische Parameter:");
    gridLayout.addComponent(labelHeadingMethDet, 0, 26);
    labelNumPeriods_deterministic = new Label("Anzahl anzugebender Perioden");
    gridLayout.addComponent(labelNumPeriods_deterministic, 0, 27);

    textfieldNumPeriodsToForecast_deterministic = new TextField();
    textfieldNumPeriodsToForecast_deterministic.setImmediate(true);
    textfieldNumPeriodsToForecast_deterministic.setDescription(toolTipNumPeriodsToForecast_deterministic);
    textfieldNumPeriodsToForecast_deterministic.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.numberPeriodsToForecastChosen_deterministic(
                    (String) textfieldNumPeriodsToForecast_deterministic.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPeriodsToForecast_deterministic, 1, 27);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 27);

}

From source file:edu.nps.moves.mmowgli.modules.actionplans.AddImageDialog.java

License:Open Source License

@SuppressWarnings("serial")
@HibernateSessionThreadLocalConstructor/*from w  w w.  jav a2s  .co  m*/
public AddImageDialog(Object apId) {
    super("Add an Image");

    addStyleName("m-greybackground");

    setClosable(false); // no x in corner

    VerticalLayout mainVL = new VerticalLayout();
    mainVL.setSpacing(true);
    mainVL.setMargin(true);
    mainVL.setSizeUndefined(); // auto size
    setContent(mainVL);

    mainHL = new HorizontalLayout();
    mainVL.addComponent(mainHL);

    mainHL.setSpacing(true);

    holder = new AbsoluteLayout();
    mainHL.addComponent(holder);
    holder.setWidth("150px");
    holder.setHeight("150px");
    holder.addStyleName("m-darkgreyborder");

    VerticalLayout rightVL = new VerticalLayout();
    mainHL.addComponent(rightVL);

    fromWebCheck = new CheckBox();
    fromWebCheck.addStyleName("v-radiobutton");
    fromWebCheck.setValue(true);
    fromWebCheck.setImmediate(true);
    fromWebCheck.addValueChangeListener(new RadioListener(fromWebCheck));

    HorizontalLayout frWebHL = new HorizontalLayout();
    rightVL.addComponent(frWebHL);
    frWebHL.addComponent(fromWebCheck);
    VerticalLayout frWebVL = new VerticalLayout();
    frWebVL.setMargin(true);
    frWebVL.addStyleName("m-greyborder");
    frWebHL.addComponent(frWebVL);
    frWebVL.setWidth("370px");

    frWebVL.addComponent(new Label("From the web:"));
    HorizontalLayout webHL = new HorizontalLayout();
    webHL.setSpacing(true);
    frWebVL.addComponent(webHL);
    webHL.addComponent(webUrl = new TextField());
    webUrl.setColumns(21);
    webHL.addComponent(testButt = new Button("Test"));
    Label sp;
    webHL.addComponent(sp = new Label());
    sp.setWidth("1px");
    webHL.setExpandRatio(sp, 1.0f);

    fromDeskCheck = new CheckBox();
    fromDeskCheck.addStyleName("v-radiobutton");
    fromDeskCheck.setValue(false);
    fromDeskCheck.addValueChangeListener(new RadioListener(fromDeskCheck));
    fromDeskCheck.setImmediate(true);
    HorizontalLayout dtHL = new HorizontalLayout();
    rightVL.addComponent(dtHL);
    dtHL.addComponent(fromDeskCheck);

    VerticalLayout dtopVL = new VerticalLayout();
    dtopVL.setMargin(true);
    dtopVL.addStyleName("m-greyborder");
    dtHL.addComponent(dtopVL);
    dtopVL.setWidth("370px");
    dtopVL.addComponent(new Label("From your desktop:"));
    HorizontalLayout localHL = new HorizontalLayout();
    localHL.setSpacing(true);
    dtopVL.addComponent(localHL);
    localHL.addComponent(localTF = new TextField());
    localTF.setColumns(21);
    localHL.addComponent(uploadWidget = new Upload());
    panel = new UploadStatus(uploadWidget);
    uploadWidget.setButtonCaption("Browse");

    File tempDir = Files.createTempDir();
    tempDir.deleteOnExit();
    handler = new UploadHandler(uploadWidget, panel, tempDir.getAbsolutePath());
    uploadWidget.setReceiver(handler);
    uploadWidget.setImmediate(true);
    panel.setWidth("100%");
    dtopVL.addComponent(panel);
    dtopVL.setComponentAlignment(panel, Alignment.TOP_CENTER);

    HorizontalLayout bottomHL = new HorizontalLayout();
    mainVL.addComponent(bottomHL);
    bottomHL.setSpacing(true);
    bottomHL.setWidth("100%");
    Label spacer;
    bottomHL.addComponent(spacer = new Label());
    spacer.setWidth("100%");
    bottomHL.setExpandRatio(spacer, 1.0f);

    bottomHL.addComponent(cancelButt = new Button("Cancel"));
    bottomHL.addComponent(submitButt = new Button("Add"));
    setDisabledFields();

    uploadWidget.addFinishedListener(new FinishedListener() {
        @Override
        public void uploadFinished(FinishedEvent event) {
            Object key = HSess.checkInit();
            System.out.println("AddImageDialog.uploadFinished()");
            String fpath = handler.getFullUploadedPath();
            if (fpath != null) { // error of some kind if null 
                if (!MalwareChecker.isFileVirusFree(fpath)) {
                    panel.state.setValue("<span style='color:red;'>Failed malware check</span>");
                    fpath = null;
                    localTF.setValue("");
                    HSess.checkClose(key);
                    return;
                }

                File f = new File(fpath);
                f.deleteOnExit();

                try {
                    MediaImage mediaImage = InstallImageDialog.putFileImageIntoDbTL(f, f.getName(),
                            event.getMIMEType());
                    f.delete();
                    media = mediaImage.media;
                    image = mediaImage.image;
                    media.setCaption(null);
                    Resource res = Mmowgli2UI.getGlobals().getMediaLocator().locate(media);
                    setupEmbeddedImageThumbnail(res, media);
                    localTF.setValue(event.getFilename());
                } catch (IOException ex) {
                    Notification.show("Error loading image", Notification.Type.ERROR_MESSAGE);
                    MSysOut.println(ERROR_LOGS, "Error in AddImageDialog loading image: "
                            + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
                }
            }
            HSess.checkClose(key);
        }
    });

    testButt.addClickListener(new testWebImageHandler());

    submitButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (fromWebCheck.getValue()) {
                if (checkBadUrl(webUrl.getValue(), event.getButton()))
                    return;
            }
            UI.getCurrent().removeWindow(AddImageDialog.this);
            if (closer != null)
                closer.windowClose(null);
        }
    });
    cancelButt.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            Object key = HSess.checkInit();
            if (media != null) {
                Media.deleteTL(media);
                media = null;
            }
            if (image != null) {
                Image.deleteTL(image);
                image = null;
            }
            uploadWidget.interruptUpload();
            UI.getCurrent().removeWindow(AddImageDialog.this);
            if (closer != null)
                closer.windowClose(null);

            HSess.checkClose(key);
        }
    });

    webUrl.focus();
}

From source file:edu.nps.moves.mmowgli.modules.administration.AbstractGameBuilderPanel.java

License:Open Source License

protected EditLine addEditBoolean(String name, String info, Object dbObj, Object dbObjId, String dbObjFieldName,
        MoveListener lis, String tooltip) {
    CheckBox cb = new CheckBox();
    cb.setReadOnly(globals.readOnlyCheck(false));

    EditLine edLine = getLineData(dbObj);
    edLine.name = name;/*from  ww  w. ja va 2 s.  c om*/
    edLine.info = info;
    edLine.ta = cb;
    edLine.fieldName = dbObjFieldName;
    edLine.objId = dbObjId;
    edLine.listener = lis;
    edLine.setTooltip(tooltip);
    lines.add(edLine);
    populateEditLine(edLine);
    return edLine;
}