List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:fi.vtt.RVaadin.RUpload.java
License:Apache License
/** * Contruct an upload element for R (implemented as Vaadin CustomComponent). * //from w w w . j av a 2 s . com * @param caption * String caption or null * @param R * the corresponding RSession to upload the files to */ public RUpload(String caption, RContainer R) { /* Create the RUpload custom component */ super.setSizeUndefined(); root = new Panel(caption); root.setWidth("90ex"); setCompositionRoot(root); HorizontalLayout hbox = new HorizontalLayout(); hbox.setWidth("100%"); /* Create the Upload component */ final Upload upload = new Upload("Choose file", this); upload.setButtonCaption("Submit"); /* Listen for events regarding the success of upload. */ upload.addSucceededListener(this); upload.addFailedListener(this); hbox.addComponent(upload); Label hfill = new Label(); hbox.addComponent(hfill); hbox.setExpandRatio(hfill, 1.0f); remove = new Button("Remove", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { String current = getSelection(); if (current != null) { /* Delete the file */ delete(current); /* Update the lists and the notification area */ int i = fileNames.indexOf(current); fileNames.remove(i); mimeTypes.remove(i); uploadedFiles.removeItem(current); /* Gray out the button, if this was the last item */ if (fileNames.isEmpty()) { remove.setEnabled(false); } } } }); hbox.addComponent(remove); remove.setEnabled(false); hbox.setComponentAlignment(remove, Alignment.BOTTOM_RIGHT); /* Notification area for already uploaded files */ uploadedFiles = new ListSelect("Already submitted files"); uploadedFiles.setMultiSelect(false); uploadedFiles.setNullSelectionAllowed(false); uploadedFiles.setHeight("4em"); uploadedFiles.setWidth("100%"); // Changed for Vaadin 7, not tested!! VerticalLayout vbox = new VerticalLayout(); vbox.addComponent(hbox); vbox.addComponent(uploadedFiles); root.setContent(vbox); /* Bind the component to the given R session */ this.R = R; }
From source file:fr.amapj.view.engine.basicform.BasicFormListPart.java
License:Open Source License
private void buildMainArea() { createColumn();//from w w w. java 2 s . c o m // Create a persistent person container listPartContainer = new BeanItemContainer(getClazz()); onPopupClose(); // Add a nested property to a many-to-one property for (ColumnInfo colInfo : colInfos) { if (colInfo.isNested()) { listPartContainer.addNestedContainerProperty(colInfo.propertyId); } } // Set up sorting if the natural order is not appropriate listPartContainer.sort(orderByInfo, new boolean[] { true, true }); // Bind it to a component beanTable = createTable(listPartContainer); // Gestion de la liste des colonnes visibles List<String> colNames = new ArrayList<String>(); for (ColumnInfo colInfo : colInfos) { colNames.add(colInfo.propertyId); } beanTable.setVisibleColumns(colNames.toArray()); // Gestion des titres de colonnes for (ColumnInfo colInfo : colInfos) { beanTable.setColumnHeader(colInfo.propertyId, colInfo.title); } beanTable.setSelectable(true); beanTable.setImmediate(true); // Activation au desactivation des boutons delete et edit beanTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { setModificationsEnabled(event.getProperty().getValue() != null); } private void setModificationsEnabled(boolean b) { Long id = IdentifiableUtil.getIdOfSelectedItem(beanTable); if ((id != null) && (b == true) && (isAccessAllowed(id) == false)) { b = false; } deleteButton.setEnabled(b); editButton.setEnabled(b); enableSpecificButton(b); } }); beanTable.setSizeFull(); beanTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { beanTable.select(event.getItemId()); } } }); HorizontalLayout toolbar = new HorizontalLayout(); Label title = new Label(getListPartTitle()); title.setSizeUndefined(); title.addStyleName("stdlistpart-text-title"); newButton = new Button("Ajouter"); newButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleAjouter(); } }); newButton.addStyleName(ChameleonTheme.BUTTON_BIG); deleteButton = new Button("Supprimer"); deleteButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleSupprimer(); } }); deleteButton.setEnabled(false); deleteButton.addStyleName(ChameleonTheme.BUTTON_BIG); editButton = new Button("Editer"); editButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleEditer(); } }); editButton.setEnabled(false); editButton.addStyleName(ChameleonTheme.BUTTON_BIG); searchField = new TextField(); searchField.setInputPrompt(getListPartInputPrompt()); searchField.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { textFilter = event.getText(); updateFilters(); } }); searchField.addStyleName(ChameleonTheme.TEXTFIELD_BIG); searchField.setWidth("50%"); toolbar.addComponent(newButton); toolbar.addComponent(deleteButton); toolbar.addComponent(editButton); addSpecificButton(toolbar); toolbar.addComponent(searchField); toolbar.setWidth("100%"); toolbar.setExpandRatio(searchField, 1); toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT); setMargin(true); setSpacing(true); addComponent(title); addComponent(toolbar); Component c = getExtraComponent(); if (c != null) { addComponent(c); } addComponent(beanTable); setExpandRatio(beanTable, 1); setSizeFull(); }
From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java
License:Open Source License
private Label fillFooter(HorizontalLayout footer1, String message, int montantCible) { Label dateLabel = new Label(message); dateLabel.addStyleName("prix"); dateLabel.setSizeFull();//from w w w . j ava2s.c om footer1.addComponent(dateLabel); footer1.setExpandRatio(dateLabel, 1.0f); Label prixTotal = new Label(new CurrencyTextFieldConverter().convertToString(montantCible)); prixTotal.addStyleName("prix"); prixTotal.setSizeFull(); footer1.addComponent(prixTotal); footer1.setExpandRatio(prixTotal, 1.0f); return prixTotal; }
From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java
License:Open Source License
private void constructHeaderLine(VerticalLayout mainLayout, GridHeaderLine line) { HorizontalLayout header1 = new HorizontalLayout(); header1.setWidth(getLargeurTotal()); if (line.height != -1) { header1.setHeight(line.height + "px"); }/* w w w.j a v a 2 s.c o m*/ for (String str : line.cells) { Label dateLabel = new Label(str); if (line.styleName != null) { dateLabel.addStyleName(line.styleName); } header1.addComponent(dateLabel); dateLabel.setSizeFull(); header1.setExpandRatio(dateLabel, 1.0f); } mainLayout.addComponent(header1); }
From source file:fr.amapj.view.engine.listpart.StandardListPart.java
License:Open Source License
private void buildMainArea() { // Lecture dans la base de donnes mcInfos = new BeanItemContainer<T>(beanClazz); // Bind it to a component cdesTable = createTable(mcInfos);//w ww. j a v a 2 s .co m drawTable(); cdesTable.setSelectable(true); cdesTable.setMultiSelect(multiSelect); cdesTable.setImmediate(true); // Activation ou desactivation des boutons delete et edit cdesTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (multiSelect) { Set s = (Set) event.getProperty().getValue(); buttonBarEditMode(s.size() > 0); } else { buttonBarEditMode(event.getProperty().getValue() != null); } } }); cdesTable.setSizeFull(); cdesTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { cdesTable.select(event.getItemId()); } } }); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addStyleName("buttonbar"); Label title2 = new Label(getTitle()); title2.setSizeUndefined(); title2.addStyleName("title"); drawButton(); for (ButtonHandler handler : buttons) { toolbar.addComponent(handler.button); } if (searchField != null) { toolbar.addComponent(searchField); toolbar.setWidth("100%"); toolbar.setExpandRatio(searchField, 1); toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT); } addComponent(title2); addSelectorComponent(); addComponent(toolbar); addExtraComponent(); addComponent(cdesTable); setExpandRatio(cdesTable, 1); refreshTable(); }
From source file:fr.amapj.view.engine.menu.MenuPart.java
License:Open Source License
private CssLayout buildMenu(CssLayout menu, CssLayout menuItemsLayout, List<MenuDescription> allMenus, Navigator navigator, AmapUI ui) { final HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName("valo-menu-title"); menu.addComponent(top);//from w w w . ja va2s. c om final Button showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menu.getStyleName().contains("valo-menu-visible")) { menu.removeStyleName("valo-menu-visible"); } else { menu.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); menu.addComponent(showMenu); String nomAmap = new ParametresService().getParametres().nomAmap; Label title = new Label("<h2>" + nomAmap + "</h2>", ContentMode.HTML); title.setSizeUndefined(); top.addComponent(title); top.setExpandRatio(title, 1); final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); SessionParameters p = SessionManager.getSessionParameters(); MenuItem settingsItem = settings.addItem(p.userPrenom + " " + p.userNom, null, null); settingsItem.addItem("Se dconnecter", new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { new PasswordManager().disconnect(); ui.buildLoginView(null, null, null); } }); menu.addComponent(settings); menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); boolean first = true; String firstEntry = null; Button firstButton = null; for (MenuDescription menuDescription : allMenus) { final String view = menuDescription.getMenuName().name().toLowerCase(); final String titleView = menuDescription.getMenuName().getTitle(); if (menuDescription.getCategorie() != null) { Label l = new Label(menuDescription.getCategorie(), ContentMode.HTML); l.setPrimaryStyleName("valo-menu-subtitle"); l.addStyleName("h4"); l.setSizeUndefined(); menuItemsLayout.addComponent(l); } final Button b = new Button(titleView, new ClickListener() { @Override public void buttonClick(final ClickEvent event) { setSelected(event.getButton(), menuItemsLayout); navigator.navigateTo("/" + view); } }); b.setId("amapj.menu." + view); b.setHtmlContentAllowed(true); b.setPrimaryStyleName("valo-menu-item"); b.setIcon(menuDescription.getMenuName().getFont()); menuItemsLayout.addComponent(b); viewNameToMenuButton.put("/" + view, b); if (first) { first = false; firstButton = b; firstEntry = view; } } // Gestion de l'url String f = Page.getCurrent().getUriFragment(); if (f != null && f.startsWith("!")) { f = f.substring(1); } if (f == null || f.equals("") || f.equals("/")) { navigateWithProtect(navigator, "/" + firstEntry); setSelected(firstButton, menuItemsLayout); } else { navigateWithProtect(navigator, f); setSelected(viewNameToMenuButton.get(f), menuItemsLayout); } return menu; }
From source file:fr.amapj.view.engine.popup.copypopup.CopyPopup.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { // Calcul du texte a afficher String str = contentSupplier.get(); // Construction de la zone d'affichage du texte HorizontalLayout hlTexte = new HorizontalLayout(); hlTexte.setMargin(true);//from w w w. j ava 2 s .c o m hlTexte.setSpacing(true); hlTexte.setWidth("100%"); TextArea listeMails = new TextArea(""); listeMails.setValue(str); listeMails.setReadOnly(true); listeMails.selectAll(); listeMails.setWidth("80%"); listeMails.setHeight(5, Unit.CM); hlTexte.addComponent(listeMails); hlTexte.setExpandRatio(listeMails, 1); hlTexte.setComponentAlignment(listeMails, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); }
From source file:fr.amapj.view.engine.popup.errorpopup.ErrorPopup.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { setColorStyle(ColorStyle.RED);/*from ww w .j a va 2 s. c o m*/ // Message logg SessionParameters p = SessionManager.getSessionParameters(); String debugMessage = null; if (p != null) { debugMessage = p.userNom + " " + p.userPrenom + " a rencontr une erreur :" + message; p.incNbError(); } else { debugMessage = "Pas d'utilisateur encore logg. Erreur :" + message; } logger.info(debugMessage, throwable); String constraintInfo = getConstraintInfo(throwable); if (constraintInfo != null) { logger.info("Constraint Information:" + constraintInfo); } // Message utilisateur String msg = "Dsol, une erreur est survenue.<br/>"; if (message != null) { msg = msg + "Information supplmentaire:<br/>" + message + "<br/>"; } if (constraintInfo != null) { msg = msg + "<br/>" + constraintInfo + "<br/>"; } msg = msg + "Veuillez cliquer sur OK pour continuer<br/>"; // Construction de la zone de texte HorizontalLayout hlTexte = new HorizontalLayout(); hlTexte.setMargin(true); hlTexte.setSpacing(true); hlTexte.setWidth("100%"); Label textArea = new Label(msg, ContentMode.HTML); textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG); textArea.setWidth("80%"); hlTexte.addComponent(textArea); hlTexte.setExpandRatio(textArea, 1); hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); }
From source file:fr.amapj.view.engine.popup.suppressionpopup.SuppressionPopup.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { setWidth(40, 450);/*from ww w . ja v a2 s.c o m*/ // Construction de la zone de texte HorizontalLayout hlTexte = new HorizontalLayout(); hlTexte.setMargin(true); hlTexte.setSpacing(true); hlTexte.setWidth("100%"); Label textArea = new Label(message); textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG); textArea.setWidth("80%"); hlTexte.addComponent(textArea); hlTexte.setExpandRatio(textArea, 1); hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); if (secured) { hlTexte = new HorizontalLayout(); hlTexte.setMargin(true); hlTexte.setSpacing(true); hlTexte.setWidth("100%"); textArea = new Label( "Veuillez confirmer en saississant le mot SUPPRIMER dans le champ de saisie ci dessous"); textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG); textArea.setWidth("80%"); hlTexte.addComponent(textArea); hlTexte.setExpandRatio(textArea, 1); hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); hlTexte = new HorizontalLayout(); hlTexte.setMargin(true); hlTexte.setSpacing(true); hlTexte.setWidth("100%"); TextField textField = new TextField(); textField.setStyleName(ChameleonTheme.TEXTFIELD_BIG); textField.setWidth("80%"); textField.setImmediate(true); textField.setBuffered(false); hlTexte.addComponent(textField); hlTexte.setExpandRatio(textField, 1); hlTexte.setComponentAlignment(textField, Alignment.MIDDLE_CENTER); textField.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { if (event.getText().equals("SUPPRIMER")) { okButton.setEnabled(true); } else { okButton.setEnabled(false); } } }); contentLayout.addComponent(hlTexte); } }
From source file:fr.amapj.view.views.appinstance.PopupCopyAllMail.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { // Construction de la zone d'affichage des mails HorizontalLayout hlTexte = new HorizontalLayout(); hlTexte.setMargin(true);/* w ww. ja v a 2s.c om*/ hlTexte.setSpacing(true); hlTexte.setWidth("100%"); TextArea listeMails = new TextArea(""); listeMails.setValue(mails); listeMails.setReadOnly(true); listeMails.selectAll(); listeMails.setWidth("80%"); listeMails.setHeight(5, Unit.CM); hlTexte.addComponent(listeMails); hlTexte.setExpandRatio(listeMails, 1); hlTexte.setComponentAlignment(listeMails, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); }