Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgkessler2008-03-26 18:44:38 +0000
committergkessler2008-03-26 18:44:38 +0000
commit540671e32e39cd7a804c249e7ed553b9363c5cd4 (patch)
tree69377df454e2b18b299a6145fa7ed32e778a6b04
parentcb4e8fd7a0fd60409ec3fcfc38ae42d0b6411ecf (diff)
downloadwebtools.jsf-540671e32e39cd7a804c249e7ed553b9363c5cd4.tar.gz
webtools.jsf-540671e32e39cd7a804c249e7ed553b9363c5cd4.tar.xz
webtools.jsf-540671e32e39cd7a804c249e7ed553b9363c5cd4.zip
[191827] Provide developers with a way to create EnumerationType's that resolve to multiple signatures.
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad.xml6
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad_html.xml6
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/AbstractEnumerationType.java137
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java120
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LocaleType.java7
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MultiSignatureEnumerationType.java48
6 files changed, 198 insertions, 126 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad.xml b/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad.xml
index e32e2f31a..8e23c028a 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad.xml
+++ b/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad.xml
@@ -507,11 +507,7 @@
<value>%property.category.event</value>
</trait>
</entity>
- <entity id="initialFocusId">
- <trait id="attribute-value-runtime-type">
- <value>org.eclipse.jst.jsf.core.attributevalues.ComponentIDReferenceType</value>
- </trait>
- </entity>
+ <entity id="initialFocusId"/>
</entity>
<entity id="form" type="tag">
<include-entity-group id="common-core-attributes"/>
diff --git a/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad_html.xml b/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad_html.xml
index 810677955..b6d4f6aa5 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad_html.xml
+++ b/jsf/plugins/org.eclipse.jst.jsf.apache.trinidad.tagsupport/metadata/trinidad_html.xml
@@ -23,11 +23,7 @@
<value>org.eclipse.jst.jsf.core.attributevalues.BooleanType</value>
</trait>
</entity>
- <entity id="initialFocusId">
- <trait id="attribute-value-runtime-type">
- <value>org.eclipse.jst.jsf.core.attributevalues.ComponentIDReferenceType</value>
- </trait>
- </entity>
+ <entity id="initialFocusId"/>
</entity>
<entity id="cellFormat" type="tag">
<include-entity-group id="common-core-attributes" uri="http://myfaces.apache.org/trinidad"/>
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/AbstractEnumerationType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/AbstractEnumerationType.java
new file mode 100644
index 000000000..fda6dd5a0
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/AbstractEnumerationType.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Oracle Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ * Vadim Dmitriev
+ *
+ ********************************************************************************/
+package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.jsf.common.internal.types.CompositeType;
+import org.eclipse.jst.jsf.metadataprocessors.AbstractRootTypeDescriptor;
+import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException;
+import org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue;
+import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues;
+import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues;
+import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues;
+import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage;
+
+/**
+ * Abstract meta-data processing type representing an enumeration attribute value runtime type
+ * <p><b>Provisional API - subject to change</b></p>
+ */
+public abstract class AbstractEnumerationType extends AbstractRootTypeDescriptor implements IValidValues, IDefaultValue, IValidELValues{
+ private List validationMessages;
+
+ /**
+ * An empty list
+ */
+ protected static List EMPTY_LIST = new ArrayList(0);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#getValidationMessages()
+ */
+ public List getValidationMessages() {
+ if (validationMessages == null){
+ validationMessages = new ArrayList();
+ }
+ return validationMessages;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue#getDefaultValue()
+ */
+ public String getDefaultValue() {
+ return getTraitValueAsString(IDefaultValue.DEFAULT_VALUE_PROP_NAME);
+ }
+
+ /**
+ * @return possible values of type as list of Strings using
+ * {@link IPossibleValues}.POSSIBLE_VALUES_PROP_NAME trait name
+ */
+ protected List getMDPossibleValues() {
+ return getTraitValueAsListOfStrings(IPossibleValues.POSSIBLE_VALUES_PROP_NAME);
+ }
+
+ /**
+ * @return possible values of type to dislay as list of Strings using
+ * {@link IPossibleValues}.POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME trait name
+ */
+ protected List getMDPossibleValuesForDisplay() {
+ return getTraitValueAsListOfStrings(IPossibleValues.POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME);
+ }
+
+ /**
+ * @return list of valid values as list of Strings using
+ * {@link IValidValues}.VALID_VALUES_PROP_NAME trait name
+ */
+ protected List getMDValidValues() {
+ return getTraitValueAsListOfStrings(IValidValues.VALID_VALUES_PROP_NAME);
+ }
+
+ /**
+ * @return Validation message for type using
+ * {@link IValidValues}.VALID_VALUES_MESSAGE_PROP_NAME trait name
+ */
+ protected String getMDValidationMessage() {
+ return getTraitValueAsString(IValidValues.VALID_VALUES_MESSAGE_PROP_NAME);
+ }
+
+ /**
+ * @return Validation severity int value for type using
+ * {@link IValidValues}.VALID_VALUES_SEVERITY_PROP_NAME trait name
+ */
+ protected int getMDValidationSeverity() {
+ String val = getTraitValueAsString(IValidValues.VALID_VALUES_SEVERITY_PROP_NAME);
+ if (val == null)
+ return IStatus.WARNING;
+
+ int severity = Integer.valueOf(val).intValue();
+ return severity;
+ }
+
+ /**
+ * @return Validation code as String value for type using
+ * {@link IValidValues}.VALID_VALUES_CODE_PROP_NAME trait name
+ */
+ protected String getMDValidationCode() {
+ return getTraitValueAsString(IValidValues.VALID_VALUES_CODE_PROP_NAME);
+ }
+
+ /**
+ * Create a {@link ValidationMessage} from metadata or use default message
+ * and add it to the collection of validation messages
+ * @param defaultMsg
+ */
+ protected void addNewValidationMessage(String defaultMsg) {
+ String msg = getMDValidationMessage();
+ if (msg == null || msg.equals("")) //$NON-NLS-1$
+ msg = defaultMsg;
+
+ String code = getMDValidationCode();
+ int severity = getMDValidationSeverity();
+ ValidationMessage val = new ValidationMessage(msg, code, severity);
+ getValidationMessages().add(val);
+ }
+
+ /**
+ * @return the value of {@link org.eclipse.jst.jsf.common.internal.types.IAssignable}.ASSIGNMENT_TYPE_NONE. Subclasses to override.
+ */
+ protected int getAssignmentType(){
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues#getExpectedRuntimeType()
+ */
+ public abstract CompositeType getExpectedRuntimeType() throws ELIsNotValidException;
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java
index e1bb995d3..df5ae3d86 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/EnumerationType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 Oracle Corporation.
+ * Copyright (c) 2006 Oracle Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,141 +7,35 @@
*
* Contributors:
* Gerry Kessler/Oracle - initial API and implementation
+ * Vadim Dmitriev
*
********************************************************************************/
package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jst.jsf.common.internal.types.CompositeType;
-import org.eclipse.jst.jsf.metadataprocessors.AbstractRootTypeDescriptor;
import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException;
-import org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue;
-import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues;
-import org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues;
-import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues;
-import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage;
/**
* Abstract meta-data processing type representing an enumeration attribute value runtime type
+ * with a single signature
*
- * <p><b>Provisional API - subject to change</b></p>
* @author Gerry Kessler - Oracle
*/
-public abstract class EnumerationType extends AbstractRootTypeDescriptor implements IValidValues, IDefaultValue, IValidELValues{
- private List validationMessages;
-
- /**
- * An empty list
- */
- protected static List EMPTY_LIST = new ArrayList(0);
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidValues#getValidationMessages()
- */
- public List getValidationMessages() {
- if (validationMessages == null){
- validationMessages = new ArrayList();
- }
- return validationMessages;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.jsf.metadataprocessors.features.IDefaultValue#getDefaultValue()
- */
- public String getDefaultValue() {
- return getTraitValueAsString(IDefaultValue.DEFAULT_VALUE_PROP_NAME);
- }
-
- /**
- * @return possible values of type as list of Strings using
- * {@link IPossibleValues}.POSSIBLE_VALUES_PROP_NAME trait name
- */
- protected List getMDPossibleValues() {
- return getTraitValueAsListOfStrings(IPossibleValues.POSSIBLE_VALUES_PROP_NAME);
- }
-
- /**
- * @return possible values of type to dislay as list of Strings using
- * {@link IPossibleValues}.POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME trait name
- */
- protected List getMDPossibleValuesForDisplay() {
- return getTraitValueAsListOfStrings(IPossibleValues.POSSIBLE_VALUES_FOR_DISPLAY_PROP_NAME);
- }
-
- /**
- * @return list of valid values as list of Strings using
- * {@link IValidValues}.VALID_VALUES_PROP_NAME trait name
- */
- protected List getMDValidValues() {
- return getTraitValueAsListOfStrings(IValidValues.VALID_VALUES_PROP_NAME);
- }
-
- /**
- * @return Validation message for type using
- * {@link IValidValues}.VALID_VALUES_MESSAGE_PROP_NAME trait name
- */
- protected String getMDValidationMessage() {
- return getTraitValueAsString(IValidValues.VALID_VALUES_MESSAGE_PROP_NAME);
- }
+public abstract class EnumerationType extends AbstractEnumerationType
+{
/**
- * @return Validation severity int value for type using
- * {@link IValidValues}.VALID_VALUES_SEVERITY_PROP_NAME trait name
- */
- protected int getMDValidationSeverity() {
- String val = getTraitValueAsString(IValidValues.VALID_VALUES_SEVERITY_PROP_NAME);
- if (val == null)
- return IStatus.WARNING;
-
- int severity = Integer.valueOf(val).intValue();
- return severity;
- }
-
- /**
- * @return Validation code as String value for type using
- * {@link IValidValues}.VALID_VALUES_CODE_PROP_NAME trait name
- */
- protected String getMDValidationCode() {
- return getTraitValueAsString(IValidValues.VALID_VALUES_CODE_PROP_NAME);
- }
-
- /**
- * Create a {@link ValidationMessage} from metadata or use default message
- * and add it to the collection of validation messages
- * @param defaultMsg
- */
- protected void addNewValidationMessage(String defaultMsg) {
- String msg = getMDValidationMessage();
- if (msg == null || msg.equals("")) //$NON-NLS-1$
- msg = defaultMsg;
-
- String code = getMDValidationCode();
- int severity = getMDValidationSeverity();
- ValidationMessage val = new ValidationMessage(msg, code, severity);
- getValidationMessages().add(val);
- }
-
- /**
* @return return Java type as string (i.e. boolean, java.lang.String, etc.)
* Must not be null.
*/
protected abstract String getReturnType();
- /**
- * @return the value of {@link org.eclipse.jst.jsf.common.internal.types.IAssignable}.ASSIGNMENT_TYPE_NONE. Subclasses to override.
- */
- protected int getAssignmentType(){
- return 0;
- }
-
/* (non-Javadoc)
* @see org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues#getExpectedRuntimeType()
*/
- public CompositeType getExpectedRuntimeType() throws ELIsNotValidException {
+ public CompositeType getExpectedRuntimeType() throws ELIsNotValidException
+ {
String type = Signature.createTypeSignature(getReturnType(), true);
return new CompositeType(type, getAssignmentType());
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LocaleType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LocaleType.java
index 09ebaf00e..cb04fdef3 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LocaleType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/LocaleType.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Oracle - initial API and implementation
+ * Vadim Dmitriev
*
********************************************************************************/
package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
@@ -31,11 +32,11 @@ import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage;
*
*/
-public class LocaleType extends EnumerationType implements IPossibleValues, IValidValues, IValidELValues{
+public class LocaleType extends MultiSignatureEnumerationType implements IPossibleValues, IValidValues, IValidELValues{
private List<IPossibleValue> _pvs;
@Override
- protected String getReturnType() {
- return "java.util.Locale"; //$NON-NLS-1$
+ protected String[] getReturnTypes() {
+ return new String[]{"java.util.Locale", "java.lang.String"}; //$NON-NLS-1$
}
public List getPossibleValues() {
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MultiSignatureEnumerationType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MultiSignatureEnumerationType.java
new file mode 100644
index 000000000..5b84c4b03
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/MultiSignatureEnumerationType.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Vadim Dmitriev and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vadim Dmitriev - initial API and implementation
+ *
+ ********************************************************************************/
+package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
+
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jst.jsf.common.internal.types.CompositeType;
+import org.eclipse.jst.jsf.metadataprocessors.features.ELIsNotValidException;
+
+/**
+ * Abstract meta-data processing type representing an enumeration attribute value
+ * of multiple runtime types
+ *
+ * @author Vadim Dmitriev
+ */
+public abstract class MultiSignatureEnumerationType extends AbstractEnumerationType {
+
+ /**
+ * @return return Java types as array of strings (i.e.
+ * new String[]{"boolean", "java.lang.String"}, etc.)
+ * Must not be null.
+ */
+ protected abstract String[] getReturnTypes();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jst.jsf.metadataprocessors.features.IValidELValues#getExpectedRuntimeType()
+ */
+ public CompositeType getExpectedRuntimeType() throws ELIsNotValidException {
+ String[] types = getReturnTypes();
+ int len = types.length;
+
+ String[] signaturedTypes = new String[ len ];
+ for( int i = 0; i < len; i++ )
+ {
+ signaturedTypes[ i ] = Signature.createTypeSignature(types[ i ], true);
+ }
+ return new CompositeType( signaturedTypes, getAssignmentType());
+ }
+
+}

Back to the top