Example usage for com.vaadin.ui GridLayout GridLayout

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

Introduction

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

Prototype

public GridLayout(int columns, int rows) 

Source Link

Document

Constructor for a grid of given size (number of columns and rows).

Usage

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

public void refreshSources() {
    sourcesLayout.removeAllComponents();
    SourceUtils.getSources().stream().sorted((s1, s2) -> s1.getName().compareToIgnoreCase(s2.getName()))
            .forEach(source -> {// w w  w  .j  a va  2  s  . c  o  m
                try {
                    GridLayout sourceLayout = new GridLayout(4, 1);
                    sourceLayout.setSizeFull();

                    Image sourceLogo = new Image();
                    URL url = source.getLogo();
                    if (url != null) {
                        sourceLogo.setSource(new ExternalResource(url));
                    }
                    sourceLogo.setWidth("150px");

                    VerticalLayout sourceText = new VerticalLayout();
                    sourceText.setSizeFull();

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

                    Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                    labelDescription.addStyleName(ValoTheme.LABEL_SMALL);
                    labelDescription.setWidth("100%");

                    sourceText.setMargin(false);
                    sourceText.addComponents(labelHeadLine, labelDescription);

                    Button buttonEdit = new Button(VaadinIcons.EDIT);
                    buttonEdit.addStyleName(ValoTheme.BUTTON_PRIMARY);
                    buttonEdit.addClickListener(
                            ce -> UI.getCurrent().addWindow(NewSourceWindow.createEditMode(source)));

                    Button buttonDelete = new Button(VaadinIcons.TRASH);
                    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
                    buttonDelete.addClickListener(ce -> {
                        sourcesLayout.removeComponent(sourceLayout);
                        sourceLayouts.remove(source.getName().toLowerCase().replaceAll(" ", "")
                                .replaceAll("-", "").replaceAll("_", ""));
                        SourceUtils.removeSource(source);
                    });

                    sourceLayout.addComponents(sourceLogo, sourceText, buttonEdit, buttonDelete);
                    sourceLayout.setComponentAlignment(sourceLogo, Alignment.MIDDLE_CENTER);
                    sourceLayout.setComponentAlignment(buttonEdit, Alignment.MIDDLE_CENTER);
                    sourceLayout.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
                    sourceLayout.setColumnExpandRatio(1, 5);
                    sourceLayout.setSpacing(true);

                    sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                            .replaceAll("_", ""), sourceLayout);
                    sourcesLayout.addComponent(sourceLayout);
                } catch (Exception e) {
                    Log.error("Skipping Source! ", e);
                }
            });
}

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

