Java Code Examples for com.vaadin.ui.HorizontalLayout.setSpacing()

The following are Jave code examples for showing how to use setSpacing() of the com.vaadin.ui.HorizontalLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: esup-ecandidat   File: CandidatCreerCompteView.java   Source Code and License Vote up 6 votes
/**
 * Rafraichi le panel de connexion sans compte
 */
private void refreshConnexionPanelStudent() {
	vlConnexionIsStudent.removeAllComponents();

	OneClickButton logBtn = new OneClickButton(
			applicationContext.getMessage("btnConnect", null, UI.getCurrent().getLocale()), FontAwesome.SIGN_OUT);
	logBtn.addClickListener(e -> {
		userController.connectCAS();
	});

	HorizontalLayout hlConnect = new HorizontalLayout();
	hlConnect.setSpacing(true);
	Label labelConnect = new Label(
			applicationContext.getMessage("accueilView.connect.cas", null, UI.getCurrent().getLocale()));
	hlConnect.addComponent(labelConnect);
	hlConnect.setComponentAlignment(labelConnect, Alignment.MIDDLE_LEFT);
	hlConnect.addComponent(logBtn);
	hlConnect.setComponentAlignment(logBtn, Alignment.MIDDLE_CENTER);

	vlConnexionIsStudent.addComponent(hlConnect);
}
 
Example 2
Project: holon-vaadin   File: QuestionDialog.java   Source Code and License Vote up 6 votes
@Override
protected void buildActions(HorizontalLayout actionsContainer) {
	actionsContainer.setSpacing(true);
	// yes
	final Button btnYes = Components.button().styleName(ValoTheme.BUTTON_PRIMARY)
			.caption(Localizable.builder().message(DEFAULT_YES_BUTTON_MESSAGE)
					.messageCode(DEFAULT_YES_BUTTON_MESSAGE_CODE).build())
			.onClick(e -> onDialogYesButtonClick(e.getButton())).build();
	getYesButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnYes)));
	actionsContainer.addComponent(btnYes);
	actionsContainer.setComponentAlignment(btnYes, Alignment.MIDDLE_LEFT);
	if (getWidth() > -1) {
		btnYes.setWidth("100%");
	}
	// no
	final Button btnNo = Components.button()
			.caption(Localizable.builder().message(DEFAULT_NO_BUTTON_MESSAGE)
					.messageCode(DEFAULT_NO_BUTTON_MESSAGE_CODE).build())
			.onClick(e -> onDialogNoButtonClick(e.getButton())).build();
	getNoButtonConfigurator().ifPresent(c -> c.configureDialogButton(Components.configure(btnNo)));
	actionsContainer.addComponent(btnNo);
	actionsContainer.setComponentAlignment(btnNo, Alignment.MIDDLE_RIGHT);
	if (getWidth() > -1) {
		btnNo.setWidth("100%");
	}
}
 
Example 3
Project: esup-ecandidat   File: SearchAnneeUnivApoField.java   Source Code and License Vote up 6 votes
/**
 * Constructeur, initialisation du champs
 * @param libelleBtnFind 
 */
public SearchAnneeUnivApoField(String libelleBtnFind) {
	super();
	layout = new HorizontalLayout();
	layout.setSpacing(true);
	anneeField = new TextField();
	anneeField.addValueChangeListener(e->showOrHideError());
	anneeField.setNullRepresentation("");
	anneeField.setReadOnly(true);
	btnSearch = new OneClickButton(libelleBtnFind,FontAwesome.SEARCH);
	btnSearch.addClickListener(e->{
		SearchAnneeUnivApoWindow window = new SearchAnneeUnivApoWindow();
		window.addAnneeUniListener(a->changeFieldValue(a));
		UI.getCurrent().addWindow(window);
	});
	layout.addComponent(anneeField);
	layout.addComponent(btnSearch);
}
 
Example 4
Project: holon-vaadin   File: AbstractDialog.java   Source Code and License Vote up 5 votes
/**
 * Constructor
 */
public AbstractDialog() {
	super();

	// defaults
	setModal(true);
	setResizable(false);
	setDraggable(false);
	setClosable(false);

	// style name
	addStyleName("h-dialog");

	// build
	content = new Panel();
	content.setWidth("100%");
	content.addStyleName(ValoTheme.PANEL_BORDERLESS);
	content.addStyleName("h-dialog-content");

	actions = new HorizontalLayout();
	actions.setWidth("100%");
	actions.setSpacing(true);
	actions.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
	actions.addStyleName("h-dialog-actions");

	root = new VerticalLayout();
	root.addComponent(content);
	root.addComponent(actions);

	setContent(root);
}
 
Example 5
Project: holon-vaadin7   File: AbstractDialog.java   Source Code and License Vote up 5 votes
/**
 * Constructor
 */
public AbstractDialog() {
	super();

	// defaults
	setModal(true);
	setResizable(false);
	setDraggable(false);
	setClosable(false);

	// style name
	addStyleName("h-dialog");

	// build
	content = new Panel();
	content.setWidth("100%");
	content.addStyleName(ValoTheme.PANEL_BORDERLESS);
	content.addStyleName("h-dialog-content");

	actions = new HorizontalLayout();
	actions.setWidth("100%");
	actions.setSpacing(true);
	actions.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
	actions.addStyleName("h-dialog-actions");

	root = new VerticalLayout();
	root.addComponent(content);
	root.addComponent(actions);

	setContent(root);
}
 
