List of usage examples for com.vaadin.ui HorizontalLayout setWidth
@Override public void setWidth(float width, Unit unit)
From source file:de.symeda.sormas.ui.utils.DateTimeField.java
License:Open Source License
@Override protected Component initContent() { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);//w w w. j ava 2s . c o m layout.setWidth(100, Unit.PERCENTAGE); dateField = new DateField(); dateField.setWidth(100, Unit.PERCENTAGE); dateField.setDateFormat(DateHelper.getLocalDatePattern()); dateField.setLenient(true); layout.addComponent(dateField); layout.setExpandRatio(dateField, 0.5f); if (!converterSet) { dateField.setConverter(converter); converterSet = true; } timeField = new ComboBox(); timeField.addContainerProperty(CAPTION_PROPERTY_ID, String.class, null); timeField.setItemCaptionPropertyId(CAPTION_PROPERTY_ID); // fill for (int hours = 0; hours <= 23; hours++) { for (int minutes = 0; minutes <= 59; minutes += 15) { ensureTimeEntry(hours, minutes); } } timeField.setNewItemsAllowed(true); timeField.setNewItemHandler(new NewItemHandler() { @Override public void addNewItem(String newItemCaption) { Date date = DateHelper.parseTime(newItemCaption); timeField.setValue(ensureTimeEntry(date)); } }); timeField.setWidth(100, Unit.PERCENTAGE); layout.addComponent(timeField); layout.setExpandRatio(timeField, 0.5f); // value cn't be set on readOnly fields dateField.setReadOnly(false); timeField.setReadOnly(false); // set field values based on internal value setInternalValue(super.getInternalValue()); dateField.setReadOnly(isReadOnly()); timeField.setReadOnly(isReadOnly()); Property.ValueChangeListener validationValueChangeListener = new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { markAsDirty(); } }; dateField.addValueChangeListener(validationValueChangeListener); timeField.addValueChangeListener(validationValueChangeListener); return layout; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.MultiscaleComponent.java
License:Open Source License
void buildEmptyComments() { // add comments VerticalLayout addComment = new VerticalLayout(); addComment.setMargin(true);/* ww w .j a v a 2 s .co m*/ addComment.setWidth(100, Unit.PERCENTAGE); final TextArea comments = new TextArea(); comments.setInputPrompt("Write your comment here..."); comments.setWidth(100, Unit.PERCENTAGE); comments.setRows(2); Button commentsOk = new Button("Add Comment"); commentsOk.addStyleName(ValoTheme.BUTTON_FRIENDLY); commentsOk.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = -5369241494545155677L; public void buttonClick(ClickEvent event) { if ("".equals(comments.getValue())) return; String newComment = comments.getValue(); // reset comments comments.setValue(""); // use some date format Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Note note = new Note(); note.setComment(newComment); note.setUsername(controller.getUser()); note.setTime(ft.format(dNow)); // show it now // pastcomments.getContainerDataSource().addItem(note); notes.add(note); // TODO write back Label commentsLabel = new Label(translateComments(notes), ContentMode.HTML); commentsPanel.setContent(commentsLabel); // write back to openbis if (!controller.addNote(note)) { Notification.show("Could not add comment to sample. How did you do that?"); } } }); HorizontalLayout inputPrompt = new HorizontalLayout(); inputPrompt.addComponent(comments); inputPrompt.addComponent(commentsOk); inputPrompt.setWidth(50, Unit.PERCENTAGE); inputPrompt.setComponentAlignment(commentsOk, Alignment.TOP_RIGHT); inputPrompt.setExpandRatio(comments, 1.0f); // addComment.addComponent(comments); // addComment.addComponent(commentsOk); addComment.addComponent(commentsPanel); addComment.addComponent(inputPrompt); // addComment.setComponentAlignment(comments, Alignment.TOP_CENTER); // addComment.setComponentAlignment(commentsOk, Alignment.MIDDLE_CENTER); addComment.setComponentAlignment(commentsPanel, Alignment.TOP_CENTER); addComment.setComponentAlignment(inputPrompt, Alignment.MIDDLE_CENTER); mainlayout.addComponent(addComment); // mainlayout.addComponent(pastcomments); Label commentsLabel = new Label("No comments added so far.", ContentMode.HTML); commentsPanel.setContent(commentsLabel); // mainlayout.addComponent(commentsPanel); // mainlayout.setComponentAlignment(commentsPanel, // Alignment.TOP_CENTER); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SearchEngineView.java
License:Open Source License
public void initUI() { mainlayout = new Panel(); mainlayout.addStyleName(ValoTheme.PANEL_BORDERLESS); // Search bar // *----------- search text field .... search button-----------* VerticalLayout searchbar = new VerticalLayout(); searchbar.setWidth(100, Unit.PERCENTAGE); setResponsive(true);/*from w w w . j a v a2s .co m*/ searchbar.setResponsive(true); // searchbar.setWidth(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setResponsive(true); buttonLayout.setWidth(75, Unit.PERCENTAGE); // searchbar.setSpacing(true); final TextField searchfield = new TextField(); searchfield.setHeight("44px"); searchfield.setImmediate(true); searchfield.setResponsive(true); searchfield.setWidth(75, Unit.PERCENTAGE); buttonLayout.setSpacing(true); searchfield.setInputPrompt("search DB"); // searchfield.setCaption("QSearch"); // searchfield.setWidth(25.0f, Unit.EM); // searchfield.setWidth(60, Unit.PERCENTAGE); // TODO would be nice to have a autofill or something similar // searchFieldLayout.addComponent(searchfield); searchbar.addComponent(searchfield); searchbar.setComponentAlignment(searchfield, Alignment.MIDDLE_RIGHT); final NativeSelect navsel = new NativeSelect(); navsel.addItem("Whole DB"); navsel.addItem("Projects Only"); navsel.addItem("Experiments Only"); navsel.addItem("Samples Only"); navsel.setValue("Whole DB"); navsel.setHeight("20px"); navsel.setNullSelectionAllowed(false); navsel.setResponsive(true); navsel.setWidth(100, Unit.PERCENTAGE); navsel.addValueChangeListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = -6896454887050432147L; @Override public void valueChange(ValueChangeEvent event) { // TODO Auto-generated method stub Notification.show((String) navsel.getValue()); switch ((String) navsel.getValue()) { case "Whole DB": datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples")); break; case "Projects Only": datahandler.setShowOptions(Arrays.asList("Projects")); break; case "Experiments Only": datahandler.setShowOptions(Arrays.asList("Experiments")); break; case "Samples Only": datahandler.setShowOptions(Arrays.asList("Samples")); break; default: datahandler.setShowOptions(Arrays.asList("Projects", "Experiments", "Samples")); break; } } }); searchbar.addComponent(buttonLayout); searchbar.setComponentAlignment(buttonLayout, Alignment.MIDDLE_RIGHT); Button searchOk = new Button(""); searchOk.setStyleName(ValoTheme.BUTTON_TINY); // searchOk.addStyleName(ValoTheme.BUTTON_BORDERLESS); searchOk.setIcon(FontAwesome.SEARCH); searchOk.setSizeUndefined(); // searchOk.setWidth(15.0f, Unit.EM); searchOk.setResponsive(true); searchOk.setHeight("20px"); searchOk.addClickListener(new ClickListener() { private static final long serialVersionUID = -2409450448301908214L; @Override public void buttonClick(ClickEvent event) { String queryString = (String) searchfield.getValue().toString(); LOGGER.debug("the query was " + queryString); if (searchfield.getValue() == null || searchfield.getValue().toString().equals("") || searchfield.getValue().toString().trim().length() == 0) { Notification.show("Query field was empty!", Type.WARNING_MESSAGE); } else { try { /** * Sample foundSample = datahandler.getOpenBisClient() .getSampleByIdentifier( * matcher.group(0).toString()); */ datahandler.setSampleResults(querySamples(queryString)); datahandler.setExpResults(queryExperiments(queryString)); datahandler.setProjResults(queryProjects(queryString)); datahandler.setLastQueryString(queryString); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add("view" + queryString); message.add("searchresults"); state.notifyObservers(message); } catch (Exception e) { LOGGER.error("after query: ", e); Notification.show("No Sample found for given barcode.", Type.WARNING_MESSAGE); } } } }); // setClickShortcut() would add global shortcut, instead we // 'scope' the shortcut to the panel: mainlayout.addAction(new com.vaadin.ui.Button.ClickShortcut(searchOk, KeyCode.ENTER)); // searchfield.addItems(this.getSearchResults("Q")); searchfield.setDescription(infotext); searchfield.addValidator(new NullValidator("Field must not be empty", false)); searchfield.setValidationVisible(false); buttonLayout.addComponent(navsel); // buttonLayout.addComponent(new Label("")); buttonLayout.addComponent(searchOk); // searchFieldLayout.setComponentAlignment(searchOk, Alignment.TOP_RIGHT); // buttonLayout.setExpandRatio(searchOk, 1); // buttonLayout.setExpandRatio(navsel, 1); // searchFieldLayout.setSpacing(true); buttonLayout.setComponentAlignment(searchOk, Alignment.BOTTOM_RIGHT); // buttonLayout.setComponentAlignment(navsel, Alignment.BOTTOM_LEFT); buttonLayout.setExpandRatio(searchOk, 1); buttonLayout.setExpandRatio(navsel, 2); // searchbar.setMargin(new MarginInfo(true, false, true, false)); mainlayout.setContent(searchbar); // mainlayout.setComponentAlignment(searchbar, Alignment.MIDDLE_RIGHT); // mainlayout.setWidth(100, Unit.PERCENTAGE); setCompositionRoot(mainlayout); }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component buildFooter(User user) { HorizontalLayout footer = new HorizontalLayout(); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Unit.PERCENTAGE); Button cancelButton = new Button(Language.get(Word.CANCEL)); cancelButton.setIcon(VaadinIcons.CLOSE); cancelButton.addClickListener(event -> { close();/* w w w . jav a 2s . c o m*/ }); saveButton = new Button(Language.get(Word.SAVE)); saveButton.setIcon(VaadinIcons.CHECK); saveButton.addStyleName(ValoTheme.BUTTON_PRIMARY); saveButton.addClickListener(event -> { boolean error = false; if (!user.getFirstName().equals(firstNameField.getValue())) { boolean success = UserUtils.changeFirstName(user, firstNameField.getValue()); if (!success) { error = true; } } if (!user.getLastName().equals(lastNameField.getValue())) { boolean success = UserUtils.changeLastName(user, lastNameField.getValue()); if (!success) { error = true; } } if (!user.getUsername().equals(usernameField.getValue())) { boolean success = UserUtils.changeUsername(user, usernameField.getValue()); if (!success) { error = true; } } if (!user.getEmail().equals(emailField.getValue())) { UI.getCurrent().addWindow(ActivateWindow.get()); boolean success = UserUtils.changeEmail(user, user.getEmail(), emailField.getValue(), emailField.getValue()); if (!success) { error = true; } } boolean wrongPW = false; if (!password1Field.isEmpty() && password1Field.getValue().equals(password2Field.getValue())) { wrongPW = !UserUtils.changePassword(user, oldPasswordField.getValue(), password1Field.getValue(), password2Field.getValue()); } if (error) { VaadinUtils.errorNotification(Language.get(Word.UNEXPECTED_ERROR)); } else if (wrongPW) { VaadinUtils.errorNotification(Language.get(Word.WRONG_PASSWORD)); } else { VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED)); close(); } }); saveButton.focus(); Label placeholder = new Label(); footer.addComponents(placeholder, cancelButton, saveButton); footer.setExpandRatio(placeholder, 5); footer.setComponentAlignment(cancelButton, Alignment.TOP_CENTER); footer.setComponentAlignment(saveButton, Alignment.TOP_CENTER); return footer; }
From source file:edu.vserver.exercises.videoMcq.QuestionWindow.java
License:Apache License
/** * Constructs a question window object for showing the question with the * answer choices and submit- and next-button. *//*from w w w .j a va 2 s .c om*/ public QuestionWindow() { super(); setModal(true); setResizable(false); setClosable(false); addStyleName("questionWindow"); optionGroup.setImmediate(true); optionGroup.addStyleName("answerOptions"); HorizontalLayout dots = new HorizontalLayout(); VerticalLayout v = new VerticalLayout(); v.setSpacing(true); v.setMargin(true); HorizontalLayout btnFooter = new HorizontalLayout(); btnFooter.addStyleName("buttons"); btnFooter.setMargin(true); btnFooter.setSpacing(true); btnFooter.setWidth(100, Unit.PERCENTAGE); btnFooter.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); submitButton = ComponentFactory.createLargeBlueButton("Submit", true, null); submitButton.setEnabled(false); nextButton = ComponentFactory.createLargeBlueButton("Next", true, SPH_Theme.NEXT_ICON_16PX); btnFooter.addComponents(submitButton, nextButton); v.addComponents(qLabel, optionGroup, btnFooter, dots); this.setContent(v); this.createButtonListeners(); }
From source file:fr.amapj.view.engine.popup.formpopup.AbstractFormPopup.java
License:Open Source License
protected Button addHelpButton(String title, String helpContent) { Button aide = new Button(title); aide.setIcon(FontAwesome.QUESTION_CIRCLE); aide.addStyleName("borderless-colored"); aide.addStyleName("question-mark"); aide.addClickListener(e -> handleAide(helpContent)); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth(100, Unit.PERCENTAGE); hl.addComponent(aide);//w w w .j ava 2s. c om hl.setComponentAlignment(aide, Alignment.MIDDLE_RIGHT); form.addComponent(hl); return aide; }
From source file:fr.univlorraine.mondossierweb.MainUI.java
License:Apache License
/** * Construction du menu tudiant/*w w w. j ava2 s . co 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); } }
From source file:fr.univlorraine.mondossierweb.views.AdminView.java
License:Apache License
private void ajoutGestionParametresApplicatifs() { layoutConfigApplication.setMargin(true); layoutConfigApplication.setSpacing(true); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true);//from w w w . j a va 2 s.c o m layoutConfigApplication.addComponent(buttonsLayout); btnEdit = new Button(applicationContext.getMessage(NAME + ".btnEdit", null, getLocale()), FontAwesome.PENCIL); btnEdit.setEnabled(false); btnEdit.addClickListener(e -> { if (confAppTable.getValue() instanceof PreferencesApplication) { //configController.editConfApp((PreferencesApplication) confAppTable.getValue()); PreferencesApplicationWindow paw = new PreferencesApplicationWindow( (PreferencesApplication) confAppTable.getValue()); paw.addCloseListener(f -> init()); tabSelectedPosition = 0; MainUI.getCurrent().addWindow(paw); } }); buttonsLayout.addComponent(btnEdit); buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_CENTER); /* Table des conf */ confAppTable = new Table(null, new BeanItemContainer<>(PreferencesApplication.class, configController.getAppParameters())); confAppTable.setSizeFull(); confAppTable.setVisibleColumns((Object[]) CONF_APP_FIELDS_ORDER); for (String fieldName : CONF_APP_FIELDS_ORDER) { confAppTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".confAppTable." + fieldName, null, getLocale())); } confAppTable.setSortContainerPropertyId("prefId"); confAppTable.setColumnCollapsingAllowed(true); confAppTable.setColumnReorderingAllowed(true); confAppTable.setSelectable(true); confAppTable.setImmediate(true); confAppTable.addItemSetChangeListener(e -> confAppTable.sanitizeSelection()); confAppTable.addValueChangeListener(e -> { // Le bouton d'dition est actif seulement si un parametre est slectionn. boolean confIsSelected = confAppTable.getValue() instanceof PreferencesApplication; btnEdit.setEnabled(confIsSelected); }); confAppTable.addItemClickListener(e -> { if (e.isDoubleClick()) { confAppTable.select(e.getItemId()); btnEdit.click(); } }); layoutConfigApplication.addComponent(confAppTable); layoutConfigApplication.setExpandRatio(confAppTable, 1); }
From source file:fr.univlorraine.mondossierweb.views.AdminView.java
License:Apache License
private void ajoutGestionSwap() { layoutSwapUser.setMargin(true);/*from w w w. jav a 2 s . c om*/ layoutSwapUser.setSpacing(true); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); layoutSwapUser.addComponent(buttonsLayout); btnEditSwap = new Button(applicationContext.getMessage(NAME + ".btnEdit", null, getLocale()), FontAwesome.PENCIL); btnEditSwap.setEnabled(false); btnEditSwap.addClickListener(e -> { if (confSwapTable.getValue() instanceof UtilisateurSwap) { //configController.editConfApp((PreferencesApplication) confAppTable.getValue()); SwapUtilisateurWindow suw = new SwapUtilisateurWindow((UtilisateurSwap) confSwapTable.getValue(), false); suw.addCloseListener(f -> init()); tabSelectedPosition = 1; MainUI.getCurrent().addWindow(suw); } }); buttonsLayout.addComponent(btnEditSwap); buttonsLayout.setComponentAlignment(btnEditSwap, Alignment.MIDDLE_LEFT); btnAddSwap = new Button(applicationContext.getMessage(NAME + ".btnAdd", null, getLocale()), FontAwesome.PLUS); btnAddSwap.setEnabled(true); btnAddSwap.addClickListener(e -> { SwapUtilisateurWindow suw = new SwapUtilisateurWindow(new UtilisateurSwap(), true); suw.addCloseListener(f -> init()); tabSelectedPosition = 1; MainUI.getCurrent().addWindow(suw); }); buttonsLayout.addComponent(btnAddSwap); buttonsLayout.setComponentAlignment(btnAddSwap, Alignment.MIDDLE_CENTER); // Deconnexion Button decoBtn = new Button("Se Dconnecter", FontAwesome.SIGN_OUT); decoBtn.setEnabled(true); decoBtn.addClickListener(e -> { getUI().getPage().setLocation("j_spring_security_logout"); }); buttonsLayout.addComponent(decoBtn); buttonsLayout.setComponentAlignment(decoBtn, Alignment.MIDDLE_RIGHT); /* Table des conf */ confSwapTable = new Table(null, new BeanItemContainer<>(UtilisateurSwap.class, configController.getSwapUtilisateurs())); confSwapTable.setSizeFull(); confSwapTable.setVisibleColumns((Object[]) SWAP_FIELDS_ORDER); for (String fieldName : SWAP_FIELDS_ORDER) { confSwapTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".confSwapTable." + fieldName, null, getLocale())); } confSwapTable.setSortContainerPropertyId("loginSource"); confSwapTable.setColumnCollapsingAllowed(true); confSwapTable.setColumnReorderingAllowed(true); confSwapTable.setSelectable(true); confSwapTable.setImmediate(true); confSwapTable.addItemSetChangeListener(e -> confSwapTable.sanitizeSelection()); confSwapTable.addValueChangeListener(e -> { // Le bouton d'dition est actif seulement si un parametre est slectionn. boolean confIsSelected = confSwapTable.getValue() instanceof UtilisateurSwap; btnEditSwap.setEnabled(confIsSelected); }); confSwapTable.addItemClickListener(e -> { if (e.isDoubleClick()) { confSwapTable.select(e.getItemId()); btnEditSwap.click(); } }); layoutSwapUser.addComponent(confSwapTable); layoutSwapUser.setExpandRatio(confSwapTable, 1); }
From source file:fr.univlorraine.mondossierweb.views.windows.ConfirmWindow.java
License:Apache License
/** * Cre une fentre de confirmation// w w w . ja va2s . c om * @param message * @param titre */ public ConfirmWindow(String message, String titre) { /* Style */ setWidth(400, Unit.PIXELS); setModal(true); setResizable(false); setClosable(false); /* Layout */ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); setContent(layout); /* Titre */ if (titre == null) { titre = applicationContext.getMessage("confirmWindow.defaultTitle", null, getLocale()); } setCaption(titre); /* Texte */ if (message == null) { message = applicationContext.getMessage("confirmWindow.defaultQuestion", null, getLocale()); } Label textLabel = new Label(message); layout.addComponent(textLabel); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); layout.addComponent(buttonsLayout); btnNon.setCaption(applicationContext.getMessage("confirmWindow.btnNon", null, getLocale())); btnNon.setIcon(FontAwesome.TIMES); btnNon.addClickListener(e -> close()); buttonsLayout.addComponent(btnNon); buttonsLayout.setComponentAlignment(btnNon, Alignment.MIDDLE_LEFT); btnOui.setCaption(applicationContext.getMessage("confirmWindow.btnOui", null, getLocale())); btnOui.setIcon(FontAwesome.CHECK); btnOui.addStyleName(ValoTheme.BUTTON_PRIMARY); btnOui.addClickListener(e -> close()); buttonsLayout.addComponent(btnOui); buttonsLayout.setComponentAlignment(btnOui, Alignment.MIDDLE_RIGHT); /* Centre la fentre */ center(); }