public Component getThirdStage(Source s) {
    Label header = new Label(Language.get(Word.CRAWLER));
    header.addStyleName(ValoTheme.LABEL_H1);

    Crawler crawler;/* ww w. ja  v  a2 s  .  com*/
    if (s.getCrawler() != null) {
        crawler = s.getCrawler();
    } else {
        crawler = new Crawler(s);
        s.setCrawler(crawler);
    }

    GridLayout mainGrid = new GridLayout(2, 2);
    mainGrid.setSizeFull();
    mainGrid.setSpacing(true);

    FormLayout layoutForms = new FormLayout();

    //Exclude or Include
    RadioButtonGroup<Boolean> radios = new RadioButtonGroup<>();
    radios.setItems(true, false);
    radios.setItemCaptionGenerator(b -> b ? Language.get(Word.INCLUDE_TAGS) : Language.get(Word.EXCLUDE_TAGS));
    radios.setItemIconGenerator(b -> b ? VaadinIcons.CHECK : VaadinIcons.CLOSE);
    radios.setSelectedItem(true);
    radios.addValueChangeListener(event -> include = event.getValue());

    //By Class
    CssLayout addByClassGroup = new CssLayout();
    addByClassGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByClass = new TextField();
    textFieldAddByClass.setWidth("465px");
    Button buttonAddByClass = new Button(VaadinIcons.PLUS);
    buttonAddByClass.addClickListener(e -> {
        crawler.addByClass(textFieldAddByClass.getValue(), include);
        refreshList(mainGrid, crawler);
        textFieldAddByClass.clear();
    });
    addByClassGroup.addComponents(textFieldAddByClass, buttonAddByClass);
    addByClassGroup.setCaption(Language.get(Word.BYCLASS));

    //ByTag
    CssLayout addByTagGroup = new CssLayout();
    addByTagGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByTag = new TextField();
    Button buttonAddByTag = new Button(VaadinIcons.PLUS);
    textFieldAddByTag.setWidth("465px");
    buttonAddByTag.addClickListener(e -> {
        crawler.addByTag(textFieldAddByTag.getValue(), include);
        refreshList(mainGrid, crawler);
        textFieldAddByTag.clear();
    });
    addByTagGroup.addComponents(textFieldAddByTag, buttonAddByTag);
    addByTagGroup.setCaption(Language.get(Word.BYTAG));

    //ByID
    CssLayout addByIDGroup = new CssLayout();
    addByIDGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByID = new TextField();
    textFieldAddByID.setWidth("465px");
    Button buttonAddByID = new Button(VaadinIcons.PLUS);
    buttonAddByID.addClickListener(e -> {
        crawler.addByID(textFieldAddByID.getValue(), include);
        refreshList(mainGrid, crawler);
        textFieldAddByID.clear();
    });
    addByIDGroup.addComponents(textFieldAddByID, buttonAddByID);
    addByIDGroup.setCaption(Language.get(Word.BYID));

    //ByAttribute
    CssLayout addByAttributeGroup = new CssLayout();
    addByAttributeGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    TextField textFieldAddByAttributeKey = new TextField();
    textFieldAddByAttributeKey.setWidth("233px");
    TextField textFieldAddByAttributeValue = new TextField();
    textFieldAddByAttributeValue.setWidth("232px");
    Button buttonAddByAttribute = new Button(VaadinIcons.PLUS);
    buttonAddByAttribute.addClickListener(e -> {
        crawler.addByAttribute(textFieldAddByAttributeKey.getValue(), textFieldAddByAttributeValue.getValue(),
                include);
        refreshList(mainGrid, crawler);
        textFieldAddByAttributeKey.clear();
        textFieldAddByAttributeValue.clear();
    });
    addByAttributeGroup.addComponents(textFieldAddByAttributeKey, textFieldAddByAttributeValue,
            buttonAddByAttribute);
    addByAttributeGroup.setCaption(Language.get(Word.BYATTRIBUTEVALUE));

    layoutForms.addComponents(radios, addByClassGroup, addByTagGroup, addByIDGroup, addByAttributeGroup);
    mainGrid.addComponent(layoutForms);

    Label labelResult = new Label();
    Panel panelResult = new Panel(labelResult);
    labelResult.setWidth("100%");
    panelResult.setWidth("100%");
    panelResult.setHeight("175px");
    mainGrid.addComponent(panelResult, 0, 1, 1, 1);

    Button buttonTestURL = new Button();
    buttonTestURL.setIcon(VaadinIcons.EXTERNAL_LINK);
    buttonTestURL.setCaption(Language.get(Word.OPEN_LINK));

    Button buttonTest = new Button(Language.get(Word.TEST), VaadinIcons.CLIPBOARD_CHECK);
    buttonTest.addClickListener(ce -> {
        Article a = CrawlerUtils.executeRandom(crawler);
        labelResult.setValue(a.getBody());
        if (reg != null) {
            reg.remove();
        }
        reg = buttonTestURL
                .addClickListener(cev -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false));
    });

    refreshList(mainGrid, crawler);

    Runnable cancel = () -> close();
    Runnable next = () -> validateThirdStage(s);

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.addComponents(header, mainGrid, getFooter(cancel, next, buttonTest, buttonTestURL));
    windowLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    windowLayout.setExpandRatio(mainGrid, 5);
    windowLayout.setWidth("1250px");
    return windowLayout;
}

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

/**
 * Value is optional/*from ww  w  . j av  a  2 s.  c o  m*/
 *
 * @param action
 * @param content
 * @param value
 * @return
 */
private Component getRow(Layout parent, Runnable onDelete, String action, String content, String value) {
    Panel panelRow = new Panel();
    GridLayout layoutRow = new GridLayout(2, 1);

    Label labelInfo = new Label("", ContentMode.HTML);
    String stringInfo = action.toUpperCase() + "<br>";
    if (value != null) {
        stringInfo += content + " = " + value;
    } else {
        stringInfo += content + " ";
    }
    labelInfo.setValue(stringInfo);

    Button buttonDelete = new Button(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        onDelete.run();
        parent.removeComponent(panelRow);
    });

    layoutRow.addComponents(labelInfo, buttonDelete);
    layoutRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_RIGHT);
    layoutRow.setComponentAlignment(labelInfo, Alignment.MIDDLE_LEFT);
    layoutRow.setWidth("100%");
    layoutRow.setMargin(true);
    layoutRow.addStyleName("crawler");
    panelRow.setContent(layoutRow);
    panelRow.setWidth("100%");
    return panelRow;
}

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

