Example usage for com.vaadin.ui VerticalLayout addComponent

List of usage examples for com.vaadin.ui VerticalLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.hack23.cia.web.impl.ui.application.views.user.party.pagemode.PartyRankingOverviewPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override/*ww w  .  j  a v  a 2  s.  c o m*/
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();

    getPartyRankingMenuItemFactory().createPartyRankingMenuBar(menuBar);

    final String pageId = getPageId(parameters);

    panelContent.addComponent(createDescription());

    getPartyRankingMenuItemFactory().createOverviewPage(panelContent);

    panel.setCaption(OVERVIEW + parameters);

    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_RANKING_VIEW, ApplicationEventGroup.USER,
            NAME, parameters, pageId);

    return panelContent;

}

From source file:com.hack23.cia.web.impl.ui.application.views.user.politician.pagemode.PoliticianOverviewPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the overview content./*from  w w  w  . j a va  2s .c  o m*/
 *
 * @param panelContent
 *            the panel content
 * @param personData
 *            the person data
 * @param viewRiksdagenPolitician
 *            the view riksdagen politician
 * @param pageId
 */
private void createOverviewContent(final VerticalLayout panelContent, final PersonData personData,
        final ViewRiksdagenPolitician viewRiksdagenPolitician, final String pageId) {
    LabelFactory.createHeader2Label(panelContent, OVERVIEW);

    final VerticalLayout overviewLayout = new VerticalLayout();
    overviewLayout.setSizeFull();

    panelContent.addComponent(overviewLayout);
    panelContent.setExpandRatio(overviewLayout, ContentRatio.LARGE_FORM);

    getPoliticianMenuItemFactory().createOverviewPage(overviewLayout, pageId);

    final Link createPoliticianPageLink = getPageLinkFactory().createPoliticianPageLink(personData);
    panelContent.addComponent(createPoliticianPageLink);

    final Image image = new Image("",
            new ExternalResource(personData.getImageUrl192().replace("http://", "https://")));

    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();

    panelContent.addComponent(horizontalLayout);

    horizontalLayout.addComponent(image);

    getFormFactory().addFormPanelTextFields(horizontalLayout, new BeanItem<>(viewRiksdagenPolitician),
            ViewRiksdagenPolitician.class,
            Arrays.asList(new String[] { "firstName", "lastName", "gender", "bornYear", "party", "active",
                    "firstAssignmentDate", "lastAssignmentDate", "currentAssignments",
                    "currentMinistryAssignments", "currentSpeakerAssignments", "currentCommitteeAssignments",
                    "currentPartyAssignments", "totalMinistryAssignments", "totalCommitteeAssignments",
                    "totalSpeakerAssignments", "totalPartyAssignments", "totalAssignments", "totalDaysServed",
                    "activeEu", "totalDaysServedEu", "activeGovernment", "totalDaysServedGovernment",
                    "activeSpeaker", "totalDaysServedSpeaker", "activeCommittee", "totalDaysServedCommittee",
                    "activeParliament", "totalDaysServedParliament", "activeParty", "totalDaysServedParty" }));

    getGridFactory().createBasicBeanItemGrid(panelContent,
            new BeanItemContainer<>(DetailData.class, personData.getPersonDetailData().getDetailList()),
            "Detail", new String[] { "code", "detail" }, new String[] { "hjid", "intressentId", "detailType" },
            null, null, null);

    panelContent.setExpandRatio(createPoliticianPageLink, ContentRatio.SMALL);
    panelContent.setExpandRatio(horizontalLayout, ContentRatio.GRID);

}

From source file:com.hack23.cia.web.impl.ui.application.views.user.politician.pagemode.PoliticianRankingOverviewPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override//from   w  ww .ja v  a 2s.  c om
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();

    getPoliticianRankingMenuItemFactory().createPoliticianRankingMenuBar(menuBar);

    final String pageId = getPageId(parameters);

    panelContent.addComponent(createDescription());

    getPoliticianRankingMenuItemFactory().createOverviewPage(panelContent);

    panel.setCaption(OVERVIEW + parameters);

    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_POLITICIAN_RANKING_VIEW,
            ApplicationEventGroup.USER, NAME, parameters, pageId);

    return panelContent;

}

From source file:com.hack23.cia.web.impl.ui.application.views.user.politician.pagemode.PoliticianRoleSummaryPageModContentFactoryImpl.java

License:Apache License

