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:ac.uk.icl.dell.vaadin.glycanbuilder.GlycanBuilderWindow.java

License:Open Source License

@Override
public void init() {
    Window mainWindow = new Window();
    setMainWindow(mainWindow);/*w ww .  jav a  2 s .  c o m*/
    setTheme("ucdb_2011theme");

    SimpleFileMenu menu = new SimpleFileMenu();

    CustomLayout layout = new CustomLayout("header_content_footer_layout");
    layout.addComponent(menu, "header");
}

From source file:ch.bfh.ti.soed.hs16.srs.white.view.TemplateLayout.java

License:Open Source License

@Override
public Component load() {
    CustomLayout customLayout = new CustomLayout("template");

    LogInView logInView = new LogInView();
    body.addComponent(logInView.load());

    customLayout.addComponent(body, "body");
    return customLayout;
}

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CustomLayout boxWrapper = CustomLayoutExt.createLayout("legendBox");
    final CssLayout mainLayout = new CssLayout();

    mainLayout.setSizeUndefined();/*  ww  w.j  a va 2  s  .  c om*/
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        final HorizontalLayout layout = new HorizontalLayout();
        layout.setMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        final Comparable key = (Comparable) keys.get(i);
        final String color = "<div style = \" width:8px;height:8px;border-radius:5px;background: #"
                + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length] + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            btnCaption = String.format("%s(%d)", key, pieDataSet.getValue(key).intValue());
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(btnCaption, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                PieChartWrapper.this.onClickedDescription(key.toString());
            }
        });
        btnLink.addStyleName("link");
        layout.addComponent(lblCircle);
        layout.setComponentAlignment(lblCircle, Alignment.MIDDLE_CENTER);
        layout.addComponent(btnLink);
        layout.setComponentAlignment(btnLink, Alignment.MIDDLE_CENTER);
        layout.setSizeUndefined();
        mainLayout.addComponent(layout);
    }
    boxWrapper.setWidth("100%");
    boxWrapper.addComponent(mainLayout, "legendBoxContent");
    return boxWrapper;
}

From source file:com.esofthead.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(AppContext.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  w w. jav  a 2  s  .co m
    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) {
            Iterator<Component> iterator = serviceMenu.iterator();

            while (iterator.hasNext()) {
                Component comp = iterator.next();
                if (comp != event.getButton()) {
                    comp.removeStyleName("selected");
                }
            }
            event.getButton().addStyleName("selected");
        }
    };

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener);
    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS,
            clickListener);
    serviceMenu.addService(AppContext.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(
                            AppContext.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(
                        AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    logoUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    logoUploadField.addStyleName("upload-field");
    logoUploadField.setSizeUndefined();
    logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY);
    logoUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    BillingAccountService billingAccountService = AppContextUtil
                            .getSpringBean(BillingAccountService.class);
                    billingAccount.setLogopath(null);
                    billingAccountService.updateWithSession(billingAccount, AppContext.getUsername());
                    Page.getCurrent().getJavaScript().execute("window.location.reload();");
                }
            });
    resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));
    resetButton.setStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(logoUploadField, resetButton);
    rightPanel.with(previewLayout, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Logo", layout);
    this.with(formContainer);
}

From source file:com.esofthead.mycollab.shell.view.MainView.java

License:Open Source License

private CustomLayout createFooter() {
    final CustomLayout footer = CustomLayoutExt.createLayout("footer");

    Link companyLink = new Link("eSoftHead", new ExternalResource("http://www.esofthead.com"));
    companyLink.setTargetName("_blank");

    footer.addComponent(companyLink, "company-url");

    Calendar currentCal = Calendar.getInstance();

    Label currentYear = new Label(String.valueOf(currentCal.get(Calendar.YEAR)));
    currentYear.setSizeUndefined();/* w w  w .  j  a  va  2 s. c  o m*/
    footer.addComponent(currentYear, "current-year");

    HorizontalLayout footerRight = new HorizontalLayout();
    footerRight.setSpacing(true);

    final Button sendFeedback = new Button("Feedback");
    sendFeedback.setStyleName("link");
    sendFeedback.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            UI.getCurrent().addWindow(new FeedbackWindow());
        }
    });
    Link blogLink = new Link("Blog", new ExternalResource("https://www.mycollab.com/blog"));
    blogLink.setTargetName("_blank");

    Link forumLink = new Link("Forum", new ExternalResource("http://forum.mycollab.com"));
    forumLink.setTargetName("_blank");

    Link wikiLink = new Link("Knowledge Base", new ExternalResource("https://www.mycollab.com/help/"));
    wikiLink.setTargetName("_blank");

    footerRight.addComponent(blogLink);
    footerRight.addComponent(forumLink);
    footerRight.addComponent(wikiLink);
    footerRight.addComponent(sendFeedback);

    footer.addComponent(footerRight, "footer-right");
    return footer;
}