public Component getFooter(Runnable cancelRunnable, Runnable nextRunnable, Component... extraComponents) {
    Label placeholder = new Label();
    Button cancel = new Button(Language.get(Word.CANCEL), VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> cancelRunnable.run());
    Button next = new Button(Language.get(Word.NEXT), VaadinIcons.ARROW_RIGHT);
    next.addClickListener(ce -> nextRunnable.run());
    GridLayout footer = new GridLayout(3 + extraComponents.length, 1);
    footer.setSpacing(true);//w  ww  .j  av  a  2s.  c  om
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE);
    footer.setSizeUndefined();
    footer.setWidth("100%");
    for (Component extraComponent : extraComponents) {
        footer.addComponent(extraComponent);
        footer.setComponentAlignment(extraComponent, Alignment.MIDDLE_CENTER);
    }
    footer.addComponents(placeholder, cancel, next);
    footer.setColumnExpandRatio(footer.getColumns() - 1 - 2, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    return footer;
}

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

public PasswordRecoveryWindow() {
    setModal(true);// www.  jav  a  2s. c  o  m
    setResizable(false);
    setDraggable(false);
    setCaption(Language.get(Word.RESET_PW));
    addCloseShortcut(ShortcutAction.KeyCode.ENTER, null);

    windowLayout = new VerticalLayout();
    windowLayout.setMargin(false);
    windowLayout.setSizeUndefined();

    forms = new FormLayout();
    forms.setMargin(true);
    forms.setSizeUndefined();

    send = new Button(Language.get(Word.SEND_RESET_CODE));

    emailOrUsername = new TextField(Language.get(Word.USERNAME_OR_EMAIL));
    emailOrUsername.setMaxLength(256);
    emailOrUsername.focus();
    forms.addComponent(emailOrUsername);

    footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE);

    Label placeholder = new Label();

    cancel = new Button(Language.get(Word.CANCEL));
    cancel.setIcon(VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> {
        close();
    });
    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);

    send.setIcon(VaadinIcons.CHECK);
    send.addStyleName(ValoTheme.BUTTON_PRIMARY);
    sendListener = send.addClickListener(ce -> changeWindow());
    send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    footer.setSizeUndefined();
    footer.setWidth("100%");
    footer.addComponents(placeholder, cancel, send);
    footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(send, Alignment.MIDDLE_CENTER);

    windowLayout.addComponents(forms, footer);
    windowLayout.setWidth("450px");

    setContent(windowLayout);
    //setWidth("450px");
}

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

