@Override public String toString() { return new StringBuilder() .append(getDisplayName()) .append(" : ") .append(getDisplayValue()) .toString(); }
public TableProperty build() { return new TableProperty(this); } }
/** * Returns <code>true</code> if any property on UI was filled for search. * If none returns <code>false</code>. Put all filled properties to new list. * * @return <code>true</code> if any property on UI was filled for search. * If none returns <code>false</code>. */ public boolean isAnyPropertyFilled() { filledPropsForSearch.clear(); boolean result = false; for(TableProperty prop : propForSearch) { if (prop.getValue() != null && StringUtils.isNotEmpty(prop.getDisplayValue())){ filledPropsForSearch.add(prop); result = true; } } return result; }
public String getValidationJS() { StringBuilder validation = new StringBuilder(); TableProperty prop = getCurrentProp(); Constraints constraints = prop.getConstraints(); if (constraints != null) { String inputId = getInputIdJS(prop.getName()); for (Constraint constraint : constraints.getAll()) { if (constraint instanceof LessThanConstraint || constraint instanceof MoreThanConstraint) { String validator = constraint instanceof LessThanConstraint ? "lessThan" : "moreThan"; String compareToField = (String) constraint.getParams()[0]; String compareToFieldId = getInputIdJS(compareToField); TableProperty compareToProperty = getProperty(prop.getName()); String compareToPropertyDisplayName = compareToProperty == null ? "" : compareToProperty.getDisplayName(); validation.append("new Validation(" + inputId + ", '" + validator + "', '', {compareToFieldId:" + compareToFieldId + ",messageParams:'" + compareToPropertyDisplayName + "'})"); } } } return validation.toString(); }
if (row.getType().equals(PropertyRowType.PROPERTY)) { TableProperty property = (TableProperty) row.getData(); String name = property.getName(); Object newValue = property.getValue(); Object oldValue = props.getPropertyValue(name); boolean enumArray = property.isEnumArray(); boolean stringArray = property.isStringArray();
private TableProperty getPropertyByName(String name) { for (TableProperty property : properties) { if (property.getName().equals(name)) { return property; } } return null; }
public boolean isChanged() throws Exception { if (propertyRows == null) { return false; } ITableProperties props = getTable().getProperties(); for (PropertyRow row : propertyRows) { if (row.getType().equals(PropertyRowType.PROPERTY)) { TableProperty property = (TableProperty) row.getData(); String name = property.getName(); Object newValue = property.getValue(); Object oldValue = props.getPropertyValue(name); boolean enumArray = property.isEnumArray(); if ((enumArray && !Arrays.equals((Enum<?>[]) oldValue, (Enum<?>[]) newValue)) || (!enumArray && ObjectUtils.notEqual(oldValue, newValue)) || (!props.getAllProperties().containsKey(name))) { return true; } } } for (String propToRemove : propsToRemove) { if (props.getAllProperties().containsKey(propToRemove)) return true; } return false; }
private String getEnumMultiSelectComponentCode(String componentId, TableProperty tableProperty) { Class<?> instanceClass = tableProperty.getType().getComponentType(); String valueString = tableProperty.getStringValue(); String[] values = EnumUtils.getNames(instanceClass); String[] displayValues = EnumUtils.getValues(instanceClass); String id = String.format("%s:%s:enumArraySelect", componentId, tableProperty.getName()); String componentCode = new HTMLRenderer().getMultiSelectComponentCode(id, values, displayValues, valueString); return getEditorHTMLCode(id, componentCode); }
public void initPropertyGroups(IOpenLTable table, ITableProperties props) { groups = new LinkedHashMap<String, List<TableProperty>>(); TablePropertyDefinition[] propDefinitions = TablePropertyDefinitionUtils .getDefaultDefinitionsForTable(table.getType()); for (TablePropertyDefinition propDefinition : propDefinitions) { Object value = props.getPropertyValue(propDefinition.getName()); if (value != null) { InheritanceLevel inheritanceLevel = props.getPropertyLevelDefinedOn(propDefinition.getName()); TableProperty prop = new TableProperty(propDefinition); prop.setValue(value); prop.setInheritanceLevel(inheritanceLevel); if (InheritanceLevel.MODULE.equals(inheritanceLevel) || InheritanceLevel.CATEGORY.equals(inheritanceLevel)) { prop.setInheritedTableId(getProprtiesTableId(inheritanceLevel, props)); } storeProperty(prop); } } }
@Override public List<TableProperty> getPropertiesToDisplay() { List<TableProperty> properties = new ArrayList<TableProperty>(); for (TableProperty property : getPropertiesManager().getProperties()) { if (property.isDimensional() && PropertiesChecker.isPropertySuitableForTableType(property.getName(), getTable().getType()) && PropertiesChecker.isPropertySuitableForLevel(InheritanceLevel.TABLE, property.getName())) { properties.add(property); } } return properties; }
public List<SelectItem> getEnumArrayItems() { List<SelectItem> items = new ArrayList<SelectItem>(); String[] values = null; String[] displayValues = null; if (isEnumType() || isEnumArray()) { Class<?> instanceClass = type.getComponentType() != null ? type.getComponentType() : type; values = EnumUtils.getNames(instanceClass); displayValues = EnumUtils.getValues(instanceClass); } if(values != null) { for (int i = 0; i < values.length; i++) { items.add(new SelectItem(values[i], displayValues[i])); } } return items; }
/** * @return Min version that can be set into new copy of original table. */ public Version getMinNextVersion() { TableProperty originalVersion = getVersion(); if (originalVersion != null && StringUtils.isNotEmpty((String) originalVersion.getValue())) { return Version.parseVersion((String) originalVersion.getValue(), 0, ".."); } else { return Version.parseVersion(INIT_VERSION, 0, ".."); } }
/** * This method must be used for all the cases when you need to display * property on UI. It converts its value from any type to string. * * @return */ public String getDisplayValue() { return getStringValue(); }
public String[] getEnumArrayValue() { if (value != null && isEnumArray()) { return EnumUtils.getNames((Enum<?>[]) value); } return null; }
public String getStringValue() { String result = StringUtils.EMPTY; if (value != null) { result = FormattersManager.getFormatter(type, getFormat()).format(value); } return result; }
public String getValidationJS() { StringBuilder validation = new StringBuilder(); TableProperty prop = getCurrentProp(); Constraints constraints = prop.getConstraints(); if (constraints != null) { String inputId = getInputIdJS(prop.getName()); for (Constraint constraint : constraints.getAll()) { if (constraint instanceof LessThanConstraint || constraint instanceof MoreThanConstraint) { String validator = constraint instanceof LessThanConstraint ? "lessThan" : "moreThan"; String compareToField = (String) constraint.getParams()[0]; String compareToFieldId = getInputIdJS(compareToField); TableProperty compareToProperty = getProperty(prop.getName()); String compareToPropertyDisplayName = compareToProperty == null ? "" : compareToProperty.getDisplayName(); validation.append("new Validation(") .append(inputId) .append(", '") .append(validator) .append("', '', {compareToFieldId:") .append(compareToFieldId) .append(",messageParams:'") .append(compareToPropertyDisplayName) .append("'})"); } } } return validation.toString(); }
if (row.getType().equals(PropertyRowType.PROPERTY)) { TableProperty property = (TableProperty) row.getData(); String name = property.getName(); Object newValue = property.getValue(); Object oldValue = props.getPropertyValue(name); boolean enumArray = property.isEnumArray(); boolean stringArray = property.isStringArray();
/** * Set predefined properties into bean. * * @param properties List of properties. */ public void setProperties(List<TableProperty> properties) { this.properties = properties; for (TableProperty property : properties) { possibleToAddProps.remove(property.getName()); } }
public boolean isChanged() throws Exception { if (propertyRows == null) { return false; } ITableProperties props = getTable().getProperties(); for (PropertyRow row : propertyRows) { if (row.getType().equals(PropertyRowType.PROPERTY)) { TableProperty property = (TableProperty) row.getData(); String name = property.getName(); Object newValue = property.getValue(); Object oldValue = props.getPropertyValue(name); boolean enumArray = property.isEnumArray(); if ((enumArray && !Arrays.equals((Enum<?>[]) oldValue, (Enum<?>[]) newValue)) || (!enumArray && ObjectUtils.notEqual(oldValue, newValue)) || (!props.getAllProperties().containsKey(name))) { return true; } } } for (String propToRemove : propsToRemove) { if (props.getAllProperties().containsKey(propToRemove)) return true; } return false; }