Example 6
Project: md-stepper   File: VerticalStepper.java   Source Code and License Vote up 5 votes
private RowLayout(Step step) {
  this.step = step;

  label = getLabelProvider().getStepLabel(step);

  divider = new CssLayout();
  divider.addStyleName(STYLE_DIVIDER);
  divider.setHeight(100, Unit.PERCENTAGE);

  contentContainer = new Panel();
  contentContainer.addStyleName(STYLE_CONTENT_CONTAINER);
  contentContainer.addStyleName(ValoTheme.PANEL_BORDERLESS);
  contentContainer.setSizeFull();

  buttonBar = new HorizontalLayout();
  buttonBar.addStyleName(STYLE_BUTTON_BAR);
  buttonBar.setMargin(false);
  buttonBar.setSpacing(true);
  buttonBar.setWidth(100, Unit.PERCENTAGE);
  buttonBar.setMargin(new MarginInfo(false, false, !isLastStep(step), false));

  rootLayout = new GridLayout(2, 3);
  rootLayout.setSizeFull();
  rootLayout.setMargin(false);
  rootLayout.setSpacing(false);
  rootLayout.setColumnExpandRatio(1, 1);
  rootLayout.setRowExpandRatio(1, 1);
  rootLayout.addComponent(label, 0, 0, 1, 0);
  rootLayout.addComponent(divider, 0, 1, 0, 2);
  rootLayout.addComponent(contentContainer, 1, 1, 1, 1);
  rootLayout.addComponent(buttonBar, 1, 2, 1, 2);

  setCompositionRoot(rootLayout);
  addStyleName(STYLE_COMPONENT);
  setWidth(100, Unit.PERCENTAGE);
  setActive(false);
}
 
Example 7
Project: esup-ecandidat   File: SearchCtrCandWindow.java   Source Code and License Vote up 4 votes
/**
 * Crée une fenêtre de recherche de centre de candidature
 */
public SearchCtrCandWindow() {
	/* Style */
	setWidth(740, Unit.PIXELS);
	setHeight(480, Unit.PIXELS);
	setModal(true);
	setResizable(true);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	setContent(layout);
	layout.setSizeFull();
	layout.setMargin(true);
	layout.setSpacing(true);

	/* Titre */
	setCaption(applicationContext.getMessage("ctrCand.window.search.title", null, Locale.getDefault()));
	
	/* Table de Resultat de recherche*/
	grid.addItems(centreCandidatureController.getListCentreCandidature());
	grid.initColumn(FIELDS_ORDER, "ctrCand.table.", CentreCandidature_.codCtrCand.getName());
	grid.addSelectionListener(e->{
		// Le bouton d'enregistrement est actif seulement si un ctrCand est sélectionnée.
		boolean isSelected = grid.getSelectedItem() instanceof CentreCandidature;
		btnValider.setEnabled(isSelected);
	});
	grid.addItemClickListener(e->{
		if (e.isDoubleClick()) {
			grid.select(e.getItemId());
			btnValider.click();				
		}
	});
	
	grid.setColumnWidth(CentreCandidature_.codCtrCand.getName(), 180);
	grid.setExpendColumn(CentreCandidature_.libCtrCand.getName());
	
	layout.addComponent(grid);
	layout.setExpandRatio(grid, 1.0f);

	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
	btnAnnuler.addClickListener(e -> close());
	buttonsLayout.addComponent(btnAnnuler);
	buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);
	
	btnValider = new OneClickButton(applicationContext.getMessage("btnValid", null, UI.getCurrent().getLocale()), FontAwesome.SAVE);
	btnValider.setEnabled(false);
	btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY);
	btnValider.addClickListener(e -> {
		performAction();
	});
	buttonsLayout.addComponent(btnValider);
	buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_RIGHT);
	

	/* Centre la fenêtre */
	center();
}
 
Example 8
Project: esup-ecandidat   File: ScolTypeTraitementView.java   Source Code and License Vote up 4 votes
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
	/* Style */
	setSizeFull();
	setMargin(true);
	setSpacing(true);
	
	/* Titre */
	Label titleParam = new Label(applicationContext.getMessage("typeTraitement.title", null, UI.getCurrent().getLocale()));
	titleParam.addStyleName(StyleConstants.VIEW_TITLE);
	addComponent(titleParam);
	
	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	addComponent(buttonsLayout);


	OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
	btnEdit.setEnabled(false);
	btnEdit.addClickListener(e -> {
		if (typeTraitementTable.getValue() instanceof TypeTraitement) {
			nomenclatureTypeController.editTypeTraitement((TypeTraitement) typeTraitementTable.getValue());
		}
	});
	buttonsLayout.addComponent(btnEdit);
	buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


	/* Table des typeTraitements */		
	typeTraitementTable.setContainerDataSource(new BeanItemContainer<TypeTraitement>(TypeTraitement.class, nomenclatureTypeController.getTypeTraitements()));
	typeTraitementTable.addGeneratedColumn(TypeTraitement_.i18nLibTypTrait.getName(), new ColumnGenerator() {

		/*** serialVersionUID*/
		private static final long serialVersionUID = 2101119091378513475L;

		@Override
		public Object generateCell(Table source, Object itemId, Object columnId) {
			final TypeTraitement typeTraitement = (TypeTraitement) itemId;
			return i18nController.getI18nTraductionLibelle(typeTraitement.getI18nLibTypTrait());
		}
	});
	typeTraitementTable.setSizeFull();
	typeTraitementTable.setVisibleColumns((Object[]) FIELDS_ORDER);
	for (String fieldName : FIELDS_ORDER) {
		typeTraitementTable.setColumnHeader(fieldName, applicationContext.getMessage("typeTraitement.table." + fieldName, null, UI.getCurrent().getLocale()));
	}
	typeTraitementTable.setSortContainerPropertyId(TypeTraitement_.codTypTrait.getName());
	typeTraitementTable.setColumnCollapsingAllowed(true);
	typeTraitementTable.setColumnReorderingAllowed(true);
	typeTraitementTable.setSelectable(true);
	typeTraitementTable.setImmediate(true);
	typeTraitementTable.addItemSetChangeListener(e -> typeTraitementTable.sanitizeSelection());
	typeTraitementTable.addValueChangeListener(e -> {
		/* Les boutons d'édition et de suppression de typeTraitement sont actifs seulement si une typeTraitement est sélectionnée. */
		boolean typeTraitementIsSelected = typeTraitementTable.getValue() instanceof TypeTraitement;
		btnEdit.setEnabled(typeTraitementIsSelected);
	});
	typeTraitementTable.addItemClickListener(e -> {
		if (e.isDoubleClick()) {
			typeTraitementTable.select(e.getItemId());
			btnEdit.click();
		}
	});
	addComponent(typeTraitementTable);
	setExpandRatio(typeTraitementTable, 1);
	
	/* Inscrit la vue aux mises à jour de typeTraitement */
	typeTraitementEntityPusher.registerEntityPushListener(this);
}
 