public RegisterWindow() {
    setModal(true);//from   w w  w  . j  ava 2s . co  m
    setResizable(false);
    setDraggable(false);
    setCaption(Language.get(Word.REGISTER));
    addCloseShortcut(KeyCode.ENTER, null);

    Button save = new Button(Language.get(Word.REGISTER));

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(false);
    windowLayout.setSizeUndefined();

    FormLayout forms = new FormLayout();
    forms.setMargin(true);
    forms.setSizeUndefined();

    TextField firstName = new TextField(Language.get(Word.FIRST_NAME));
    firstName.focus();
    firstName.setMaxLength(20);
    firstName.addValueChangeListener(event -> {
        String firstNameError = UserUtils.checkName(event.getValue());
        if (!firstNameError.isEmpty()) {
            firstName.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(firstNameError);
            save.setEnabled(setError(firstName, true));
        } else {
            firstName.setComponentError(null);
            boolean enabled = setError(firstName, false);
            save.setEnabled(enabled);
        }
    });
    forms.addComponent(firstName);

    TextField lastName = new TextField(Language.get(Word.LAST_NAME));
    lastName.setMaxLength(20);
    lastName.addValueChangeListener(event -> {
        String lastNameError = UserUtils.checkName(event.getValue());
        if (!lastNameError.isEmpty()) {
            lastName.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(lastNameError);
            save.setEnabled(setError(lastName, true));
        } else {
            lastName.setComponentError(null);
            save.setEnabled(setError(lastName, false));
        }
    });
    forms.addComponent(lastName);

    TextField userName = new TextField(Language.get(Word.USERNAME));
    userName.setMaxLength(20);
    userName.addValueChangeListener(event -> {
        String userNameError = UserUtils.checkUsername(event.getValue());
        if (!userNameError.isEmpty()) {
            userName.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(userNameError);
            save.setEnabled(setError(userName, true));
        } else {
            userName.setComponentError(null);
            save.setEnabled(setError(userName, false));

        }
    });
    forms.addComponent(userName);

    TextField email1 = new TextField(Language.get(Word.EMAIL));
    email1.setMaxLength(256);
    email1.addValueChangeListener(event -> {
        String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase());
        if (!email1Error.isEmpty()) {
            email1.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(email1Error);
            save.setEnabled(setError(email1, true));
        } else {
            email1.setComponentError(null);
            save.setEnabled(setError(email1, false));
        }
    });
    forms.addComponent(email1);

    TextField email2 = new TextField(Language.get(Word.EMAIL_AGAIN));
    email2.setMaxLength(256);
    email2.addValueChangeListener(event -> {
        String email2Error = UserUtils.checkEmail(event.getValue().toLowerCase())
                + UserUtils.checkSecondEmail(email1.getValue().toLowerCase(), event.getValue().toLowerCase());
        if (!email2Error.isEmpty()) {
            email2.setComponentError(new UserError(email2Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(email2Error);
            save.setEnabled(setError(email2, true));
        } else {
            email2.setComponentError(null);
            save.setEnabled(setError(email2, false));
        }
    });
    forms.addComponent(email2);

    ProgressBar strength = new ProgressBar();

    PasswordField password1 = new PasswordField(Language.get(Word.PASSWORD));
    password1.setMaxLength(51);
    password1.addValueChangeListener(event -> {
        String password1Error = UserUtils.checkPassword(event.getValue());
        strength.setValue(UserUtils.calculatePasswordStrength(event.getValue()));
        if (!password1Error.isEmpty()) {
            password1.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(password1Error);
            save.setEnabled(setError(password1, true));
        } else {
            password1.setComponentError(null);
            save.setEnabled(setError(password1, false));
        }

    });
    forms.addComponent(password1);

    strength.setWidth("184px");
    strength.setHeight("1px");
    forms.addComponent(strength);

    PasswordField password2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN));
    password2.setMaxLength(51);
    password2.addValueChangeListener(event -> {
        String password2Error = UserUtils.checkPassword(event.getValue())
                + UserUtils.checkSecondPassword(password1.getValue(), event.getValue());
        if (!password2Error.isEmpty()) {
            password2.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(password2Error);
            save.setEnabled(setError(password2, true));
        } else {
            password2.setComponentError(null);
            save.setEnabled(setError(password2, false));
        }
    });
    forms.addComponent(password2);

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Unit.PERCENTAGE);

    Label placeholder = new Label();

    Button cancel = new Button(Language.get(Word.CANCEL));
    cancel.setIcon(VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> {
        close();
    });
    cancel.setClickShortcut(KeyCode.ESCAPE, null);

    save.setEnabled(false);
    save.setIcon(VaadinIcons.CHECK);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addClickListener(ce -> {
        try {
            User user = UserUtils.registerUser(userName.getValue(), password1.getValue(), password2.getValue(),
                    email1.getValue().toLowerCase(), email2.getValue().toLowerCase(), firstName.getValue(),
                    lastName.getValue());
            UserUtils.setCurrentUser(user);
            close();
            UI.getCurrent().addWindow(ActivateWindow.get());
        } catch (UserCreationException ex) {
            Log.error("Registration failed", ex);
            VaadinUtils.errorNotification(Language.get(Word.REG_FAILED));
        }
    });
    save.setClickShortcut(KeyCode.ENTER, null);

    footer.addComponents(placeholder, cancel, save);
    footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(forms);
    windowLayout.addComponent(footer);

    setContent(windowLayout);
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.description.DescriptionViewImpl.java

License:Open Source License

