Example usage for com.vaadin.ui CustomLayout addComponent

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

Introduction

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

Prototype

public void addComponent(Component c, String location) 

Source Link

Document

Adds the component into this container to given location.

Usage

From source file:com.mcparland.john.Demo.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    CustomLayout layout = new CustomLayout("mylayout");
    setContent(layout);//from ww w  . j a  va2s.  co m
    Label header = new Label("Custom layout");
    header.addStyleName("header");
    layout.addComponent(header, "header");
    Label menu = new Label("menu");
    layout.addComponent(menu, "menu");
    Label content = new Label("This is content of page.");
    layout.addComponent(content, "content");
    Label footer = new Label("Created by Vaadin, 2013");
    layout.addComponent(footer, "footer");
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.about.AboutView.java

License:Apache License

public AboutView() {
    CustomLayout aboutContent = new CustomLayout("aboutview");
    aboutContent.setStyleName("about-content");

    // you can add Vaadin components in predefined slots in the custom
    // layout/*ww  w .j  av  a  2  s . co  m*/
    aboutContent.addComponent(new Label(
            FontAwesome.INFO_CIRCLE.getHtml() + " This application is using Vaadin " + Version.getFullVersion(),
            ContentMode.HTML), "info");

    setSizeFull();
    setStyleName("about-view");
    addComponent(aboutContent);
    setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER);
}

From source file:com.morevaadin.vaadin.theming.ThemingContent.java

License:Apache License

public ThemingContent() {

    CustomLayout layout = new CustomLayout("layout");

    setCompositionRoot(layout);/*from  w w w.  j av  a  2 s  .  c  o  m*/

    layout.addComponent(menuBar, "top");
    layout.addComponent(new Button("Does nothing"), "bottom");

    VerticalLayout vLayout = new VerticalLayout();

    vLayout.addComponent(new InlineDateField());
    vLayout.addComponent(new TextField("", "Nothing to put in here"));
    vLayout.setSpacing(true);
    vLayout.setMargin(true);

    layout.addComponent(vLayout, "left");
}

From source file:com.mycollab.module.project.view.milestone.MilestoneListViewImpl.java

License:Open Source License