Example 9
Project: esup-ecandidat   File: CandidatCompteMinimaView.java   Source Code and License Vote up 4 votes
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
	/* Style */
	setMargin(true);
	setSpacing(true);
	setSizeFull();
	
	/* Titre */
	HorizontalLayout hlLangue = new HorizontalLayout();
	hlLangue.setWidth(100, Unit.PERCENTAGE);
	hlLangue.setSpacing(true);
	
	/*Le titre*/
	labelTitle.addStyleName(StyleConstants.VIEW_TITLE);
	hlLangue.addComponent(labelTitle);
	hlLangue.setExpandRatio(labelTitle, 1);
	hlLangue.setComponentAlignment(labelTitle, Alignment.MIDDLE_LEFT);
	
	if (cacheController.getLangueEnServiceWithoutDefault().size()>0){
		Langue langueDef = cacheController.getLangueDefault();
		Image flagDef = new Image(null, new ThemeResource("images/flags/"+langueDef.getCodLangue()+".png"));
		flagDef.addClickListener(e->updateLangue(langueDef));
		flagDef.addStyleName(StyleConstants.CLICKABLE);
		hlLangue.addComponent(flagDef);
		hlLangue.setComponentAlignment(flagDef, Alignment.MIDDLE_CENTER);
		cacheController.getLangueEnServiceWithoutDefault().forEach(langue->{
			Image flag = new Image(null, new ThemeResource("images/flags/"+langue.getCodLangue()+".png"));
			flag.addClickListener(e->updateLangue(langue));
			flag.addStyleName(StyleConstants.CLICKABLE);
			hlLangue.addComponent(flag);
			hlLangue.setComponentAlignment(flag, Alignment.MIDDLE_CENTER);
			
		});
	}

	addComponent(hlLangue);
	
	/*Panel scrollable de contenu*/
	Panel panelContent = new Panel();
	panelContent.setSizeFull();
	panelContent.addStyleName(ValoTheme.PANEL_BORDERLESS);
	addComponent(panelContent);
	setExpandRatio(panelContent, 1);
	
	VerticalLayout vlContent = new VerticalLayout();
	vlContent.setSpacing(true);
	panelContent.setContent(vlContent);
	
	
	restResult.setContentMode(ContentMode.HTML);
	restResult.addStyleName(StyleConstants.LABEL_MORE_BOLD);
	restResult.addStyleName(ValoTheme.LABEL_COLORED);
	restResult.setValue("");
	vlContent.addComponent(restResult);
	
	/* Texte */		
	labelAccueil.setValue("");
	labelAccueil.setContentMode(ContentMode.HTML);		
	vlContent.addComponent(labelAccueil);
	
	connexionLayout.addStyleName(StyleConstants.MAX_WIDTH_500);
	connexionLayout.addCasListener(()->userController.connectCAS());
	connexionLayout.addStudentListener((user,pwd)->userController.connectCandidatInterne(user, pwd));
	connexionLayout.addForgotPasswordListener(()->{UI.getCurrent().addWindow(new CandidatIdOublieWindow(ConstanteUtils.FORGOT_MODE_ID_OUBLIE));});
	connexionLayout.addForgotCodeActivationListener(()->{UI.getCurrent().addWindow(new CandidatIdOublieWindow(ConstanteUtils.FORGOT_MODE_CODE_ACTIVATION));});
	vlContent.addComponent(connexionLayout);
}
 
Example 10
Project: esup-ecandidat   File: AdminLockCandidatView.java   Source Code and License Vote up 4 votes
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
	/* Style */
	setSizeFull();
	setMargin(true);
	setSpacing(true);
	
	/* Titre */
	Label titleParam = new Label(applicationContext.getMessage("lock.candidat.title", null, UI.getCurrent().getLocale()));
	titleParam.addStyleName(StyleConstants.VIEW_TITLE);
	addComponent(titleParam);
	
	Label subTitleParam = new Label(applicationContext.getMessage("lock.candidat.subtitle", null, UI.getCurrent().getLocale()), ContentMode.HTML);
	subTitleParam.addStyleName(StyleConstants.VIEW_SUBTITLE);
	addComponent(subTitleParam);		
	
	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	addComponent(buttonsLayout);

	LockCandidatListener listener = this;
	btnDelete.setCaption(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()));
	btnDelete.setEnabled(false);
	btnDelete.addClickListener(e -> {
		if (table.getValue() instanceof LockCandidat) {
			lockCandidatController.deleteLock((LockCandidat) table.getValue(), listener);
		}
	});
	buttonsLayout.addComponent(btnDelete);
	buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_LEFT);
	
	btnDeleteAll.setCaption(applicationContext.getMessage("lock.candidat.all.btn", null, UI.getCurrent().getLocale()));
	btnDeleteAll.setEnabled(false);
	btnDeleteAll.addClickListener(e -> {
		lockCandidatController.deleteAllLock(container.getItemIds(), listener);
	});
	buttonsLayout.addComponent(btnDeleteAll);
	buttonsLayout.setComponentAlignment(btnDeleteAll, Alignment.MIDDLE_RIGHT);

	/* Table des locks */
	container.addNestedContainerProperty(LockCandidat_.id.getName()+"."+LockCandidatPK_.numDossierOpiCptMin.getName());
	container.addNestedContainerProperty(LockCandidat_.id.getName()+"."+LockCandidatPK_.ressourceLock.getName());
	table.setSizeFull();
	table.setVisibleColumns((Object[]) FIELDS_ORDER);
	for (String fieldName : FIELDS_ORDER) {
		table.setColumnHeader(fieldName, applicationContext.getMessage("lock.candidat.table." + fieldName, null, UI.getCurrent().getLocale()));
	}
	table.setSortContainerPropertyId(LockCandidat_.datLock.getName());
	table.setColumnCollapsingAllowed(true);
	table.setColumnReorderingAllowed(true);
	table.setSelectable(true);
	table.setImmediate(true);
	table.addItemSetChangeListener(e -> table.sanitizeSelection());
	table.addValueChangeListener(e -> {
		if (table.getValue()==null){
			btnDelete.setEnabled(false);
		}else{
			btnDelete.setEnabled(true);
		}
		
	});
	table.addItemClickListener(e -> {
		if (e.isDoubleClick()) {
			table.select(e.getItemId());
			btnDelete.click();
		}
	});
	addComponent(table);
	setExpandRatio(table, 1);
}
 