/**
 * Creates the role summary.//  w w w .  j ava  2  s .c om
 *
 * @param roleSummaryLayoutTabsheet
 *            the role summary layout tabsheet
 * @param assignmentList
 *            the assignment list
 * @param viewRiksdagenPolitician
 *            the view riksdagen politician
 */
private void createRoleSummary(final VerticalLayout roleSummaryLayoutTabsheet,
        final List<AssignmentData> assignmentList, final ViewRiksdagenPolitician viewRiksdagenPolitician) {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();

    layout.addComponent(new Label(TOTAL_ASSIGNMENTS + assignmentList.size()));

    if (viewRiksdagenPolitician != null) {

        layout.addComponent(new Label(GOVERNMENT_EXPERIENCE
                + convertToYearsString(viewRiksdagenPolitician.getTotalDaysServedGovernment())));
        layout.addComponent(new Label(SPEAKER_EXPERIENCE
                + convertToYearsString(viewRiksdagenPolitician.getTotalDaysServedSpeaker())));
        layout.addComponent(new Label(COMMITTEE_EXPERIENCE
                + convertToYearsString(viewRiksdagenPolitician.getTotalDaysServedCommittee())));
        layout.addComponent(new Label(
                EU_EXPERIENCE + convertToYearsString(viewRiksdagenPolitician.getTotalDaysServedEu())));
        layout.addComponent(new Label(PARLIAMENT_EXPERIENCE
                + convertToYearsString(viewRiksdagenPolitician.getTotalDaysServedParliament())));
        layout.addComponent(new Label(
                PARTY_EXPERIENCE + convertToYearsString(viewRiksdagenPolitician.getTotalDaysServedParty())));
    }

    roleSummaryLayoutTabsheet.addComponent(layout);
    roleSummaryLayoutTabsheet.setExpandRatio(layout, ContentRatio.GRID);

}

From source file:com.haulmont.cuba.web.app.folders.CubaFoldersPane.java

License:Apache License

protected void createFoldersPaneLayout(Component appFoldersPane, Component searchFoldersPane) {
    if (appFoldersPane != null && searchFoldersPane != null) {
        vertSplit = new VerticalSplitPanel();
        vertSplit.setSplitPosition(verticalSplitPos);

        VerticalLayout afLayout = new VerticalLayout();
        afLayout.setSpacing(true);/*from   w  w w .  ja  va 2  s  . c o m*/
        afLayout.setSizeFull();
        if (appFoldersLabel != null)
            addFoldersLabel(afLayout, appFoldersLabel);
        afLayout.addComponent(appFoldersPane);
        afLayout.setExpandRatio(appFoldersPane, 1);
        vertSplit.setFirstComponent(afLayout);

        VerticalLayout sfLayout = new VerticalLayout();
        sfLayout.setSpacing(true);
        sfLayout.setSizeFull();
        if (searchFoldersLabel != null)
            addFoldersLabel(sfLayout, searchFoldersLabel);
        sfLayout.addComponent(searchFoldersPane);
        sfLayout.setExpandRatio(searchFoldersPane, 1);
        vertSplit.setSecondComponent(sfLayout);

        addComponent(vertSplit);
    } else {
        if (appFoldersPane != null) {
            if (appFoldersLabel != null)
                addFoldersLabel(this, appFoldersLabel);
            addComponent(appFoldersPane);
            setExpandRatio(appFoldersPane, 1);
        }
        if (searchFoldersPane != null) {
            if (searchFoldersLabel != null)
                addFoldersLabel(this, searchFoldersLabel);
            addComponent(searchFoldersPane);
            setExpandRatio(searchFoldersPane, 1);
        }
    }
}

From source file:com.haulmont.cuba.web.AppUI.java

License:Apache License

