/** * @see org.projectforge.web.common.timeattr.AttrWicketComponentFactory#createComponents(org.projectforge.web.wicket.flowlayout.AbstractFieldsetPanel, * org.projectforge.framework.persistence.attr.api.AttrDescription, * org.projectforge.framework.persistence.attr.api.EntityWithAttributes) */ @Override public ComponentWrapperPanel createComponents(final String id, final AttrGroup group, final AttrDescription desc, final EntityWithAttributes entity) { final MinMaxNumberField<BigDecimal> textField = new MinMaxNumberField<>( InputPanel.WICKET_ID, new AttrModel<>(entity, desc.getPropertyName(), BigDecimal.class), new BigDecimal(desc.getMinIntValue()), new BigDecimal(desc.getMaxIntValue()) ); setAndOutputMarkupId(textField, group, desc); textField.setRequired(desc.isRequired()); return new InputPanel(id, textField); }
/** * @see org.projectforge.web.common.timeattr.AttrWicketComponentFactory#createComponents(org.projectforge.web.wicket.flowlayout.AbstractFieldsetPanel, * org.projectforge.framework.persistence.attr.api.AttrDescription, * org.projectforge.framework.persistence.attr.api.EntityWithAttributes) */ @Override public ComponentWrapperPanel createComponents(final String id, final AttrGroup group, final AttrDescription desc, final EntityWithAttributes entity) { final MaxLengthTextField textField = new MaxLengthTextField( InputPanel.WICKET_ID, new AttrModel<>(entity, desc.getPropertyName(), String.class), desc.getMaxLength() ); setAndOutputMarkupId(textField, group, desc); textField.setRequired(desc.isRequired()); return new InputPanel(id, textField); }
@Override public ComponentWrapperPanel createWicketComponent(final String id, final AttrGroup group, final AttrDescription desc, final EntityWithAttributes entity) { // TODO RK cachen der factory Object factoryObject = desc.getWicketComponentFactoryClass(); AttrWicketComponentFactory factory; if (factoryObject instanceof AttrWicketComponentFactory) { factory = (AttrWicketComponentFactory) factoryObject; } else { throw new UnsupportedOperationException( "Attr cannot load component factory: " + desc.getPropertyName() + "; " + desc.getWicketComponentFactoryClass()); } return factory.createComponents(id, group, desc, entity); }
@Override public AttrDescription getAttrDescription(final AttrGroup attrGroup, final String descriptionName) { return (attrGroup == null) ? null : attrGroup .getDescriptions() .stream() .filter(desc -> desc.getPropertyName().equals(descriptionName)) .findFirst() .orElse(null); } }
@Override public ComponentWrapperPanel createComponents(final String id, final AttrGroup group, final AttrDescription desc, final EntityWithAttributes entity) { final DatePanel dp = new DatePanel( id, new AttrModel<>(entity, desc.getPropertyName(), Date.class), DatePanelSettings.get().withTargetType(java.sql.Date.class) ); dp.setRequired(desc.isRequired()); setAndOutputMarkupId(dp.getFormComponent(), group, desc); return dp; }
@Override public void populateItem(final Item<ICellPopulator<U>> item, final String componentId, final IModel<U> model) { final U entity = model.getObject(); // set column heading if (getDisplayModel().getObject() == null) { final AttrDescription attrDescription = guiAttrSchemaService.getAttrDescription(entity, groupName, descName); final String i18nkey = attrDescription.getI18nkey(); final String translation = I18nHelper.getLocalizedMessage(i18nkey); getDisplayModel().setObject(translation); } final Optional<IModel<String>> stringAttribute = guiAttrSchemaService.getStringAttribute(entity, new Date(), groupName, descName); if (stringAttribute.isPresent()) { item.add(new Label(componentId, stringAttribute.get())); } else { // empty label item.add(new Label(componentId)); } if (cellItemListener != null) { cellItemListener.populateItem(item, componentId, model); } }
@Override public <PK extends Serializable, T extends TimeableAttrRow<PK>, U extends EntityWithTimeableAttr<PK, T> & EntityWithConfigurableAttr> Optional<IModel<String>> getStringAttribute(final U entity, final Date date, final String groupName, final String descName) { final T attrRowForCurrentDate = timeableService.getAttrRowValidAtDate(entity, groupName, date); if (attrRowForCurrentDate == null) { return Optional.empty(); } final String attribute = attrRowForCurrentDate.getStringAttribute(descName); if (attribute == null) { return Optional.empty(); } final AttrDescription attrDescription = getAttrDescription(entity, groupName, descName); final IModel<String> valueModel = (attrDescription.getWicketComponentFactoryClass() instanceof DropDownAttrWicketComponentFactory) ? new ResourceModel(attribute) : // DropDownAttrWicketComponentFactory -> it's a list of i18nkeys, so we need a ResourceModel for the translation new Model<>(attribute); return Optional.of(valueModel); }
private ColumnMetadata getColumnMetadataFromColumnDesc(EntityMetadata entm, AttrDescription ad) { ColumnMetadataBean mb = new ColumnMetadataBean(entm); mb.setName(ad.getPropertyName()); mb.setJavaType(String.class); // TODO RK more fields return mb; }
new AttrModel<>(entity, desc.getPropertyName(), String.class), i18nKeyList, new IChoiceRenderer<String>() dropdownChoice.setRequired(desc.isRequired());
protected DivPanel createContent(final EntityWithAttributes entity, final Consumer<GridBuilder> gridBuilderConsumer) { final GridBuilder gridBuilder = new GridBuilder(null, "content"); gridBuilder.newSplitPanel(GridSize.COL100); // this can be used to create content before the rest of the content is created if (gridBuilderConsumer != null) { gridBuilderConsumer.accept(gridBuilder); } // create the content according to the descriptions of this group (from the xml file) for (final AttrDescription desc : attrGroup.getDescriptions()) { final String label = getString(desc.getI18nkey()); final FieldsetPanel fs = gridBuilder.newFieldset(label); final ComponentWrapperPanel component = attrSchemaService.createWicketComponent(fs.newChildId(), attrGroup, desc, entity); fs.add((Component) component); } return gridBuilder.getMainContainer(); } }
/** * @see org.projectforge.web.common.timeattr.AttrWicketComponentFactory#createComponents(org.projectforge.web.wicket.flowlayout.AbstractFieldsetPanel, * org.projectforge.framework.persistence.attr.api.AttrDescription, * org.projectforge.framework.persistence.attr.api.EntityWithAttributes) */ @Override public ComponentWrapperPanel createComponents(final String id, final AttrGroup group, final AttrDescription desc, final EntityWithAttributes entity) { final MinMaxNumberField<Integer> textField = new MinMaxNumberField<>( InputPanel.WICKET_ID, new AttrModel<>(entity, desc.getPropertyName(), Integer.class), desc.getMinIntValue(), desc.getMaxIntValue() ); setAndOutputMarkupId(textField, group, desc); textField.setRequired(desc.isRequired()); return new InputPanel(id, textField); }
default void setAndOutputMarkupId(final Component component, final AttrGroup group, final AttrDescription desc) { component.setMarkupId(group.getName() + "-" + desc.getPropertyName()).setOutputMarkupId(true); } }
@Override public Map<String, SearchColumnMetadata> getAdditionallySearchFields(EntityMetadata entm, String params) { Map<String, SearchColumnMetadata> ret = new HashMap<>(); AttrSchemaService service = AttrSchemaServiceSpringBeanImpl.get(); AttrSchema schema = service.getAttrSchema(params); if (schema != null) { for (AttrGroup group : schema.getGroups()) { for (AttrDescription ad : group.getDescriptions()) { ColumnMetadata cmd = getColumnMetadataFromColumnDesc(entm, ad); SearchColumnMetadataBean scmd = new SearchColumnMetadataBean(ad.getPropertyName(), cmd); scmd.setIndexType(String.class); scmd.setIndexed(true); ret.put(ad.getPropertyName(), scmd); } } return ret; } else { log.info("Can't get AttrSchema. Continoue without."); return null; } }
@Override public ComponentWrapperPanel createComponents(final String id, final AttrGroup group, final AttrDescription desc, final EntityWithAttributes entity) { final CheckBoxPanel checkBox = new CheckBoxPanel( id, new AttrModel<>(entity, desc.getPropertyName(), Boolean.class), null ); setAndOutputMarkupId(checkBox.getFormComponent(), group, desc); return checkBox; }