Example 11
Project: esup-ecandidat   File: ScolTypeStatutPieceView.java   Source Code and License Vote up 4 votes
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
	/* Style */
	setSizeFull();
	setMargin(true);
	setSpacing(true);
	
	/* Titre */
	Label titleParam = new Label(applicationContext.getMessage("typeStatutPiece.title", null, UI.getCurrent().getLocale()));
	titleParam.addStyleName(StyleConstants.VIEW_TITLE);
	addComponent(titleParam);
	
	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	addComponent(buttonsLayout);


	OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
	btnEdit.setEnabled(false);
	btnEdit.addClickListener(e -> {
		if (typeStatutPieceTable.getValue() instanceof TypeStatutPiece) {
			typeStatutController.editTypeStatutPiece((TypeStatutPiece) typeStatutPieceTable.getValue());
		}
	});
	buttonsLayout.addComponent(btnEdit);
	buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


	/* Table des typeStatutPieces */
	BeanItemContainer<TypeStatutPiece> container = new BeanItemContainer<TypeStatutPiece>(TypeStatutPiece.class, typeStatutController.getTypeStatutPieces());		
	typeStatutPieceTable.setContainerDataSource(container);
	typeStatutPieceTable.addGeneratedColumn(TypeStatutPiece_.i18nLibTypStatutPiece.getName(), new ColumnGenerator() {
		
		/*** serialVersionUID*/
		private static final long serialVersionUID = 2101119091378513475L;

		@Override
		public Object generateCell(Table source, Object itemId, Object columnId) {
			final TypeStatutPiece type = (TypeStatutPiece) itemId;
			return i18nController.getI18nTraductionLibelle(type.getI18nLibTypStatutPiece());
		}
	});
	typeStatutPieceTable.setSizeFull();
	typeStatutPieceTable.setVisibleColumns((Object[]) FIELDS_ORDER);
	for (String fieldName : FIELDS_ORDER) {
		typeStatutPieceTable.setColumnHeader(fieldName, applicationContext.getMessage("typeStatutPiece.table." + fieldName, null, UI.getCurrent().getLocale()));
	}
	typeStatutPieceTable.setSortContainerPropertyId(TypeStatutPiece_.codTypStatutPiece.getName());
	typeStatutPieceTable.setColumnCollapsingAllowed(true);
	typeStatutPieceTable.setColumnReorderingAllowed(true);
	typeStatutPieceTable.setSelectable(true);
	typeStatutPieceTable.setImmediate(true);
	typeStatutPieceTable.addItemSetChangeListener(e -> typeStatutPieceTable.sanitizeSelection());
	typeStatutPieceTable.addValueChangeListener(e -> {
		/* Les boutons d'édition et de suppression de typeStatutPiece sont actifs seulement si une typeStatutPiece est sélectionnée. */
		boolean typeStatutPieceIsSelected = typeStatutPieceTable.getValue() instanceof TypeStatutPiece;
		btnEdit.setEnabled(typeStatutPieceIsSelected);
	});
	typeStatutPieceTable.addItemClickListener(e -> {
		if (e.isDoubleClick()) {
			typeStatutPieceTable.select(e.getItemId());
			btnEdit.click();
		}
	});
	addComponent(typeStatutPieceTable);
	setExpandRatio(typeStatutPieceTable, 1);
	
	/* Inscrit la vue aux mises à jour de typeStatutPiece */
	typeStatutPieceEntityPusher.registerEntityPushListener(this);
}
 
Example 12
Project: esup-ecandidat   File: CtrCandPreferenceWindowTemplate.java   Source Code and License Vote up 4 votes
/**
 * Créé un template de préférence
 */
public CtrCandPreferenceWindowTemplate() {
	super();
	
	/* Style */
	setModal(true);
	setWidth(900,Unit.PIXELS);
	setResizable(true);
	setClosable(true);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	layout.setWidth(100, Unit.PERCENTAGE);
	layout.setMargin(true);
	layout.setSpacing(true);
	setContent(layout);
	
	/*Les messages d'information*/
	panelInfo.setCaption(applicationContext.getMessage("informations", null, UI.getCurrent().getLocale()));
	panelInfo.setIcon(FontAwesome.INFO_CIRCLE);
	panelInfo.setWidthMax();		
	layout.addComponent(panelInfo);
	
	/*On ajoute le layout specifique*/
	layoutSpecifique.setSpacing(true);
	layoutSpecifique.setSizeFull();
	layout.addComponent(layoutSpecifique);

	/* Ajoute les boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	OneClickButton btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
	btnAnnuler.addClickListener(e -> close());
	buttonsLayout.addComponent(btnAnnuler);
	buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);
	
	btnReinit.setCaption(applicationContext.getMessage("preference.btnInit", null, UI.getCurrent().getLocale()));
	buttonsLayout.addComponent(btnReinit);
	buttonsLayout.setComponentAlignment(btnReinit, Alignment.MIDDLE_CENTER);
	
	btnRecordSession.setCaption(applicationContext.getMessage("preference.btnRecordSession", null, UI.getCurrent().getLocale()));
	buttonsLayout.addComponent(btnRecordSession);
	buttonsLayout.setComponentAlignment(btnRecordSession, Alignment.MIDDLE_CENTER);
	
	btnRecordDb.setCaption(applicationContext.getMessage("preference.btnRecordDb", null, UI.getCurrent().getLocale()));
	buttonsLayout.addComponent(btnRecordDb);
	buttonsLayout.setComponentAlignment(btnRecordDb, Alignment.MIDDLE_RIGHT);

	/* Centre la fenêtre */
	center();
}
 