private void constructBody() {
    CustomLayout bodyContent = CustomLayoutExt.createLayout("milestoneView");
    bodyContent.setWidth("100%");
    bodyContent.setStyleName("milestone-view");

    MHorizontalLayout closedHeaderLayout = new MHorizontalLayout();

    closedHeader = ELabel.html("").withWidthUndefined();
    closedHeaderLayout.with(closedHeader).withAlign(closedHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(closedHeaderLayout, "closed-header");
    closeContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(closeContainer, "closed-milestones");

    MHorizontalLayout inProgressHeaderLayout = new MHorizontalLayout();
    inProgressHeader = ELabel.html("").withWidthUndefined();
    inProgressHeaderLayout.addComponent(inProgressHeader);
    inProgressHeaderLayout.setComponentAlignment(inProgressHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(inProgressHeaderLayout, "in-progress-header");
    inProgressContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(this.inProgressContainer, "in-progress-milestones");

    MHorizontalLayout futureHeaderLayout = new MHorizontalLayout();
    futureHeader = ELabel.html("").withWidthUndefined();
    futureHeaderLayout.addComponent(futureHeader);
    futureHeaderLayout.setComponentAlignment(futureHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(futureHeaderLayout, "future-header");
    futureContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(this.futureContainer, "future-milestones");

    this.addComponent(bodyContent);
}

From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java

License:Open Source License

private void buildLogoPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(true);
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    Label logoDesc = new Label(UserUIContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION));
    leftPanel.with(logoDesc).withWidth("250px");

    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation");
    previewLayout.setStyleName("example-block");
    previewLayout.setHeight("40px");
    previewLayout.setWidth("520px");

    Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(),
            150);//from w  ww.  jav  a2s.  c om
    previewLayout.addComponent(currentLogo, "mainLogo");
    final ServiceMenu serviceMenu = new ServiceMenu();

    Button.ClickListener clickListener = new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {

            for (Component comp : serviceMenu) {
                if (comp != event.getButton()) {
                    comp.removeStyleName("selected");
                }
            }
            event.getButton().addStyleName("selected");
        }
    };

    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY,
            clickListener);
    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS,
            clickListener);
    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE,
            clickListener);
    serviceMenu.selectService(0);

    previewLayout.addComponent(serviceMenu, "serviceMenu");

    MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    final UploadField logoUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplay() {
            byte[] imageData = (byte[]) this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(
                            UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                UI.getCurrent().addWindow(new LogoEditWindow(imageData));
            } else {
                throw new UserInvalidInputException(
                        UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    logoUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    logoUploadField.addStyleName("upload-field");
    logoUploadField.setSizeUndefined();
    logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY);
    logoUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setLogopath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        Page.getCurrent().getJavaScript().execute("window.location.reload();");
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, logoUploadField);
    rightPanel.with(previewLayout, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Logo", layout);
    this.with(formContainer);
}

From source file:cz.zcu.pia.social.network.frontend.components.login.ComponentLogin.java

/**
 * PostConstruct//from  ww w . j  a va  2  s.c  om
 */
@PostConstruct
public void postConstruct() {

    CustomLayout content = new CustomLayout("login");
    content.setSizeUndefined();
    this.addComponent(content);

    nickname.setCaption(msgs.getMessage(INFO_USERNAME));
    password.setCaption(msgs.getMessage(INFO_PASSWORD));
    Button login = createLoginButton();

    Button infoRegister = createRegisterButton();
    content.addComponent(infoRegister, "register-button");

    content.addComponent(nickname, "username");
    content.addComponent(password, "password");
    content.addComponent(login, "okbutton");

}

From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPost.java

/**
 * Adds click listeners to the buttons//w w  w .  j  a  v a2  s.  co  m
 */
private void addClickListeners() {
    this.likes.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateLikeRating(postId);
            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();

        }
    });
    this.disagrees.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateDisagreeRating(postId);

            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();
        }
    });
    this.tags.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.tags"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(110, Unit.PIXELS);
            subWindow.setResizable(false);
            Panel panel = new Panel();

            panel.setSizeFull();
            HorizontalLayout tagsWrapper = new HorizontalLayout();
            tagsWrapper.setStyleName("margin-left-big");
            panel.setContent(tagsWrapper);
            tagsWrapper.setSpacing(true);
            tagsWrapper.setMargin(true);
            tagsWrapper.setSizeUndefined();

            for (Tag t : postService.getPostTags(postId)) {
                CustomLayout tag = new CustomLayout("tag");
                Button tagLabel = new Button(t.getTagName());
                tag.addComponent(tagLabel, "button");

                tagsWrapper.addComponent(tag);
            }

            subWindow.setContent(panel);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.comments.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.comments"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(600, Unit.PIXELS);
            subWindow.setResizable(true);

            ComponentPostComments componentPostComments = applicationContext
                    .getBean(ComponentPostComments.class, postId);
            subWindow.setContent(componentPostComments);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.name.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("header.profile") + "- " + name.getCaption());

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(350, Unit.PIXELS);
            subWindow.setResizable(true);

            Users user = postService.getPostById(postId).getUser();
            ComponentProfilePost profilePost = applicationContext.getBean(ComponentProfilePost.class, user);

            subWindow.setContent(profilePost);
            UI.getCurrent().addWindow(subWindow);
        }
    });
}

From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPostAdd.java

/**
 * Constructor//from  www .  j a  v  a 2s . com
 */
public ComponentPostAdd() {

    this.setSpacing(true);

    message.setWidth(100, Unit.PERCENTAGE);
    message.setHeight(100, Unit.PIXELS);
    message.setMaxLength(1000);

    tags = new HorizontalLayout();
    tags.setSpacing(true);
    tags.setSizeUndefined();

    newTag = new TextField();
    newTag.setImmediate(true);
    OnEnterKeyHandler onEnterHandler = new OnEnterKeyHandler() {
        @Override
        public void onEnterKeyPressed() {
            CustomLayout tag = new CustomLayout("tag");
            Button tagsButton = new Button(newTag.getValue());
            taglist.add(tagsButton);
            newTag.setValue("");
            newTag.focus();
            tagsButton.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    tags.removeComponent(event.getButton().getParent());
                    taglist.remove(event.getButton());
                }
            });

            tag.addComponent(tagsButton, "button");

            tags.addComponent(tag);
        }
    };
    onEnterHandler.installOn(newTag);

}

From source file:de.symeda.sormas.ui.AboutView.java

License:Open Source License

