List of usage examples for org.apache.commons.lang3 StringUtils capitalize
public static String capitalize(final String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:org.jbpm.formModeler.core.processing.BindingManagerImpl.java
@Override public void setPropertyValue(Object destination, String propName, Object value) throws NoSuchFieldException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { Field field = destination.getClass().getDeclaredField(propName); Method setterMethod = destination.getClass().getMethod("set" + StringUtils.capitalize(propName), new Class[] { field.getType() }); setterMethod.invoke(destination, new Object[] { value }); }
From source file:org.jbpm.formModeler.service.bb.mvc.components.handling.BeanHandler.java
public synchronized CommandResponse handle(CommandRequest request, String action) throws Exception { if (log.isDebugEnabled()) log.debug("Entering handle " + getBeanName() + " action: " + action); // Calculate the action to invoke. action = StringUtils.capitalize(action); action = reverseActionsShortcuts.getProperty(action, action); // Double click control. if (isEnableDoubleClickControl() && !isEnabledForActionHandling()) { // Duplicates can only be prevented in session components, and if they are enabled for that purpose log.warn("Discarding duplicated execution in component " + getBeanName() + ", action: " + action + ". User should be advised not to double click!"); return null; }/*from w ww . ja va 2s .co m*/ try { String methodName = "action" + action; beforeInvokeAction(request, action); CommandResponse response = null; Method handlerMethod = this.getClass().getMethod(methodName, new Class[] { CommandRequest.class }); if (log.isDebugEnabled()) log.debug("Invoking method " + methodName + " on " + getBeanName()); response = (CommandResponse) handlerMethod.invoke(this, new Object[] { request }); afterInvokeAction(request, action); if (response == null) { response = new ShowScreenResponse( CurrentComponentRenderer.lookup().getCurrentComponent().getBaseComponentJSP()); } if (!(response instanceof SendStreamResponse)) { setEnabledForActionHandling(false); } if (log.isDebugEnabled()) log.debug("Leaving handle " + getBeanName() + " - " + action); return response; } catch (Exception ex) { log.warn("Error handling action '" + action + "': ", ex); } return null; }
From source file:org.jpos.qi.eeuser.ConsumersView.java
protected Component buildAndBindCustomComponent(String propertyId) { if ("roles".equalsIgnoreCase(propertyId)) { CheckBoxGroup<Role> checkBoxGroup = new CheckBoxGroup<>(QIUtils.getCaptionFromId(propertyId)); checkBoxGroup.setItems(((ConsumersHelper) getHelper()).getRoles()); checkBoxGroup.setItemCaptionGenerator(role -> StringUtils.capitalize(role.getName())); formatField(propertyId, checkBoxGroup).bind(propertyId); return checkBoxGroup; }/*from w ww. j a v a 2 s .co m*/ if ("user".equalsIgnoreCase(propertyId)) { ComboBox<User> box = createUserBox(); formatField(propertyId, box).bind(propertyId); box.setEnabled(false); box.setValue(this.selectedUser); return box; } if ("startdate".equalsIgnoreCase(propertyId) || "endDate".equalsIgnoreCase(propertyId)) { return buildAndBindDateField(propertyId); } return null; }
From source file:org.jpos.qi.eeuser.UsersView.java
protected Component buildAndBindCustomComponent(String propertyId) { if ("roles".equals(propertyId)) { CheckBoxGroup g = new CheckBoxGroup(StringUtils.capitalize(getCaptionFromId(propertyId))); g.setItems(((UsersHelper) getHelper()).getRoles()); g.setItemCaptionGenerator((ItemCaptionGenerator<Role>) item -> StringUtils.capitalize(item.getName())); List<Validator> v = getValidators(propertyId); Binder.BindingBuilder builder = getBinder().forField(g); for (Validator val : v) { builder.withValidator(val); }/* w w w. j a v a 2 s . c o m*/ builder.bind(propertyId); return g; } return null; }
From source file:org.jpos.qi.minigl.NewEntryForm.java
private void createAndBindFields(Binder binder) { TextField accountCode = createTextField("accountCode"); ComboBox layer = createLayersSelector(); TextField detail = createTextField("detail"); TextField tags = createTextField("tags"); TextField amount = createTextField("amount"); RadioButtonGroup credit = createCreditOrDebit(); binder.forField(accountCode).withNullRepresentation("").withConverter(new AccountConverter()) .withValidator((Validator<Account>) (value, context) -> { if (value != null && !(value instanceof FinalAccount)) return ValidationResult.error(app.getMessage("errorMessage.accountNotFinal")); else if (value == null) return ValidationResult.error(app.getMessage("errorMessage.req", StringUtils.capitalize(accountCode.getCaption()))); return ValidationResult.ok(); }).asRequired(app.getMessage("errorMessage.req", StringUtils.capitalize(layer.getCaption()))) .bind("account"); binder.forField(layer).withConverter(new ShortToLayerConverter(journal)) .asRequired(app.getMessage("errorMessage.req", StringUtils.capitalize(layer.getCaption()))) .bind("layer"); binder.forField(detail)/* www .j a v a 2 s . c o m*/ .withValidator(new StringLengthValidator( app.getMessage("errorMessage.invalidField", detail.getCaption()), 0, 255)) .withValidator(new RegexpValidator(app.getMessage("errorMessage.invalidField", detail.getCaption()), TEXT_REGEX)) .bind("detail"); binder.forField(tags) .withValidator(new StringLengthValidator( app.getMessage("errorMessage.invalidField", tags.getCaption()), 0, 255)) .withValidator(new RegexpValidator(app.getMessage("errorMessage.invalidField", tags.getCaption()), TEXT_REGEX)) .withConverter(new StringToTagConverter()).bind("tags"); binder.forField(amount) .asRequired(app.getMessage("errorMessage.req", StringUtils.capitalize(amount.getCaption()))) .withConverter(new StringToBigDecimalConverter(app.getMessage("errorMessage.invalidAmount"))) .withValidator(new BigDecimalRangeValidator(app.getMessage("errorMessage.invalidAmount"), new BigDecimal("1"), new BigDecimal("99999999999999"))) .withNullRepresentation(BigDecimal.ZERO).bind("amount"); binder.bind(credit, "credit"); addComponent(accountCode); addComponent(layer); addComponent(detail); addComponent(tags); addComponent(amount); addComponent(credit); setComponentAlignment(credit, Alignment.BOTTOM_CENTER); }
From source file:org.jpos.qi.QIEntityView.java
protected CheckBox buildAndBindBooleanField(String id) { CheckBox box = new CheckBox(StringUtils.capitalize(getCaptionFromId("field." + id)), false); Binder.BindingBuilder builder = formatField(id, box); builder.bind(id);/*w w w . java 2 s . c o m*/ return box; }
From source file:org.jpos.qi.QIEntityView.java
protected DateField buildAndBindDateField(String id) { DateField dateField = new DateField(getCaptionFromId("field." + id)); List<Validator> v = getValidators(id); Binder.BindingBuilder builder = getBinder().forField(dateField); for (Validator val : v) { builder.withValidator(val); }//from w w w. j a v a2s . c o m if (isRequired(id)) { builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); } ; builder.withConverter(new LocalDateToDateConverter()).bind(id); return dateField; }
From source file:org.jpos.qi.QIEntityView.java
protected Binder.BindingBuilder formatField(String id, HasValue field) { List<Validator> v = getValidators(id); Binder.BindingBuilder builder = getBinder().forField(field); for (Validator val : v) builder.withValidator(val); if (isRequired(id)) builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); ViewConfig.FieldConfig config = viewConfig.getFields().get(id); String width = config != null ? config.getWidth() : null; if (field instanceof AbstractComponent) ((AbstractComponent) field).setWidth(width); builder = builder.withNullRepresentation(""); return builder; }
From source file:org.jpos.qi.sysconfig.SysConfigView.java
@Override protected Component buildAndBindCustomComponent(String propertyId) { if ("id".equals(propertyId)) { TextField id = new TextField(getCaptionFromId(propertyId)); List<Validator> validators = getValidators(propertyId); Binder<SysConfig> binder = getBinder(); Binder.BindingBuilder builder = binder.forField(id) .asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId(propertyId)))) .withNullRepresentation("").withConverter(userInputValue -> userInputValue, toPresentation -> removePrefix(toPresentation)); validators.forEach(builder::withValidator); builder.bind(propertyId);/*from w w w . ja va 2s. c o m*/ return id; } return null; }
From source file:org.jpos.util.FieldFactory.java
public DateField buildAndBindDateField(String id) { DateField dateField = new DateField(getCaptionFromId("field." + id)); Binder.BindingBuilder builder = getBinder().forField(dateField); builder.withConverter(new LocalDateToDateConverter()).bind(id); if (viewConfig == null) return dateField; List<Validator> v = getValidators(id); for (Validator val : v) builder.withValidator(val); if (isRequired(id)) builder.asRequired(getApp().getMessage("errorMessage.req", StringUtils.capitalize(getCaptionFromId("field." + id)))); if ("endDate".equals(id)) dateField.addValueChangeListener( (HasValue.ValueChangeListener<LocalDate>) event -> dateField.addStyleName("expired-date")); return dateField; }