Example 13
Project: history-api-navigation   File: DemoUI.java   Source Code and License Vote up 4 votes
@Override
protected void init(VaadinRequest request)
{
    setLocale(Locale.US);

    final HorizontalLayout rootLayout = new HorizontalLayout();
    rootLayout.setSpacing(false);
    rootLayout.setSizeFull();

    final VerticalLayout navigationLayout = new VerticalLayout();
    navigationLayout.setWidth(null);
    final Label title = new Label("HTML5 History API<br>Navigation", ContentMode.HTML);
    title.setStyleName(ValoTheme.LABEL_H1);
    title.addStyleName(ValoTheme.TEXTFIELD_ALIGN_CENTER);
    navigationLayout.addComponent(title);
    rootLayout.addComponent(navigationLayout);

    final TextField param1Field = new TextField("Parameter 1");
    final TextField param2Field = new TextField("Parameter 2");

    final Button homeButton = new Button("Home View",
            event -> getNavigator().navigateTo(HomeView.VIEW_NAME + "/" +
                    getParameters(param1Field.getValue(), param2Field.getValue())));
    navigationLayout.addComponent(homeButton);

    final Button parameterButton = new Button("Other View",
            event -> getNavigator().navigateTo(OtherView.VIEW_NAME + "/" +
                    getParameters(param1Field.getValue(), param2Field.getValue())));
    navigationLayout.addComponents(parameterButton, param1Field, param2Field);

    final Panel contentPanel = new Panel();
    contentPanel.setSizeFull();
    rootLayout.addComponent(contentPanel);
    rootLayout.setExpandRatio(contentPanel, 1.0f);

    setNavigator(HistoryApiNavigatorFactory.createHistoryApiNavigator(this, new CustomViewDisplay(contentPanel)));

    final HomeView homeView = new HomeView();
    getNavigator().addView(HomeView.VIEW_NAME, homeView);
    getNavigator().addView(OtherView.VIEW_NAME, new OtherView());

    setContent(rootLayout);
}
 
Example 14
Project: esup-ecandidat   File: ScolTagWindow.java   Source Code and License Vote up 4 votes
/**
 * Crée une fenêtre d'édition de tag
 * @param tag la tag à éditer
 */
public ScolTagWindow(Tag tag) {
	/* Style */
	setModal(true);
	setWidth(550,Unit.PIXELS);
	setResizable(true);
	setClosable(true);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	layout.setWidth(100, Unit.PERCENTAGE);
	layout.setMargin(true);
	layout.setSpacing(true);
	setContent(layout);

	/* Titre */
	setCaption(applicationContext.getMessage("tag.window", null, UI.getCurrent().getLocale()));

	/* Formulaire */
	fieldGroup = new CustomBeanFieldGroup<>(Tag.class);
	fieldGroup.setItemDataSource(tag);
	FormLayout formLayout = new FormLayout();
	formLayout.setWidth(100, Unit.PERCENTAGE);
	formLayout.setSpacing(true);
	for (String fieldName : FIELDS_ORDER) {
		String caption = applicationContext.getMessage("tag.table." + fieldName, null, UI.getCurrent().getLocale());
		Field<?> field;
		if (fieldName.equals(Tag_.colorTag.getName())){
			field = fieldGroup.buildAndBind(caption, fieldName, RequiredColorPickerField.class);
		}else{
			field = fieldGroup.buildAndBind(caption, fieldName);
		}
		
		field.setWidth(100, Unit.PERCENTAGE);			
		formLayout.addComponent(field);
	}
	
	RequiredColorPickerField fieldColor = (RequiredColorPickerField)fieldGroup.getField(Tag_.colorTag.getName());
	if (tag.getColorTag()!=null){			
		fieldColor.changeFieldColor(tag.getColorTag());
	}

	layout.addComponent(formLayout);

	/* Ajoute les boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
	btnAnnuler.addClickListener(e -> close());
	buttonsLayout.addComponent(btnAnnuler);
	buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);

	btnEnregistrer = new OneClickButton(applicationContext.getMessage("btnSave", null, UI.getCurrent().getLocale()), FontAwesome.SAVE);
	btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY);		
	btnEnregistrer.addClickListener(e -> {
		try {
			/* Valide la saisie */
			fieldGroup.commit();
			/* Enregistre la tag saisie */
			tagController.saveTag(tag);
			/* Ferme la fenêtre */
			close();
		} catch (CommitException ce) {
		}
	});
	buttonsLayout.addComponent(btnEnregistrer);
	buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);

	/* Centre la fenêtre */
	center();
}
 
Example 15
Project: esup-ecandidat   File: CtrCandOdfCandidatureWindow.java   Source Code and License Vote up 4 votes
/**
 * Crée une fenêtre de choix pour le gestionnaire : proposition ou candidature simple
 * @param message
 */
