本文整理匯總了Java中com.vaadin.ui.HorizontalLayout.setWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java HorizontalLayout.setWidth方法的具體用法?Java HorizontalLayout.setWidth怎麽用?Java HorizontalLayout.setWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.ui.HorizontalLayout
的用法示例。
在下文中一共展示了HorizontalLayout.setWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: RowLayout
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
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);
}
示例2: getLayoutBtnConditionnel
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* @param btn
* @return le layout de bouton conditionnel
*/
private HorizontalLayout getLayoutBtnConditionnel(final OneClickButton btn) {
btn.addStyleName(ValoTheme.BUTTON_TINY);
HorizontalLayout layout = new HorizontalLayout();
layout.setWidth(100, Unit.PERCENTAGE);
layout.addComponent(btn);
layout.setComponentAlignment(btn, Alignment.MIDDLE_CENTER);
return layout;
}
示例3: SearchCtrCandWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* 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();
}
示例4: CandidatIdOublieWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre de demande d'envoie d'identifiant ou de code d'activation
*/
public CandidatIdOublieWindow(String mode) {
/* Style */
setModal(true);
setWidth(600,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 */
if (mode.equals(ConstanteUtils.FORGOT_MODE_ID_OUBLIE)){
setCaption(applicationContext.getMessage("compteMinima.id.oublie.title", null, UI.getCurrent().getLocale()));
layout.addComponent(new Label(applicationContext.getMessage("compteMinima.id.oublie", null, UI.getCurrent().getLocale())));
}else{
setCaption(applicationContext.getMessage("compteMinima.code.oublie.title", null, UI.getCurrent().getLocale()));
layout.addComponent(new Label(applicationContext.getMessage("compteMinima.code.oublie", null, UI.getCurrent().getLocale())));
}
/* Formulaire */
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
RequiredTextField rtf = new RequiredTextField();
rtf.setRequiredError(applicationContext.getMessage("validation.obigatoire", null, UI.getCurrent().getLocale()));
rtf.setNullRepresentation("");
rtf.setRequired(true);
rtf.setCaption(applicationContext.getMessage("compteMinima.table.mailPersoCptMin", null, UI.getCurrent().getLocale()));
rtf.addValidator(new EmailValidator(applicationContext.getMessage("validation.error.mail", null, Locale.getDefault())));
rtf.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(rtf);
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("btnSend", null, UI.getCurrent().getLocale()), FontAwesome.SEND);
btnEnregistrer.addStyleName(ValoTheme.BUTTON_PRIMARY);
btnEnregistrer.addClickListener(e -> {
rtf.preCommit();
if (rtf.isValid()){
if (candidatController.initPasswordOrActivationCode(rtf.getValue(), mode)){
close();
}
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例5: addHeaderAndButtons
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
private void addHeaderAndButtons() {
HorizontalLayout topLayout = new HorizontalLayout();
topLayout.setWidth("80%");
Label header = new Label("Message Console");
header.addStyleName(ValoTheme.LABEL_H2);
Button showButton = new Button("");
showButton.setCaption("Show");
showButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
// showButton.setIcon(VaadinIcons.PLUS_CIRCLE);
showButton.addClickListener(click -> {
System.out.println("[x] Show button clicked ...");
dataGrid.setItems();
});
Button sendButton = new Button("");
sendButton.setCaption("Send");
sendButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
sendButton.setIcon(VaadinIcons.PLUS);
sendButton.addClickListener(click -> {
System.out.println("[x] Send button clicked ...");
Runnable runner = new Runnable() {
@Override
public void run() {
sender.send();
}
};
new Thread(runner).start();
});
topLayout.addComponent(header);
topLayout.setComponentAlignment(header, Alignment.BOTTOM_CENTER);
topLayout.addComponent(showButton);
topLayout.setComponentAlignment(showButton, Alignment.MIDDLE_CENTER);
topLayout.addComponent(sendButton);
topLayout.setComponentAlignment(sendButton, Alignment.MIDDLE_CENTER);
addComponent(topLayout);
}
示例6: StepLabel
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* Construct a new label with the given caption, description and icon.
*
* @param caption
* The caption to show
* @param description
* The description to show
* @param icon
* The icon to show
*/
public StepLabel(String caption, String description, FontIcon icon) {
active = false;
nexted = false;
skipped = false;
editable = false;
clickable = false;
iconLabel = new Label();
iconLabel.setWidthUndefined();
iconLabel.setContentMode(ContentMode.HTML);
iconLabel.addStyleName(STYLE_STEP_ICON);
captionLabel = new Label();
captionLabel.setWidth(100, Unit.PERCENTAGE);
captionLabel.addStyleName(STYLE_STEP_CAPTION);
descriptionLabel = new Label();
descriptionLabel.setWidth(100, Unit.PERCENTAGE);
descriptionLabel.addStyleName(ValoTheme.LABEL_LIGHT);
descriptionLabel.addStyleName(ValoTheme.LABEL_SMALL);
descriptionLabel.addStyleName(STYLE_STEP_DESCRIPTION);
captionWrapper = new VerticalLayout();
captionWrapper.setSpacing(false);
captionWrapper.setMargin(false);
captionWrapper.setSizeFull();
captionWrapper.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
captionWrapper.addComponent(captionLabel);
captionWrapper.addComponent(descriptionLabel);
rootLayout = new HorizontalLayout();
rootLayout.setSpacing(false);
rootLayout.setMargin(false);
rootLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
rootLayout.setWidth(100, Unit.PERCENTAGE);
rootLayout.addComponent(iconLabel);
rootLayout.addComponent(captionWrapper);
rootLayout.setExpandRatio(captionWrapper, 1);
setCompositionRoot(rootLayout);
addStyleName(STYLE_ROOT_LAYOUT);
setIcon(icon);
setCaption(caption);
setDescription(description);
setIconNexted(DEFAULT_ICON_NEXTED);
setIconSkipped(DEFAULT_ICON_SKIPPED);
setIconEditable(DEFAULT_ICON_EDITABLE);
setIconError(DEFAULT_ICON_ERROR);
}
示例7: addHeaderAndButtons
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
private void addHeaderAndButtons() {
HorizontalLayout topLayout = new HorizontalLayout();
topLayout.setWidth("80%");
Label header = new Label("Streaming Console");
header.addStyleName(ValoTheme.LABEL_H2);
Button showButton = new Button("");
showButton.setCaption("Stream");
showButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
// showButton.setIcon(VaadinIcons.PLUS_CIRCLE);
showButton.addClickListener(click -> {
System.out.println("[x] Show button clicked ...");
// Start the data feed thread
new FeederThread().start();
});
Button sendButton = new Button("");
sendButton.setCaption("Send");
sendButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
sendButton.setIcon(VaadinIcons.PLUS);
sendButton.addClickListener(click -> {
Runnable r = new Runnable() {
@Override
public void run() {
System.out.println("[x] Send button clicked ...");
sender.stream();
}
};
new Thread(r).start();
});
topLayout.addComponent(header);
topLayout.setComponentAlignment(header, Alignment.BOTTOM_CENTER);
topLayout.addComponent(showButton);
topLayout.setComponentAlignment(showButton, Alignment.MIDDLE_CENTER);
topLayout.addComponent(sendButton);
topLayout.setComponentAlignment(sendButton, Alignment.MIDDLE_CENTER);
addComponent(topLayout);
}
示例8: AdminLangueWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition de langue
* @param langue la langue à éditer
*/
public AdminLangueWindow(Langue langue) {
/* Style */
setModal(true);
setWidth(350,Unit.PIXELS);
setResizable(false);
setClosable(false);
/* Layout */
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
layout.setSpacing(true);
setContent(layout);
/* Titre */
setCaption(applicationContext.getMessage("langue.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(Langue.class);
fieldGroup.setItemDataSource(langue);
FormLayout formLayout = new FormLayout();
formLayout.setSpacing(true);
formLayout.setSizeUndefined();
for (String fieldName : LANGUE_FIELDS_ORDER) {
formLayout.addComponent(fieldGroup.buildAndBind(applicationContext.getMessage("langue.table." + fieldName, null, UI.getCurrent().getLocale()), fieldName));
}
fieldGroup.getField(Langue_.codLangue.getName()).setReadOnly(true);
fieldGroup.getField(Langue_.libLangue.getName()).setReadOnly(true);
if (langue.getCodLangue().equals(NomenclatureUtils.LANGUE_FR)){
fieldGroup.getField(Langue_.tesLangue.getName()).setEnabled(false);
}
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 langue saisie */
langueController.saveLangue(langue);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例9: init
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* 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);
}
示例10: FormulaireWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* 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();
}
示例11: init
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* 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);
}
示例12: init
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* 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);
}
示例13: ScolTagWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* 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();
}
示例14: ScolMotivationAvisWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition de motivationAvis
* @param motivationAvis la motivationAvis à éditer
*/
public ScolMotivationAvisWindow(MotivationAvis motivationAvis) {
/* 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("motivAvis.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(MotivationAvis.class);
fieldGroup.setItemDataSource(motivationAvis);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
String caption = applicationContext.getMessage("motivAvis.table." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
}
((I18nField)fieldGroup.getField(MotivationAvis_.i18nLibMotiv.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 (!motivationAvisController.isCodMotivUnique((String) fieldGroup.getField(MotivationAvis_.codMotiv.getName()).getValue(), motivationAvis.getIdMotiv())){
Notification.show(applicationContext.getMessage("window.error.cod.nonuniq", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
/* Valide la saisie */
fieldGroup.commit();
/* Enregistre la motivationAvis saisie */
motivationAvisController.saveMotivationAvis(motivationAvis);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}
示例15: ScolMessageWindow
import com.vaadin.ui.HorizontalLayout; //導入方法依賴的package包/類
/**
* Crée une fenêtre d'édition de message
* @param message la message à éditer
*/
public ScolMessageWindow(Message message) {
/* Style */
setModal(true);
setWidth(850,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("message.window", null, UI.getCurrent().getLocale()));
/* Formulaire */
fieldGroup = new CustomBeanFieldGroup<>(Message.class);
fieldGroup.setItemDataSource(message);
FormLayout formLayout = new FormLayout();
formLayout.setWidth(100, Unit.PERCENTAGE);
formLayout.setSpacing(true);
for (String fieldName : FIELDS_ORDER) {
String caption = applicationContext.getMessage("message.table." + fieldName, null, UI.getCurrent().getLocale());
Field<?> field = fieldGroup.buildAndBind(caption, fieldName);
field.setWidth(100, Unit.PERCENTAGE);
formLayout.addComponent(field);
if (fieldName.equals(Message_.codMsg.getName())){
field.setEnabled(false);
}
}
((I18nField)fieldGroup.getField(Message_.i18nValMessage.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 message saisie */
messageController.saveMessage(message);
/* Ferme la fenêtre */
close();
} catch (CommitException ce) {
}
});
buttonsLayout.addComponent(btnEnregistrer);
buttonsLayout.setComponentAlignment(btnEnregistrer, Alignment.MIDDLE_RIGHT);
/* Centre la fenêtre */
center();
}