public AboutView() {
    CustomLayout aboutContent = new CustomLayout("aboutview");
    aboutContent.setStyleName("about-content");

    // Info section
    VerticalLayout infoLayout = new VerticalLayout();
    infoLayout.setSpacing(false);/*from   ww w.j a v  a 2s.  co m*/
    infoLayout.setMargin(false);
    aboutContent.addComponent(infoLayout, "info");

    Label versionLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " "
            + I18nProperties.getCaption(Captions.aboutSormasVersion) + ": " + InfoProvider.get().getVersion(),
            ContentMode.HTML);
    infoLayout.addComponent(versionLabel);

    Link whatsNewLink = new Link(I18nProperties.getCaption(Captions.aboutWhatsNew),
            new ExternalResource(
                    "https://github.com/hzi-braunschweig/SORMAS-Project/releases/tag/releases%2Fversion-"
                            + InfoProvider.get().getBaseVersion()));
    whatsNewLink.setTargetName("_blank");
    infoLayout.addComponent(whatsNewLink);

    Link sormasWebsiteLink = new Link(I18nProperties.getCaption(Captions.aboutSormasWebsite),
            new ExternalResource("https://sormasorg.helmholtz-hzi.de/"));
    sormasWebsiteLink.setTargetName("_blank");
    infoLayout.addComponent(sormasWebsiteLink);

    Link sormasGithubLink = new Link("SORMAS Github",
            new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project"));
    sormasGithubLink.setTargetName("_blank");
    infoLayout.addComponent(sormasGithubLink);

    Link changelogLink = new Link(I18nProperties.getCaption(Captions.aboutChangelog),
            new ExternalResource("https://github.com/hzi-braunschweig/SORMAS-Project/releases"));
    changelogLink.setTargetName("_blank");
    infoLayout.addComponent(changelogLink);

    // Documents section
    VerticalLayout documentsLayout = new VerticalLayout();
    documentsLayout.setSpacing(false);
    documentsLayout.setMargin(false);
    aboutContent.addComponent(documentsLayout, "documents");

    Button classificationDocumentButton = new Button(
            I18nProperties.getCaption(Captions.aboutCaseClassificationRules));
    CssStyles.style(classificationDocumentButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
    documentsLayout.addComponent(classificationDocumentButton);

    try {
        String serverUrl = new URL(((VaadinServletRequest) VaadinService.getCurrentRequest())
                .getHttpServletRequest().getRequestURL().toString()).getAuthority();
        StreamResource classificationResource = DownloadUtil.createStringStreamResource(
                ClassificationHtmlRenderer.createHtmlForDownload(serverUrl,
                        FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases()),
                "classification_rules.html", "text/html");
        new FileDownloader(classificationResource).extend(classificationDocumentButton);
    } catch (MalformedURLException e) {

    }

    Button dataDictionaryButton = new Button(I18nProperties.getCaption(Captions.aboutDataDictionary));
    CssStyles.style(dataDictionaryButton, ValoTheme.BUTTON_LINK, CssStyles.BUTTON_COMPACT);
    documentsLayout.addComponent(dataDictionaryButton);
    FileDownloader dataDictionaryDownloader = new FileDownloader(
            new ClassResource("/doc/SORMAS_Data_Dictionary.xlsx"));
    dataDictionaryDownloader.extend(dataDictionaryButton);

    Link technicalManualLink = new Link(I18nProperties.getCaption(Captions.aboutTechnicalManual),
            new ExternalResource(
                    "https://github.com/hzi-braunschweig/SORMAS-Project/files/2585973/SORMAS_Technical_Manual_Webversion_20180911.pdf"));
    technicalManualLink.setTargetName("_blank");
    documentsLayout.addComponent(technicalManualLink);

    setSizeFull();
    setStyleName("about-view");
    addComponent(aboutContent);
    setComponentAlignment(aboutContent, Alignment.MIDDLE_CENTER);
}

From source file:de.symeda.sormas.ui.caze.CaseDataView.java

License:Open Source License

@Override
public void enter(ViewChangeEvent event) {
    super.enter(event);
    setHeightUndefined();//from   ww  w  .  j  ava  2  s .co  m

    CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(getCaseRef().getUuid());

    String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, CASE_LOC),
            LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TASKS_LOC),
            LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SAMPLES_LOC));

    VerticalLayout container = new VerticalLayout();
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    CustomLayout layout = new CustomLayout();
    layout.addStyleName(CssStyles.ROOT_COMPONENT);
    layout.setTemplateContents(htmlLayout);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeightUndefined();
    container.addComponent(layout);

    CommitDiscardWrapperComponent<?> editComponent;
    if (getViewMode() == ViewMode.SIMPLE) {
        editComponent = ControllerProvider.getCaseController()
                .getCaseCombinedEditComponent(getCaseRef().getUuid(), ViewMode.SIMPLE);
    } else {
        editComponent = ControllerProvider.getCaseController().getCaseDataEditComponent(getCaseRef().getUuid(),
                ViewMode.NORMAL);
    }

    // setSubComponent(editComponent);
    editComponent.setMargin(false);
    editComponent.setWidth(100, Unit.PERCENTAGE);
    editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
    editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
    layout.addComponent(editComponent, CASE_LOC);

    TaskListComponent taskList = new TaskListComponent(TaskContext.CASE, getCaseRef());
    taskList.addStyleName(CssStyles.SIDE_COMPONENT);
    layout.addComponent(taskList, TASKS_LOC);

    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_VIEW) && !caze.isUnreferredPortHealthCase()) {
        SampleListComponent sampleList = new SampleListComponent(getCaseRef());
        sampleList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(sampleList, SAMPLES_LOC);
    }
}