public CtrCandOdfCandidatureWindow(String message) {
	/* Style */
	setWidth(630, Unit.PIXELS);
	setModal(true);
	setResizable(false);
	setClosable(false);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	layout.setMargin(true);
	layout.setSpacing(true);
	setContent(layout);

	/* Titre */
	setCaption(applicationContext.getMessage("candidature.gest.window", null, UI.getCurrent().getLocale()));

	/* Texte */
	layout.addComponent(new Label(message));
	layout.addComponent(new Label(applicationContext.getMessage("candidature.gest.window.choice", null, UI.getCurrent().getLocale())));
	
	/*Le container d'options*/
	BeanItemContainer<SimpleTablePresentation> optContainer = new BeanItemContainer<SimpleTablePresentation>(SimpleTablePresentation.class);
	SimpleTablePresentation optionClassique = new SimpleTablePresentation(ConstanteUtils.OPTION_CLASSIQUE,applicationContext.getMessage("candidature.gest.window.choice.classique", null, UI.getCurrent().getLocale()),null);
	SimpleTablePresentation optionProposition = new SimpleTablePresentation(ConstanteUtils.OPTION_PROP,applicationContext.getMessage("candidature.gest.window.choice.proposition", null, UI.getCurrent().getLocale()),null);
	optContainer.addItem(optionClassique);
	optContainer.addItem(optionProposition);
	
	optionGroupAction.setContainerDataSource(optContainer);
	optionGroupAction.addStyleName(StyleConstants.OPTION_GROUP_HORIZONTAL);
	optionGroupAction.setItemCaptionPropertyId(SimpleTablePresentation.CHAMPS_TITLE);
	optionGroupAction.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	optionGroupAction.setValue(optionClassique);
	
	layout.addComponent(optionGroupAction);
	layout.setComponentAlignment(optionGroupAction, Alignment.MIDDLE_CENTER);
	

	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	OneClickButton btnNon = new OneClickButton(applicationContext.getMessage("confirmWindow.btnNon", null, UI.getCurrent().getLocale()),FontAwesome.TIMES);
	btnNon.addClickListener(e -> close());
	buttonsLayout.addComponent(btnNon);
	buttonsLayout.setComponentAlignment(btnNon, Alignment.MIDDLE_LEFT);

	OneClickButton btnOui = new OneClickButton(applicationContext.getMessage("confirmWindow.btnOui", null, UI.getCurrent().getLocale()),FontAwesome.CHECK);
	btnOui.setIcon(FontAwesome.CHECK);
	btnOui.addStyleName(ValoTheme.BUTTON_PRIMARY);
	btnOui.addClickListener(e -> {
		SimpleTablePresentation option = (SimpleTablePresentation)optionGroupAction.getValue();
		odfCandidatureListener.btnOkClick(option.getCode());
		close();
	});
	buttonsLayout.addComponent(btnOui);
	buttonsLayout.setComponentAlignment(btnOui, Alignment.MIDDLE_RIGHT);

	/* Centre la fenêtre */
	center();
}
 
Example 16
Project: esup-ecandidat   File: SearchCommissionWindow.java   Source Code and License Vote up 4 votes
/**Crée une fenêtre de recherche de commission
 * @param ctrCand
 */
public SearchCommissionWindow(CentreCandidature ctrCand) {
	/* Style */
	setWidth(850, Unit.PIXELS);
	setHeight(480, Unit.PIXELS);
	setModal(true);
	setResizable(true);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	setContent(layout);
	layout.setHeight(100, Unit.PERCENTAGE);
	layout.setMargin(true);
	layout.setSpacing(true);

	/* Titre */
	setCaption(applicationContext.getMessage("commission.window.search.title", null, Locale.getDefault()));
	
	/* Table de Resultat de recherche*/
	List<Commission> listeCommission;
	if (ctrCand != null){
		listeCommission = commissionController.getCommissionsByCtrCand(ctrCand);
	}else{
		listeCommission = commissionController.getCommissionsGestionnaire();
	}
	
	grid.addItems(listeCommission);
	grid.initColumn(FIELDS_ORDER, "commission.table.", Commission_.codComm.getName());
	grid.addSelectionListener(e->{
		// Le bouton d'enregistrement est actif seulement si une commission est sélectionnée.
		boolean isSelected = grid.getSelectedItem() instanceof Commission;
		btnValider.setEnabled(isSelected);
	});
	grid.addItemClickListener(e->{
		if (e.isDoubleClick()) {
			grid.select(e.getItemId());
			btnValider.click();				
		}
	});
	
	layout.addComponent(grid);
	layout.setExpandRatio(grid, 1.0f);

	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
	btnAnnuler.addClickListener(e -> close());
	buttonsLayout.addComponent(btnAnnuler);
	buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);
	
	btnValider = new OneClickButton(applicationContext.getMessage("btnValid", null, UI.getCurrent().getLocale()), FontAwesome.SAVE);
	btnValider.setEnabled(false);
	btnValider.addStyleName(ValoTheme.BUTTON_PRIMARY);
	btnValider.addClickListener(e -> {
		performAction();
	});
	buttonsLayout.addComponent(btnValider);
	buttonsLayout.setComponentAlignment(btnValider, Alignment.MIDDLE_RIGHT);
	

	/* Centre la fenêtre */
	center();
}
 
