List of usage examples for com.vaadin.ui Panel Panel
public Panel()
From source file:com.github.mjvesa.herd.HerdIDE.java
License:Apache License
private Panel createMainPanel() { Panel p = new Panel(); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true);/*ww w .jav a2 s. co m*/ p.setContent(vl); p.setSizeFull(); return p; }
From source file:com.github.peholmst.i18n4vaadin.cdi.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout content = new VerticalLayout(); content.setMargin(true);//ww w . j a va 2 s . co m content.setSpacing(true); content.setSizeFull(); setContent(content); languageChanger = new ComboBox(); languageChanger.setContainerDataSource( new BeanItemContainer<java.util.Locale>(java.util.Locale.class, i18n.getSupportedLocales())); languageChanger.setImmediate(true); languageChanger.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (languageChanger.getValue() != null) { i18n.setLocale((java.util.Locale) languageChanger.getValue()); } } }); content.addComponent(languageChanger); Panel viewContent = new Panel(); viewContent.setSizeFull(); content.addComponent(viewContent); content.setExpandRatio(viewContent, 1); Navigator navigator = new Navigator(this, viewContent); navigator.addProvider(viewProvider); navigator.navigateTo("demo"); setNavigator(navigator); updateStrings(); }
From source file:com.github.peholmst.i18n4vaadin.simple.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout content = new VerticalLayout(); content.setMargin(true);//from w ww . j a v a2 s.co m content.setSpacing(true); content.setSizeFull(); setContent(content); languageChanger = new ComboBox(); languageChanger.setContainerDataSource( new BeanItemContainer<java.util.Locale>(java.util.Locale.class, i18n.getSupportedLocales())); languageChanger.setImmediate(true); languageChanger.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (languageChanger.getValue() != null) { i18n.setLocale((java.util.Locale) languageChanger.getValue()); } } }); content.addComponent(languageChanger); Panel viewContent = new Panel(); viewContent.setSizeFull(); content.addComponent(viewContent); content.setExpandRatio(viewContent, 1); Navigator navigator = new Navigator(this, viewContent); navigator.addView("demo", DemoView.class); navigator.navigateTo("demo"); setNavigator(navigator); updateStrings(); }
From source file:com.github.peholmst.springsecuritydemo.ui.LoginView.java
License:Apache License
@SuppressWarnings("serial") protected void init() { final Panel loginPanel = new Panel(); loginPanel.setCaption(getApplication().getMessage("login.title")); ((VerticalLayout) loginPanel.getContent()).setSpacing(true); final TextField username = new TextField(getApplication().getMessage("login.username")); username.setWidth("100%"); loginPanel.addComponent(username);//from w w w . j ava 2 s . c o m final TextField password = new TextField(getApplication().getMessage("login.password")); password.setSecret(true); password.setWidth("100%"); loginPanel.addComponent(password); final Button loginButton = new Button(getApplication().getMessage("login.button")); loginButton.setStyleName("primary"); // TODO Make it possible to submit the form by pressing <Enter> in any // of the text fields loginPanel.addComponent(loginButton); ((VerticalLayout) loginPanel.getContent()).setComponentAlignment(loginButton, Alignment.MIDDLE_RIGHT); loginButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { final Authentication auth = new UsernamePasswordAuthenticationToken(username.getValue(), password.getValue()); try { if (logger.isDebugEnabled()) { logger.debug("Attempting authentication for user '" + auth.getName() + "'"); } Authentication returned = getAuthenticationManager().authenticate(auth); if (logger.isDebugEnabled()) { logger.debug("Authentication for user '" + auth.getName() + "' succeeded"); } fireEvent(new LoginEvent(LoginView.this, returned)); } catch (BadCredentialsException e) { if (logger.isDebugEnabled()) { logger.debug("Bad credentials for user '" + auth.getName() + "'", e); } getWindow().showNotification(getApplication().getMessage("login.badCredentials.title"), getApplication().getMessage("login.badCredentials.descr"), Notification.TYPE_WARNING_MESSAGE); } catch (DisabledException e) { if (logger.isDebugEnabled()) { logger.debug("Account disabled for user '" + auth.getName() + "'", e); } getWindow().showNotification(getApplication().getMessage("login.disabled.title"), getApplication().getMessage("login.disabled.descr"), Notification.TYPE_WARNING_MESSAGE); } catch (LockedException e) { if (logger.isDebugEnabled()) { logger.debug("Account locked for user '" + auth.getName() + "'", e); } getWindow().showNotification(getApplication().getMessage("login.locked.title"), getApplication().getMessage("login.locked.descr"), Notification.TYPE_WARNING_MESSAGE); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("Error while attempting authentication for user '" + auth.getName() + "'"); } ExceptionUtils.handleException(getWindow(), e); } } }); HorizontalLayout languages = new HorizontalLayout(); languages.setSpacing(true); final Button.ClickListener languageListener = new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Locale locale = (Locale) event.getButton().getData(); if (logger.isDebugEnabled()) { logger.debug("Changing locale to [" + locale + "] and restarting the application"); } getApplication().setLocale(locale); getApplication().close(); } }; for (Locale locale : getApplication().getSupportedLocales()) { if (!getLocale().equals(locale)) { final Button languageButton = new Button(getApplication().getLocaleDisplayName(locale)); languageButton.setStyleName(Button.STYLE_LINK); languageButton.setData(locale); languageButton.addListener(languageListener); languages.addComponent(languageButton); } } loginPanel.addComponent(languages); loginPanel.setWidth("300px"); final HorizontalLayout viewLayout = new HorizontalLayout(); viewLayout.addComponent(loginPanel); viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); viewLayout.setSizeFull(); viewLayout.setMargin(true); setCompositionRoot(viewLayout); setSizeFull(); }
From source file:com.hack23.cia.web.impl.ui.application.views.admin.system.pagemode.AdminApplicationConfigurationPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ADMIN" }) @Override//from ww w . j a v a2 s .c o m public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); final String pageId = getPageId(parameters); final int pageNr = getPageNr(parameters); getMenuItemFactory().createMainPageMenuBar(menuBar); LabelFactory.createHeader2Label(content, ADMIN_APPLICATION_CONFIGURATION); final DataContainer<ApplicationConfiguration, Long> dataContainer = getApplicationManager() .getDataContainer(ApplicationConfiguration.class); final BeanItemContainer<ApplicationConfiguration> politicianDocumentDataSource = new BeanItemContainer<>( ApplicationConfiguration.class, dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, ApplicationConfiguration_.configurationGroup)); createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE); getGridFactory().createBasicBeanItemGrid(content, politicianDocumentDataSource, "ApplicationConfiguration", new String[] { "hjid", "configurationGroup", "component", "componentTitle", "configTitle", "configDescription", "componentDescription", "propertyId", "propertyValue" }, new String[] { "hjid", "modelObjectId", "modelObjectVersion", "createdDate", "updatedDate", "propertyId", "componentDescription", "componentTitle" }, new PageItemPropertyClickListener(AdminViews.ADMIN_APPLICATIONS_CONFIGURATION_VIEW_NAME, "hjid"), null, null); if (pageId != null && !pageId.isEmpty()) { final ApplicationConfiguration applicationConfiguration = dataContainer.load(Long.valueOf(pageId)); if (applicationConfiguration != null) { final VerticalLayout leftLayout = new VerticalLayout(); leftLayout.setSizeFull(); final VerticalLayout rightLayout = new VerticalLayout(); rightLayout.setSizeFull(); final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth(ContentSize.FULL_SIZE); content.addComponent(horizontalLayout); horizontalLayout.addComponent(leftLayout); horizontalLayout.addComponent(rightLayout); getFormFactory().addFormPanelTextFields(leftLayout, new BeanItem<>(applicationConfiguration), ApplicationConfiguration.class, Arrays.asList(new String[] { "configurationGroup", "component", "configTitle", "configDescription", "propertyValue", "createdDate", "updatedDate" })); final UpdateApplicationConfigurationRequest request = new UpdateApplicationConfigurationRequest(); request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); request.setApplicationConfigurationId(applicationConfiguration.getHjid()); request.setConfigTitle(applicationConfiguration.getConfigTitle()); request.setConfigDescription(applicationConfiguration.getConfigDescription()); request.setComponentTitle(applicationConfiguration.getConfigTitle()); request.setComponentDescription(applicationConfiguration.getComponentDescription()); request.setPropertyValue(applicationConfiguration.getPropertyValue()); final ClickListener buttonListener = new UpdateApplicationConfigurationClickListener(request, getApplicationManager()); final Panel updateFormPanel = new Panel(); updateFormPanel.setSizeFull(); rightLayout.addComponent(updateFormPanel); final FormLayout updateFormContent = new FormLayout(); updateFormPanel.setContent(updateFormContent); getFormFactory().addRequestInputFormFields(updateFormContent, new BeanItem<>(request), UpdateApplicationConfigurationRequest.class, Arrays.asList(new String[] { "configTitle", "configDescription", "componentTitle", "componentDescription", "propertyValue" }), "Update Configuration", buttonListener); } } getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_APPLICATION_CONFIGURATION_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId); return content; }
From source file:com.hack23.cia.web.impl.ui.application.views.admin.system.pagemode.EmailPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ADMIN" }) @Override// w ww .java 2s. co m public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); final String pageId = getPageId(parameters); getMenuItemFactory().createMainPageMenuBar(menuBar); LabelFactory.createHeader2Label(content, ADMIN_EMAIL); final VerticalLayout emailLayout = new VerticalLayout(); emailLayout.setSizeFull(); final Panel formPanel = new Panel(); formPanel.setSizeFull(); emailLayout.addComponent(formPanel); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final SendEmailRequest sendEmailRequest = new SendEmailRequest(); sendEmailRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); sendEmailRequest.setEmail(""); sendEmailRequest.setSubject(""); sendEmailRequest.setContent(""); final ClickListener sendEmailListener = new SendEmailClickListener(sendEmailRequest, getApplicationManager()); getFormFactory().addRequestInputFormFields(formContent, new BeanItem<>(sendEmailRequest), SendEmailRequest.class, Arrays.asList(new String[] { "email", "subject", "content" }), "Email", sendEmailListener); content.addComponent(emailLayout); content.setExpandRatio(emailLayout, ContentRatio.LARGE_FORM); panel.setCaption("Admin email"); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_EMAIL_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId); return content; }
From source file:com.hack23.cia.web.impl.ui.application.views.common.chartfactory.impl.AbstractChartDataManagerImpl.java
License:Apache License
/** * Adds the chart.//from w w w . j av a2s . com * * @param content * the content * @param caption * the caption * @param chart * the chart */ protected final void addChart(final AbstractOrderedLayout content, final String caption, final DCharts chart) { final HorizontalLayout horizontalLayout = new HorizontalLayout(); final int browserWindowWidth = Page.getCurrent().getBrowserWindowWidth() - 50; final int browserWindowHeight = Page.getCurrent().getBrowserWindowHeight() - 200; horizontalLayout.setWidth(browserWindowWidth, Unit.PIXELS); horizontalLayout.setHeight(browserWindowHeight, Unit.PIXELS); final Panel formPanel = new Panel(); formPanel.setSizeFull(); formPanel.setContent(horizontalLayout); content.addComponent(formPanel); content.setExpandRatio(formPanel, ContentRatio.LARGE); chart.setWidth(browserWindowWidth - 50, Unit.PIXELS); chart.setHeight(browserWindowHeight - 100, Unit.PIXELS); chart.setMarginRight(5); chart.setMarginLeft(5); chart.setMarginBottom(5); chart.setMarginTop(5); chart.setEnableDownload(true); chart.setChartImageFormat(ChartImageFormat.PNG); horizontalLayout.addComponent(chart); chart.setCaption(caption); }
From source file:com.hack23.cia.web.impl.ui.application.views.common.formfactory.impl.FormFactoryImpl.java
License:Apache License
@Override public <T extends Serializable> void addFormPanelTextFields(final AbstractOrderedLayout panelContent, final BeanItem<T> item, final Class<T> beanType, final List<String> displayProperties) { final Panel formPanel = new Panel(); formPanel.setSizeFull();/* w ww .ja v a 2 s.c o m*/ panelContent.addComponent(formPanel); panelContent.setExpandRatio(formPanel, ContentRatio.GRID); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final BeanFieldGroup<T> fieldGroup = new BeanFieldGroup<>(beanType); fieldGroup.setItemDataSource(item); fieldGroup.setReadOnly(true); for (final String property : displayProperties) { final Field<?> buildAndBind = fieldGroup.buildAndBind(property); buildAndBind.setWidth(ContentSize.FULL_SIZE); formContent.addComponent(buildAndBind); } final Collection<Object> unboundPropertyIds = fieldGroup.getUnboundPropertyIds(); for (final Object property : unboundPropertyIds) { LOGGER.debug(LOG_MSG_PROPERTY, property); } }
From source file:com.hack23.cia.web.impl.ui.application.views.common.pagemode.MainViewRegisterPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ANONYMOUS" }) @Override/* w w w.j av a2 s .c om*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); final String pageId = getPageId(parameters); getMenuItemFactory().createMainPageMenuBar(menuBar); final VerticalLayout registerLayout = new VerticalLayout(); registerLayout.setSizeFull(); final Panel formPanel = new Panel(); formPanel.setSizeFull(); registerLayout.addComponent(formPanel); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final RegisterUserRequest reqisterRequest = new RegisterUserRequest(); reqisterRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); reqisterRequest.setUsername(""); reqisterRequest.setEmail(""); reqisterRequest.setCountry(""); reqisterRequest.setUserpassword(""); final ClickListener reqisterListener = new RegisterUserClickListener(reqisterRequest, getApplicationManager()); getFormFactory().addRequestInputFormFields(formContent, new BeanItem<>(reqisterRequest), RegisterUserRequest.class, Arrays.asList(new String[] { "username", "email", "country", "userpassword" }), "Register", reqisterListener); content.addComponent(registerLayout); panel.setCaption(CITIZEN_INTELLIGENCE_AGENCY_MAIN); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MAIN_VIEW, ApplicationEventGroup.USER, CommonsViews.MAIN_VIEW_NAME, parameters, pageId); return content; }
From source file:com.hack23.cia.web.impl.ui.application.views.user.document.pagemode.DocumentDataPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" }) @Override//from w w w. j av a 2s . c o m public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout panelContent = createPanelContent(); final String pageId = getPageId(parameters); final DataContainer<DocumentElement, String> documentElementDataContainer = getApplicationManager() .getDataContainer(DocumentElement.class); final DataContainer<DocumentContentData, String> documentContentDataDataContainer = getApplicationManager() .getDataContainer(DocumentContentData.class); getApplicationManager().getDataContainer(CommitteeProposalComponentData.class); final DocumentElement documentElement = documentElementDataContainer.load(pageId); if (documentElement != null) { getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId); LabelFactory.createHeader2Label(panelContent, DOCUMENT_DATA); final List<DocumentContentData> documentContentlist = documentContentDataDataContainer .getAllBy(DocumentContentData_.id, pageId); if (!documentContentlist.isEmpty()) { final Panel formPanel = new Panel(); formPanel.setSizeFull(); panelContent.addComponent(formPanel); final FormLayout formContent = new FormLayout(); formPanel.setContent(formContent); final Label htmlContent = new Label(documentContentlist.get(0).getContent(), ContentMode.HTML); formContent.addComponent(htmlContent); panelContent.setExpandRatio(formPanel, ContentRatio.GRID); } panel.setContent(panelContent); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId); } return panelContent; }