List of usage examples for com.vaadin.ui CssLayout setStyleName
@Override public void setStyleName(String style)
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private CssLayout buildLoginSidebarLayout() { CssLayout loginSidebarLayout = new CssLayout(); loginSidebarLayout.setStyleName("login-sidebar"); Label htmlLabel = new Label(); htmlLabel.setContentMode(ContentMode.HTML); Path customHtmlDirectory = Paths.get(FacadeProvider.getConfigFacade().getCustomFilesPath()); Path filePath = customHtmlDirectory.resolve("loginsidebar.html"); try {/*from w w w . j a va 2s .c o m*/ byte[] encoded = Files.readAllBytes(filePath); htmlLabel.setValue(new String(encoded, "UTF-8")); } catch (IOException e) { htmlLabel.setValue(""); } loginSidebarLayout.addComponent(htmlLabel); return loginSidebarLayout; }
From source file:de.symeda.sormas.ui.login.LoginScreen.java
License:Open Source License
private CssLayout buildLoginDetailsLayout() { CssLayout loginDetailsLayout = new CssLayout(); loginDetailsLayout.setStyleName("login-details"); Label htmlLabel = new Label(); htmlLabel.setContentMode(ContentMode.HTML); Path customHtmlDirectory = Paths.get(FacadeProvider.getConfigFacade().getCustomFilesPath()); Path filePath = customHtmlDirectory.resolve("logindetails.html"); try {//from w w w. ja v a 2s. c o m byte[] encoded = Files.readAllBytes(filePath); htmlLabel.setValue(new String(encoded, "UTF-8")); } catch (IOException e) { htmlLabel.setValue(""); } loginDetailsLayout.addComponent(htmlLabel); return loginDetailsLayout; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultFormView.java
License:Apache License
@SuppressWarnings("serial") private void createFooterAndPopulateActions(FormActions actions) { CssLayout buttons = new CssLayout(); buttons.setStyleName("actions"); boolean allHidden = true; for (final FormAction action : actions) { final Button button = new Button(action.getTitle()); button.setDisableOnClick(true);/*from w w w . ja va 2 s .c o m*/ button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { presenter.executeAction(action); } finally { button.setEnabled(true); } } }); if (action.getActionHandler() instanceof SearchFormAction) { if (searchAction == null) { searchAction = action; // button.setClickShortcut(KeyCode.ENTER); } } if (action.isHidden()) { button.setVisible(false); } else { allHidden = false; } buttons.addComponent(button); } if (!allHidden) { rootLayout.addComponent(buttons); } }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTableView.java
License:Apache License
private Layout initButtonBar() { CssLayout buttonbar = new CssLayout(); buttonbar.setStyleName("actions"); if (tableModel.isEditable()) { if (tableModel.isModeChangeable()) { editButton = new Button(getMessage("portlet.crud.button.editMode")); editButton.setEnabled(true); buttonbar.addComponent(editButton); } else if (!tableModel.isFormEditEnabled()) { saveButton = new Button(getMessage("portlet.crud.button.save")); saveButton.setVisible(false); saveButton.setEnabled(true); buttonbar.addComponent(saveButton); }/*from ww w.jav a2 s . co m*/ revertButton = new Button(getMessage("portlet.crud.button.reset")); revertButton.setVisible(false); revertButton.setEnabled(true); buttonbar.addComponent(revertButton); insertButton = new Button(getMessage("portlet.crud.button.blankRow")); insertButton.setVisible(false); insertButton.setEnabled(presenter.isInsertable()); buttonbar.addComponent(insertButton); removeButton = new Button(getMessage("portlet.crud.button.removeRow")); removeButton.setVisible(false); removeButton.setEnabled(presenter.isDeleteable()); buttonbar.addComponent(removeButton); } if (presenter.isExcelExport()) { excelExportButton = new Button("Excel"); buttonbar.addComponent(excelExportButton); } if (presenter.isCSVExport()) { csvExportButton = new Button("CSV"); buttonbar.addComponent(csvExportButton); } for (TableAction action : tableModel.getActions()) { Button actionButton = new Button(action.getTitle()); if (action.getId() != null) { actionButtons.put(action.getId(), actionButton); } else { actionButtons.put("table-action-" + tableActionDummyIdCounter++, actionButton); } buttonToTableActionMap.put(actionButton, action); buttonbar.addComponent(actionButton); } return buttonbar; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTextAreaView.java
License:Apache License
@Override public void showEditor(String xhtml) { final RichTextArea richTextArea = new RichTextArea(); richTextArea.setNullRepresentation(""); richTextArea.setWidth("100%"); richTextArea.setValue(xhtml);/*from w ww .jav a 2 s . com*/ Button saveButton = new Button("Speichern", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String changedContent = (String) richTextArea.getValue(); presenter.contentChanged(changedContent); } }); Button cancelButton = new Button("Abbrechen", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { presenter.cancelEditing(); } }); CssLayout buttons = new CssLayout(saveButton, cancelButton); buttons.setStyleName("actions"); VerticalLayout layout = new VerticalLayout(richTextArea, buttons); layout.setSpacing(true); if (getHeight() >= 0f) { richTextArea.setHeight("100%"); layout.setExpandRatio(richTextArea, 1f); } setCompositionRoot(layout); }
From source file:ed.cracken.pos.ui.products.ProductForm.java
public void initComponents() { setId("product-form"); setStyleName("product-form-wrapper"); addStyleName("product-form"); VerticalLayout formLayout = new VerticalLayout(); formLayout.setHeightUndefined();//from ww w . ja v a 2 s. c o m formLayout.setSpacing(true); formLayout.setStyleName("form-layout"); formLayout.addComponent(productName = new TextField("Name")); HorizontalLayout priceAndStockLayout = new HorizontalLayout(); priceAndStockLayout.addComponent(price = new TextField("Price")); priceAndStockLayout.addComponent(stockCount = new TextField("Stock")); formLayout.addComponent(priceAndStockLayout); formLayout.addComponent(availability = new ComboBox("Availability")); formLayout.addComponent(category = new CategoryField("Category")); CssLayout separator = new CssLayout(); separator.setStyleName("expander"); formLayout.addComponent(separator); formLayout.addComponent(save = new Button("Save") { { setStyleName("primary"); setId("save"); } }); formLayout.addComponent(cancel = new Button("Cancel") { { setStyleName("cancel"); setId("cancel"); } }); formLayout.addComponent(delete = new Button("Delete") { { setStyleName("danger"); setId("delete"); } }); addComponent(formLayout); }
From source file:ed.cracken.pos.ui.purchases.PurchaseItemForm.java
public PurchaseItemForm(PurchaserLogic viewLogic) { setId("product-form"); setStyleName("product-form-wrapper"); addStyleName("product-form"); VerticalLayout formLayout = new VerticalLayout(); formLayout.setHeightUndefined();/*from ww w . j a va 2 s . c o m*/ formLayout.setSpacing(true); formLayout.setStyleName("form-layout"); formLayout.addComponent(productId = new TextField("Code")); formLayout.addComponent(description = new TextField("Description")); formLayout.addComponent(price = new DecimalNumberField("Price")); formLayout.addComponent(quantity = new DecimalNumberField("Quantity")); formLayout.addComponent(discount = new DecimalNumberField("Discount")); formLayout.addComponent(subtotal = new DecimalNumberField("Subtotal")); price.setConverter(BigDecimal.class); quantity.addTextChangeListener((FieldEvents.TextChangeEvent event) -> { if (!event.getText().isEmpty()) { try { NumberFormat nf = DecimalFormat.getInstance(); nf.setMaximumFractionDigits(2); ItemTo item; BigDecimal r = BigDecimal.valueOf(nf.parse(event.getText()).longValue()) .multiply((item = fieldGroup.getItemDataSource().getBean()).getPrice()); subtotal.setReadOnly(false); subtotal.setValue(nf.format(r.doubleValue())); subtotal.setReadOnly(true); } catch (ParseException ex) { Logger.getLogger(PurchaseItemForm.class.getName()).log(Level.SEVERE, null, ex); } } }); CssLayout separator = new CssLayout(); separator.setStyleName("expander"); formLayout.addComponent(separator); formLayout.addComponent(save = new StyledButton("Aplicar", "primary", "save")); formLayout.addComponent(cancel = new StyledButton("Cancelar", "cancel", "cancel")); formLayout.addComponent(delete = new StyledButton("Quitar", "danger", "delete")); save.addClickListener((Button.ClickEvent event) -> { try { fieldGroup.commit(); viewLogic.updateItem(fieldGroup.getItemDataSource().getBean()); } catch (FieldGroup.CommitException e) { e.printStackTrace(System.err); } }); cancel.addClickListener((Button.ClickEvent event) -> { viewLogic.cancelItemChanges(); }); delete.addClickListener((Button.ClickEvent event) -> { viewLogic.removeItem(fieldGroup.getItemDataSource().getBean()); }); addComponent(formLayout); configBinding(); }
From source file:ed.cracken.pos.ui.seller.SellItemForm.java
public SellItemForm(SellerLogic viewLogic) { setId("product-form"); setStyleName("product-form-wrapper"); addStyleName("product-form"); VerticalLayout formLayout = new VerticalLayout(); formLayout.setHeightUndefined();/* ww w . j a v a 2 s . c o m*/ formLayout.setSpacing(true); formLayout.setStyleName("form-layout"); formLayout.addComponent(productId = new TextField("Code")); formLayout.addComponent(description = new TextField("Description")); formLayout.addComponent(price = new DecimalNumberField("Price")); formLayout.addComponent(quantity = new DecimalNumberField("Quantity")); formLayout.addComponent(discount = new DecimalNumberField("Discount")); formLayout.addComponent(subtotal = new DecimalNumberField("Subtotal")); price.setConverter(BigDecimal.class); quantity.addTextChangeListener((FieldEvents.TextChangeEvent event) -> { if (!event.getText().isEmpty()) { try { NumberFormat nf = DecimalFormat.getInstance(); nf.setMaximumFractionDigits(2); ItemTo item; BigDecimal r = BigDecimal.valueOf(nf.parse(event.getText()).longValue()) .multiply((item = fieldGroup.getItemDataSource().getBean()).getPrice()); subtotal.setReadOnly(false); subtotal.setValue(nf.format(r.doubleValue())); subtotal.setReadOnly(true); } catch (ParseException ex) { Logger.getLogger(SellItemForm.class.getName()).log(Level.SEVERE, null, ex); } } }); CssLayout separator = new CssLayout(); separator.setStyleName("expander"); formLayout.addComponent(separator); formLayout.addComponent(save = new StyledButton("Aplicar", "primary", "save")); formLayout.addComponent(cancel = new StyledButton("Cancelar", "cancel", "cancel")); formLayout.addComponent(delete = new StyledButton("Quitar", "danger", "delete")); save.addClickListener((Button.ClickEvent event) -> { try { fieldGroup.commit(); viewLogic.updateItem(fieldGroup.getItemDataSource().getBean()); } catch (FieldGroup.CommitException e) { e.printStackTrace(System.err); } }); cancel.addClickListener((Button.ClickEvent event) -> { viewLogic.cancelItemChanges(); }); delete.addClickListener((Button.ClickEvent event) -> { viewLogic.removeItem(fieldGroup.getItemDataSource().getBean()); }); addComponent(formLayout); configBinding(); }
From source file:fr.amapj.view.views.login.LoginPart.java
License:Open Source License
public void buildLoginView(ValoMenuLayout root, AmapUI ui, String loginFromUrl, String passwordFromUrl, String sudo) {/*from w ww . j a v a2 s .co m*/ this.ui = ui; CssLayout loginAera = root.prepareForLoginPage(); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSizeFull(); loginAera.setStyleName("login-backgroundimage"); loginAera.addComponent(loginLayout); // Recuperation des parametres String nomAmap = new ParametresService().getParametres().nomAmap; ui.getPage().setTitle(nomAmap); // Zone de saisie login/password MyLoginForm myLoginForm = new MyLoginForm(loginFromUrl, passwordFromUrl, sudo, nomAmap); myLoginForm.addStyleName("login-layout"); loginLayout.addComponent(myLoginForm); loginLayout.setComponentAlignment(myLoginForm, Alignment.MIDDLE_CENTER); loginLayout.setExpandRatio(myLoginForm, 10); Label l1 = new Label("Application fonctionnant avec AmapJ - "); Link link = new Link("Plus d'infos", new ExternalResource("http://amapj.fr")); link.setTargetName("_blank"); HorizontalLayout hL = new HorizontalLayout(); hL.addComponent(l1); hL.setComponentAlignment(l1, Alignment.MIDDLE_CENTER); hL.addComponent(link); hL.setComponentAlignment(link, Alignment.MIDDLE_CENTER); hL.setMargin(true); loginLayout.addComponent(hL); loginLayout.setComponentAlignment(hL, Alignment.BOTTOM_CENTER); loginLayout.setExpandRatio(hL, 1); // Si les deux champs ont t remplis on tente une validation automatique if ((passwordFromUrl != null) && (loginFromUrl != null)) { myLoginForm.login(loginFromUrl, passwordFromUrl); } }
From source file:fr.univlorraine.mondossierweb.MainUI.java
License:Apache License
/** * Construction du menu tudiant/*from www . j ava 2s . c o m*/ */ private void buildMainMenuEtudiant() { //Si l'tudiant dont on affiche le dossier est renseign if (etudiant != null) { //Ajout du style au menu mainMenu.setPrimaryStyleName(ValoTheme.MENU_PART); //On fixe la largeur du menu mainMenu.setWidth("233px"); //Si on a une url pour la photo de l'tudiant if (etudiant.getPhoto() != null) { //Layout contenant la photo HorizontalLayout photoLayout = new HorizontalLayout(); //Ajout du style au layout photoLayout.addStyleName(ValoTheme.MENU_SUBTITLE); //On fixe la largeur du layout photoLayout.setWidth(213, Unit.PIXELS); //La layout a des marges photoLayout.setMargin(true); //Bouton qui indique, en fonction de l'icone, si l'tudiant est inscrit pour l'anne en cours. Par dfaut, icone indiquant que l'tudiant est inscrit Button etuInscritBtn = new Button("", FontAwesome.CHECK_CIRCLE); //Ajout du style au bouton etuInscritBtn.setPrimaryStyleName(ValoTheme.BUTTON_BORDERLESS); //Si l'tudiant est inscrit pour l'anne en cours if (etudiant.isInscritPourAnneeEnCours()) { //On fixe la description du bouton etuInscritBtn.setDescription("Inscrit pour l'anne universitaire " + Utils.getAnneeUniversitaireEnCours(etudiantController.getAnneeUnivEnCours(this))); } else { //On change l'icone du bouton pour indiquer que l'tudiant n'est pas inscrit etuInscritBtn.setIcon(FontAwesome.EXCLAMATION_CIRCLE); //On fixe la description du bouton etuInscritBtn.setDescription("Non Inscrit pour l'anne universitaire " + Utils.getAnneeUniversitaireEnCours(etudiantController.getAnneeUnivEnCours(this))); } //Ajout d'un lment vide dans le layout photoLayout.addComponent(new HorizontalLayout()); //Cration de l'image contenant la photo Image fotoEtudiant = new Image(null, new ExternalResource(etudiant.getPhoto())); fotoEtudiant.setWidth("120px"); //Ajout de la photo au layout photoLayout.addComponent(fotoEtudiant); //Alignement de la photo photoLayout.setComponentAlignment(fotoEtudiant, Alignment.MIDDLE_CENTER); //La photo prend toute la place disponible dans son layout photoLayout.setExpandRatio(fotoEtudiant, 1); //Ajout au layout du bouton, qui indique, en fonction de l'icone, si l'tudiant est inscrit pour l'anne en cours photoLayout.addComponent(etuInscritBtn); //Ajout du layout de la photo au menu mainMenu.addComponent(photoLayout); } //Ajout du Prnom/Nom et codetu de l'tudiant dans le menu Label usernameLabel = new Label(etudiant.getNom() + "<br />" + etudiant.getCod_etu(), ContentMode.HTML); usernameLabel.addStyleName(ValoTheme.MENU_SUBTITLE); usernameLabel.addStyleName("retourALaLigneAutomatique"); usernameLabel.setSizeUndefined(); mainMenu.addComponent(usernameLabel); /* Etat Civil */ addItemMenu("Etat-civil", EtatCivilView.NAME, FontAwesome.USER); //info annuelles visibles que si tudiant inscrit pour l'anne en cours if (etudiant.isInscritPourAnneeEnCours()) { addItemMenu("Informations annuelles", InformationsAnnuellesView.NAME, FontAwesome.INFO_CIRCLE); } /* Adresses */ addItemMenu(applicationContext.getMessage(AdressesView.NAME + ".title", null, getLocale()), AdressesView.NAME, FontAwesome.HOME); /* Inscriptions */ addItemMenu("Inscriptions", InscriptionsView.NAME, FontAwesome.FILE_TEXT); /* Calendrier */ addItemMenu("Calendrier des preuves", CalendrierView.NAME, FontAwesome.CALENDAR); /* Notes et Rsultats */ addItemMenu(applicationContext.getMessage(NotesView.NAME + ".title", null, getLocale()), NotesView.NAME, FontAwesome.LIST); /* Sparation avant Bouton "Aide" */ CssLayout bottomMainMenu1 = new CssLayout(); bottomMainMenu1.setStyleName(ValoTheme.MENU_SUBTITLE); bottomMainMenu1.setSizeUndefined(); mainMenu.addComponent(bottomMainMenu1); /* Aide */ Button helpBtn = new Button(applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()), FontAwesome.SUPPORT); helpBtn.setPrimaryStyleName(ValoTheme.MENU_ITEM); helpBtn.addClickListener(e -> { UI.getCurrent() .addWindow(new HelpBasicWindow( applicationContext.getMessage("helpWindow.text.etudiant", null, getLocale()), applicationContext.getMessage("helpWindow.defaultTitle", null, getLocale()), true)); }); mainMenu.addComponent(helpBtn); /* Deconnexion */ //Voir si on peut accder l'appli hors ENT, le dtecter, et afficher le bouton dconnexion if (configController.isLogoutCasPropose() && userController.isEtudiant()) { Button decoBtn = new Button("Dconnexion", FontAwesome.SIGN_OUT); decoBtn.setPrimaryStyleName(ValoTheme.MENU_ITEM); decoBtn.addClickListener(e -> { getUI().getPage().setLocation("j_spring_security_logout"); }); mainMenu.addComponent(decoBtn); } /* Sparation */ CssLayout bottomMainMenu = new CssLayout(); bottomMainMenu.setStyleName(ValoTheme.MENU_SUBTITLE); bottomMainMenu.setSizeUndefined(); mainMenu.addComponent(bottomMainMenu); } }