private VerticalLayout getPrognoseMethodenInfos() {
    VerticalLayout vl = new VerticalLayout();
    infoText0 = new Label("<h1>Prognosemethode</h1>");
    infoText0.setContentMode(Label.CONTENT_XHTML);
    infoText1 = new Label("<h2>Methode zur Parametereingabe</h2>");
    infoText1.setContentMode(Label.CONTENT_XHTML);

    gl = new GridLayout(2, 4);
    gl.setSizeFull();//from  w w  w  .j  a v  a  2s.  c o  m
    gl.setColumnExpandRatio(1, 1.0f);

    gl.addComponent(iconStochastic, 0, 0);
    gl.setComponentAlignment(iconStochastic, Alignment.MIDDLE_CENTER);
    gl.addComponent(stochasticHeadline, 1, 0);
    gl.addComponent(stochasticText, 1, 1);

    gl.addComponent(iconDeterministic, 0, 2);
    gl.setComponentAlignment(iconDeterministic, Alignment.MIDDLE_CENTER);
    gl.addComponent(deterministicHeadline, 1, 2);
    gl.addComponent(deterministicText, 1, 3);

    vl.addComponent(infoText0);
    vl.addComponent(infoText1);
    vl.addComponent(gl);

    return vl;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.description.DescriptionViewImpl.java

License:Open Source License

private VerticalLayout getEingabeMethodeInfo() {
    VerticalLayout vl = new VerticalLayout();
    headline0 = new Label("<h1>Eingabemethode</h1>");
    headline0.setContentMode(Label.CONTENT_XHTML);
    headline1 = new Label("<h2>Methode zur Berechnung des Unternehmenswertes</h2>");
    headline1.setContentMode(Label.CONTENT_XHTML);

    gl = new GridLayout(2, 6);
    gl.setSizeFull();//  ww w  . j a  v  a  2 s.  co  m
    gl.setColumnExpandRatio(1, 1.0f);

    gl.addComponent(iconFCF, 0, 0);
    gl.setComponentAlignment(iconFCF, Alignment.MIDDLE_CENTER);
    gl.addComponent(fcfHeadline, 1, 0);
    gl.addComponent(fcfText, 1, 1);

    //      gl.addComponent(iconUKV, 0, 2);
    //      gl.setComponentAlignment(iconUKV, Alignment.MIDDLE_CENTER);
    //      gl.addComponent(ukvHeadline, 1, 2);
    //      gl.addComponent(ukvText, 1, 3);
    //      
    //      gl.addComponent(iconGKV, 0 , 4);
    //      gl.setComponentAlignment(iconGKV, Alignment.MIDDLE_CENTER);
    //      gl.addComponent(gkvHeadline, 1, 4);
    //      gl.addComponent(gkvText, 1, 5);

    vl.addComponent(headline0);
    vl.addComponent(headline1);
    vl.addComponent(gl);

    return vl;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.description.DescriptionViewImpl.java

License:Open Source License

private VerticalLayout getBerechnungsMethodeInfo() {
    VerticalLayout vl = new VerticalLayout();
    headline0 = new Label("<h1>Berechnungsmethoden</h1>");
    headline0.setContentMode(Label.CONTENT_XHTML);
    headline1 = new Label("<h2>Methode zur Prognoseerstellung</h2>");
    headline1.setContentMode(Label.CONTENT_XHTML);

    gl = new GridLayout(2, 6);
    gl.setSizeFull();//from  w  w w. j  ava2  s .  co  m
    gl.setColumnExpandRatio(1, 1.0f);

    gl.addComponent(iconAPV, 0, 0);
    gl.setComponentAlignment(iconAPV, Alignment.MIDDLE_CENTER);
    gl.addComponent(apvHeadline, 1, 0);
    gl.addComponent(apvText, 1, 1);

    //      gl.addComponent(iconFTE, 0, 2);
    //      gl.setComponentAlignment(iconFTE, Alignment.MIDDLE_CENTER);
    //      gl.addComponent(fteHeadline, 1, 2);
    //      gl.addComponent(fteText, 1, 3);
    //      
    //      gl.addComponent(iconWACC, 0 , 4);
    //      gl.setComponentAlignment(iconWACC, Alignment.MIDDLE_CENTER);
    //      gl.addComponent(waccHeadline, 1, 4);
    //      gl.addComponent(waccText, 1, 5);

    vl.addComponent(headline0);
    vl.addComponent(headline1);
    vl.addComponent(gl);

    return vl;
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.parameterScreen.input.ParameterInputViewImpl.java

License:Open Source License

private void generateUi() {
    setMargin(true);/*from www. java 2  s  .co m*/
    //setSizeFull();

    gridLayout = new GridLayout(3, 30);
    gridLayout.setSpacing(true);
    gridLayout.setSizeUndefined();
    gridLayout.setStyleName("parameter");

    addComponent(gridLayout);

    //Hhe des FragezeichenIcons
    String heightQuestionIcon = "20px";

    // Basisjahr

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

    textfieldBasisYear = new TextField();
    textfieldBasisYear.setImmediate(true);
    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);

    labelBasisYear.setStyleName("parameter");
    textfieldBasisYear.setStyleName("parameter");

    questionIconBasisYear = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418765983_circle_help_question-mark-128.png"));
    questionIconBasisYear.setHeight(heightQuestionIcon);
    questionIconBasisYear.setStyleName("questionIcon");
    questionIconBasisYear.setDescription(toolTipBasisYear);

    gridLayout.addComponent(questionIconBasisYear, 2, 1);

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

    textfieldNumPeriodsToForecast = new TextField();
    textfieldNumPeriodsToForecast.setImmediate(true);
    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, 2);

    labelNumPeriods.setStyleName("parameter");
    textfieldNumPeriodsToForecast.setStyleName("parameter");

    questionIconNumPeriods = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418765983_circle_help_question-mark-128.png"));
    questionIconNumPeriods.setHeight(heightQuestionIcon);
    questionIconNumPeriods.setStyleName("questionIcon");
    questionIconNumPeriods.setDescription(toolTipNumPeriodsToForecast);

    gridLayout.addComponent(questionIconNumPeriods, 2, 2);

    //Anzahl der Iterationen
    labelIterations = new Label("Anzahl der Iterationen");
    gridLayout.addComponent(labelIterations, 0, 3);

    textfieldIterations = new TextField();
    textfieldIterations.setImmediate(true);
    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, 3);

    labelIterations.setStyleName("parameter");
    textfieldIterations.setStyleName("parameter");

    questionIconIterations = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418765983_circle_help_question-mark-128.png"));
    questionIconIterations.setHeight(heightQuestionIcon);
    questionIconIterations.setStyleName("questionIcon");
    questionIconIterations.setDescription(toolTipIterations);

    gridLayout.addComponent(questionIconIterations, 2, 3);

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

    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.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.relevantPastPeriodsChosen((String) textfieldNumPastPeriods.getValue());
        }
    });

    gridLayout.addComponent(textfieldNumPastPeriods, 1, 4);

    labelNumPastPeriods.setStyleName("parameter");
    textfieldNumPastPeriods.setStyleName("parameter");

    questionIconNumPastPeriods = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418765983_circle_help_question-mark-128.png"));
    questionIconNumPastPeriods.setHeight(heightQuestionIcon);
    questionIconNumPastPeriods.setStyleName("questionIcon");
    questionIconNumPastPeriods.setDescription(toolTipNumPastPeriods);

    gridLayout.addComponent(questionIconNumPastPeriods, 2, 4);

    // Anzahl anzugebender, vergangener Perioden
    //      labelNumSpecifiedPastPeriods = new Label("Anzahl anzugebender, vergangener Perioden");
    //      gridLayout.addComponent(labelNumSpecifiedPastPeriods, 0, 5);
    //      
    //      textfieldNumSpecifiedPastPeriods = new TextField();
    //      textfieldNumSpecifiedPastPeriods.setImmediate(true);
    //      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, 5);
    //      
    //      labelNumSpecifiedPastPeriods.setStyleName("parameter");
    //      textfieldNumSpecifiedPastPeriods.setStyleName("parameter");
    //      
    //      questionIconNumSpecifiedPastPeriods = new Embedded (null, new ThemeResource("./images/icons/newIcons/1418765983_circle_help_question-mark-128.png"));
    //      questionIconNumSpecifiedPastPeriods.setHeight(heightQuestionIcon);
    //      questionIconNumSpecifiedPastPeriods.setStyleName("questionIcon");
    //      questionIconNumSpecifiedPastPeriods.setDescription(toolTipNumSpecifiedPastPeriods);
    //      
    //      gridLayout.addComponent(questionIconNumSpecifiedPastPeriods, 2, 5);

    // Deterministische Parameter

    //Anzahl anzugebender Perioden
    labelNumPeriods_deterministic = new Label("Anzahl Perioden");
    gridLayout.addComponent(labelNumPeriods_deterministic, 0, 7);

    textfieldNumPeriodsToForecast_deterministic = new TextField();
    textfieldNumPeriodsToForecast_deterministic.setImmediate(true);
    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, 7);

    labelNumPeriods_deterministic.setStyleName("parameter");
    textfieldNumPeriodsToForecast_deterministic.setStyleName("parameter");

    questionIconNumPeriods_deterministic = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418765983_circle_help_question-mark-128.png"));
    questionIconNumPeriods_deterministic.setHeight(heightQuestionIcon);
    questionIconNumPeriods_deterministic.setStyleName("questionIcon");
    questionIconNumPeriods_deterministic.setDescription(toolTipNumPeriodsToForecast_deterministic);

    gridLayout.addComponent(questionIconNumPeriods_deterministic, 2, 7);

}