Example 17
Project: esup-ecandidat   File: ScolMailView.java   Source Code and License Vote up 4 votes
private void populateMailTypeDecLayout(VerticalLayout layoutMailTypeDec) {
	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layoutMailTypeDec.addComponent(buttonsLayout);
	
	OneClickButton btnNew = new OneClickButton(applicationContext.getMessage("mail.btnNouveau", null, UI.getCurrent().getLocale()), FontAwesome.PLUS);
	btnNew.setEnabled(true);
	btnNew.addClickListener(e -> {
		mailController.editNewMail();
	});
	buttonsLayout.addComponent(btnNew);
	buttonsLayout.setComponentAlignment(btnNew, Alignment.MIDDLE_LEFT);


	OneClickButton btnEditMailTypeDec = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
	btnEditMailTypeDec.setEnabled(false);
	btnEditMailTypeDec.addClickListener(e -> {
		if (mailTypeDecTable.getValue() instanceof Mail) {
			mailController.editMail((Mail) mailTypeDecTable.getValue());
		}
	});
	buttonsLayout.addComponent(btnEditMailTypeDec);
	buttonsLayout.setComponentAlignment(btnEditMailTypeDec, Alignment.MIDDLE_CENTER);
	
	OneClickButton btnDelete = new OneClickButton(applicationContext.getMessage("btnDelete", null, UI.getCurrent().getLocale()), FontAwesome.TRASH_O);
	btnDelete.setEnabled(false);
	btnDelete.addClickListener(e -> {
		if (mailTypeDecTable.getValue() instanceof Mail) {
			mailController.deleteMail((Mail) mailTypeDecTable.getValue());
		}			
	});
	buttonsLayout.addComponent(btnDelete);
	buttonsLayout.setComponentAlignment(btnDelete, Alignment.MIDDLE_RIGHT);


	/* Table des mails avec type de decision */
	BeanItemContainer<Mail> container = new BeanItemContainer<Mail>(Mail.class, mailController.getMailsTypeDecScol());
	container.addNestedContainerProperty(Mail_.typeAvis.getName()+"."+TypeAvis_.libelleTypAvis.getName());
	mailTypeDecTable.setContainerDataSource(container);		
	mailTypeDecTable.addBooleanColumn(Mail_.tesMail.getName());
	mailTypeDecTable.setSizeFull();
	mailTypeDecTable.setVisibleColumns((Object[]) MAIL_FIELDS_ORDER);
	for (String fieldName : MAIL_FIELDS_ORDER) {
		mailTypeDecTable.setColumnHeader(fieldName, applicationContext.getMessage("mail.table." + fieldName, null, UI.getCurrent().getLocale()));
	}
	mailTypeDecTable.setSortContainerPropertyId(Mail_.codMail.getName());
	mailTypeDecTable.setColumnCollapsingAllowed(true);
	mailTypeDecTable.setColumnReorderingAllowed(true);
	mailTypeDecTable.setSelectable(true);
	mailTypeDecTable.setImmediate(true);
	mailTypeDecTable.addItemSetChangeListener(e -> mailTypeDecTable.sanitizeSelection());
	mailTypeDecTable.addValueChangeListener(e -> {
		/* Les boutons d'édition de mail sont actifs seulement si un mail est sélectionnée. */
		boolean mailIsSelected = mailTypeDecTable.getValue() instanceof Mail;
		btnEditMailTypeDec.setEnabled(mailIsSelected);
		btnDelete.setEnabled(mailIsSelected);
	});
	mailTypeDecTable.addItemClickListener(e -> {
		if (e.isDoubleClick()) {
			mailTypeDecTable.select(e.getItemId());
			btnEditMailTypeDec.click();
		}
	});
	layoutMailTypeDec.addComponent(mailTypeDecTable);
	layoutMailTypeDec.setExpandRatio(mailTypeDecTable, 1);
}
 
Example 18
Project: esup-ecandidat   File: ScolTypeStatutPieceWindow.java   Source Code and License Vote up 4 votes
/**
 * Crée une fenêtre d'édition de typeStatutPiece
 * @param typeStatutPiece la typeStatutPiece à éditer
 */
public ScolTypeStatutPieceWindow(TypeStatutPiece typeStatutPiece) {
	/* Style */
	setModal(true);
	setWidth(550,Unit.PIXELS);
	setResizable(true);
	setClosable(true);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	layout.setWidth(100, Unit.PERCENTAGE);
	layout.setMargin(true);
	layout.setSpacing(true);
	setContent(layout);

	/* Titre */
	setCaption(applicationContext.getMessage("typeStatutPiece.window", null, UI.getCurrent().getLocale()));

	/* Formulaire */
	fieldGroup = new CustomBeanFieldGroup<>(TypeStatutPiece.class);
	fieldGroup.setItemDataSource(typeStatutPiece);
	FormLayout formLayout = new FormLayout();
	formLayout.setWidth(100, Unit.PERCENTAGE);
	formLayout.setSpacing(true);
	for (String fieldName : FIELDS_ORDER) {
		String caption = applicationContext.getMessage("typeStatutPiece.table." + fieldName, null, UI.getCurrent().getLocale());
		Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
		field.setWidth(100, Unit.PERCENTAGE);			
		formLayout.addComponent(field);
		if (fieldName.equals(TypeStatutPiece_.i18nLibTypStatutPiece.getName())){
			field.setEnabled(true);
		}else{
			field.setEnabled(false);
		}
	}
	
	((I18nField)fieldGroup.getField(TypeStatutPiece_.i18nLibTypStatutPiece.getName())).addCenterListener(e-> {if(e){center();}});

	layout.addComponent(formLayout);

	/* Ajoute les boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
	btnAnnuler.addClickListener(e -> close());
	buttonsLayout.addComponent(btnAnnuler);
	buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);

	btnEnregistrer = new OneClickButton(applicationContext.getMessage("btnSave", null, UI.getCurrent().getLocale()), FontAwesome.SAVE);
	btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY);		
	btnEnregistrer.addClickListener(e -> {
		try {
			/* Valide la saisie */
			fieldGroup.commit();
			/* Enregistre la typeStatutPiece saisie */
			typeStatutController.saveTypeStatutPiece(typeStatutPiece);
			/* Ferme la fenêtre */
			close();
		} catch (CommitException ce) {
		}
	});
	buttonsLayout.addComponent(btnEnregistrer);
	buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);

	/* Centre la fenêtre */
	center();
}
 
