bug 311325 - Igor Jacy Lino Campista's 2nd patch reviewed and applied: Java 5 warnings (Generics and for-each) fixed
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/emf/dom1.ecore b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/emf/dom1.ecore
index 2c8f1e5..18bf3ff 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/emf/dom1.ecore
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/emf/dom1.ecore
@@ -206,7 +206,11 @@
<eParameters name="seq3" upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eParameters name="partial" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eOperations>
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="validRootElements" eType="#//Set"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="validRootElements">
+ <eGenericType eClassifier="#//Set">
+ <eTypeArguments eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eGenericType>
+ </eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Serializable" instanceClassName="java.io.Serializable"
abstract="true" interface="true"/>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/Validator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/Validator.java
index 4888bf2..603f8e1 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/Validator.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/I/Validator.java
@@ -50,10 +50,10 @@
* @return the value of the '<em>Valid Root Elements</em>' attribute.
* @see #setValidRootElements(Set)
* @see org.eclipse.wst.xml.vex.core.internal.provisional.dom.DomEMFPackage#getValidator_ValidRootElements()
- * @model dataType="org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.Set"
+ * @model dataType="org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.Set<org.eclipse.emf.ecore.EString>"
* @generated
*/
- Set getValidRootElements();
+ Set<String> getValidRootElements();
/**
* Sets the value of the '{@link org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.Validator#getValidRootElements <em>Valid Root Elements</em>}' attribute.
@@ -63,7 +63,7 @@
* @see #getValidRootElements()
* @generated
*/
- void setValidRootElements(Set value);
+ void setValidRootElements(Set<String> value);
/**
* <!-- begin-user-doc -->
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ContentImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ContentImpl.java
index 25c96c0..d36e755 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ContentImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ContentImpl.java
@@ -149,7 +149,7 @@
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case DomEMFPackage.CONTENT__LENGTH:
- return new Integer(getLength());
+ return getLength();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -163,7 +163,7 @@
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DomEMFPackage.CONTENT__LENGTH:
- setLength(((Integer)newValue).intValue());
+ setLength((Integer)newValue);
return;
}
super.eSet(featureID, newValue);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/DomEMFPackageImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/DomEMFPackageImpl.java
index 0119b69..f123d64 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/DomEMFPackageImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/DomEMFPackageImpl.java
@@ -215,20 +215,10 @@
private static boolean isInited = false;
/**
- * Creates, registers, and initializes the <b>Package</b> for this
- * model, and for any others upon which it depends. Simple
- * dependencies are satisfied by calling this method on all
- * dependent packages before doing anything else. This method drives
- * initialization for interdependent packages directly, in parallel
- * with this package, itself.
- * <p>Of this package and its interdependencies, all packages which
- * have not yet been registered by their URI values are first created
- * and registered. The packages are then initialized in two steps:
- * meta-model objects for all of the packages are created before any
- * are initialized, since one package's meta-model objects may refer to
- * those of another.
- * <p>Invocation of this method will not affect any packages that have
- * already been initialized.
+ * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
+ *
+ * <p>This method is used to initialize {@link DomEMFPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #eNS_URI
@@ -240,7 +230,7 @@
if (isInited) return (DomEMFPackage)EPackage.Registry.INSTANCE.getEPackage(DomEMFPackage.eNS_URI);
// Obtain or create and register package
- DomEMFPackageImpl theDomEMFPackage = (DomEMFPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof DomEMFPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new DomEMFPackageImpl());
+ DomEMFPackageImpl theDomEMFPackage = (DomEMFPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof DomEMFPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new DomEMFPackageImpl());
isInited = true;
@@ -253,6 +243,9 @@
// Mark meta-data to indicate it can't be changed
theDomEMFPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(DomEMFPackage.eNS_URI, theDomEMFPackage);
return theDomEMFPackage;
}
@@ -1142,7 +1135,10 @@
addEParameter(op, ecorePackage.getEString(), "value", 0, 1, IS_UNIQUE, IS_ORDERED);
initEClass(validatorEClass, Validator.class, "Validator", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getValidator_ValidRootElements(), this.getSet(), "validRootElements", null, 0, 1, Validator.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ EGenericType g1 = createEGenericType(this.getSet());
+ EGenericType g2 = createEGenericType(ecorePackage.getEString());
+ g1.getETypeArguments().add(g2);
+ initEAttribute(getValidator_ValidRootElements(), g1, "validRootElements", null, 0, 1, Validator.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
op = addEOperation(validatorEClass, this.getAttributeDefinition(), "getAttributeDefinition", 0, 1, IS_UNIQUE, IS_ORDERED);
addEParameter(op, ecorePackage.getEString(), "element", 0, 1, IS_UNIQUE, IS_ORDERED);
@@ -1153,8 +1149,8 @@
op = addEOperation(validatorEClass, null, "getValidItems", 0, 1, IS_UNIQUE, IS_ORDERED);
addEParameter(op, ecorePackage.getEString(), "element", 0, 1, IS_UNIQUE, IS_ORDERED);
- EGenericType g1 = createEGenericType(this.getSet());
- EGenericType g2 = createEGenericType(ecorePackage.getEString());
+ g1 = createEGenericType(this.getSet());
+ g2 = createEGenericType(ecorePackage.getEString());
g1.getETypeArguments().add(g2);
initEOperation(op, g1);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/PositionImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/PositionImpl.java
index 89b4ff0..0bd5a14 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/PositionImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/PositionImpl.java
@@ -104,7 +104,7 @@
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case DomEMFPackage.POSITION__OFFSET:
- return new Integer(getOffset());
+ return getOffset();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -118,7 +118,7 @@
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DomEMFPackage.POSITION__OFFSET:
- setOffset(((Integer)newValue).intValue());
+ setOffset((Integer)newValue);
return;
}
super.eSet(featureID, newValue);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentFragmentImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentFragmentImpl.java
index 2b14c47..599009c 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentFragmentImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentFragmentImpl.java
@@ -236,7 +236,7 @@
if (resolve) return getContent();
return basicGetContent();
case DomEMFPackage.VEX_DOCUMENT_FRAGMENT__LENGTH:
- return new Integer(getLength());
+ return getLength();
case DomEMFPackage.VEX_DOCUMENT_FRAGMENT__ELEMENTS:
return getElements();
case DomEMFPackage.VEX_DOCUMENT_FRAGMENT__NODE_NAMES:
@@ -260,7 +260,7 @@
setContent((Content)newValue);
return;
case DomEMFPackage.VEX_DOCUMENT_FRAGMENT__LENGTH:
- setLength(((Integer)newValue).intValue());
+ setLength((Integer)newValue);
return;
case DomEMFPackage.VEX_DOCUMENT_FRAGMENT__ELEMENTS:
getElements().clear();
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java
index a53007c..dff9374 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXDocumentImpl.java
@@ -176,7 +176,6 @@
* @generated
*/
protected VEXDocumentImpl() {
-
super();
}
@@ -552,7 +551,7 @@
case DomEMFPackage.VEX_DOCUMENT__ENCODING:
return getEncoding();
case DomEMFPackage.VEX_DOCUMENT__LENGTH:
- return new Integer(getLength());
+ return getLength();
case DomEMFPackage.VEX_DOCUMENT__ROOT_ELEMENT:
if (resolve) return getRootElement();
return basicGetRootElement();
@@ -581,7 +580,7 @@
setEncoding((String)newValue);
return;
case DomEMFPackage.VEX_DOCUMENT__LENGTH:
- setLength(((Integer)newValue).intValue());
+ setLength((Integer)newValue);
return;
case DomEMFPackage.VEX_DOCUMENT__ROOT_ELEMENT:
setRootElement((VEXElement)newValue);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXElementImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXElementImpl.java
index 2b29cb6..477f1a3 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXElementImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXElementImpl.java
@@ -551,7 +551,7 @@
case DomEMFPackage.VEX_ELEMENT__NAME:
return getName();
case DomEMFPackage.VEX_ELEMENT__EMPTY:
- return isEmpty() ? Boolean.TRUE : Boolean.FALSE;
+ return isEmpty();
case DomEMFPackage.VEX_ELEMENT__PARENT:
if (resolve) return getParent();
return basicGetParent();
@@ -593,7 +593,7 @@
setName((String)newValue);
return;
case DomEMFPackage.VEX_ELEMENT__EMPTY:
- setEmpty(((Boolean)newValue).booleanValue());
+ setEmpty((Boolean)newValue);
return;
case DomEMFPackage.VEX_ELEMENT__PARENT:
setParent((VEXElement)newValue);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java
index d982cc4..131facc 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/VEXNodeImpl.java
@@ -385,12 +385,12 @@
if (resolve) return getContent();
return basicGetContent();
case DomEMFPackage.VEX_NODE__END_OFFSET:
- return new Integer(getEndOffset());
+ return getEndOffset();
case DomEMFPackage.VEX_NODE__END_POSITION:
if (resolve) return getEndPosition();
return basicGetEndPosition();
case DomEMFPackage.VEX_NODE__START_OFFSET:
- return new Integer(getStartOffset());
+ return getStartOffset();
case DomEMFPackage.VEX_NODE__START_POSITION:
if (resolve) return getStartPosition();
return basicGetStartPosition();
@@ -414,13 +414,13 @@
setContent((Content)newValue);
return;
case DomEMFPackage.VEX_NODE__END_OFFSET:
- setEndOffset(((Integer)newValue).intValue());
+ setEndOffset((Integer)newValue);
return;
case DomEMFPackage.VEX_NODE__END_POSITION:
setEndPosition((Position)newValue);
return;
case DomEMFPackage.VEX_NODE__START_OFFSET:
- setStartOffset(((Integer)newValue).intValue());
+ setStartOffset((Integer)newValue);
return;
case DomEMFPackage.VEX_NODE__START_POSITION:
setStartPosition((Position)newValue);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ValidatorImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ValidatorImpl.java
index 2dad9ec..d043f88 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ValidatorImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src-emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/impl/ValidatorImpl.java
@@ -49,7 +49,7 @@
* @generated
* @ordered
*/
- protected Set validRootElements;
+ protected Set<String> validRootElements;
/**
* <!-- begin-user-doc -->
@@ -75,7 +75,7 @@
* <!-- end-user-doc -->
* @generated
*/
- public Set getValidRootElements() {
+ public Set<String> getValidRootElements() {
return validRootElements;
}
@@ -84,8 +84,8 @@
* <!-- end-user-doc -->
* @generated
*/
- public void setValidRootElements(Set newValidRootElements) {
- Set oldValidRootElements = validRootElements;
+ public void setValidRootElements(Set<String> newValidRootElements) {
+ Set<String> oldValidRootElements = validRootElements;
validRootElements = newValidRootElements;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DomEMFPackage.VALIDATOR__VALID_ROOT_ELEMENTS, oldValidRootElements, validRootElements));
@@ -165,11 +165,12 @@
* <!-- end-user-doc -->
* @generated
*/
+ @SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DomEMFPackage.VALIDATOR__VALID_ROOT_ELEMENTS:
- setValidRootElements((Set)newValue);
+ setValidRootElements((Set<String>)newValue);
return;
}
super.eSet(featureID, newValue);
@@ -184,7 +185,7 @@
public void eUnset(int featureID) {
switch (featureID) {
case DomEMFPackage.VALIDATOR__VALID_ROOT_ELEMENTS:
- setValidRootElements((Set)null);
+ setValidRootElements((Set<String>)null);
return;
}
super.eUnset(featureID);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java
index a0df950..e16b160 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/css/StyleSheetReader.java
@@ -199,8 +199,7 @@
this.currentRules = new ArrayList<Rule>();
for (int i = 0; i < selectors.getLength(); i++) {
Selector selector = selectors.item(i);
- Rule rule = new Rule(selector);
- this.currentRules.add(rule);
+ this.currentRules.add(new Rule(selector));
}
}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java
index 2d46657..dfeb7de 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentBuilder.java
@@ -126,7 +126,7 @@
this.appendChars(true);
- StackEntry entry = (StackEntry) this.stack.removeLast();
+ StackEntry entry = this.stack.removeLast();
// we must insert the trailing sentinel first, else the insertion
// pushes the end position of the element to after the sentinel
@@ -182,7 +182,7 @@
if (domDocument == null) {
initDOM();
}
- if (stack.size() == 0) {
+ if (stack.isEmpty()) {
rootElement = new RootElement(qName);
org.w3c.dom.Element domElement = domDocument.createElement(qName);
element = this.rootElement;
@@ -197,7 +197,7 @@
org.w3c.dom.Element domElement = domDocument.createElement(qName);
element.setElement(domElement);
- VEXElement parent = ((StackEntry) stack.getLast()).element;
+ VEXElement parent = stack.getLast().element;
parent.addChild(element);
}
@@ -269,8 +269,7 @@
private StringBuffer cleanUpTextContent(boolean trimTrailing) {
StringBuffer sb;
- StackEntry entry = this.stack.size() > 0 ? (StackEntry) this.stack
- .getLast() : null;
+ StackEntry entry = this.stack.isEmpty() ? null : this.stack.getLast();
if (entry != null && entry.pre) {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java
index aa01857..3ebecb0 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/DocumentWriter.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.dom;
@@ -289,8 +290,8 @@
List<String> attrs = element.getAttributeNames();
Collections.sort(attrs);
- if (attrs.size() == 0) {
- if (content.size() == 0) {
+ if (attrs.isEmpty()) {
+ if (content.isEmpty()) {
wrapper.add("<" + element.getName() + " />");
} else {
wrapper.add("<" + element.getName() + ">");
@@ -308,7 +309,7 @@
.getAttribute(attrs.get(i))));
}
if (i == attrs.size() - 1) {
- if (content.size() == 0) {
+ if (content.isEmpty()) {
sb.append("/>");
} else {
sb.append(">");
@@ -322,7 +323,7 @@
addNode(content.get(i), wrapper);
}
- if (content.size() > 0) {
+ if (!content.isEmpty()) {
wrapper.add("</" + element.getName() + ">");
}
}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapper.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapper.java
index d2a7bda..4dc19e4 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapper.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapper.java
@@ -54,10 +54,10 @@
thisIsWhite = true;
}
- if (lastIsWhite || parts.size() == 0) {
+ if (lastIsWhite || parts.isEmpty()) {
this.parts.add(s.substring(i, j));
}
- else if (parts.size() > 0) {
+ else if (!parts.isEmpty()) {
this.parts.add(((String) this.parts
.remove(this.parts.size() - 1))
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/AbstractBlockBox.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/AbstractBlockBox.java
index ee98cdf..f0f7453 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/AbstractBlockBox.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/AbstractBlockBox.java
@@ -678,7 +678,7 @@
} else {
- if (pendingInlines.size() > 0) {
+ if (!pendingInlines.isEmpty()) {
blockBoxes.add(ParagraphBox.create(context, element,
pendingInlines, width));
pendingInlines.clear();
@@ -720,7 +720,7 @@
pendingInlines.addAll(afterInlines);
}
- if (pendingInlines.size() > 0) {
+ if (!pendingInlines.isEmpty()) {
blockBoxes.add(ParagraphBox.create(context, element,
pendingInlines, width));
pendingInlines.clear();
@@ -744,7 +744,7 @@
* the end.
*/
public Object next() {
- if (this.pushStack.size() > 0) {
+ if (!this.pushStack.isEmpty()) {
return this.pushStack.removeLast();
} else if (startOffset == endOffset) {
return null;
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutUtils.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutUtils.java
index 5c650a7..ba12ea7 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutUtils.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutUtils.java
@@ -134,7 +134,7 @@
String display = styleSheet.getStyles(childElement)
.getDisplay();
if (displayStyles.contains(display)) {
- if (nonMatching.size() > 0) {
+ if (!nonMatching.isEmpty()) {
VEXNode firstNode = (VEXNode) nonMatching.get(0);
VEXNode lastNode = (VEXNode) nonMatching.get(nonMatching
.size() - 1);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java
index f05cd1a..777cd59 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/AbstractValidator.java
@@ -36,7 +36,7 @@
if (seq2 != null) {
for (int i = 0; i < seq2.size(); i++) {
if (i == 0 && seq2.get(i).equals(Validator.PCDATA)
- && list.size() > 0
+ && !list.isEmpty()
&& list.get(list.size() - 1).equals(Validator.PCDATA)) {
// Avoid consecutive PCDATA's
continue;
@@ -47,7 +47,7 @@
if (seq3 != null) {
for (int i = 0; i < seq3.size(); i++) {
if (i == 0 && seq3.get(i).equals(Validator.PCDATA)
- && list.size() > 0
+ && !list.isEmpty()
&& list.get(list.size() - 1).equals(Validator.PCDATA)) {
// Avoid consecutive PCDATA's
continue;
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java
index 436dfa2..cbd0c04 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/validator/WTPVEXValidator.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- *Copyright (c) 2008 Standard for Technology in Automotive Retail 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
+ * Copyright (c) 2008 Standard for Technology in Automotive Retail 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:
- * David Carver (STAR) - initial API and implementation
- * Holger Voormann - bug 283646 - Document wizard throws NPW with DITA is selected
+ * Contributors:
+ * David Carver (STAR) - initial API and implementation
+ * Holger Voormann - bug 283646 - Document wizard throws NPW with DITA is selected
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.validator;
@@ -72,7 +73,7 @@
CMElementDeclaration cmelement = getElementDeclaration(element);
EList<AttributeDefinition> attributeList = new BasicEList<AttributeDefinition>(
cmelement.getAttributes().getLength());
- Iterator iter = cmelement.getAttributes().iterator();
+ Iterator<?> iter = cmelement.getAttributes().iterator();
while (iter.hasNext()) {
CMAttributeDeclaration attribute = (CMAttributeDeclaration) iter
.next();
@@ -113,11 +114,8 @@
public Set<String> getValidItems(String element) {
CMElementDeclaration elementDec = (CMElementDeclaration) getSchema()
.getElements().getNamedItem(element);
- List<CMNode> nodes = getAvailableContent(element, elementDec);
Set<String> results = new HashSet<String>();
- Iterator iter = nodes.iterator();
- while (iter.hasNext()) {
- CMNode node = (CMNode) iter.next();
+ for (CMNode node : getAvailableContent(element, elementDec)) {
if (node instanceof CMElementDeclaration) {
CMElementDeclaration elem = (CMElementDeclaration) node;
results.add(elem.getElementName());
@@ -160,10 +158,9 @@
return list;
}
- public Set getValidRootElements() {
+ public Set<String> getValidRootElements() {
Set<String> results = new HashSet<String>();
-
- Iterator iter = getSchema().getElements().iterator();
+ Iterator<?> iter = getSchema().getElements().iterator();
while (iter.hasNext()) {
CMElementDeclaration element = (CMElementDeclaration) iter.next();
results.add(element.getElementName());
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java
index 911b813..6fe2cab 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.core/src/org/eclipse/wst/xml/vex/core/internal/widget/VexWidgetImpl.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.widget;
@@ -269,11 +270,11 @@
}
public boolean canRedo() {
- return this.redoList.size() > 0;
+ return !this.redoList.isEmpty();
}
public boolean canUndo() {
- return this.undoList.size() > 0;
+ return !this.undoList.isEmpty();
}
public boolean canUnwrap() {
@@ -1021,7 +1022,7 @@
}
public void redo() throws CannotRedoException {
- if (redoList.size() == 0) {
+ if (redoList.isEmpty()) {
throw new CannotRedoException();
}
UndoableAndOffset event = redoList.removeLast();
@@ -1249,7 +1250,7 @@
}
public void undo() throws CannotUndoException {
- if (undoList.size() == 0) {
+ if (undoList.isEmpty()) {
throw new CannotUndoException();
}
UndoableAndOffset event = undoList.removeLast();
@@ -1300,7 +1301,7 @@
if (compoundEdit != null) {
compoundEdit.addEdit(edit);
} else {
- if ( undoList.size() > 0
+ if ( !undoList.isEmpty()
&& undoList.getLast().edit.combine(edit)) {
return;
} else {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.classpath b/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.classpath
index ddf0f40..c835067 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.classpath
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.settings/org.eclipse.jdt.core.prefs b/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.settings/org.eclipse.jdt.core.prefs
index 3e83e77..b82e528 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.settings/org.eclipse.jdt.core.prefs
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,12 @@
-#Sun Jul 15 01:10:48 CEST 2007
+#Sun May 09 19:51:40 CEST 2010
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/META-INF/MANIFEST.MF b/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/META-INF/MANIFEST.MF
index 6b59dd2..814fa68 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/META-INF/MANIFEST.MF
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.dita/META-INF/MANIFEST.MF
@@ -7,3 +7,4 @@
Require-Bundle: org.eclipse.wst.xml.vex.core;bundle-version="[0.5.0,1.0.0)",
org.eclipse.wst.xml.vex.ui;bundle-version="[0.5.0,1.0.0)"
Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java
index 436f2f8..e32bb39 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java
@@ -8,6 +8,7 @@
* Contributors:
* John Krasnay - initial API and implementation
* Ed Burnette - 7/23/2006 - Changes needed to build on 3.2.
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.config;
@@ -80,11 +81,8 @@
ConfigRegistry configRegistry = ConfigRegistry.getInstance();
IExtensionRegistry extRegistry = Platform.getExtensionRegistry();
- String[] namespaces = extRegistry.getNamespaces();
- for (int i = 0; i < namespaces.length; i++) {
-
- String ns = namespaces[i];
- Bundle bundle = Platform.getBundle(ns);
+ for (String namespace : extRegistry.getNamespaces()) {
+ Bundle bundle = Platform.getBundle(namespace);
if (bundle == null)
continue;
@@ -118,7 +116,7 @@
if (source == null) {
- source = ConfigPlugin.load(ns);
+ source = ConfigPlugin.load(namespace);
if (source != null) {
try {
@@ -191,20 +189,20 @@
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
- for (int i = 0; i < projects.length; i++) {
+ for (IProject project : projects) {
try {
- if (projects[i].isOpen()
- && projects[i].hasNature(PluginProjectNature.ID)) {
+ if (project.isOpen()
+ && project.hasNature(PluginProjectNature.ID)) {
monitor
.subTask(Messages
- .getString("ConfigLoaderJob.loadingProject") + projects[i].getName()); //$NON-NLS-1$
- PluginProject.load(projects[i]);
+ .getString("ConfigLoaderJob.loadingProject") + project.getName()); //$NON-NLS-1$
+ PluginProject.load(project);
monitor.worked(1);
}
} catch (CoreException e) {
String message = MessageFormat.format(Messages
.getString("ConfigLoaderJob.natureError"), //$NON-NLS-1$
- new Object[] { projects[i].getName() });
+ new Object[] { project.getName() });
VexPlugin.getInstance().log(IStatus.ERROR, message, e);
}
}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java
index 2ce75e2..f01799b 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.config;
@@ -43,10 +44,7 @@
ConfigPlugin configPlugin = new ConfigPlugin(namespace);
configPlugin.setUniqueIdentifer(namespace);
- IExtension[] exts = Platform.getExtensionRegistry().getExtensions(
- namespace);
- for (int i = 0; i < exts.length; i++) {
- IExtension ext = exts[i];
+ for (IExtension ext : Platform.getExtensionRegistry().getExtensions(namespace)) {
try {
configPlugin.addItem(ext.getExtensionPointUniqueIdentifier(),
ext.getSimpleIdentifier(), ext.getLabel(),
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigRegistry.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigRegistry.java
index c638480..2d03d98 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigRegistry.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigRegistry.java
@@ -301,8 +301,7 @@
} else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta[] resources = event.getDelta()
.getAffectedChildren();
- for (int i = 0; i < resources.length; i++) {
- final IResourceDelta delta = resources[i];
+ for (final IResourceDelta delta : resources) {
if (delta.getResource() instanceof IProject) {
final IProject project = (IProject) delta.getResource();
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypeFactory.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypeFactory.java
index fdb6750..e9ec09a 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypeFactory.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypeFactory.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.config;
@@ -31,9 +32,7 @@
doctypeElement.setAttribute(ATTR_OUTLINE_PROVIDER, doctype
.getOutlineProvider());
- String[] names = doctype.getRootElements();
- for (int i = 0; i < names.length; i++) {
- String name = names[i];
+ for (String name : doctype.getRootElements()) {
ConfigurationElement rootElement = new ConfigurationElement(
ELT_ROOT_ELEMENT);
rootElement.setAttribute(ATTR_NAME, name);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java
index 1c967ea..ad11b95 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/DoctypePropertyPage.java
@@ -284,8 +284,8 @@
rootElementsTable.removeAll();
- final java.util.List l = new ArrayList(validator
- .getValidRootElements());
+ final List<String> l =
+ new ArrayList<String>(validator.getValidRootElements());
Collections.sort(l);
for (int i = 0; i < l.size(); i++) {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java
index d77f5e0..488828b 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java
@@ -95,7 +95,7 @@
public URL getBaseUrl() {
try {
- return this.getProject().getLocation().toFile().toURL();
+ return this.getProject().getLocation().toFile().toURI().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(Messages
.getString("PluginProject.malformedUrl"), e); //$NON-NLS-1$
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java
index 7b74109..dea63f8 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/DocumentTypeSelectionPage.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.editor;
@@ -162,8 +163,8 @@
if (roots.length == 0) {
Validator validator = dt.getValidator();
if (validator != null) {
- Set set = validator.getValidRootElements();
- roots = (String[]) set.toArray(new String[set.size()]);
+ Set<String> set = validator.getValidRootElements();
+ roots = set.toArray(new String[set.size()]);
}
} else {
selectedRoot = roots[0];
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java
index 95ae7c7..badfde9 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/editor/VexEditorMultiPage.java
@@ -342,7 +342,7 @@
return;
}
- URL url = inputPath.toFile().toURL();
+ URL url = inputPath.toFile().toURI().toURL();
DocumentReader reader = new DocumentReader();
reader.setDebugging(this.debugging);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/AbstractAddRowHandler.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/AbstractAddRowHandler.java
index 8232596..eef9fef 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/AbstractAddRowHandler.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/AbstractAddRowHandler.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.handlers;
@@ -45,7 +46,7 @@
private void addRow(final VexWidget widget) {
final List<Object> rowsToInsert = new ArrayList<Object>();
- final List<Object> rowCellsToInsert = new ArrayList<Object>();
+ final List<List<Object>> rowCellsToInsert = new ArrayList<List<Object>>();
VexHandlerUtil.iterateTableCells(widget, new ITableCellCallback() {
@@ -90,7 +91,7 @@
// the caret, relative to the insertion point of the new rows
//
int outerOffset = VexHandlerUtil.getOuterRange(rowsToInsert.get(0)).getStart();
- List firstCells = (List) rowCellsToInsert.get(0);
+ List<Object> firstCells = rowCellsToInsert.get(0);
Object firstInner = firstCells.isEmpty()
? rowsToInsert.get(0)
: firstCells.get(0);
@@ -113,7 +114,7 @@
.clone());
}
- List cellsToInsert = (List) rowCellsToInsert.get(i);
+ List<Object> cellsToInsert = rowCellsToInsert.get(i);
for (int j = 0; j < cellsToInsert.size(); j++) {
Object cell = cellsToInsert.get(j);
if (cell instanceof Element) {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/NextTableCellHandler.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/NextTableCellHandler.java
index 28d9470..9f947fd 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/NextTableCellHandler.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/NextTableCellHandler.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.handlers;
@@ -26,21 +27,21 @@
Box[] cells = row.getChildren();
// in this row
- for (int i = 0; i < cells.length; i++) {
- if (cells[i].getStartOffset() > offset) {
- widget.moveTo(cells[i].getStartOffset());
- widget.moveTo(cells[i].getEndOffset(), true);
+ for (Box cell : cells) {
+ if (cell.getStartOffset() > offset) {
+ widget.moveTo(cell.getStartOffset());
+ widget.moveTo(cell.getEndOffset(), true);
return;
}
- }
+ }
// in other row
Box[] rows = row.getParent().getChildren();
- for (int i = 0; i < rows.length; i++) {
- if (rows[i].getStartOffset() > offset) {
- cells = rows[i].getChildren();
- if (cells.length > 0) {
- Box cell = cells[0];
+ for (Box boxRow : rows) {
+ if (boxRow.getStartOffset() > offset) {
+ Box[] rowCells = boxRow.getChildren();
+ if (rowCells.length > 0) {
+ Box cell = rowCells[0];
widget.moveTo(cell.getStartOffset());
widget.moveTo(cell.getEndOffset(), true);
} else {
@@ -48,7 +49,7 @@
}
return;
}
- }
+ }
// We didn't find a "next row", so let's dup the current one
VexHandlerUtil.duplicateTableRow(widget, row);
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/VexHandlerUtil.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/VexHandlerUtil.java
index 521166a..4bfb3bb 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/VexHandlerUtil.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/handlers/VexHandlerUtil.java
@@ -269,13 +269,12 @@
int previousSiblingStart = -1;
VEXElement parent = vexWidget.getDocument().getElementAt(startOffset);
List<VEXNode> children = parent.getChildNodes();
- for (int i = 0; i < children.size(); i++) {
- VEXNode child = children.get(i);
- if (startOffset == child.getStartOffset()) {
+ for (VEXNode child : children) {
+ if (startOffset == child.getStartOffset()) {
break;
}
- previousSiblingStart = child.getStartOffset();
- }
+ previousSiblingStart = child.getStartOffset();
+ }
return previousSiblingStart;
}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/outline/DocumentOutlinePage.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/outline/DocumentOutlinePage.java
index cf63e27..0338358 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/outline/DocumentOutlinePage.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/outline/DocumentOutlinePage.java
@@ -8,6 +8,7 @@
* Contributors:
* John Krasnay - initial API and implementation
* Torsten Stolpmann - bug 257946 - fixed outline view to work with multipage editor.
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.outline;
@@ -173,7 +174,7 @@
String providerClassName = doctype.getOutlineProvider();
if (bundle != null && providerClassName != null) {
try {
- Class clazz = bundle.loadClass(providerClassName);
+ Class<?> clazz = bundle.loadClass(providerClassName);
this.outlineProvider = (IOutlineProvider) clazz.newInstance();
} catch (Exception ex) {
String message = Messages
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/swt/ContentAssist.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/swt/ContentAssist.java
index 2057faf..b7cc9df 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/swt/ContentAssist.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/swt/ContentAssist.java
@@ -8,6 +8,7 @@
* Contributors:
* John Krasnay - initial implementation
* Holger Voormann
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.swt;
@@ -218,12 +219,11 @@
private void repopulateList() {
String filterText = textWidget.getText();
List<AbstractVexAction> actionList = new LinkedList<AbstractVexAction>();
- for (int i = 0; i < actions.length; i++) {
- AbstractVexAction action = actions[i];
- if (action.getText().contains(filterText)) {
+ for (AbstractVexAction action : actions) {
+ if (action.getText().contains(filterText)) {
actionList.add(action);
}
- }
+ }
viewer.setInput(actionList.toArray(new AbstractVexAction[actionList.size()]));
viewer.getTable().setSelection(0);
}
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/wizards/NewDocumentWizard.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/wizards/NewDocumentWizard.java
index b5e0ab4..c972d9a 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/wizards/NewDocumentWizard.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/wizards/NewDocumentWizard.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.wizards;
@@ -20,7 +21,6 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IFileEditorMapping;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -153,8 +153,7 @@
FileEditorMapping[] mappings = (FileEditorMapping[]) ereg
.getFileEditorMappings();
FileEditorMapping mapping = null;
- for (int i = 0; i < mappings.length; i++) {
- IFileEditorMapping fem = mappings[i];
+ for (FileEditorMapping fem : mappings) {
if (fem.getLabel().equals(fileName)) {
mapping = (FileEditorMapping) fem;
break;
@@ -164,9 +163,8 @@
if (mapping != null) {
// found mapping for fileName
// make sure it includes our editor
- IEditorDescriptor[] editors = mapping.getEditors();
- for (int i = 0; i < editors.length; i++) {
- if (editors[i].getId().equals(editorId)) {
+ for (IEditorDescriptor editor : mapping.getEditors()) {
+ if (editor.getId().equals(editorId)) {
// already mapped
return;
}
@@ -208,12 +206,12 @@
private static EditorDescriptor getEditorDescriptor(String editorId) {
EditorRegistry reg = (EditorRegistry) PlatformUI.getWorkbench()
.getEditorRegistry();
- IEditorDescriptor[] editors = reg.getSortedEditorsFromPlugins();
- for (int i = 0; i < editors.length; i++) {
- if (editors[i].getId().equals(editorId)) {
- return (EditorDescriptor) editors[i];
+ for (IEditorDescriptor editor : reg.getSortedEditorsFromPlugins()) {
+ if (editor.getId().equals(editorId)) {
+ return (EditorDescriptor) editor;
}
}
+
return null;
}
}
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/META-INF/MANIFEST.MF b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/META-INF/MANIFEST.MF
index 3283174..ee36f6c 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/META-INF/MANIFEST.MF
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/META-INF/MANIFEST.MF
@@ -23,3 +23,4 @@
org.eclipse.wst.xml.vex.core.internal.layout;x-internal:=true,
org.eclipse.wst.xml.vex.core.internal.provisional.dom.tests;x-internal:=true,
org.eclipse.wst.xml.vex.core.tests
+Bundle-Localization: plugin
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java
index 2e1ce22..630baf6 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DTDValidatorTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.dom;
@@ -122,8 +123,8 @@
private void assertValidItemsAt(VEXDocument doc, int offset,
String... expectedItems) {
Set<String> expected = new HashSet<String>(expectedItems.length);
- for (int i = 0; i < expectedItems.length; i++) {
- expected.add(expectedItems[i]);
+ for (String item : expectedItems) {
+ expected.add(item);
}
String elementName = doc.getElementAt(offset).getName();
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DomTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DomTest.java
index 9ee6211..20b788c 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DomTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/DomTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.dom;
@@ -16,7 +17,6 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
@@ -48,7 +48,6 @@
}
public void testWTPStructruedDocument() throws Exception {
- IStructuredModel model = null;
IModelManager modelManager = StructuredModelManager.getModelManager();
IStructuredDocument structuredDocument = modelManager.createStructuredDocumentFor(ContentTypeIdForXML.ContentTypeID_XML);
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/SpaceNormalizerTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/SpaceNormalizerTest.java
index f08a13f..39d2b35 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/SpaceNormalizerTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/SpaceNormalizerTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.dom;
@@ -68,10 +69,10 @@
if (!fTestProjectInitialized) {
getAndCreateProject();
- Enumeration<String> e = Platform.getBundle(
+ Enumeration<?> e = Platform.getBundle(
VEXCoreTestPlugin.PLUGIN_ID).getEntryPaths("/projectFiles");
while (e.hasMoreElements()) {
- String path = e.nextElement();
+ String path = (String) e.nextElement();
URL url = Platform.getBundle(VEXCoreTestPlugin.PLUGIN_ID)
.getEntry(path);
if (!url.getFile().endsWith("/")) {
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapperTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapperTest.java
index f481c3c..de1bbbc 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapperTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/dom/TextWrapperTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.dom;
@@ -35,8 +36,8 @@
"words ",
"and here are some long ones. We make sure we have some short stuff and some long stuff, just to make sure it all wraps." };
- for (int i = 0; i < inputs.length; i++) {
- wrapper.add(inputs[i]);
+ for (String input : inputs) {
+ wrapper.add(input);
}
results = wrapper.wrap(40);
assertWidth(results, 40);
@@ -67,11 +68,11 @@
private void assertPreserved(String[] inputs, String[] results) {
StringBuffer inputSB = new StringBuffer();
StringBuffer resultSB = new StringBuffer();
- for (int i = 0; i < inputs.length; i++) {
- inputSB.append(inputs[i]);
+ for (String input : inputs) {
+ inputSB.append(input);
}
- for (int i = 0; i < results.length; i++) {
- resultSB.append(results[i]);
+ for (String result : results) {
+ resultSB.append(result);
}
assertEquals(inputSB.toString(), resultSB.toString());
}
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutTestSuite.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutTestSuite.java
index 189a211..c64ab59 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutTestSuite.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/LayoutTestSuite.java
@@ -4,16 +4,16 @@
* 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:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.layout;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Stack;
@@ -28,13 +28,9 @@
import org.eclipse.wst.xml.vex.core.internal.css.StyleSheet;
import org.eclipse.wst.xml.vex.core.internal.css.StyleSheetReader;
import org.eclipse.wst.xml.vex.core.internal.dom.DocumentReader;
-import org.eclipse.wst.xml.vex.core.internal.layout.Box;
-import org.eclipse.wst.xml.vex.core.internal.layout.LayoutContext;
-import org.eclipse.wst.xml.vex.core.internal.layout.RootBox;
-import org.eclipse.wst.xml.vex.core.internal.layout.TextBox;
-import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
import org.eclipse.wst.xml.vex.core.internal.provisional.dom.IWhitespacePolicy;
import org.eclipse.wst.xml.vex.core.internal.provisional.dom.IWhitespacePolicyFactory;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
import org.eclipse.wst.xml.vex.core.internal.widget.CssWhitespacePolicy;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
@@ -48,215 +44,212 @@
*/
public class LayoutTestSuite extends TestCase {
- public String id;
- public String doc;
- public int layoutWidth = 100;
- public BoxSpec result;
- public String css;
+ public String id;
+ public String doc;
+ public int layoutWidth = 100;
+ public BoxSpec result;
+ public String css;
- public static Test suite() throws ParserConfigurationException,
- FactoryConfigurationError, IOException, SAXException {
- TestSuite suite = new TestSuite(LayoutTestSuite.class.getName());
- suite.addTest(loadSuite("block-inline.xml"));
- suite.addTest(loadSuite("before-after.xml"));
- suite.addTest(loadSuite("linebreaks.xml"));
- suite.addTest(loadSuite("tables.xml"));
- return suite;
- }
+ public static Test suite() throws ParserConfigurationException,
+ FactoryConfigurationError, IOException, SAXException {
+ TestSuite suite = new TestSuite(LayoutTestSuite.class.getName());
+ suite.addTest(loadSuite("block-inline.xml"));
+ suite.addTest(loadSuite("before-after.xml"));
+ suite.addTest(loadSuite("linebreaks.xml"));
+ suite.addTest(loadSuite("tables.xml"));
+ return suite;
+ }
- public static Test loadSuite(String filename)
- throws ParserConfigurationException, FactoryConfigurationError,
- IOException, SAXException {
- XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser()
- .getXMLReader();
- TestCaseBuilder builder = new TestCaseBuilder();
- xmlReader.setContentHandler(builder);
- // xmlReader.setEntityResolver(builder);
- URL url = LayoutTestSuite.class.getResource(filename);
- xmlReader.parse(new InputSource(url.toString()));
+ public static Test loadSuite(String filename)
+ throws ParserConfigurationException, FactoryConfigurationError,
+ IOException, SAXException {
+ XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser()
+ .getXMLReader();
+ TestCaseBuilder builder = new TestCaseBuilder();
+ xmlReader.setContentHandler(builder);
+ // xmlReader.setEntityResolver(builder);
+ URL url = LayoutTestSuite.class.getResource(filename);
+ xmlReader.parse(new InputSource(url.toString()));
- TestSuite suite = new TestSuite(filename);
- for (Iterator it = builder.testCases.iterator(); it.hasNext();) {
- LayoutTestSuite test = (LayoutTestSuite) it.next();
- suite.addTest(test);
- }
- return suite;
- }
+ TestSuite suite = new TestSuite(filename);
+ for (TestCase test : builder.testCases) {
+ suite.addTest(test);
+ }
+ return suite;
+ }
- public LayoutTestSuite() {
- super("testLayout");
- }
+ public LayoutTestSuite() {
+ super("testLayout");
+ }
- public String getName() {
- return this.id;
- }
+ public String getName() {
+ return this.id;
+ }
- public void testLayout() throws Exception {
+ public void testLayout() throws Exception {
- URL url = LayoutTestSuite.class.getResource(this.css);
- StyleSheetReader reader = new StyleSheetReader();
- final StyleSheet ss = reader.read(url);
+ URL url = LayoutTestSuite.class.getResource(this.css);
+ StyleSheetReader reader = new StyleSheetReader();
+ final StyleSheet ss = reader.read(url);
- FakeGraphics g = new FakeGraphics();
+ FakeGraphics g = new FakeGraphics();
- LayoutContext context = new LayoutContext();
- context.setBoxFactory(new MockBoxFactory());
- context.setGraphics(g);
- context.setStyleSheet(ss);
+ LayoutContext context = new LayoutContext();
+ context.setBoxFactory(new MockBoxFactory());
+ context.setGraphics(g);
+ context.setStyleSheet(ss);
- DocumentReader docReader = new DocumentReader();
- docReader.setWhitespacePolicyFactory(new IWhitespacePolicyFactory() {
- public IWhitespacePolicy getPolicy(String publicId) {
- return new CssWhitespacePolicy(ss);
- }
- });
- VEXDocument doc = docReader.read(this.doc);
- context.setDocument(doc);
+ DocumentReader docReader = new DocumentReader();
+ docReader.setWhitespacePolicyFactory(new IWhitespacePolicyFactory() {
+ public IWhitespacePolicy getPolicy(String publicId) {
+ return new CssWhitespacePolicy(ss);
+ }
+ });
+ VEXDocument doc = docReader.read(this.doc);
+ context.setDocument(doc);
- RootBox rootBox = new RootBox(context, doc.getRootElement(),
- this.layoutWidth);
- rootBox.layout(context, 0, Integer.MAX_VALUE);
+ RootBox rootBox = new RootBox(context, doc.getRootElement(),
+ this.layoutWidth);
+ rootBox.layout(context, 0, Integer.MAX_VALUE);
- assertBox(this.result, rootBox, "");
- }
+ assertBox(this.result, rootBox, "");
+ }
- private static void assertBox(BoxSpec boxSpec, Box box, String indent) {
+ private static void assertBox(BoxSpec boxSpec, Box box, String indent) {
- System.out.println(indent + boxSpec.className);
+ System.out.println(indent + boxSpec.className);
- if (boxSpec.className != null) {
- String actualClassName = box.getClass().getName();
- if (boxSpec.className.lastIndexOf('.') == -1) {
- // no dot in box spec classname, so strip the prefix from the
- // actual classname
- int lastDot = actualClassName.lastIndexOf('.');
- actualClassName = actualClassName.substring(lastDot + 1);
- }
- assertEquals(boxSpec.className, actualClassName);
- }
+ if (boxSpec.className != null) {
+ String actualClassName = box.getClass().getName();
+ if (boxSpec.className.lastIndexOf('.') == -1) {
+ // no dot in box spec classname, so strip the prefix from the
+ // actual classname
+ int lastDot = actualClassName.lastIndexOf('.');
+ actualClassName = actualClassName.substring(lastDot + 1);
+ }
+ assertEquals(boxSpec.className, actualClassName);
+ }
- if (boxSpec.element != null) {
- assertNotNull(box.getElement());
- assertEquals(boxSpec.element, box.getElement().getName());
- }
+ if (boxSpec.element != null) {
+ assertNotNull(box.getElement());
+ assertEquals(boxSpec.element, box.getElement().getName());
+ }
- if (boxSpec.text != null && box instanceof TextBox) {
- assertEquals(boxSpec.text, ((TextBox) box).getText());
- }
+ if (boxSpec.text != null && box instanceof TextBox) {
+ assertEquals(boxSpec.text, ((TextBox) box).getText());
+ }
- if (boxSpec.children.size() > 0 && box.getChildren() == null) {
- fail("Expected " + boxSpec.children.size() + " children, but "
- + boxSpec.className + "'s children is null");
- }
+ if (!boxSpec.children.isEmpty() && box.getChildren() == null) {
+ fail("Expected " + boxSpec.children.size() + " children, but "
+ + boxSpec.className + "'s children is null");
+ }
- if (boxSpec.children.size() != box.getChildren().length) {
- System.out.println("Wrong number of child boxes");
- System.out.println(" Expected:");
- for (Iterator it = boxSpec.children.iterator(); it.hasNext();) {
- BoxSpec childSpec = (BoxSpec) it.next();
- System.out.print(" " + childSpec.className);
- if (childSpec.text != null) {
- System.out.print(" '" + childSpec.text + "'");
- }
- System.out.println();
- }
- System.out.println(" Actual:");
- for (int i = 0; i < box.getChildren().length; i++) {
- Box childBox = box.getChildren()[i];
- System.out.println(" " + childBox.getClass() + ": "
- + childBox);
- }
- fail("Wrong number of child boxes.");
- }
+ if (boxSpec.children.size() != box.getChildren().length) {
+ System.out.println("Wrong number of child boxes");
+ System.out.println(" Expected:");
+ for (BoxSpec childSpec : boxSpec.children) {
+ System.out.print(" " + childSpec.className);
+ if (childSpec.text != null) {
+ System.out.print(" '" + childSpec.text + "'");
+ }
+ System.out.println();
+ }
+ System.out.println(" Actual:");
+ for (Box childBox : box.getChildren()) {
+ System.out.println(" " + childBox.getClass() + ": "
+ + childBox);
+ }
+ fail("Wrong number of child boxes.");
+ }
- for (int i = 0; i < boxSpec.children.size(); i++) {
- assertBox((BoxSpec) boxSpec.children.get(i), box.getChildren()[i],
- indent + " ");
- }
+ for (int i = 0; i < boxSpec.children.size(); i++) {
+ assertBox((BoxSpec) boxSpec.children.get(i), box.getChildren()[i],
+ indent + " ");
+ }
- }
+ }
- private static class TestCaseBuilder extends DefaultHandler {
+ private static class TestCaseBuilder extends DefaultHandler {
- private List testCases;
- private String css;
- private LayoutTestSuite testCase;
- private BoxSpec boxSpec;
- private Stack boxSpecs;
- private boolean inDoc;
+ private List<TestCase> testCases;
+ private String css;
+ private LayoutTestSuite testCase;
+ private BoxSpec boxSpec;
+ private Stack<BoxSpec> boxSpecs;
+ private boolean inDoc;
- public void characters(char[] ch, int start, int length)
- throws SAXException {
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
- String s = new String(ch, start, length).trim();
- if (s.length() > 0) {
- if (inDoc) {
- this.testCase.doc = new String(ch, start, length);
- } else {
- throw new IllegalStateException();
- }
- }
- }
+ String s = new String(ch, start, length).trim();
+ if (s.length() > 0) {
+ if (inDoc) {
+ this.testCase.doc = new String(ch, start, length);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+ }
- public void endElement(String uri, String localName, String qName)
- throws SAXException {
- if (qName.equals("box")) {
- if (this.boxSpecs.isEmpty()) {
- this.boxSpec = null;
- } else {
- this.boxSpec = (BoxSpec) this.boxSpecs.pop();
- }
- } else if (qName.equals("doc")) {
- this.inDoc = false;
- }
- }
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+ if (qName.equals("box")) {
+ if (this.boxSpecs.isEmpty()) {
+ this.boxSpec = null;
+ } else {
+ this.boxSpec = this.boxSpecs.pop();
+ }
+ } else if (qName.equals("doc")) {
+ this.inDoc = false;
+ }
+ }
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
- if (qName.equals("testcases")) {
- this.testCases = new ArrayList();
- this.css = attributes.getValue("css");
- if (this.css == null) {
- this.css = "test.css";
- }
- this.testCase = null;
- this.boxSpecs = new Stack();
- } else if (qName.equals("test")) {
- this.testCase = new LayoutTestSuite();
- this.testCase.id = attributes.getValue("id");
- this.testCase.css = this.css;
- String layoutWidth = attributes.getValue("layoutWidth");
- if (layoutWidth != null) {
- this.testCase.layoutWidth = Integer.parseInt(layoutWidth);
- }
- testCases.add(this.testCase);
- } else if (qName.equals("doc")) {
- this.inDoc = true;
- } else if (qName.equals("result")) {
- } else if (qName.equals("box")) {
- BoxSpec parent = this.boxSpec;
- this.boxSpec = new BoxSpec();
- this.boxSpec.className = attributes.getValue("class");
- this.boxSpec.element = attributes.getValue("element");
- this.boxSpec.text = attributes.getValue("text");
- if (parent == null) {
- this.testCase.result = this.boxSpec;
- } else {
- this.boxSpecs.push(parent);
- parent.children.add(this.boxSpec);
- }
- } else {
- throw new SAXException("Unrecognized element: " + qName);
- }
- }
- }
+ if (qName.equals("testcases")) {
+ this.testCases = new ArrayList<TestCase>();
+ this.css = attributes.getValue("css");
+ if (this.css == null) {
+ this.css = "test.css";
+ }
+ this.testCase = null;
+ this.boxSpecs = new Stack<BoxSpec>();
+ } else if (qName.equals("test")) {
+ this.testCase = new LayoutTestSuite();
+ this.testCase.id = attributes.getValue("id");
+ this.testCase.css = this.css;
+ String layoutWidth = attributes.getValue("layoutWidth");
+ if (layoutWidth != null) {
+ this.testCase.layoutWidth = Integer.parseInt(layoutWidth);
+ }
+ testCases.add(this.testCase);
+ } else if (qName.equals("doc")) {
+ this.inDoc = true;
+ } else if (qName.equals("result")) {
+ } else if (qName.equals("box")) {
+ BoxSpec parent = this.boxSpec;
+ this.boxSpec = new BoxSpec();
+ this.boxSpec.className = attributes.getValue("class");
+ this.boxSpec.element = attributes.getValue("element");
+ this.boxSpec.text = attributes.getValue("text");
+ if (parent == null) {
+ this.testCase.result = this.boxSpec;
+ } else {
+ this.boxSpecs.push(parent);
+ parent.children.add(this.boxSpec);
+ }
+ } else {
+ throw new SAXException("Unrecognized element: " + qName);
+ }
+ }
+ }
- private static class BoxSpec {
- public String className;
- public String element;
- public List children = new ArrayList();
- public String text;
- }
+ private static class BoxSpec {
+ public String className;
+ public String element;
+ public List<BoxSpec> children = new ArrayList<BoxSpec>();
+ public String text;
+ }
}
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/TableLayoutTest.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/TableLayoutTest.java
index e3340e1..4dc2770 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/TableLayoutTest.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src/org/eclipse/wst/xml/vex/core/internal/layout/TableLayoutTest.java
@@ -1,244 +1,244 @@
-/*******************************************************************************
- * Copyright (c) 2009 Holger Voormann 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:
- * Holger Voormann - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.vex.core.internal.layout;
-
-import java.util.Arrays;
-import java.util.Stack;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.xml.vex.core.internal.core.DisplayDevice;
-import org.eclipse.wst.xml.vex.core.internal.css.MockDisplayDevice;
-import org.eclipse.wst.xml.vex.core.internal.css.StyleSheet;
-import org.eclipse.wst.xml.vex.core.internal.css.StyleSheetReader;
-import org.eclipse.wst.xml.vex.core.internal.dom.Document;
-import org.eclipse.wst.xml.vex.core.internal.dom.Element;
-import org.eclipse.wst.xml.vex.core.internal.dom.RootElement;
-import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
-
-public class TableLayoutTest extends TestCase {
-
- private static interface StackVisitor {
- void visit(StackElement element);
- }
-
- private static class StackElement {
- public final int indent;
- public final Box box;
- public StackElement(int indent, Box box) {
- this.indent = indent;
- this.box = box;
- }
- }
-
- private LayoutContext context;
- private VEXDocument document;
- private RootBox rootBox;
- private int caretPosition;
-
- @Override
- protected void setUp() throws Exception {
-
- // display dummy
- DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
-
- // context dummy
- context = new LayoutContext();
- context.setBoxFactory(new MockBoxFactory());
- context.setGraphics(new FakeGraphics());
-
- // set CSS
- String css = "root {display:block}"
- + "inline {display:inline}"
- + "table {display:table}"
- + "tcap {display:table-caption}"
- + "td {display:table-cell}"
- + "tc {display:table-column}"
- + "tcg {display:table-column-group}"
- + "tfg {display:table-footer-group}"
- + "thg {display:table-header-group}"
- + "tr {display:table-row}"
- + "trg {display:table-row-group}";
- StyleSheet styleSheet = new StyleSheetReader().read(css);
- context.setStyleSheet(styleSheet);
-
- resetDocument();
- }
-
- @Override
- protected void tearDown() throws Exception {
- rootBox = null;
- document = null;
- context = null;
- }
-
- private void resetDocument() {
- document = new Document(new RootElement("root"));
- context.setDocument(document);
- caretPosition = 1;
- rootBox = new RootBox(this.context, document.getRootElement(), 500);
- }
-
- private void insertElement(String elementName) {
- document.insertElement(caretPosition, new Element(elementName));
- caretPosition++;
- }
-
- private void insertText(String text) {
- document.insertText(caretPosition, text);;
- caretPosition += text.length();
- }
-
- public void testValidTable() throws Exception {
-
- // single cell Table
- insertElement("table");
- insertElement("tr");
- insertElement("td");
- insertText("a");
- assertCount(1, TableBox.class);
- assertCount(1, TableRowBox.class);
- assertCount(1, TableCellBox.class);
- assertCount(1, DocumentTextBox.class);
- assertEquals("a", contentAsText());
-
- // 2x2 table plus text
- resetDocument();
- insertText("_");
- insertElement("table");
- insertElement("tr");
- insertElement("td");
- insertText("a");
- caretPosition++;
- insertElement("td");
- insertText("b");
- caretPosition+=2;
- insertElement("tr");
- insertElement("td");
- insertText("c");
- caretPosition++;
- insertElement("td");
- insertText("d");
- assertCount(1, TableBox.class);
- assertCount(2, TableRowBox.class);
- assertCount(4, TableCellBox.class);
- assertCount(5, DocumentTextBox.class);
- assertEquals("_abcd", contentAsText());
- }
-
- // table elements outside table (separately tested to improve tracing if
- // StackOverflowError will be thrown)
- public void testCaptionOutsideTable() { test("tcap"); }
- public void testCellOutsideTable() { test("td"); }
- public void testColumnOutsideTable() { test("tc"); }
- public void testColumnGroupOutsideTable() { test("tcg"); }
- public void testFooterGroupOutsideTable() { test("tfg"); }
- public void testHeaderGroupOutsideTable() { test("thg"); }
- public void testRowOutsideTable() { test("tr"); }
- public void testRowGroupOutsideTable() { test("trg"); }
-
- // invalid nested table elements (separately tested to improve tracing if
- // StackOverflowError will be thrown)
- public void testInvalidNesting1() { test("inline", "tcap"); }
- public void testInvalidNesting2() { test("table", "td"); }
- public void testInvalidNesting3() { test("td", "tr"); }
- public void testInvalidNesting4() { test("trg", "trg"); }
- public void testInvalidNesting5() { test("tr", "tfg"); }
- public void testInvalidNesting6() { test("td", "thg"); }
- public void testInvalidNesting7() { test("table", "tc"); }
- public void testInvalidNesting8() { test("thg", "tcg"); }
-
- public void test(String ... elements) {
- resetDocument();
- insertElement("inline");
- for (int i = 0; i < elements.length; i++) {
- insertElement(elements[i]);
- }
- insertText("x");
- assertCount(1, DocumentTextBox.class);
- assertEquals("x", contentAsText());
- }
-
- private String contentAsText() {
- return document.getText(0, document.getLength());
- }
-
- private void assertCount(int expected, Class<? extends Box> blockClass) {
- int count = count(blockClass);
- String message = "expected count of <"
- + blockClass.getSimpleName()
- + ">: <"
- + expected
- + "> but was: <"
- + count
- + ">\n"
- + "Actual layout stack trace:\n"
- + layoutStackToString();
- assertEquals(message, expected, count);
- }
-
- private int count(final Class<? extends Box> blockClass) {
- final int[] mutableInteger = new int[1];
- mutableInteger[0] = 0;
- travelLayoutStack(new StackVisitor() {
-
- public void visit(StackElement element) {
- if (element.box.getClass().equals(blockClass)) {
- mutableInteger[0]++;
- }
- }
-
- });
- return mutableInteger[0];
- }
-
- private String layoutStackToString() {
- final StringBuilder result = new StringBuilder();
- travelLayoutStack(new StackVisitor() {
-
- public void visit(StackElement element) {
- if (element.indent > 0) {
- char[] indentChars = new char[element.indent * 2];
- Arrays.fill(indentChars, ' ');
- result.append(indentChars);
- }
- result.append(element.box.getClass().getSimpleName());
- result.append('\n');
-
- }
-
- });
- return result.toString();
- }
-
- private void travelLayoutStack(StackVisitor visitor) {
-
- // already layouted?
- Box[] rootElementChildren = rootBox.getChildren()[0].getChildren();
- if (rootElementChildren == null || rootElementChildren.length == 0) {
- rootBox.layout(this.context, 0, Integer.MAX_VALUE);
- }
-
- Stack<StackElement> stack = new Stack<StackElement>();
- stack.push(new StackElement(0, rootBox));
- while (!stack.isEmpty()) {
- StackElement current = stack.pop();
- visitor.visit(current);
-
- // iterate deep-first
- Box[] children = current.box.getChildren();
- for (int i = 0; i < children.length; i++) {
- stack.push(new StackElement(current.indent + 1, children[i]));
- }
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 Holger Voormann 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:
+ * Holger Voormann - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
+ *******************************************************************************/
+package org.eclipse.wst.xml.vex.core.internal.layout;
+
+import java.util.Arrays;
+import java.util.Stack;
+
+import junit.framework.TestCase;
+
+import org.eclipse.wst.xml.vex.core.internal.core.DisplayDevice;
+import org.eclipse.wst.xml.vex.core.internal.css.MockDisplayDevice;
+import org.eclipse.wst.xml.vex.core.internal.css.StyleSheet;
+import org.eclipse.wst.xml.vex.core.internal.css.StyleSheetReader;
+import org.eclipse.wst.xml.vex.core.internal.dom.Document;
+import org.eclipse.wst.xml.vex.core.internal.dom.Element;
+import org.eclipse.wst.xml.vex.core.internal.dom.RootElement;
+import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXDocument;
+
+public class TableLayoutTest extends TestCase {
+
+ private static interface StackVisitor {
+ void visit(StackElement element);
+ }
+
+ private static class StackElement {
+ public final int indent;
+ public final Box box;
+ public StackElement(int indent, Box box) {
+ this.indent = indent;
+ this.box = box;
+ }
+ }
+
+ private LayoutContext context;
+ private VEXDocument document;
+ private RootBox rootBox;
+ private int caretPosition;
+
+ @Override
+ protected void setUp() throws Exception {
+
+ // display dummy
+ DisplayDevice.setCurrent(new MockDisplayDevice(90, 90));
+
+ // context dummy
+ context = new LayoutContext();
+ context.setBoxFactory(new MockBoxFactory());
+ context.setGraphics(new FakeGraphics());
+
+ // set CSS
+ String css = "root {display:block}"
+ + "inline {display:inline}"
+ + "table {display:table}"
+ + "tcap {display:table-caption}"
+ + "td {display:table-cell}"
+ + "tc {display:table-column}"
+ + "tcg {display:table-column-group}"
+ + "tfg {display:table-footer-group}"
+ + "thg {display:table-header-group}"
+ + "tr {display:table-row}"
+ + "trg {display:table-row-group}";
+ StyleSheet styleSheet = new StyleSheetReader().read(css);
+ context.setStyleSheet(styleSheet);
+
+ resetDocument();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ rootBox = null;
+ document = null;
+ context = null;
+ }
+
+ private void resetDocument() {
+ document = new Document(new RootElement("root"));
+ context.setDocument(document);
+ caretPosition = 1;
+ rootBox = new RootBox(this.context, document.getRootElement(), 500);
+ }
+
+ private void insertElement(String elementName) {
+ document.insertElement(caretPosition, new Element(elementName));
+ caretPosition++;
+ }
+
+ private void insertText(String text) {
+ document.insertText(caretPosition, text);;
+ caretPosition += text.length();
+ }
+
+ public void testValidTable() throws Exception {
+
+ // single cell Table
+ insertElement("table");
+ insertElement("tr");
+ insertElement("td");
+ insertText("a");
+ assertCount(1, TableBox.class);
+ assertCount(1, TableRowBox.class);
+ assertCount(1, TableCellBox.class);
+ assertCount(1, DocumentTextBox.class);
+ assertEquals("a", contentAsText());
+
+ // 2x2 table plus text
+ resetDocument();
+ insertText("_");
+ insertElement("table");
+ insertElement("tr");
+ insertElement("td");
+ insertText("a");
+ caretPosition++;
+ insertElement("td");
+ insertText("b");
+ caretPosition+=2;
+ insertElement("tr");
+ insertElement("td");
+ insertText("c");
+ caretPosition++;
+ insertElement("td");
+ insertText("d");
+ assertCount(1, TableBox.class);
+ assertCount(2, TableRowBox.class);
+ assertCount(4, TableCellBox.class);
+ assertCount(5, DocumentTextBox.class);
+ assertEquals("_abcd", contentAsText());
+ }
+
+ // table elements outside table (separately tested to improve tracing if
+ // StackOverflowError will be thrown)
+ public void testCaptionOutsideTable() { test("tcap"); }
+ public void testCellOutsideTable() { test("td"); }
+ public void testColumnOutsideTable() { test("tc"); }
+ public void testColumnGroupOutsideTable() { test("tcg"); }
+ public void testFooterGroupOutsideTable() { test("tfg"); }
+ public void testHeaderGroupOutsideTable() { test("thg"); }
+ public void testRowOutsideTable() { test("tr"); }
+ public void testRowGroupOutsideTable() { test("trg"); }
+
+ // invalid nested table elements (separately tested to improve tracing if
+ // StackOverflowError will be thrown)
+ public void testInvalidNesting1() { test("inline", "tcap"); }
+ public void testInvalidNesting2() { test("table", "td"); }
+ public void testInvalidNesting3() { test("td", "tr"); }
+ public void testInvalidNesting4() { test("trg", "trg"); }
+ public void testInvalidNesting5() { test("tr", "tfg"); }
+ public void testInvalidNesting6() { test("td", "thg"); }
+ public void testInvalidNesting7() { test("table", "tc"); }
+ public void testInvalidNesting8() { test("thg", "tcg"); }
+
+ public void test(String ... elements) {
+ resetDocument();
+ insertElement("inline");
+ for (String element : elements) {
+ insertElement(element);
+ }
+ insertText("x");
+ assertCount(1, DocumentTextBox.class);
+ assertEquals("x", contentAsText());
+ }
+
+ private String contentAsText() {
+ return document.getText(0, document.getLength());
+ }
+
+ private void assertCount(int expected, Class<? extends Box> blockClass) {
+ int count = count(blockClass);
+ String message = "expected count of <"
+ + blockClass.getSimpleName()
+ + ">: <"
+ + expected
+ + "> but was: <"
+ + count
+ + ">\n"
+ + "Actual layout stack trace:\n"
+ + layoutStackToString();
+ assertEquals(message, expected, count);
+ }
+
+ private int count(final Class<? extends Box> blockClass) {
+ final int[] mutableInteger = new int[1];
+ mutableInteger[0] = 0;
+ travelLayoutStack(new StackVisitor() {
+
+ public void visit(StackElement element) {
+ if (element.box.getClass().equals(blockClass)) {
+ mutableInteger[0]++;
+ }
+ }
+
+ });
+ return mutableInteger[0];
+ }
+
+ private String layoutStackToString() {
+ final StringBuilder result = new StringBuilder();
+ travelLayoutStack(new StackVisitor() {
+
+ public void visit(StackElement element) {
+ if (element.indent > 0) {
+ char[] indentChars = new char[element.indent * 2];
+ Arrays.fill(indentChars, ' ');
+ result.append(indentChars);
+ }
+ result.append(element.box.getClass().getSimpleName());
+ result.append('\n');
+
+ }
+
+ });
+ return result.toString();
+ }
+
+ private void travelLayoutStack(StackVisitor visitor) {
+
+ // already layouted?
+ Box[] rootElementChildren = rootBox.getChildren()[0].getChildren();
+ if (rootElementChildren == null || rootElementChildren.length == 0) {
+ rootBox.layout(this.context, 0, Integer.MAX_VALUE);
+ }
+
+ Stack<StackElement> stack = new Stack<StackElement>();
+ stack.push(new StackElement(0, rootBox));
+ while (!stack.isEmpty()) {
+ StackElement current = stack.pop();
+ visitor.visit(current);
+
+ // iterate deep-first
+ for (Box child : current.box.getChildren()) {
+ stack.push(new StackElement(current.indent + 1, child));
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockCssWhitespacePolicy.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockCssWhitespacePolicy.java
index 18b7d24..d448e84 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockCssWhitespacePolicy.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockCssWhitespacePolicy.java
@@ -7,6 +7,7 @@
*
* Contributors:
* John Krasnay - initial API and implementation
+ * Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
*******************************************************************************/
package org.eclipse.wst.xml.vex.core.internal.provisional.dom.tests;
@@ -15,7 +16,7 @@
import org.eclipse.wst.xml.vex.core.internal.provisional.dom.I.VEXElement;
/**
- * Implementation of WhitespacePolicy using a CSS stylesheet.
+ * Mock implementation of WhitespacePolicy using a CSS stylesheet.
*/
public class MockCssWhitespacePolicy implements IWhitespacePolicy {
@@ -26,7 +27,6 @@
* The stylesheet used for the policy.
*/
public MockCssWhitespacePolicy(StyleSheet styleSheet) {
- this.styleSheet = styleSheet;
}
public boolean isBlock(VEXElement element) {
@@ -37,8 +37,4 @@
return false;
}
- // ===================================================== PRIVATE
-
- private StyleSheet styleSheet;
-
}
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockDocumentBuilder.java b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockDocumentBuilder.java
index 379dd8c..42f10a4 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockDocumentBuilder.java
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.core.tests/src_emf/org/eclipse/wst/xml/vex/core/internal/provisional/dom/tests/MockDocumentBuilder.java
@@ -128,7 +128,7 @@
try {
VEXElement element;
- if (stack.size() == 0) {
+ if (stack.isEmpty()) {
rootElement = DomEMFFactoryImpl.eINSTANCE.createVEXElement();
rootElement.setName(qName);
element = this.rootElement;
@@ -223,8 +223,7 @@
StringBuffer sb;
- StackEntry entry = this.stack.size() > 0 ? (StackEntry) this.stack
- .getLast() : null;
+ StackEntry entry = this.stack.isEmpty() ? null : this.stack.getLast();
if (entry != null && entry.pre) {
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/META-INF/MANIFEST.MF b/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/META-INF/MANIFEST.MF
index 6493923..f1fe955 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/META-INF/MANIFEST.MF
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/META-INF/MANIFEST.MF
@@ -13,3 +13,4 @@
Export-Package: org.eclipse.wst.xml.vex.ui.internal.editor.tests;x-internal:=true,
org.eclipse.wst.xml.vex.ui.internal.tests;x-internal:=true,
org.eclipse.wst.xml.vex.ui.tests
+Bundle-Localization: plugin
diff --git a/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/build.properties b/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/build.properties
index 34d2e4d..aa1a008 100644
--- a/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/build.properties
+++ b/sourceediting/tests/org.eclipse.wst.xml.vex.ui.tests/build.properties
@@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.properties