Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Thienel2012-04-27 15:12:14 -0400
committerFlorian Thienel2012-04-27 15:12:14 -0400
commit2f027a1dc33f086ec784018b5f5b3877fc0d171c (patch)
tree79cca54abc8298af25e041a9261f2393d37ce8ed
parent14d99e2b2d3c8f3d082f9b4a12120bf9237c8647 (diff)
downloadorg.eclipse.mylyn.docs.vex-2f027a1dc33f086ec784018b5f5b3877fc0d171c.tar.gz
org.eclipse.mylyn.docs.vex-2f027a1dc33f086ec784018b5f5b3877fc0d171c.tar.xz
org.eclipse.mylyn.docs.vex-2f027a1dc33f086ec784018b5f5b3877fc0d171c.zip
bug 377714: fixed combo box for enum attributes
Signed-off-by: Florian Thienel <florian@thienel.org>
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java11
-rw-r--r--org.eclipse.vex.core.tests/testResources/test1.dtd3
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/WTPVEXValidator.java8
3 files changed, 16 insertions, 6 deletions
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java
index 39f5850d..5a00ae28 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/dom/DTDValidatorTest.java
@@ -47,6 +47,17 @@ public class DTDValidatorTest extends TestCase {
assertSame(adType, adType2);
}
+
+ public void testEnumAttribute() throws Exception {
+ final Document doc = new Document(new RootElement("section"));
+ doc.setValidator(validator);
+ final Element sectionElement = doc.getRootElement();
+ final AttributeDefinition attributeDefinition = validator.getAttributeDefinitions(sectionElement).get(0);
+ assertEquals("enatt", attributeDefinition.getName());
+
+ final String[] enumValues = attributeDefinition.getValues();
+ assertEquals(3, enumValues.length);
+ }
// public void testEmptyDTD() throws Exception {
// VEXDocument doc;
diff --git a/org.eclipse.vex.core.tests/testResources/test1.dtd b/org.eclipse.vex.core.tests/testResources/test1.dtd
index 86cbc195..3633eddd 100644
--- a/org.eclipse.vex.core.tests/testResources/test1.dtd
+++ b/org.eclipse.vex.core.tests/testResources/test1.dtd
@@ -12,4 +12,5 @@
<!-- a dummy attribute, just to make sure attribute def serialization is OK -->
<!ATTLIST section
- name CDATA #IMPLIED> \ No newline at end of file
+ name CDATA #IMPLIED
+ enatt (value1|value2|value3) #IMPLIED> \ No newline at end of file
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/WTPVEXValidator.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/WTPVEXValidator.java
index 8b9c0aeb..f57d6967 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/WTPVEXValidator.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/validator/WTPVEXValidator.java
@@ -180,14 +180,12 @@ public class WTPVEXValidator implements Validator {
private AttributeDefinition createAttributeDefinition(final CMAttributeDeclaration attribute) {
@SuppressWarnings("deprecation")
final String defaultValue = attribute.getDefaultValue();
- String[] values = null;
+ final String[] values = attribute.getAttrType().getEnumeratedValues();
AttributeDefinition.Type type = null;
- if (attribute.getAttrType().equals(CMDataType.ENUM)) {
+ if (attribute.getAttrType().getDataTypeName().equals(CMDataType.ENUM)) {
type = AttributeDefinition.Type.ENUMERATION;
- values = attribute.getAttrType().getEnumeratedValues();
- } else if (attribute.getAttrType().equals(CMDataType.NOTATION)) {
+ } else if (attribute.getAttrType().getDataTypeName().equals(CMDataType.NOTATION)) {
type = AttributeDefinition.Type.ENUMERATION;
- values = attribute.getAttrType().getEnumeratedValues();
} else
type = AttributeDefinition.Type.get(attribute.getAttrType().getDataTypeName());
final boolean required = attribute.getUsage() == CMAttributeDeclaration.REQUIRED;

Back to the top