use of com.vaadin.ui.TextField in project opencms-core by alkacon.
the class CmsLogFileApp method getComponentForState.
/**
* @see org.opencms.ui.apps.A_CmsWorkplaceApp#getComponentForState(java.lang.String)
*/
@Override
protected Component getComponentForState(String state) {
if (m_tableFilter != null) {
m_infoLayout.removeComponent(m_tableFilter);
m_tableFilter = null;
}
if (!state.startsWith(PATH_LOGCHANNEL)) {
m_rootLayout.setMainHeightFull(true);
m_fileView = new CmsLogFileView(this);
addPublishButton();
addDownloadButton(m_fileView);
addSettingsButton();
addChannelButton();
addMarkButton();
addRefreshButton();
m_table = null;
return m_fileView;
}
m_uiContext.clearToolbarButtons();
m_rootLayout.setMainHeightFull(true);
m_table = new CmsLogChannelTable(this);
m_tableFilter = new TextField();
m_tableFilter.setIcon(FontOpenCms.FILTER);
m_tableFilter.setPlaceholder(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_FILTER_0));
m_tableFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
m_tableFilter.setWidth("200px");
m_tableFilter.setValueChangeMode(ValueChangeMode.TIMEOUT);
m_tableFilter.setValueChangeTimeout(400);
m_tableFilter.addValueChangeListener(new ValueChangeListener<String>() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent<String> event) {
filterTable(event.getValue());
}
});
m_infoLayout.addComponent(m_tableFilter);
return m_table;
}
use of com.vaadin.ui.TextField in project stockstat by rroart.
the class MyIclijUI method getIntegerField.
private TextField getIntegerField(String text, String configKey) {
TextField tf = new TextField(text);
Integer origValue = (Integer) controlService.getIclijConf().getConfigValueMap().get(configKey);
tf.setValue("" + origValue);
// Handle changes in the value
tf.addValueChangeListener(new HasValue.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
// Assuming that the value type is a String
String value = (String) event.getValue();
// Do something with the value
try {
controlService.getIclijConf().getConfigValueMap().put(configKey, new Integer(value));
} catch (Exception e) {
log.error(Constants.EXCEPTION, e);
}
}
});
// tf.setImmediate(true);
return tf;
}
use of com.vaadin.ui.TextField in project esup-ecandidat by EsupPortail.
the class GridFormatting method addStringFilter.
/**
* Ajoute un filtre en TextField sur une colonne
* @param filterRow
* @param container
* @param propertys
*/
private void addStringFilter(final String property) {
final HeaderCell cell = getFilterCell(property);
final TextField filterField = new TextField();
filterField.setImmediate(true);
filterField.setWidth(100, Unit.PERCENTAGE);
filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
filterField.setInputPrompt(applicationContext.getMessage("filter.all", null, UI.getCurrent().getLocale()));
filterField.addTextChangeListener(change -> {
// Can't modify filters so need to replace
container.removeContainerFilters(property);
// (Re)create the filter if necessary
if (!change.getText().isEmpty()) {
container.addContainerFilter(new InsensitiveStringFilter(property, change.getText()));
}
fireFilterListener();
});
cell.setComponent(filterField);
}
use of com.vaadin.ui.TextField in project esup-ecandidat by EsupPortail.
the class I18nField method getValueField.
/**
* Recupere la valeur du champs contenant la liste de traduction
*
* @param i18n
* @return la liste des traductions
*/
@SuppressWarnings("unchecked")
private List<I18nTraduction> getValueField(final I18n i18n) {
List<I18nTraduction> listeToRet = new ArrayList<>();
listLayoutTraductions.forEach(e -> {
if (e.getComponentCount() == 0) {
return;
}
// langue par défaut
if (e.getComponent(0) instanceof TextField || e.getComponent(0) instanceof RichTextArea) {
AbstractField<String> tf = (AbstractField<String>) e.getComponent(0);
listeToRet.add(new I18nTraduction(MethodUtils.cleanHtmlValue(tf.getValue()), i18n, langueParDefaut));
} else if (e.getComponent(0) instanceof HorizontalLayout) {
AbstractField<String> tf = (AbstractField<String>) e.getComponent(1);
listeToRet.add(new I18nTraduction(MethodUtils.cleanHtmlValue(tf.getValue()), i18n, new Langue(tf.getId())));
} else {
ComboBox cbLangue = (ComboBox) e.getComponent(0);
Langue langue = (Langue) cbLangue.getValue();
AbstractField<String> tf = (AbstractField<String>) e.getComponent(1);
listeToRet.add(new I18nTraduction(tf.getValue(), i18n, langue));
}
});
return listeToRet;
}
use of com.vaadin.ui.TextField in project esup-ecandidat by EsupPortail.
the class OffreFormationView method init.
/**
* Initialise la vue
*/
@SuppressWarnings("unchecked")
@PostConstruct
public void init() {
/* Style */
setMargin(true);
setSpacing(true);
setSizeFull();
/* Titre */
final Label title = new Label(applicationContext.getMessage(NAME + ".title", null, UI.getCurrent().getLocale()));
title.addStyleName(StyleConstants.VIEW_TITLE);
addComponent(title);
lockLabel.setValue(applicationContext.getMessage("lock.message.odf", null, UI.getCurrent().getLocale()));
lockLabel.addStyleName(ValoTheme.LABEL_FAILURE);
lockLabel.setVisible(false);
addComponent(lockLabel);
addComponent(new Label(applicationContext.getMessage("odf.label", null, UI.getCurrent().getLocale()), ContentMode.HTML));
container.addContainerProperty(ConstanteUtils.ODF_CAPTION, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_TYPE, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_DIP_ID, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_ID, Integer.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_TITLE, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_MOT_CLE, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_DATE, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_MODE_CAND, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_DIPLOME, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_FORM_CTR_CAND, String.class, null);
container.addContainerProperty(ConstanteUtils.ODF_ICON, com.vaadin.server.Resource.class, null);
tree.setSizeFull();
tree.setItemCaptionPropertyId(ConstanteUtils.ODF_CAPTION);
tree.setItemIconPropertyId(ConstanteUtils.ODF_ICON);
tree.setVisibleColumns((Object[]) FIELDS_ORDER);
for (final String fieldName : FIELDS_ORDER) {
tree.setColumnHeader(fieldName, applicationContext.getMessage("odf.table." + fieldName, null, UI.getCurrent().getLocale()));
}
tree.setColumnWidth(ConstanteUtils.ODF_FORM_MOT_CLE, 150);
tree.setColumnWidth(ConstanteUtils.ODF_FORM_DATE, 220);
tree.setColumnWidth(ConstanteUtils.ODF_FORM_MODE_CAND, 220);
tree.setImmediate(true);
tree.addItemClickListener(e -> {
final Item item = e.getItem();
final String type = (String) item.getItemProperty(ConstanteUtils.ODF_TYPE).getValue();
// permet d'ouvrir un element de l'arbre en cliquant dessus
if (type != null && !type.equals(ConstanteUtils.ODF_TYPE_FORM)) {
final Object itemId = e.getItemId();
if (itemId != null) {
final Boolean isCollapse = tree.isCollapsed(itemId);
if (isCollapse != null) {
tree.setCollapsed(itemId, !isCollapse);
}
}
}
// verifications
if (cptMin == null) {
return;
}
if (isLocked) {
Notification.show(applicationContext.getMessage("lock.message.odf", null, UI.getCurrent().getLocale()), Type.WARNING_MESSAGE);
return;
}
if (type != null && type.equals(ConstanteUtils.ODF_TYPE_FORM)) {
final Integer idForm = (Integer) item.getItemProperty(ConstanteUtils.ODF_FORM_ID).getValue();
candidatureController.candidatToFormation(idForm, this, false);
}
});
/* tree.addGeneratedColumn(ConstanteUtils.ODF_TYPE, new ColumnGenerator() {
* private static final long serialVersionUID = -7536672274094786260L;
*
* @Override
* public Object generateCell(Table source, Object itemId, Object columnId) {
* final Item item = source.getItem(itemId);
* String type = (String) item.getItemProperty(ConstanteUtils.ODF_TYPE).getValue();
* if (type != null){
* return applicationContext.getMessage("odf.type." + type, null, UI.getCurrent().getLocale());
* }
* return null;
* }
* }); */
tree.setCellStyleGenerator(new Table.CellStyleGenerator() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public String getStyle(final Table source, final Object itemId, final Object propertyId) {
final Item item = tree.getItem(itemId);
final Property<String> propertyType = item.getItemProperty(ConstanteUtils.ODF_TYPE);
if (propertyType != null) {
final String value = propertyType.getValue();
if (value != null && value.equals(ConstanteUtils.ODF_TYPE_CTR)) {
return "level-1-Ctr";
} else if (value != null && value.equals(ConstanteUtils.ODF_TYPE_DIP)) {
return "level-2-Dip";
} else if (value != null && value.equals(ConstanteUtils.ODF_TYPE_FORM)) {
return "level-3-Form";
}
}
return null;
}
});
/* tree.setItemStyleGenerator(new ItemStyleGenerator() {
*
* private static final long serialVersionUID = 2940526202958994909L;
*
* @Override
* public String getStyle(Tree source, Object itemId) {
* Item item = tree.getItem(itemId);
* Property<String> propertyType = item.getItemProperty(ConstanteUtils.ODF_TYPE);
* if (propertyType!=null){
* String value = propertyType.getValue();
* if (value!=null && value.equals(ConstanteUtils.ODF_TYPE_CTR)){
* return "level-1-Ctr";
* }else if (value!=null && value.equals(ConstanteUtils.ODF_TYPE_DIP)){
* return "level-2-Dip";
* }else if (value!=null && value.equals(ConstanteUtils.ODF_TYPE_FORM)){
* return "level-3-Form";
* }
* }
* return null;
* }
* }); */
// tfFilter.setCaption(applicationContext.getMessage("odf.filter", null, UI.getCurrent().getLocale()));
final TextField tfFilter = new TextField();
tfFilter.setInputPrompt(applicationContext.getMessage("odf.filter", null, UI.getCurrent().getLocale()));
tfFilter.setImmediate(true);
/* tfFilter.addTextChangeListener(e->{
* container.removeAllContainerFilters();
* Filter filterTitle = new SimpleStringFilter(ConstanteUtils.ODF_FORM_TITLE, e.getText(), true, false);
* Filter filterMotCle = new SimpleStringFilter(ConstanteUtils.ODF_FORM_MOT_CLE, e.getText(), true, false);
* Filter filterDip = new SimpleStringFilter(ConstanteUtils.ODF_FORM_DIPLOME, e.getText(), true, false);
* Filter filterCtrCand = new SimpleStringFilter(ConstanteUtils.ODF_FORM_CTR_CAND, e.getText(), true, false);
* container.addContainerFilter(new Or(filterDip,filterMotCle,filterTitle,filterCtrCand));
* tree.refreshRowCache();
* }); */
final Label labelFilter = new Label(applicationContext.getMessage("odf.filter.nofilter", null, UI.getCurrent().getLocale()));
btnFilter.setCaption(applicationContext.getMessage("odf.filter.btn", null, UI.getCurrent().getLocale()));
btnFilter.addClickListener(e -> {
final String valFilter = tfFilter.getValue();
if (valFilter != null && !valFilter.equals("")) {
labelFilter.setValue(applicationContext.getMessage("odf.filter.label", new Object[] { valFilter }, UI.getCurrent().getLocale()));
} else {
labelFilter.setValue(applicationContext.getMessage("odf.filter.nofilter", null, UI.getCurrent().getLocale()));
}
container.removeAllContainerFilters();
final Filter filterTitle = new SimpleStringFilter(ConstanteUtils.ODF_FORM_TITLE, valFilter, true, false);
final Filter filterMotCle = new SimpleStringFilter(ConstanteUtils.ODF_FORM_MOT_CLE, valFilter, true, false);
final Filter filterDip = new SimpleStringFilter(ConstanteUtils.ODF_FORM_DIPLOME, valFilter, true, false);
final Filter filterCtrCand = new SimpleStringFilter(ConstanteUtils.ODF_FORM_CTR_CAND, valFilter, true, false);
container.addContainerFilter(new Or(filterDip, filterMotCle, filterTitle, filterCtrCand));
tree.setPageLength(0);
});
tfFilter.addShortcutListener(new ShortcutListener(null, ShortcutAction.KeyCode.ENTER, null) {
private static final long serialVersionUID = 6231790311427334925L;
@Override
public void handleAction(final Object sender, final Object target) {
btnFilter.click();
}
});
hlFilter.setSpacing(true);
hlFilter.addComponent(tfFilter);
hlFilter.addComponent(btnFilter);
hlFilter.addComponent(labelFilter);
hlFilter.setComponentAlignment(tfFilter, Alignment.BOTTOM_LEFT);
hlFilter.setComponentAlignment(btnFilter, Alignment.BOTTOM_LEFT);
hlFilter.setComponentAlignment(labelFilter, Alignment.MIDDLE_LEFT);
noFormationLabel.setValue(applicationContext.getMessage("odf.no.formation", null, UI.getCurrent().getLocale()));
addComponent(noFormationLabel);
addComponent(hlFilter);
addComponent(tree);
setExpandRatio(tree, 1);
updateOdfTree();
}
Aggregations