Example usage for com.vaadin.ui CustomLayout setHeight

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

Introduction

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

Prototype

@Override
    public void setHeight(String height) 

Source Link

Usage

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   ww  w. ja  v  a2  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 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 ww w.  j a  va 2 s  . com
        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.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  .  j  a v a2 s.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:org.fossa.rolp.ui.dashboard.AdminDashboard.java

License:Open Source License

public AdminDashboard(RolpApplication app) {
    super("./applicationMainLayout/adminLayout");
    this.app = app;

    buildButtonBattery();// w  w  w. j  a  va2s.co  m

    CustomLayout lehrerListe = new CustomLayout("./lehrerDashboards/liste");
    lehrerListe.addStyleName("liste");

    lehrerListe.addComponent(getLehrerList(), "list");
    lehrerListe.setHeight("260px");

    addComponent(lehrerListe, "liste");
    addComponent(horizontalButtonBattery, "horizontalButtonBattery");
    addComponent(verticalButtonBattery, "verticalButtonBattery");
}

From source file:org.fossa.rolp.ui.dashboard.FachlehrerDashboard.java

License:Open Source License

public FachlehrerDashboard(RolpApplication app) {
    super(app);//w  w w  .j ava2s . c om
    this.app = app;
    setCaption(" - FachlehrerDashboard - ");
    setWidth("100%");
    setHeight("100%");

    buildButtonBatteries();

    CustomLayout layout = new CustomLayout("./lehrerDashboards/fachLehrerDashboardMain");
    setContent(layout);

    CustomLayout headline = new CustomLayout("./lehrerDashboards/headline");
    headline.addStyleName("headline");

    Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH));
    logo.setType(Embedded.TYPE_IMAGE);
    logo.setWidth("100px");
    logo.setHeight("96px");

    headline.addComponent(logo, "logo");

    CustomLayout faecherListe = new CustomLayout("./lehrerDashboards/liste");
    faecherListe.addStyleName("liste");
    faecherList = getFaecherList();
    faecherList.setHeight("250px");
    faecherList.setStyleName("list");
    faecherListe.addComponent(faecherList, "list");
    faecherListe.setHeight("260px");

    layout.addComponent(faecherListe, "liste");
    layout.addComponent(headline, "headline");
    layout.addComponent(horizontalButtonBattery, "horizontalButtonBattery");

    lehrerBlog = getLehrerBlog();
    layout.addComponent(lehrerBlog, "blog");
    windowCloseButton.setWidth("100%");
    layout.addComponent(windowCloseButton, "windowCloseButton");

}

From source file:org.fossa.rolp.ui.dashboard.KlassenlehrerDashboard.java

License:Open Source License

public KlassenlehrerDashboard(RolpApplication app) {
    super(app);/*from www .j a  v a2 s.c  om*/
    this.app = app;
    setCaption(" - KlassenlehrerDashboard - ");
    setWidth("100%");
    setHeight("100%");

    buildButtonBatteries();

    CustomLayout layout = new CustomLayout("./lehrerDashboards/klassenLehrerDashboardMain");
    setContent(layout);

    CustomLayout headline = new CustomLayout("./lehrerDashboards/headline");
    headline.addStyleName("headline");

    Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH));
    logo.setType(Embedded.TYPE_IMAGE);
    logo.setWidth("100px");
    logo.setHeight("96px");

    headline.addComponent(logo, "logo");
    headline.addComponent(headdataEditingPanel, "headdataEditingPanel");

    Panel hints = new Panel();
    hints.addStyleName("hints");
    hinweistext = new Label();
    hinweistext.setContentMode(Label.CONTENT_XHTML);
    hinweistext.setReadOnly(true);
    hinweistext.setHeight("250px");
    hints.setHeight("250px");
    hints.setScrollable(true);
    hints.addComponent(hinweistext);
    refreshHinweistext();

    CustomLayout schuelerListe = new CustomLayout("./lehrerDashboards/liste");
    schuelerListe.addStyleName("liste");
    schuelerList = getSchuelerList();
    schuelerList.setHeight("250px");
    schuelerList.setStyleName("list");
    schuelerListe.addComponent(schuelerList, "list");
    schuelerListe.setHeight("260px");
    layout.addComponent(schuelerListe, "liste");

    layout.addComponent(headline, "headline");
    layout.addComponent(horizontalButtonBattery, "horizontalButtonBattery");
    layout.addComponent(verticalButtonBattery, "verticalButtonBattery");

    layout.addComponent(hints, "hints");
    windowCloseButton.setWidth("100%");
    layout.addComponent(windowCloseButton, "windowCloseButton");
    //      app.getAnimator().animate(horizontalButtonBattery, AnimType.ROLL_DOWN_OPEN_POP).setDuration(500).setDelay(500);
}