Example 19
Project: esup-ecandidat   File: ScolTypeStatutView.java   Source Code and License Vote up 4 votes
/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
	/* Style */
	setSizeFull();
	setMargin(true);
	setSpacing(true);
	
	/* Titre */
	Label titleParam = new Label(applicationContext.getMessage("typeStatut.title", null, UI.getCurrent().getLocale()));
	titleParam.addStyleName(StyleConstants.VIEW_TITLE);
	addComponent(titleParam);
	
	/* Boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	addComponent(buttonsLayout);


	OneClickButton btnEdit = new OneClickButton(applicationContext.getMessage("btnEdit", null, UI.getCurrent().getLocale()), FontAwesome.PENCIL);
	btnEdit.setEnabled(false);
	btnEdit.addClickListener(e -> {
		if (typeStatutTable.getValue() instanceof TypeStatut) {
			nomenclatureTypeController.editTypeStatut((TypeStatut) typeStatutTable.getValue());
		}
	});
	buttonsLayout.addComponent(btnEdit);
	buttonsLayout.setComponentAlignment(btnEdit, Alignment.MIDDLE_LEFT);


	/* Table des typeStatuts */		
	typeStatutTable.setContainerDataSource(new BeanItemContainer<TypeStatut>(TypeStatut.class, nomenclatureTypeController.getTypeStatuts()));
	typeStatutTable.addGeneratedColumn(TypeStatut_.i18nLibTypStatut.getName(), new ColumnGenerator() {
		
		/*** serialVersionUID*/
		private static final long serialVersionUID = 2101119091378513475L;

		@Override
		public Object generateCell(Table source, Object itemId, Object columnId) {
			final TypeStatut type = (TypeStatut) itemId;
			return i18nController.getI18nTraductionLibelle(type.getI18nLibTypStatut());
		}
	});
	typeStatutTable.setSizeFull();
	typeStatutTable.setVisibleColumns((Object[]) FIELDS_ORDER);
	for (String fieldName : FIELDS_ORDER) {
		typeStatutTable.setColumnHeader(fieldName, applicationContext.getMessage("typeStatut.table." + fieldName, null, UI.getCurrent().getLocale()));
	}
	typeStatutTable.setSortContainerPropertyId(TypeStatut_.codTypStatut.getName());
	typeStatutTable.setColumnCollapsingAllowed(true);
	typeStatutTable.setColumnReorderingAllowed(true);
	typeStatutTable.setSelectable(true);
	typeStatutTable.setImmediate(true);
	typeStatutTable.addBooleanColumn(TypeStatut_.temCommVisible.getName());
	typeStatutTable.setColumnWidth(TypeStatut_.temCommVisible, 250);
	typeStatutTable.addItemSetChangeListener(e -> typeStatutTable.sanitizeSelection());
	typeStatutTable.addValueChangeListener(e -> {
		/* Les boutons d'édition et de suppression de typeStatut sont actifs seulement si une typeStatut est sélectionnée. */
		boolean typeStatutIsSelected = typeStatutTable.getValue() instanceof TypeStatut;
		btnEdit.setEnabled(typeStatutIsSelected);
	});
	typeStatutTable.addItemClickListener(e -> {
		if (e.isDoubleClick()) {
			typeStatutTable.select(e.getItemId());
			btnEdit.click();
		}
	});
	addComponent(typeStatutTable);
	setExpandRatio(typeStatutTable, 1);
	
	/* Inscrit la vue aux mises à jour de typeStatut */
	typeStatutEntityPusher.registerEntityPushListener(this);
}
 
Example 20
Project: esup-ecandidat   File: FormulaireWindow.java   Source Code and License Vote up 4 votes
/**
 * Crée une fenêtre d'édition de formulaire
 * @param formulaire la formulaire à éditer
 */
public FormulaireWindow(Formulaire formulaire) {
	/* Style */
	setModal(true);
	setWidth(550,Unit.PIXELS);
	setResizable(true);
	setClosable(true);

	/* Layout */
	VerticalLayout layout = new VerticalLayout();
	layout.setWidth(100, Unit.PERCENTAGE);
	layout.setMargin(true);
	layout.setSpacing(true);
	setContent(layout);

	/* Titre */
	setCaption(applicationContext.getMessage("formulaire.window", null, UI.getCurrent().getLocale()));

	/* Formulaire */
	fieldGroup = new CustomBeanFieldGroup<>(Formulaire.class);
	fieldGroup.setItemDataSource(formulaire);
	FormLayout formLayout = new FormLayout();
	formLayout.setWidth(100, Unit.PERCENTAGE);
	formLayout.setSpacing(true);
	for (String fieldName : FIELDS_ORDER) {
		String caption = applicationContext.getMessage("formulaire.table." + fieldName, null, UI.getCurrent().getLocale());
		Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
		field.setWidth(100, Unit.PERCENTAGE);
		formLayout.addComponent(field);
	}
	
	((I18nField)fieldGroup.getField(Formulaire_.i18nUrlFormulaire.getName())).addValidator(new I18nUrlValidator(applicationContext.getMessage("validation.i18n.url.malformed", null, UI.getCurrent().getLocale())));
	((I18nField)fieldGroup.getField(Formulaire_.i18nLibFormulaire.getName())).addCenterListener(e-> {if(e){center();}});
	((I18nField)fieldGroup.getField(Formulaire_.i18nUrlFormulaire.getName())).addCenterListener(e-> {if(e){center();}});

	layout.addComponent(formLayout);

	/* Ajoute les boutons */
	HorizontalLayout buttonsLayout = new HorizontalLayout();
	buttonsLayout.setWidth(100, Unit.PERCENTAGE);
	buttonsLayout.setSpacing(true);
	layout.addComponent(buttonsLayout);

	btnAnnuler = new OneClickButton(applicationContext.getMessage("btnAnnuler", null, UI.getCurrent().getLocale()), FontAwesome.TIMES);
	btnAnnuler.addClickListener(e -> close());
	buttonsLayout.addComponent(btnAnnuler);
	buttonsLayout.setComponentAlignment(btnAnnuler, Alignment.MIDDLE_LEFT);

	btnEnregistrer = new OneClickButton(applicationContext.getMessage("btnSave", null, UI.getCurrent().getLocale()), FontAwesome.SAVE);
	btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY);		
	btnEnregistrer.addClickListener(e -> {
		try {
			/*Si le code de profil existe dejà --> erreur*/
			if (!formulaireController.isCodFormUnique((String) fieldGroup.getField(Formulaire_.codFormulaire.getName()).getValue(),(String) fieldGroup.getField(Formulaire_.idFormulaireLimesurvey.getName()).getValue(), formulaire.getIdFormulaire())){
				Notification.show(applicationContext.getMessage("formulaire.error.cod.nonuniq", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
				return;
			}				
			/* Valide la saisie */
			fieldGroup.commit();
			/* Enregistre la formulaire saisie */
			formulaireController.saveFormulaire(formulaire);
			/* Ferme la fenêtre */
			close();
		} catch (CommitException ce) {
		}
	});
	buttonsLayout.addComponent(btnEnregistrer);
	buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);

	/* Centre la fenêtre */
	center();
}