Example usage for com.vaadin.ui CustomLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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();//from   ww  w  . java2 s  . com
    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. j  a va  2s. 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/* w  w  w  .j  av  a  2 s.c om*/
        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.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);/*  www  .  ja  va 2s .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) {

            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.airline.CelestiaLogin.java

@Override
protected void init(VaadinRequest request) {
    //Vista final para la UI
    final VerticalLayout layout = new VerticalLayout();

    Panel loginPanel = new Panel("Login");
    CustomLayout login = new CustomLayout("LoginLayout");
    //Seccin de Vista del Login
    //VerticalLayout login=new VerticalLayout(); 
    Label label = new Label("Iniciar Sesin / Registrarse");
    TextField user = new TextField("", "Usuario");
    TextField passwd = new TextField("", "Contrasea");

    Button init_session = new Button("Iniciar Sesin");
    init_session.setStyleName(ValoTheme.BUTTON_PRIMARY);
    init_session.addClickListener(cliqueo -> {
        Notification.show("Bienvenido " + user.getValue());
    });//from  ww w .  j  a v a  2 s  .  c  o m

    login.addComponent(label);
    login.addComponent(user);
    login.addComponent(passwd);
    login.addComponent(init_session);
    login.setWidth("500px");
    //login.setMargin(true);
    login.setResponsive(true);

    layout.addComponent(login);
    layout.setComponentAlignment(login, Alignment.MIDDLE_CENTER);
    setContent(login);
}

From source file:org.opennms.features.pluginmgr.vaadin.config.opennms.PluginManagerAdminApplication.java

License:Open Source License

private void addHeader(VaadinRequest request) {
    if (m_headerProvider != null) {
        try {/*w w  w  .j  a  v a  2 s . c  om*/
            setHeaderHtml(
                    m_headerProvider.getHeaderHtml(((VaadinServletRequest) request).getHttpServletRequest()));
        } catch (final Exception e) {
            LOG.error("failed to get header HTML for request " + request.getPathInfo(), e.getCause());
        }
    }
    if (m_headerHtml != null) {
        InputStream is = null;
        try {
            is = new ByteArrayInputStream(m_headerHtml.getBytes());
            final CustomLayout headerLayout = new CustomLayout(is);
            headerLayout.setWidth("100%");
            headerLayout.addStyleName("onmsheader");
            m_rootLayout.addComponent(headerLayout);
        } catch (final IOException e) {
            closeQuietly(is);
            LOG.debug("failed to get header layout data", e);
        }
    }
}

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

private void addHeader() {
    if (m_headerHtml != null && m_showHeader) {
        InputStream is = null;/*from w w w.  ja v a 2  s  .  com*/
        try {
            is = new ByteArrayInputStream(m_headerHtml.getBytes());
            final CustomLayout headerLayout = new CustomLayout(is);
            headerLayout.setWidth("100%");
            headerLayout.addStyleName("onmsheader");
            m_rootLayout.addComponent(headerLayout);
        } catch (final IOException e) {
            try {
                is.close();
            } catch (final IOException closeE) {
                LOG.debug("failed to close HTML input stream", closeE);
            }
            LOG.debug("failed to get header layout data", e);
        }
    }
}

From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java

License:Open Source License

private void addHeader() {
    if (m_headerProvider != null) {
        try {//from  ww w  .  j a  v  a2  s .  c om
            URL pageUrl = Page.getCurrent().getLocation().toURL();
            setHeaderHtml(m_headerProvider.getHeaderHtml(new HttpServletRequestVaadinImpl(m_request, pageUrl)));
        } catch (final Exception e) {
            LOG.error("failed to get header HTML for request " + m_request.getPathInfo(), e.getCause());
        }
    }
    if (m_headerHtml != null) {
        InputStream is = null;
        try {
            is = new ByteArrayInputStream(m_headerHtml.getBytes());
            final CustomLayout headerLayout = new CustomLayout(is);
            headerLayout.setWidth("100%");
            headerLayout.addStyleName("onmsheader");
            m_rootLayout.addComponent(headerLayout);
        } catch (final IOException e) {
            closeQuietly(is);
            LOG.debug("failed to get header layout data", e);
        }
    }
}