List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:management.limbr.ui.login.LogInViewImpl.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();/*from ww w . ja v a 2 s.c o m*/ usernameField = new TextField(messages.get("usernameFieldLabel")); usernameField.setWidth(20.0f, Unit.EM); usernameField.setRequired(true); usernameField.setInputPrompt(messages.get("usernameFieldPrompt")); usernameField .addValidator(new StringLengthValidator(messages.get("usernameFieldValidation"), 3, 256, false)); usernameField.setImmediate(true); usernameField.setInvalidAllowed(false); passwordField = new PasswordField(messages.get("passwordFieldLabel")); passwordField.setWidth(20.0f, Unit.EM); passwordField.setInputPrompt(messages.get("passwordFieldPrompt")); passwordField .addValidator(new StringLengthValidator(messages.get("passwordFieldValidation"), 8, 256, false)); passwordField.setImmediate(true); passwordField.setRequired(true); passwordField.setNullRepresentation(""); Button logInButton = new Button(messages.get("logInButtonLabel")); logInButton.addClickListener(event -> { usernameField.setValidationVisible(false); passwordField.setValidationVisible(false); try { usernameField.commit(); passwordField.commit(); } catch (Validator.InvalidValueException e) { Notification.show(e.getMessage()); usernameField.setValidationVisible(true); passwordField.setValidationVisible(true); LOG.debug("Validation of log in fields failed.", e); } listeners.forEach(LogInViewListener::logInClicked); }); VerticalLayout fields = new VerticalLayout(usernameField, passwordField, logInButton); fields.setCaption(messages.get("logInCaption", LimbrApplication.getApplicationName())); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); VerticalLayout mainLayout = new VerticalLayout(fields); mainLayout.setSizeFull(); mainLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); mainLayout.setStyleName(ValoTheme.FORMLAYOUT_LIGHT); setCompositionRoot(mainLayout); listeners.forEach(listener -> listener.viewInitialized(this)); }
From source file:module.contents.presentationTier.component.PageView.java
License:Open Source License
private void renderPageMenuArea(final AbstractComponentContainer container) { final VerticalLayout verticalLayout = createVerticalLayout(container); menuArea = new PageMenuComponent(page); verticalLayout.addComponent(menuArea); if (page.canEdit()) { final AddSectionButton createSectionComponent = new AddSectionButton(new ContentEditorSaveListner() { @Override/*from w w w .j a v a 2 s. c om*/ public void save(final String title, final String content) { final Section section = page.addSection(title, content); pageBodyComponent.addSection(section); rerenderMenuArea(); } }); verticalLayout.addComponent(createSectionComponent); verticalLayout.setComponentAlignment(createSectionComponent, Alignment.BOTTOM_LEFT); } }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private void initView() { setCompositionRoot(root);// w w w . j av a 2 s. co m root.setSizeFull(); root.setSplitPosition(15); root.setStyleName("small previews"); previewArea.setWidth("100%"); previewTabs = new VerticalLayout(); previewTabs.setSizeFull(); previewTabs.setHeight(null); compoundTabs = new VerticalLayout(); compoundTabs.setSizeFull(); compoundTabs.setHeight(null); bennuStylesTabs = new VerticalLayout(); bennuStylesTabs.setSizeFull(); bennuStylesTabs.setHeight(null); VerticalLayout menu = new VerticalLayout(); menu.setSizeFull(); menu.setStyleName("sidebar-menu"); Button syncThemes = new Button("Sync Themes", new ClickListener() { @Override public void buttonClick(ClickEvent event) { syncThemes(); } }); menu.addComponent(syncThemes); menu.addComponent(new Label("Single Components")); menu.addComponent(previewTabs); menu.addComponent(new Label("Compound Styles")); menu.addComponent(compoundTabs); menu.addComponent(new Label("Bennu Styles")); menu.addComponent(bennuStylesTabs); root.setFirstComponent(menu); CssLayout toolbar = new CssLayout(); toolbar.setWidth("100%"); toolbar.setStyleName("toolbar"); toolbar.addComponent(editorToggle); final Window downloadWindow = new Window("Download Theme"); GridLayout l = new GridLayout(3, 2); l.setSizeUndefined(); l.setMargin(true); l.setSpacing(true); downloadWindow.setContent(l); downloadWindow.setModal(true); downloadWindow.setResizable(false); downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null); downloadWindow.addStyleName("opaque"); Label caption = new Label("Theme Name"); l.addComponent(caption); l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); final TextField name = new TextField(); name.setValue("my-chameleon"); name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed")); name.setRequired(true); name.setRequiredError("Please give a name for the theme"); downloadWindow.addComponent(name); Label info = new Label( "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.", Label.CONTENT_XHTML); info.addStyleName("tiny"); info.setWidth("200px"); l.addComponent(info, 1, 1, 2, 1); Button download = new Button(null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { getApplication().getMainWindow().addWindow(downloadWindow); name.focus(); } }); download.setDescription("Donwload the current theme"); download.setIcon(new ThemeResource("download.png")); download.setStyleName("icon-only"); toolbar.addComponent(download); menu.addComponent(toolbar); menu.setExpandRatio(toolbar, 1); menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER); }
From source file:net.sf.gazpachoquest.questionnaires.views.login.OldLoginView.java
License:Open Source License
public OldLoginView() { setSizeFull();//from w w w . j a v a 2s .c om // Language bar in the top-right corner for selecting // invitation interface language final HorizontalLayout languageBar = new HorizontalLayout(); languageBar.setHeight("50px"); // addComponent(languageBar); // setComponentAlignment(languageBar, Alignment.TOP_RIGHT); // Allow selecting a language. We are in a constructor of a // CustomComponent, so preselecting the current // language of the application can not be done before // this (and the selection) component are attached to // the application. final ComboBox languageSelector = new ComboBox("Select a language") { @Override public void attach() { super.attach(); // setValue(getLocale()); } }; // for (int i=0; i<locales.length; i++) { String locale = "es"; languageSelector.addItem(locale); languageSelector.setItemCaption(locale, "espaol"); // Automatically select the current locale // if (locales[i].equals(getLocale())) languageSelector.setValue(locale); // } // Create the invitation input field invitationTextField = new TextField("Invitation key:"); invitationTextField.setWidth("300px"); invitationTextField.setRequired(true); invitationTextField.setInputPrompt("Your questionnair invitation key (eg. 12345678)"); invitationTextField.setInvalidAllowed(false); // Create login button enterButton = new Button("Enter", this); // Add both to a panel VerticalLayout fields = new VerticalLayout(languageSelector, invitationTextField, enterButton); fields.setCaption("Please enter your invitation key to access the questionnair"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); // The view root layout VerticalLayout viewLayout = new VerticalLayout(fields); viewLayout.setSizeFull(); viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); setCompositionRoot(viewLayout); }
From source file:no.uib.probe.mnpc_2017.view.ApplicationLayout.java
public ApplicationLayout() { this.setWidth("100%"); this.setHeightUndefined(); // this.setStyleName(Reindeer.LAYOUT_WHITE); this.setMargin(false); this.setSpacing(true); VerticalLayout headerLayout = new VerticalLayout(); headerLayout.setWidth("100%"); headerLayout.setHeight("77px"); this.addComponent(headerLayout); Panel mainBodyPanel = new Panel(); // headerLayout.setStyleName(Reindeer.LAYOUT_BLUE); HorizontalLayout topLayoutContainer = new HorizontalLayout(); headerLayout.addComponent(topLayoutContainer); headerLayout.setComponentAlignment(topLayoutContainer, Alignment.MIDDLE_CENTER); topLayoutContainer.setWidthUndefined(); topLayoutContainer.setHeight("100%"); VerticalLayout logoLayout = new VerticalLayout(); logoLayout.setWidth("200px"); logoLayout.setHeight("100%"); logoLayout.setStyleName("starlogo"); logoLayout.setMargin(new MarginInfo(false, true, false, false)); Label title = new Label("NPC 2017"); logoLayout.addComponent(title);/* ww w . j a v a 2 s . c om*/ topLayoutContainer.addComponent(logoLayout); topLayoutContainer.setComponentAlignment(logoLayout, Alignment.MIDDLE_RIGHT); HorizontalLayout mainMenuContainer = new HorizontalLayout(); mainMenuContainer.setWidth("780px"); topLayoutContainer.addComponent(mainMenuContainer); topLayoutContainer.setComponentAlignment(mainMenuContainer, Alignment.MIDDLE_RIGHT); VerticalLayout layoutI = new VerticalLayout(); mainMenuContainer.addComponent(generateMenuBtn("Home", layoutI)); VerticalLayout layoutII = new VerticalLayout(); mainMenuContainer.addComponent(generateMenuBtn("Programme", layoutII)); VerticalLayout layoutIII = new VerticalLayout(); mainMenuContainer.addComponent(generateMenuBtn("Practical Information", layoutIII)); VerticalLayout layoutIV = new VerticalLayout(); mainMenuContainer.addComponent(generateMenuBtn("Exhibition & Sponsorship", layoutIV)); VerticalLayout layoutV = new VerticalLayout(); mainMenuContainer.addComponent(generateMenuBtn("Registration", layoutV)); VerticalLayout layoutVI = new VerticalLayout(); mainMenuContainer.addComponent(generateMenuBtn("Contact", layoutVI)); }
From source file:org.accelerators.activiti.admin.ui.LoginView.java
License:Open Source License
@SuppressWarnings("serial") public LoginView(AdminApp application) { // Set application reference this.app = application; // Init window caption app.getMainWindow().setCaption(app.getMessage(Messages.Title)); // Set layout to full size setSizeFull();/* ww w . jav a 2 s .c o m*/ // Set style this.setStyleName("login-background"); // Add header bar final HorizontalLayout header = new HorizontalLayout(); header.setHeight("50px"); header.setWidth("100%"); addComponent(header); setComponentAlignment(header, Alignment.MIDDLE_CENTER); // Setup grid GridLayout loginGrid = new GridLayout(1, 2); loginGrid.setWidth("250px"); addComponent(loginGrid); setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER); // Add title to header GridLayout logoGrid = new GridLayout(1, 1); loginGrid.addComponent(logoGrid, 0, 0); loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER); Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png")); logoImage.setType(Embedded.TYPE_IMAGE); logoImage.addStyleName("login-image"); logoGrid.addComponent(logoImage, 0, 0); logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER); // Add field and button layout VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setSizeFull(); buttonLayout.setSpacing(true); buttonLayout.setMargin(false); buttonLayout.setStyleName("login-form"); loginGrid.addComponent(buttonLayout, 0, 1); loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); // Add username field username = new TextField(app.getMessage(Messages.Username)); username.setWidth("100%"); buttonLayout.addComponent(username); // Add password field password = new PasswordField(app.getMessage(Messages.Password)); password.setWidth("100%"); buttonLayout.addComponent(password); // Add Login button buttonLayout.addComponent(login); buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT); // Set focus to this component username.focus(); // Add shortcut to login button login.setClickShortcut(KeyCode.ENTER); login.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { // Athenticate the user authenticate((String) username.getValue(), (String) password.getValue()); // Switch to the main view app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app)); } catch (Exception e) { getWindow().showNotification(e.toString()); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); footer.setWidth("100%"); addComponent(footer); }
From source file:org.activiti.administrator.ui.LoginView.java
License:Apache License
@SuppressWarnings("serial") public LoginView(AdminApp application) { // Set application reference this.app = application; // Init window caption app.getMainWindow().setCaption(app.getMessage(Messages.Title)); // Set style//from w w w .j a va 2 s . c o m setStyleName(Reindeer.LAYOUT_WHITE); // Set layout to full size setSizeFull(); // Create main layout VerticalLayout mainLayout = new VerticalLayout(); // Add layout styles mainLayout.setStyleName(Reindeer.LAYOUT_WHITE); mainLayout.setWidth("100%"); mainLayout.setHeight("100%"); mainLayout.setMargin(false); mainLayout.setSpacing(false); // Add layout addComponent(mainLayout); setComponentAlignment(mainLayout, Alignment.TOP_LEFT); // Add field and button layout VerticalLayout buttonLayout = new VerticalLayout(); buttonLayout.setSpacing(true); buttonLayout.setMargin(true); buttonLayout.setWidth("200px"); buttonLayout.setStyleName("login-form"); // Add username field username = new TextField(app.getMessage(Messages.Username)); username.setWidth("100%"); buttonLayout.addComponent(username); // Add password field password = new PasswordField(app.getMessage(Messages.Password)); password.setWidth("100%"); buttonLayout.addComponent(password); // Add Login button buttonLayout.addComponent(login); buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_LEFT); // Add button layout mainLayout.addComponent(buttonLayout); // Add footer text Label footerText = new Label(app.getMessage(Messages.Footer)); footerText.setSizeUndefined(); footerText.setStyleName(Reindeer.LABEL_SMALL); footerText.addStyleName("footer"); mainLayout.addComponent(footerText); mainLayout.setComponentAlignment(footerText, Alignment.BOTTOM_CENTER); // Set focus to this component username.focus(); // Add shortcut to login button login.setClickShortcut(KeyCode.ENTER); login.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { try { // Athenticate the user authenticate((String) username.getValue(), (String) password.getValue()); // Switch to the main view app.switchView(MainView.class.getName(), new MainView(app)); } catch (Exception e) { getWindow().showNotification(e.toString()); } } }); }
From source file:org.activiti.explorer.ui.content.file.ImageAttachmentRenderer.java
License:Apache License
@Override public Component getDetailComponent(Attachment attachment) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeUndefined();/*from w ww . java 2 s.c o m*/ verticalLayout.setSpacing(true); verticalLayout.setMargin(true); Label description = new Label(attachment.getDescription()); description.setSizeUndefined(); verticalLayout.addComponent(description); // Image TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); String mimeType = extractMineType(attachment.getType()); InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()), mimeType, 900, 550); Resource resource = new StreamResource(new InputStreamStreamSource(imageStream), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get()); Embedded image = new Embedded(null, resource); verticalLayout.addComponent(image); // Linke HorizontalLayout LinkLayout = new HorizontalLayout(); LinkLayout.setSpacing(true); verticalLayout.addComponent(LinkLayout); verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER); Label fullSizeLabel = new Label( ExplorerApp.get().getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE)); LinkLayout.addComponent(fullSizeLabel); Link link = null; if (attachment.getUrl() != null) { link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl())); } else { taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); Resource res = new StreamResource( new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())), attachment.getName() + extractExtention(attachment.getType()), ExplorerApp.get()); link = new Link(attachment.getName(), res); } link.setIcon(Images.RELATED_CONTENT_PICTURE); link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK); LinkLayout.addComponent(link); return verticalLayout; }
From source file:org.activiti.explorer.ui.reports.SaveReportPopupWindow.java
License:Apache License
protected void createSaveButton(final I18nManager i18nManager, final VerticalLayout layout) { layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Button saveButton = new Button(i18nManager.getMessage(Messages.BUTTON_SAVE)); layout.addComponent(saveButton);/*from ww w . j a v a 2 s .c om*/ layout.setComponentAlignment(saveButton, Alignment.MIDDLE_CENTER); saveButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { String reportName = null; // Validate String error = null; if (nameField.getValue() == null || ((String) nameField.getValue()).length() == 0) { error = i18nManager.getMessage(Messages.REPORTING_SAVE_POPUP_NAME_EMPTY); } else { reportName = ExplorerApp.get().getLoggedInUser().getId() + "_" + nameField.getValue(); if (reportName.length() > 255) { error = i18nManager.getMessage(Messages.REPORTING_SAVE_POPUP_NAME_TOO_LONG); } else { boolean nameUsed = ProcessEngines.getDefaultProcessEngine().getHistoryService() .createHistoricProcessInstanceQuery().processInstanceBusinessKey(reportName) .count() != 0; if (nameUsed) { error = i18nManager.getMessage(Messages.REPORTING_SAVE_POPUP_NAME_EXISTS); } } } if (error != null) { setHeight(185, UNITS_PIXELS); layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Label errorLabel = new Label(error); errorLabel.addStyleName(ExplorerLayout.STYLE_ERROR); layout.addComponent(errorLabel); } else { // Re-run reports to store the data for good now (the previous process instance was deleted) if (originalFormProperties != null) { startProcessInstanceWithFormProperties(reportName); } else { startProcessInstance(reportName); } // Remove the popup if (componentToDisableOnClose != null) { componentToDisableOnClose.setEnabled(false); } close(); } } }); }
From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initDescription(HorizontalLayout layout) { final CssLayout descriptionLayout = new CssLayout(); descriptionLayout.setWidth(100, UNITS_PERCENTAGE); layout.addComponent(descriptionLayout); layout.setExpandRatio(descriptionLayout, 1.0f); layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT); String descriptionText = null; if (task.getDescription() != null && !"".equals(task.getDescription())) { descriptionText = task.getDescription(); } else {/*from w w w .j av a2 s . c o m*/ descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION); } final Label descriptionLabel = new Label(descriptionText); descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE); descriptionLayout.addComponent(descriptionLabel); descriptionLayout.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // layout for textarea + ok button final VerticalLayout editLayout = new VerticalLayout(); editLayout.setSpacing(true); // textarea final TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setNullRepresentation(""); descriptionTextArea.setWidth(100, UNITS_PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace descriptionLayout.replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); descriptionLayout.replaceComponent(editLayout, descriptionLabel); } }); } } }); }