本文整理匯總了Java中com.vaadin.ui.FormLayout.setWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java FormLayout.setWidth方法的具體用法?Java FormLayout.setWidth怎麽用?Java FormLayout.setWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.ui.FormLayout
的用法示例。
在下文中一共展示了FormLayout.setWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
@PostConstruct
void init() {
FormLayout formLayout = new FormLayout();
formLayout.addComponent(usernameField);
formLayout.addComponent(passwordField);
formLayout.addComponent(loginButton);
formLayout.setWidth(null);
addComponent(formLayout);
loginButton.setClickShortcut( ShortcutAction.KeyCode.ENTER ) ;
loginButton.addClickListener((Button.ClickListener) clickEvent -> {
if (usernameField.isEmpty()) {
Notification.show("Username is required");
usernameField.focus();
} else if (passwordField.isEmpty()) {
Notification.show("Password is required");
passwordField.focus();
} else {
handler.login(this, usernameField.getValue(), passwordField.getValue());
}
});
usernameField.focus();
// setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
}
示例2: ViewWithPopup
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
public ViewWithPopup(String title) {
addComponent(new Label(title));
button = new Button("Open Popup");
PopupExtensionManualBundle bundle = PopupExtension.extendWithManualBundle(button);
addComponent(bundle.getDataTransferComponent());
final PopupExtension popupExtension = bundle.getPopupExtension();
popupExtension.setOffset(100, 50);
popupExtension.setDirection(Alignment.BOTTOM_RIGHT);
FormLayout popupLayout = new FormLayout();
popupLayout.setWidth("500px");
popupLayout.addComponent(new Label("Problematic Combobox (press F5)"));
popupLayout.addComponent(new ComboBox("POPUP CONTENT"));
popupExtension.setContent(popupLayout);
button.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
popupExtension.toggle();
}
});
addComponent(button);
}
示例3: AdresseForm
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition d'adresse
* @param fieldGroupAdresse l'adresse à éditer
*/
public AdresseForm(CustomBeanFieldGroup<Adresse> fieldGroupAdresse, Boolean withCedex) {
setSpacing(true);
setSizeFull();
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
if (withCedex || (!withCedex && !fieldName.equals(Adresse_.cedexAdr.getName()))){
String caption = applicationContext.getMessage("adresse." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field;
if (fieldName.equals(Adresse_.codBdiAdr.getName())){
field = fieldGroupAdresse.buildAndBind(caption, fieldName,RequiredIntegerField.class);
((RequiredIntegerField)field).setNullRepresentation("");
((RequiredIntegerField)field).setMaxLength(5);
}else{
field = fieldGroupAdresse.buildAndBind(caption, fieldName);
}
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
}
}
initForm(fieldGroupAdresse);
addComponent(formLayout);
}
示例4: populateForm
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
@Override
public void populateForm() {
try {
this.name = new TextField("Name");
this.name.focus();
this.name.setImmediate(true);
this.name.setRequired(true);
this.name.setRequiredError("Name cannot be empty");
FormLayout innerForm = new FormLayout();
innerForm.addComponent(this.name);
innerForm.addComponent(getManagerConnector());
innerForm.addComponent(getApplianceDefinition());
innerForm.setWidth(100, Unit.PERCENTAGE);
VerticalLayout layout = new VerticalLayout();
layout.addComponent(innerForm);
// TODO: Future. Need to dynamically show/hide attributes based on manager type
getAttributesPanel();
layout.addComponent(getVirtualSystemPanel());
this.form.setMargin(true);
this.form.setWidth(689, Unit.PIXELS);
this.form.addComponent(layout);
} catch (Exception e) {
log.error("Fail to populate Distributed Appliance form", e);
ViewUtil.iscNotification("Fail to populate Distributed Appliance form (" + e.getMessage() + ")",
Notification.Type.ERROR_MESSAGE);
}
}
示例5: buildMainLayout
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
@AutoGenerated
private FormLayout buildMainLayout() {
// common part: create layout
mainLayout = new FormLayout();
mainLayout.setImmediate(false);
mainLayout.setWidth("-1px");
mainLayout.setHeight("-1px");
mainLayout.setMargin(true);
mainLayout.setSpacing(true);
// top-level component properties
setWidth("-1px");
setHeight("-1px");
// textFieldSubdomain
textFieldSubdomain = new TextField();
textFieldSubdomain.setCaption("Enter Sub Domain");
textFieldSubdomain.setImmediate(false);
textFieldSubdomain
.setDescription("You can enter sub domain name - do not use spaces or wildcard characters.");
textFieldSubdomain.setWidth("-1px");
textFieldSubdomain.setHeight("-1px");
textFieldSubdomain.setInvalidAllowed(false);
textFieldSubdomain
.setInputPrompt("Examples: sales hr business marketing.");
mainLayout.addComponent(textFieldSubdomain);
mainLayout.setExpandRatio(textFieldSubdomain, 1.0f);
// buttonSave
buttonSave = new Button();
buttonSave.setCaption("Save");
buttonSave.setImmediate(true);
buttonSave.setWidth("-1px");
buttonSave.setHeight("-1px");
mainLayout.addComponent(buttonSave);
mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
return mainLayout;
}
示例6: postConstruct
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
@Override
public void postConstruct() {
super.postConstruct();
setSizeFull();
layout = new VerticalLayout();
layout.setSizeFull();
layout.setSpacing(true);
setCompositionRoot(layout);
infoLabel = new Label("Vaadin4Spring Security Demo - SignUp");
infoLabel.addStyleName(ValoTheme.LABEL_H2);
infoLabel.setSizeUndefined();
layout.addComponent(infoLabel);
layout.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER);
container = new VerticalLayout();
container.setSizeUndefined();
container.setSpacing(true);
layout.addComponent(container);
layout.setComponentAlignment(container, Alignment.MIDDLE_CENTER);
layout.setExpandRatio(container, 1);
form = new FormLayout();
form.setWidth("400px");
form.setSpacing(true);
container.addComponent(form);
buildForm();
btnSignUp = new Button("Signup", FontAwesome.FLOPPY_O);
btnSignUp.addStyleName(ValoTheme.BUTTON_FRIENDLY);
btnSignUp.addClickListener(this);
container.addComponent(btnSignUp);
container.setComponentAlignment(btnSignUp, Alignment.MIDDLE_CENTER);
}
示例7: addFormLayout
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
private FormLayout addFormLayout() {
FormLayout formLayout = new FormLayout();
formLayout.setWidth( "250px" );
formLayout.setHeight( "250px" );
formLayout.addStyleName( "outlined" );
formLayout.setSpacing( true );
addComponent( formLayout, "left: 10px; top: 10px;" );
return formLayout;
}
示例8: addFormLayout
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
private FormLayout addFormLayout() {
FormLayout formLayout = new FormLayout();
formLayout.setWidth( "300px" );
formLayout.setHeight( "200px" );
formLayout.addStyleName( "outlined" );
formLayout.setSpacing( true );
mainLayout.addComponent( formLayout );
mainLayout.setComponentAlignment( formLayout, Alignment.MIDDLE_CENTER );
return formLayout;
}
示例9: addFormLayout
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
private FormLayout addFormLayout( int x, int y ) {
FormLayout formLayout = new FormLayout();
formLayout.setWidth( String.format( "%spx", x ) );
formLayout.setHeight( String.format( "%spx", y ) );
formLayout.addStyleName( "outlined" );
formLayout.setSpacing( true );
addComponent( formLayout, "left: 350px; top: 50px;" );
return formLayout;
}
示例10: ScolTypeTraitementWindow
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition de typeTraitement
* @param typeTraitement la typeTraitement à éditer
*/
public ScolTypeTraitementWindow(TypeTraitement typeTraitement) {
/* 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("typeTraitement.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(TypeTraitement.class);
fieldGroup.setItemDataSource(typeTraitement);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
String caption = applicationContext.getMessage("typeTraitement.table." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
if (fieldName.equals(TypeTraitement_.i18nLibTypTrait.getName())){
field.setEnabled(true);
}else{
field.setEnabled(false);
}
}
((I18nField)fieldGroup.getField(TypeTraitement_.i18nLibTypTrait.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 typeTraitement saisie */
nomenclatureTypeController.saveTypeTraitement(typeTraitement);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例11: PieceJustifWindow
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition de pieceJustif
* @param pieceJustif la pieceJustif à éditer
*/
public PieceJustifWindow(PieceJustif pieceJustif) {
/* 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("pieceJustif.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(PieceJustif.class);
fieldGroup.setItemDataSource(pieceJustif);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
String caption = applicationContext.getMessage("pieceJustif.table." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
}
((I18nField)fieldGroup.getField(PieceJustif_.i18nLibPj.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 (!pieceJustifController.isCodPjUnique((String) fieldGroup.getField(PieceJustif_.codPj.getName()).getValue(), pieceJustif.getIdPj())){
Notification.show(applicationContext.getMessage("window.error.cod.nonuniq", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
/* Valide la saisie */
fieldGroup.commit();
/* Enregistre la pieceJustif saisie */
pieceJustifController.savePieceJustif(pieceJustif);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例12: CtrCandPostItAddWindow
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/**Crée une fenêtre d'édition de postit
* @param postIt
*/
public CtrCandPostItAddWindow(PostIt postIt) {
/* Layout */
VerticalLayout layout = new VerticalLayout();
layout.setWidth(600, Unit.PIXELS);
layout.setMargin(true);
layout.setSpacing(true);
setContent(layout);
/* Titre */
setCaption(applicationContext.getMessage("postit.add.window", null, UI.getCurrent().getLocale()));
/*Layout adresse*/
fieldGroup = new CustomBeanFieldGroup<PostIt>(PostIt.class,ConstanteUtils.TYP_FORM_CANDIDAT);
fieldGroup.setItemDataSource(postIt);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
Field<?> field = fieldGroup.buildAndBind(applicationContext.getMessage("postit.table." + PostIt_.messagePostIt.getName(), null, UI.getCurrent().getLocale()), PostIt_.messagePostIt.getName(), RequiredTextArea.class);
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
layout.addComponent(formLayout);
layout.setExpandRatio(formLayout, 1);
/* 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 du cursus*/
fieldGroup.commit();
/* Enregistre le cursus saisi */
postItWindowListener.btnOkClick(candidatureCtrCandController.savePostIt(postIt));
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例13: ScolTypeStatutWindow
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition de typeStatut
* @param typeStatut la typeStatut à éditer
*/
public ScolTypeStatutWindow(TypeStatut typeStatut) {
/* 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("typeStatut.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(TypeStatut.class);
fieldGroup.setItemDataSource(typeStatut);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
String caption = applicationContext.getMessage("typeStatut.table." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
if (fieldName.equals(TypeStatut_.i18nLibTypStatut.getName()) || fieldName.equals(TypeStatut_.temCommVisible.getName())){
field.setEnabled(true);
}else{
field.setEnabled(false);
}
}
((I18nField)fieldGroup.getField(TypeStatut_.i18nLibTypStatut.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 typeStatut saisie */
typeStatutController.saveTypeStatut(typeStatut);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例14: ScolAlertSvaParametreWindow
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/** Crée une fenêtre d'édition de date d'alerte SVA
* @param parametreDate
* @param parametreDefinitif
*/
public ScolAlertSvaParametreWindow(Parametre parametreDate, Parametre parametreDefinitif) {
/* Style */
setModal(true);
setWidth(600,Unit.PIXELS);
setResizable(true);
setClosable(true);
ParametreSvaPresentation parametre = new ParametreSvaPresentation(parametreDate.getValParam(),parametreDefinitif.getValParam());
/* Layout */
VerticalLayout layout = new VerticalLayout();
layout.setWidth(100, Unit.PERCENTAGE);
layout.setMargin(true);
layout.setSpacing(true);
setContent(layout);
/* Titre */
setCaption(applicationContext.getMessage("alertSva.date.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(ParametreSvaPresentation.class);
fieldGroup.setItemDataSource(parametre);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
ComboBoxPresentation field = fieldGroup.buildAndBind(applicationContext.getMessage("alertSva.date.title", null, UI.getCurrent().getLocale()),
ParametreSvaPresentation.CHAMPS_DATE, ComboBoxPresentation.class);
field.setListe(alertSvaController.getListeDateSVA());
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
RequiredStringCheckBox fieldDefinitif = fieldGroup.buildAndBind(applicationContext.getMessage("alertSva.definitif.title", null, UI.getCurrent().getLocale()),
ParametreSvaPresentation.CHAMPS_DEFINITF, RequiredStringCheckBox.class);
fieldDefinitif.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(fieldDefinitif);
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 alertSva saisie */
changeAlertSVAWindowListener.btnOkClick(parametre);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例15: ScolTypeStatutPieceWindow
import com.vaadin.ui.FormLayout; //導入方法依賴的package包/類
/**
* 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();
}