From source file:com.esofthead.mycollab.shell.view.MainView.java

License:Open Source License

private CustomLayout createTopMenu() {
    final CustomLayout layout = CustomLayoutExt.createLayout("topNavigation");
    layout.setStyleName("topNavigation");
    layout.setHeight("40px");
    layout.setWidth("100%");

    Button accountLogo = AccountLogoFactory
            .createAccountLogoImageComponent(ThemeManager.loadLogoPath(AppContext.getAccountId()), 150);

    accountLogo.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from  www.jav a  2s. co  m
        public void buttonClick(final ClickEvent event) {
            final UserPreference pref = AppContext.getUserPreference();
            if (pref.getLastmodulevisit() == null
                    || ModuleNameConstants.PRJ.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
            } else if (ModuleNameConstants.CRM.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
            } else if (ModuleNameConstants.ACCOUNT.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule(this, null));
            } else if (ModuleNameConstants.FILE.equals(pref.getLastmodulevisit())) {
                EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
            }
        }
    });
    layout.addComponent(accountLogo, "mainLogo");

    serviceMenu = new ServiceMenu();
    serviceMenu.addStyleName("topNavPopup");

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM),
            MyCollabResource.newResource(WebResourceIds._16_customer), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            MyCollabResource.newResource(WebResourceIds._16_project), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    if (!event.isCtrlKey() && !event.isMetaKey()) {
                        EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
                    }
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT),
            MyCollabResource.newResource(WebResourceIds._16_document), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
                }
            });

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PEOPLE),
            MyCollabResource.newResource(WebResourceIds._16_account), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });

    layout.addComponent(serviceMenu, "serviceMenu");

    final MHorizontalLayout accountLayout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, true, false, false));
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final Label accountNameLabel = new Label(AppContext.getSubDomain());
    accountNameLabel.setStyleName("subdomain");
    accountLayout.addComponent(accountNameLabel);

    // display trial box if user in trial mode
    SimpleBillingAccount billingAccount = AppContext.getBillingAccount();
    if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) {
        Label informLbl = new Label("", ContentMode.HTML);
        informLbl.addStyleName("trialEndingNotification");
        informLbl.setHeight("100%");
        HorizontalLayout informBox = new HorizontalLayout();
        informBox.addStyleName("trialInformBox");
        informBox.setSizeFull();
        informBox.addComponent(informLbl);
        informBox.setMargin(new MarginInfo(false, true, false, false));
        informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
            }
        });
        accountLayout.addComponent(informBox);
        accountLayout.setSpacing(true);
        accountLayout.setComponentAlignment(informBox, Alignment.MIDDLE_LEFT);

        Date createdTime = billingAccount.getCreatedtime();
        long timeDeviation = System.currentTimeMillis() - createdTime.getTime();
        int daysLeft = (int) Math.floor(timeDeviation / (1000 * 60 * 60 * 24));
        if (daysLeft > 30) {
            BillingService billingService = ApplicationContextUtil.getSpringBean(BillingService.class);
            BillingPlan freeBillingPlan = billingService.getFreeBillingPlan();
            billingAccount.setBillingPlan(freeBillingPlan);

            informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>"
                    + " 0 DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
        } else {
            if (AppContext.isAdmin()) {
                informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft)
                        + " DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
            } else {
                informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft)
                        + " DAYS LEFT</div><div class='informBlock'>&gt;&gt;</div>");
            }
        }
    }

    NotificationButton notificationButton = new NotificationButton();
    accountLayout.addComponent(notificationButton);
    if (AppContext.getSession().getTimezone() == null) {
        EventBusFactory.getInstance().post(new ShellEvent.NewNotification(this, new TimezoneNotification()));
    }

    if (StringUtils.isBlank(AppContext.getSession().getAvatarid())) {
        EventBusFactory.getInstance()
                .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification()));
    }

    if (SiteConfiguration.getDeploymentMode() != DeploymentMode.site && AppContext.isAdmin()) {
        try {
            Client client = ClientBuilder.newBuilder().build();
            WebTarget target = client.target("https://api.mycollab.com/api/checkupdate");
            Response response = target.request().get();
            String values = response.readEntity(String.class);
            Gson gson = new Gson();
            Properties props = gson.fromJson(values, Properties.class);
            String version = props.getProperty("version");
            if (!MyCollabVersion.getVersion().equals(version)) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.NewNotification(this, new NewUpdateNotification(props)));
            }
        } catch (Exception e) {
            LOG.error("Error when call remote api", e);
        }
    }

    UserAvatarComp userAvatar = new UserAvatarComp();
    accountLayout.addComponent(userAvatar);
    accountLayout.setComponentAlignment(userAvatar, Alignment.MIDDLE_LEFT);

    final PopupButton accountMenu = new PopupButton(AppContext.getSession().getDisplayName());
    final VerticalLayout accLayout = new VerticalLayout();
    accLayout.setWidth("140px");

    final Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" }));
                }
            });
    myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE));
    myProfileBtn.setStyleName("link");
    accLayout.addComponent(myProfileBtn);

    final Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" }));
                }
            });
    myAccountBtn.setStyleName("link");
    myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING));
    accLayout.addComponent(myAccountBtn);

    final Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    accountMenu.setPopupVisible(false);
                    EventBusFactory.getInstance()
                            .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
                }
            });
    userMgtBtn.setStyleName("link");
    userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS));
    accLayout.addComponent(userMgtBtn);

    final Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    AppContext.getInstance().clearSession();
                    EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null));
                }
            });
    signoutBtn.setStyleName("link");
    signoutBtn.setIcon(FontAwesome.SIGN_OUT);
    accLayout.addComponent(signoutBtn);

    accountMenu.setContent(accLayout);
    accountMenu.setStyleName("accountMenu");
    accountMenu.addStyleName("topNavPopup");
    accountLayout.addComponent(accountMenu);

    layout.addComponent(accountLayout, "accountMenu");

    return layout;
}