protected void showCriticalExceptionMessage(Exception exception) {
    String initErrorCaption = messages.getMainMessage("app.initErrorCaption");
    String initErrorMessage = messages.getMainMessage("app.initErrorMessage");

    VerticalLayout content = new VerticalLayout();
    content.setStyleName("c-init-error-view");
    content.setSizeFull();/*from  www  .  j  a v  a  2 s. c om*/

    VerticalLayout errorPanel = new VerticalLayout();
    errorPanel.setStyleName("c-init-error-panel");
    errorPanel.setWidthUndefined();
    errorPanel.setSpacing(true);

    Label captionLabel = new Label(initErrorCaption);
    captionLabel.setWidthUndefined();
    captionLabel.setStyleName("c-init-error-caption");
    captionLabel.addStyleName("h2");
    captionLabel.setValue(initErrorCaption);

    errorPanel.addComponent(captionLabel);

    Label messageLabel = new Label(initErrorCaption);
    messageLabel.setWidthUndefined();
    messageLabel.setStyleName("c-init-error-message");
    messageLabel.setValue(initErrorMessage);

    errorPanel.addComponent(messageLabel);

    Button retryButton = new Button(messages.getMainMessage("app.initRetry"));
    retryButton.setStyleName("c-init-error-retry");
    retryButton.addClickListener(event -> {
        // always restart UI
        String url = ControllerUtils.getLocationWithoutParams() + "?restartApp";
        getPage().open(url, "_self");
    });

    errorPanel.addComponent(retryButton);
    errorPanel.setComponentAlignment(retryButton, Alignment.MIDDLE_CENTER);

    content.addComponent(errorPanel);
    content.setComponentAlignment(errorPanel, Alignment.MIDDLE_CENTER);

    setContent(content);
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);// www .  j  a  v a 2s. c o  m
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}

From source file:com.haulmont.cuba.web.gui.components.presentations.PresentationEditor.java

License:Apache License

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();

    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();//from  w  w  w . j  av  a 2s  .  c o  m
    root.setSpacing(true);
    setContent(root);

    messages = AppBeans.get(Messages.class);

    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);

    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);

    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);

    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);

    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);

    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);

    nameField.focus();
}

From source file:com.haulmont.cuba.web.gui.components.table.AbbreviatedCellClickListener.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//ww  w .  ja v  a  2s  .  co  m
public void onClick(Entity item, String columnId) {
    Table.Column column = table.getColumn(columnId);
    MetaProperty metaProperty;
    String value;
    if (DynamicAttributesUtils.isDynamicAttribute(columnId)) {
        metaProperty = dynamicAttributesTools.getMetaPropertyPath(item.getMetaClass(), columnId)
                .getMetaProperty();
        value = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty,
                item.getValueEx(columnId));
    } else {
        value = item.getValueEx(columnId);
    }
    if (column.getMaxTextLength() != null) {
        boolean isMultiLineCell = StringUtils.contains(value, "\n");
        if (value == null
                || (value.length() <= column.getMaxTextLength() + MAX_TEXT_LENGTH_GAP && !isMultiLineCell)) {
            // todo artamonov if we click with CTRL and Table is multiselect then we lose previous selected items
            //noinspection SuspiciousMethodCalls
            if (!table.getSelected().contains(item)) {
                table.setSelected(item);
            }
            // do not show popup view
            return;
        }
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.setSpacing(false);
    layout.setWidthUndefined();
    layout.setStyleName("c-table-view-textcut");

    CubaTextArea textArea = new CubaTextArea();
    textArea.setValue(Strings.nullToEmpty(value));
    textArea.setReadOnly(true);

    CubaResizableTextAreaWrapper content = new CubaResizableTextAreaWrapper(textArea);
    content.setResizableDirection(ResizeDirection.BOTH);

    // todo implement injection for ThemeConstains in components
    ThemeConstants theme = App.getInstance().getThemeConstants();
    if (theme != null) {
        content.setWidth(theme.get("cuba.web.Table.abbreviatedPopupWidth"));
        content.setHeight(theme.get("cuba.web.Table.abbreviatedPopupHeight"));
    } else {
        content.setWidth("320px");
        content.setHeight("200px");
    }

    layout.addComponent(content);

    CubaEnhancedTable enhancedTable = table.unwrap(CubaEnhancedTable.class);
    enhancedTable.showCustomPopup(layout);
    enhancedTable.setCustomPopupAutoClose(false);
}

From source file:com.haulmont.cuba.web.gui.components.table.WebTableFieldFactory.java

License:Apache License

protected Component getComponentImplementation(com.haulmont.cuba.gui.components.Component columnComponent) {
    com.vaadin.ui.Component composition = columnComponent.unwrapComposition(com.vaadin.ui.Component.class);
    Component componentImpl = composition;
    if (composition instanceof com.vaadin.v7.ui.Field && ((com.vaadin.v7.ui.Field) composition).isRequired()) {
        VerticalLayout layout = new VerticalLayout(); // vaadin8 replace with CssLayout
        layout.setMargin(false);//from ww  w  . j a  v  a  2  s  .  c o  m
        layout.setSpacing(false);
        layout.addComponent(composition);

        if (composition.getWidth() < 0) {
            layout.setWidthUndefined();
        }

        componentImpl = layout;
    }
    return componentImpl;
}