Index: src/org/teiid/designer/ui/properties/extension/messages.properties =================================================================== --- src/org/teiid/designer/ui/properties/extension/messages.properties (revision 2129) +++ src/org/teiid/designer/ui/properties/extension/messages.properties (working copy) @@ -14,6 +14,5 @@ propertyDefinitiontNotFound = The property definition "{0}" could not be found. unexpectedPropertySourceId = Unexpected parameter "{0}" passed into ModelExtensionPropertySource.getPropertyValue(Object). valueIsNotAnAllowedValue = Value "{0}" is not an allowed value for property "{1}." Value was reset to be an empty value. -valueIsNotAnAllowedValueFirstValueUsed = Value "{0}" is not an allowed value for property "{1}." The first allowed value of "{2}" will be used. unexpectedPropertyValueType = The property "{0}" has a new value that is not a string. workspaceFileNotFound = The workspace file for "{0}" could not be found. \ No newline at end of file Index: src/org/teiid/designer/ui/properties/extension/Messages.java =================================================================== --- src/org/teiid/designer/ui/properties/extension/Messages.java (revision 2129) +++ src/org/teiid/designer/ui/properties/extension/Messages.java (working copy) @@ -24,7 +24,6 @@ public static String unexpectedPropertySourceId; public static String unexpectedPropertyValueType; public static String valueIsNotAnAllowedValue; - public static String valueIsNotAnAllowedValueFirstValueUsed; public static String workspaceFileNotFound; static { Index: src/org/teiid/designer/ui/properties/extension/ModelExtensionPropertyDescriptor.java =================================================================== --- src/org/teiid/designer/ui/properties/extension/ModelExtensionPropertyDescriptor.java (revision 2130) +++ src/org/teiid/designer/ui/properties/extension/ModelExtensionPropertyDescriptor.java (working copy) @@ -231,33 +231,29 @@ try { String value = assistant.getPropertyValue(this.eObject, propId); String[] allowedValues = propDefn.getAllowedValues(); + boolean hasAllowedValues = ((allowedValues != null) && (allowedValues.length != 0)); + // no value if (CoreStringUtil.isEmpty(value)) { - // no value but prop defn has allowed values. must return an int so use first allowed value - if ((allowedValues != null) && (allowedValues.length != 0)) { - return 0; + // prop defn has allowed values but since we must return an int because there are allowed values return -1 + // which will clear selection in comboboxcelleditor + if (hasAllowedValues) { + return -1; } - // must convert to empty string if null as TextCellEditor requires non-null value + // ensure value is empty string not null as TextCellEditor requires non-null value value = CoreStringUtil.Constants.EMPTY_STRING; - } else { + } else if (hasAllowedValues) { // a value that is an allowed values must be converted to the index - if ((allowedValues != null) && (allowedValues.length != 0)) { - for (int i = 0; i < allowedValues.length; ++i) { - if (allowedValues[i].equalsIgnoreCase(value)) { - return i; - } - } - - // value is not an allowed value - if (this.propDefn.isRequired()) { - log(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.valueIsNotAnAllowedValueFirstValueUsed, - new Object[] { value, propId, allowedValues[0] }))); - value = allowedValues[0]; - } else { - log(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.valueIsNotAnAllowedValue, value, propId))); + for (int i = 0; i < allowedValues.length; ++i) { + if (allowedValues[i].equalsIgnoreCase(value)) { + return i; } } + + // current value is not a current allowed value so just clear comboboxcelleditor selection + log(new Status(IStatus.ERROR, PLUGIN_ID, NLS.bind(Messages.valueIsNotAnAllowedValue, value, propId))); + return -1; } return value; @@ -280,17 +276,15 @@ ModelObjectExtensionAssistant assistant = getModelExtensionAssistant(propId); if (assistant != null) { + // if integer, value must be an index to an allowed value so convert to the value at that index if (value instanceof Integer) { int index = (Integer)value; - - // only could be an index to an allowed value so convert to the value at that index String[] allowedValues = propDefn.getAllowedValues(); - if ((allowedValues != null) && (allowedValues.length == 0)) { - if ((index < 0) || (index > (allowedValues.length - 1))) { - // set to default value - value = null; - } + // make sure index makes sense + if ((index < 0) || (allowedValues == null) || (allowedValues.length == 0) || (index > (allowedValues.length - 1))) { + // don't return a value + value = CoreStringUtil.Constants.EMPTY_STRING; } else { value = allowedValues[index]; } @@ -357,13 +351,24 @@ // integer values are indexes into allowed values collection if (value instanceof Integer) { - String stringValue = propDefn.getAllowedValues()[(Integer)value]; + // if no value set to empty string + String stringValue = CoreStringUtil.Constants.EMPTY_STRING; - if (!CoreStringUtil.equals(stringValue, propDefn.getDefaultValue())) { + if (((Integer)value).intValue() == -1) { + // error if no value and value is required + if (propDefn.isRequired()) { + return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); + } + } else { + stringValue = propDefn.getAllowedValues()[(Integer)value]; + } + + if (!CoreStringUtil.valuesAreEqual(stringValue, propDefn.getDefaultValue())) { return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); } } + // value return null; } @@ -382,6 +387,10 @@ String[] allowedValues = getPropertyDefinition().getAllowedValues(); if ((allowedValues != null) && (allowedValues.length != 0)) { + if (((Integer)element).intValue() == -1) { + return CoreStringUtil.Constants.EMPTY_STRING; + } + return allowedValues[(Integer)element]; } }