From source file:com.klwork.explorer.project.ProjectSearchPanel.java

License:Apache License

protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    //CssLayout csslayout2 = new CssLayout();
    CustomLayout csslayout = new CustomLayout("circularButton");
    csslayout.setHeight(24, Unit.PIXELS);
    csslayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(csslayout);//from w  w  w . jav  a 2 s. co  m

    inputField = new TextField();
    inputField.setWidth(50, Unit.PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt("??");
    inputField.focus();
    csslayout.addComponent(inputField, "searchInput");

    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
}

From source file:com.klwork.explorer.ui.business.outproject.ProjectSearchPanel.java

License:Apache License

protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    //CssLayout csslayout2 = new CssLayout();
    CustomLayout csslayout = new CustomLayout("circularButton");
    //csslayout.setHeight(24, Unit.PIXELS);
    csslayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(csslayout);//from  ww  w .  j  a v a 2s  .  c  o  m

    inputField = new TextField();
    inputField.setWidth(50, Unit.PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt("??");
    inputField.focus();
    csslayout.addComponent(inputField, "searchInput");

    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
}

From source file:com.klwork.explorer.ui.custom.TaskListHeader.java

License:Apache License

protected void initInputField() {
    // Csslayout is used to style inputtext as rounded
    //CssLayout csslayout2 = new CssLayout();
    CustomLayout csslayout = new CustomLayout("circularButton");
    csslayout.setHeight(24, Unit.PIXELS);
    csslayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(csslayout);//from  www  .jav a2s . co m

    inputField = new TextField();
    inputField.setWidth(100, Unit.PERCENTAGE);
    inputField.addStyleName(ExplorerLayout.STYLE_SEARCHBOX);
    inputField.setInputPrompt(i18nManager.getMessage(Messages.TASK_CREATE_NEW));
    inputField.focus();
    csslayout.addComponent(inputField, "searchInput");

    layout.setComponentAlignment(csslayout, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(csslayout, 1.0f);
}

From source file:com.lst.deploymentautomation.vaadin.core.AppView.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    if (title.getParent() == null) {
        try {/*w  w  w.  j  a v  a 2s.  c  o m*/
            CustomLayout titleWrapper = new CustomLayout(
                    new ByteArrayInputStream("<h1 location='title'></h1>".getBytes("UTF-8")));
            titleWrapper.addComponent(title, "title");
            Component header = createHeader(titleWrapper);
            header.addStyleName("view-header");
            layout.addComponent(header);
        } catch (IOException e) {
            //should not happen; rethrow
            throw new RuntimeException(e);
        }
    }
}