Index: features/org.jboss.tools.common.core.feature/feature.xml =================================================================== --- features/org.jboss.tools.common.core.feature/feature.xml (revision 43203) +++ features/org.jboss.tools.common.core.feature/feature.xml (working copy) @@ -16,6 +16,12 @@ %license + getAnnotations(); - - /** - * Get element annotation of a certain annotation type. - * - * @param annotationTypeName - * the name of the annotation type - * @return the element annotation of the given annotation type, or a null - * value - */ - IAnnotationDeclaration getAnnotation(String annotationTypeName); - - /** - * This method is similar to getAnnotation(String annotationTypeName). But - * JDT doesn't have API for getting IAnnotation from method parameters so - * this method is preferable for method parameters. - * - * @param annotationTypeName - * the name of the annotation type - * @return the text source reference of the annotation of the given annotation type, or a null - * value - */ - IJavaSourceReference getAnnotationPosition(String annotationTypeName); - - /** - * Determine if the element has an annotation of a certain annotation type. - * - * @param annotationTypeName - * the annotation type to check for - * @return true if the element has an annotation of the given annotation - * type, or false otherwise - */ - boolean isAnnotationPresent(String annotationTypeName); -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/TypeDeclaration.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/TypeDeclaration.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/TypeDeclaration.java (working copy) @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import org.eclipse.core.resources.IResource; - -/** - * - * @author Viacheslav Kabanovich - * - */ -public class TypeDeclaration extends ParametedType implements ITypeDeclaration { - IResource resource; - int length; - int startPosition; - - public TypeDeclaration(ParametedType type, IResource resource, int startPosition, int length) { - this.setFactory(type.getFactory()); - this.type = type.getType(); - arrayIndex = type.arrayIndex; - this.resource = resource; - this.length = length; - this.startPosition = startPosition; - - signature = type.signature; - parameterTypes = type.parameterTypes; - - allInheritedTypes = type.allInheritedTypes; - inheritanceIsBuilt = type.inheritanceIsBuilt; - inheritedTypes = type.inheritedTypes; - superType = type.superType; - primitive = type.primitive; - - isLower = type.isLower; - isUpper = type.isUpper; - isVariable = type.isVariable; - } - - public int getLength() { - return length; - } - - public int getStartPosition() { - return startPosition; - } - - public IResource getResource() { - return resource; - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaReference.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaReference.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaReference.java (working copy) @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; - -/** - * @author Alexey Kazakov - */ -public interface IJavaReference { - - /** - * Returns the closest java member of this element. - * For example for local variable (method parameter) it will return the parent method. - * @return - */ - IMember getSourceMember(); - - /** - * Returns java element. For java members this method will return the same object as getSourceMember(); - * @return - */ - IJavaElement getSourceElement(); -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationDeclaration.java (working copy) @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.IType; - -/** - * Represents an annotation declaration. For example, in CDI, a qualifier or a scope - * declaration of a bean/injection/produce method. - * - * @author Alexey Kazakov - */ -public interface IAnnotationDeclaration extends IJavaSourceReference { - - /** - * Returns the member value pairs. - * - * @return the member value pairs - */ - IMemberValuePair[] getMemberValuePairs(); - - /** - * Convenience method that allows to get one member value without enumerating pairs. - * @param name - * @return member value, may be null, e.g. when value is an expression - */ - Object getMemberValue(String name); - - /** - * Returns the member which is annotated by this declaration. - * - * @return the member which is annotated by this declaration - */ - IMember getParentMember(); - - /** - * Returns the corresponding type name of the annotation. - * - * @return the corresponding type name of the annotation - */ - String getTypeName(); - - /** - * Returns the corresponding IType of the annotation. May be null. - * - * @return the corresponding IType of the annotation - */ - IType getType(); - - /** - * Returns the corresponding annotation. May be null. - * - * @return the corresponding annotation - */ - IAnnotationType getAnnotation(); - - /** - * Returns underlying Java annotation if this declaration is based on Java source. - * Returns null if this declaration is based on xml source. - * - * @return underlying Java annotation if it exists - */ - IAnnotation getJavaAnnotation(); - - /** - * Returns resource which contains this declaration - * @return - */ - IResource getResource(); -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaSourceReference.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaSourceReference.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaSourceReference.java (working copy) @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import org.jboss.tools.common.text.ITextSourceReference; - -/** - * @author Alexey Kazakov - */ -public interface IJavaSourceReference extends ITextSourceReference, IJavaReference { - -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ParametedTypeFactory.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ParametedTypeFactory.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ParametedTypeFactory.java (working copy) @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.util.EclipseJavaUtil; - -public class ParametedTypeFactory { - // I S J C F D Z - static Map primitives = new HashMap(); - static { - primitives.put(Signature.C_INT, "Ljava.lang.Integer;"); //$NON-NLS-1$ - primitives.put(Signature.C_SHORT, "Ljava.lang.Short;"); //$NON-NLS-1$ - primitives.put(Signature.C_LONG, "Ljava.lang.Long;"); //$NON-NLS-1$ - primitives.put(Signature.C_CHAR, "Ljava.lang.Character;"); //$NON-NLS-1$ - primitives.put(Signature.C_FLOAT, "Ljava.lang.Float;"); //$NON-NLS-1$ - primitives.put(Signature.C_DOUBLE, "Ljava.lang.Double;"); //$NON-NLS-1$ - primitives.put(Signature.C_BOOLEAN, "Ljava.lang.Boolean;"); //$NON-NLS-1$ - primitives.put(Signature.C_BYTE, "Ljava.lang.Boolean;"); //$NON-NLS-1$ - } - //unresolved Object signature - public static String OBJECT = "QObject;"; //$NON-NLS-1$ - Map cache = new Hashtable(); - - public ParametedType newParametedType(IType type) { - ParametedType parametedType = new ParametedType(); - if(type != null && !type.isBinary()) { - ISourceRange r = null; - try { - r = type.getNameRange(); - } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); - } - if(r != null) { - parametedType = new TypeDeclaration(parametedType, type.getResource(), r.getOffset(), r.getLength()); - } - } - parametedType.setFactory(this); - parametedType.setType(type); - if(type != null) parametedType.setSignature(Signature.C_RESOLVED + type.getFullyQualifiedName() + Signature.C_SEMICOLON); - String[] ps = null; - try { - ps = type.getTypeParameterSignatures(); - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - if(ps != null && ps.length > 0) { - for (int i = 0; i < ps.length; i++) { - try { - ParametedType p = getParametedTypeForParameter(type, ps[i], null); - if(p != null) parametedType.addParameter(p); - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - } - } - return parametedType; - } - - public ParametedType getParametedType(IMember context, String typeSignature) throws JavaModelException { - return getParametedType(context, null, typeSignature); - } - - public ParametedType getParametedType(IMember context, IParametedType basetype, String typeSignature) throws JavaModelException { - if(typeSignature == null) return null; - if(basetype != null) { - ParametedType param = ((ParametedType)basetype).findParameter(typeSignature); - if(param != null) return param; - } - - IType contextType = context instanceof IType ? (IType)context : context.getDeclaringType(); - - String key = context == null || context.isBinary() || OBJECT.equals(typeSignature) ? typeSignature : contextType.getFullyQualifiedName() + "+" + typeSignature; - if(cache.containsKey(key)) return cache.get(key); - ParametedType result = new ParametedType(); - result.setFactory(this); - result.setSignature(typeSignature); - - typeSignature = typeSignature.substring(result.getArrayIndex()); - - char c = typeSignature.length() == 0 ? '\0' : typeSignature.charAt(0); - if(primitives.containsKey(c) && typeSignature.length() == 1) { - typeSignature = primitives.get(c); - result.setSignature(result.getArrayPrefix() + typeSignature); - result.setPrimitive(true); - } else if(c == Signature.C_EXTENDS) { - typeSignature = typeSignature.substring(1); - result.setUpper(true); - } else if(c == Signature.C_SUPER) { - typeSignature = typeSignature.substring(1); - result.setLower(true); - } else if(c == Signature.C_STAR && typeSignature.length() == 1) { - result.setUpper(true); - return result; - } - - int startToken = typeSignature.indexOf(Signature.C_GENERIC_START); - if(startToken < 0) { - String resovedTypeName = EclipseJavaUtil.resolveTypeAsString(contextType, typeSignature); - if(resovedTypeName == null) return null; - if(!context.isBinary() || typeSignature.charAt(0) == Signature.C_TYPE_VARIABLE) { - StringBuffer ns = new StringBuffer(); - ns.append(result.getArrayPrefix()); - if(result.isLower()) ns.append(Signature.C_SUPER); - if(result.isUpper()) ns.append(Signature.C_EXTENDS); - ns.append(Signature.C_RESOLVED).append(resovedTypeName).append(Signature.C_SEMICOLON); - result.setSignature(ns.toString()); - } - IType type = EclipseJavaUtil.findType(context.getJavaProject(), resovedTypeName); - if(type != null) { - result.setType(type); - cache.put(key, result); - return result; - } - if(context instanceof IMethod) { - String[] ps = ((IMethod)context).getTypeParameterSignatures(); - for (int i = 0; i < ps.length; i++) { - ParametedType st = getParametedTypeForParameter(context, ps[i], result); - if(st != null) { - if(st.getSignature().indexOf(Signature.C_COLON) >= 0) { - CommonPlugin.getDefault().logWarning("Wrong signature=" + st.getSignature()); - } - return st; - } - } - } - String[] ps = contextType.getTypeParameterSignatures(); - for (int i = 0; i < ps.length; i++) { - ParametedType st = getParametedTypeForParameter(contextType, ps[i], result); - if(st != null) return st; - } - } else { - int endToken = typeSignature.lastIndexOf(Signature.C_GENERIC_END); - if(endToken < startToken) return null; - String typeName = typeSignature.substring(0, startToken) + typeSignature.substring(endToken + 1); - String resovedTypeName = EclipseJavaUtil.resolveTypeAsString(contextType, typeName); - if(resovedTypeName == null) return null; - IType type = EclipseJavaUtil.findType(context.getJavaProject(), resovedTypeName); - if(type != null) { - result.setType(type); - cache.put(key, result); - StringBuffer newParams = new StringBuffer(); - String[] paramSignatures = null; - try { - paramSignatures = Signature.getTypeArguments(typeSignature); - } catch (IllegalArgumentException e) { - CommonPlugin.getDefault().logError(e); - } - if(paramSignatures != null) for (String paramSignature: paramSignatures) { - ParametedType param = getParametedType(context, basetype, paramSignature); - if(param == null) { - param = new ParametedType(); - param.setSignature(paramSignature); - } - result.addParameter(param); - newParams.append(param.getSignature()); - } - if(!context.isBinary()) { - StringBuffer ns = new StringBuffer(); - ns.append(result.getArrayPrefix()); - if(result.isLower()) ns.append(Signature.C_SUPER); - if(result.isUpper()) ns.append(Signature.C_EXTENDS); - ns.append(Signature.C_RESOLVED) - .append(resovedTypeName) - .append(Signature.C_GENERIC_START) - .append(newParams) - .append(Signature.C_GENERIC_END) - .append(Signature.C_SEMICOLON); - result.setSignature(ns.toString()); - } - return result; - } - } - return null; - } - - public ParametedType getParametedTypeForParameter(IMember context, String typeParameterSignature, ParametedType result) throws JavaModelException { - IType contextType = context instanceof IType ? (IType)context : context.getDeclaringType(); - String key = context == null ? typeParameterSignature : contextType.getFullyQualifiedName() + "+" + typeParameterSignature; - - String t = Signature.getTypeVariable(typeParameterSignature); - String[] bounds = Signature.getTypeParameterBounds(typeParameterSignature); - - t = Signature.C_RESOLVED + t + Signature.C_SEMICOLON; - if(result == null || t.equals(result.getSignature())) { - if(bounds.length > 0 && bounds[0].length() > 0) { - ParametedType st = getParametedType(contextType, bounds[0]); - if(st != null) { - result = new TypeDeclaration(st, context.getResource(), 0, 0); - result.setUpper(true); - } - } else if(result != null) { - result.setSignature(t); - } - if(result == null) { - result = new ParametedType(); - result.setFactory(this); - result.setSignature(t); - } - result.setVariable(true); - cache.put(key, result); - return result; - } - return null; - } - - public void clean() { - cache.clear(); - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IParametedType.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IParametedType.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IParametedType.java (working copy) @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import java.util.List; - -import org.eclipse.jdt.core.IType; - -/** - * Represents a wrapper for IType object which could be parameted. - * For example if we have some method - * List getList() {...} - * then IParametedType for return type of this method will wrap List<> and its signature. - */ -public interface IParametedType { - - /** - * Returns the corresponding IType of the declaration. May be null. - * - * @return the corresponding IType of the declaration. - */ - IType getType(); - - /** - * Returns signature of the declaration. - * - * @return signature of the declaration - */ - public String getSignature(); - - /** - * Returns true if the type is a primitive type. - * - * @return true if the type is a primitive type - */ - boolean isPrimitive(); - - /** - * Returns the simple name of the type. In case of IType this method will return the short name of the type. - * If this type is primitive then the method will return the name of the primitive type. - * - * Implementations may not return null. - * - * @return the simple name of the type. - */ - String getSimpleName(); - - /** - * Returns type parameters - * - * @return type parameters - */ - List getParameters(); -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ITypeDeclaration.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ITypeDeclaration.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ITypeDeclaration.java (working copy) @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import org.jboss.tools.common.text.ITextSourceReference; - -/** - * @author Alexey Kazakov - */ -public interface ITypeDeclaration extends IParametedType, ITextSourceReference { - -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java (working copy) @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java.impl; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.SourceRange; -import org.eclipse.jdt.internal.core.MemberValuePair; -import org.jboss.tools.common.java.IJavaAnnotation; - -public class AnnotationLiteral implements IJavaAnnotation { - IResource declaringResource; - IType annotationType; - - String source; - ISourceRange range; - IMemberValuePair[] memberValues = new IMemberValuePair[0]; - - IJavaElement parent; - - public AnnotationLiteral(IResource declaringResource, String source, ISourceRange range, IMemberValuePair[] memberValues, IType annotationType) { - this.declaringResource = declaringResource; - this.source = source; - this.range = range; - this.memberValues = memberValues; - this.annotationType = annotationType; - } - - public AnnotationLiteral(IResource declaringResource, int offset, int length, Object value, int valueType, IType annotationType) { - this.declaringResource = declaringResource; - this.range = new SourceRange(offset, length); - if(value != null) { - this.memberValues = new IMemberValuePair[]{ - createPair("value", value, valueType) - }; - } - this.annotationType = annotationType; - } - - public void addMemberValuePair(String name, Object value, int valueType) { - IMemberValuePair[] pairs = new IMemberValuePair[memberValues.length + 1]; - System.arraycopy(memberValues, 0, pairs, 0, memberValues.length); - pairs[memberValues.length] = createPair(name, value, valueType); - memberValues = pairs; - } - - private IMemberValuePair createPair(String name, Object value, int valueType) { - return new MemberValuePair(name, value, valueType); - } - - public int getStartPosition() { - return range == null ? -1 : range.getOffset(); - } - - public int getLength() { - return range == null ? -1 : range.getLength(); - } - - public IResource getResource() { - return declaringResource; - } - - public String getTypeName() { - if(annotationType != null) return annotationType.getFullyQualifiedName(); - return null; - } - - public IType getType() { - return annotationType; - } - - public IMember getParentMember() { - //Do we need it? - return null; - } - - public IJavaElement getParentElement() { - return parent; - } - - public void setParentElement(IJavaElement element) { - parent = element; - } - - public IMemberValuePair[] getMemberValuePairs() { - return memberValues; - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java (working copy) @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java.impl; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.java.IJavaAnnotation; -import org.jboss.tools.common.util.EclipseJavaUtil; - -public class JavaAnnotation implements IJavaAnnotation { - IAnnotation annotation; - - String annotationTypeName; - IType type; - - public JavaAnnotation(IAnnotation annotation, IType declaringType) { - this.annotation = annotation; - try { - String name = annotation.getElementName(); - annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name); - type = EclipseJavaUtil.findType(annotation.getJavaProject(), annotationTypeName); - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - } - - public IResource getResource() { - return annotation.getResource(); - } - - public String getTypeName() { - return annotationTypeName; - } - - public IType getType() { - return type; - } - - public int getLength() { - try { - ISourceRange range = annotation.getSourceRange(); - if(range != null) { - return range.getLength(); - } - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - return 0; - } - - public int getStartPosition() { - try { - ISourceRange range = annotation.getSourceRange(); - if(range != null) { - return range.getOffset(); - } - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - return 0; - } - - public IMember getParentMember() { - IJavaElement ancestor = annotation.getParent(); - while(ancestor != null) { - if(ancestor instanceof IMember) { - return (IMember)ancestor; - } - ancestor = ancestor.getParent(); - } - return null; - } - - public IJavaElement getParentElement() { - return annotation.getParent(); - } - - public IMemberValuePair[] getMemberValuePairs() { - try { - return annotation.getMemberValuePairs(); - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - return new IMemberValuePair[0]; - } - - public IAnnotation getAnnotation() { - return annotation; - } - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java (working copy) @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009-2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IImportDeclaration; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.IType; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.java.IAnnotationDeclaration; -import org.jboss.tools.common.java.IAnnotationType; -import org.jboss.tools.common.java.IJavaAnnotation; -import org.jboss.tools.common.util.EclipseJavaUtil; - -/** - * - * @author Viacheslav Kabanovich - * - */ -public class AnnotationDeclaration implements IAnnotationDeclaration { - protected IJavaAnnotation annotation; - protected Map values; - - public AnnotationDeclaration() {} - - public void setDeclaration(IJavaAnnotation annotation) { - this.annotation = annotation; - IMemberValuePair[] pairs = getMemberValuePairs(); - if(pairs.length > 0) { - values = new HashMap(); - for (IMemberValuePair pair: pairs) { - String name = pair.getMemberName(); - Object value = resolveMemberValue(pair); - if(value != null) { - values.put(name, value); - } - } - } - } - - public IJavaAnnotation getDeclaration() { - return annotation; - } - - public IResource getResource() { - return annotation.getResource(); - } - - public IMemberValuePair[] getMemberValuePairs() { - return annotation.getMemberValuePairs(); - } - - public Object getMemberValue(String name) { - if(name == null) name = "value"; //$NON-NLS-1$ -// IMemberValuePair[] pairs = getMemberValuePairs(); -// for (IMemberValuePair pair: pairs) { -// if(name.equals(pair.getMemberName())) { -// return resolveMemberValue(pair); -// } -// } - return values == null ? null : values.get(name); - } - - public IMember getParentMember() { - return annotation.getParentMember(); - } - - public String getTypeName() { - return annotation.getTypeName(); - } - - public IType getType() { - return annotation.getType(); - } - - public int getLength() { - return annotation.getLength(); - } - - public int getStartPosition() { - return annotation.getStartPosition(); - } - - public IAnnotationType getAnnotation() { - return null; - } - - public IAnnotation getJavaAnnotation() { - if(annotation instanceof JavaAnnotation) { - return ((JavaAnnotation) annotation).getAnnotation(); - } - return null; - } - - public Object resolveMemberValue(IMemberValuePair pair) { - Object value = pair.getValue(); - int k = pair.getValueKind(); - if(k == IMemberValuePair.K_QUALIFIED_NAME || k == IMemberValuePair.K_SIMPLE_NAME - || (value instanceof Object[] && k == IMemberValuePair.K_UNKNOWN)) { - IAnnotation a = getJavaAnnotation(); - if(a != null && a.getAncestor(IJavaElement.COMPILATION_UNIT) instanceof ICompilationUnit) { - value = validateNamedValue(value, a); - } - } - return value; - } - - private Object validateNamedValue(Object value, IAnnotation a) { - if(value instanceof Object[]) { - Object[] vs = (Object[])value; - for (int i = 0; i < vs.length; i++) { - vs[i] = validateNamedValue(vs[i], a); - } - } else { - ICompilationUnit u = (ICompilationUnit)a.getAncestor(IJavaElement.COMPILATION_UNIT); - IType type = (IType)a.getAncestor(IJavaElement.TYPE); - try { - IImportDeclaration[] is = u.getImports(); - String stringValue = value.toString(); - int lastDot = stringValue.lastIndexOf('.'); - String lastToken = stringValue.substring(lastDot + 1); - if(lastDot < 0) { - IField f = (a.getParent() == type) ? type.getField(lastToken) : EclipseJavaUtil.findField(type, lastToken); - if(f != null && f.exists()) { - value = f.getDeclaringType().getFullyQualifiedName() + "." + lastToken; - } else { - String v = getFullName(type, is, lastToken); - if(v != null) { - value = v; - } - } - return value; - } - String prefix = stringValue.substring(0, lastDot); - String t = EclipseJavaUtil.resolveType(type, prefix); - if(t != null) { - IType q = EclipseJavaUtil.findType(type.getJavaProject(), t); - if(q != null && q.getField(lastToken).exists()) { - value = t + "." + lastToken; - } - } - - } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); - } - } - - return value; - } - - private String getFullName(IType type, IImportDeclaration[] is, String name) throws CoreException { - for (IImportDeclaration d: is) { - String n = d.getElementName(); - if(n.equals(name) || n.endsWith("." + name)) { - return n; - } - if(Flags.isStatic(d.getFlags()) && n.endsWith(".*")) { - String typename = n.substring(0, n.length() - 2); - IType t = EclipseJavaUtil.findType(type.getJavaProject(), typename); - if(t != null && t.exists()) { - IField f = EclipseJavaUtil.findField(t, name); - if(f != null) { - return f.getDeclaringType().getFullyQualifiedName() + "." + name; - } - } - - } - } - return null; - } - - @Override - public IMember getSourceMember() { - return getParentMember(); - } - - @Override - public IJavaElement getSourceElement() { - return annotation.getParentElement(); - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ParametedType.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ParametedType.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/ParametedType.java (working copy) @@ -1,443 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.jdt.core.ISourceRange; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeParameter; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.jboss.tools.common.CommonPlugin; - -/** - * - * @author Viacheslav Kabanovich - * - */ -//@SuppressWarnings("nls") -public class ParametedType implements IParametedType { - protected ParametedTypeFactory typeFactory = null; - protected IType type; - protected int arrayIndex = 0; - protected String signature; - protected List parameterTypes = new ArrayList(); - protected boolean primitive; - - protected boolean isUpper = false; - protected boolean isLower = false; - protected boolean isVariable = false; - - boolean inheritanceIsBuilt = false; - protected ParametedType superType = null; - protected Set inheritedTypes = new HashSet(); - Set allInheritedTypes = null; - - public static interface PositionProvider { - ISourceRange getRange(String superTypeName); - } - - PositionProvider provider = null; - - public ParametedType() {} - - /* - * (non-Javadoc) - * @see org.jboss.tools.common.java.IParametedType#isPrimitive() - */ - public boolean isPrimitive() { - return primitive; - } - - public void setPrimitive(boolean primitive) { - this.primitive = primitive; - } - - public boolean isUpper() { - return isUpper; - } - - public void setUpper(boolean b) { - isUpper = b; - } - - public boolean isLower() { - return isLower; - } - - public void setLower(boolean b) { - isLower = b; - } - - public boolean isVariable() { - return isVariable; - } - - public void setVariable(boolean b) { - isVariable = b; - } - - public ParametedTypeFactory getFactory() { - return typeFactory; - } - - public void setFactory(ParametedTypeFactory typefactory) { - this.typeFactory = typefactory; - } - - public IType getType() { - return type; - } - - public int getArrayIndex() { - return arrayIndex; - } - - public String getArrayPrefix() { - return toArrayPrefix(arrayIndex); - } - - static String[] PREFIXES = new String[4]; - static { - PREFIXES[0] = ""; //$NON-NLS-1$ - for (int i = 1; i < PREFIXES.length; i++) PREFIXES[i] = PREFIXES[i - 1] + Signature.C_ARRAY; - } - - private static String toArrayPrefix(int arrayIndex) { - return arrayIndex < PREFIXES.length ? PREFIXES[arrayIndex] : PREFIXES[3] + toArrayPrefix(arrayIndex - 3); - } - - public String getSignature() { - return signature; - } - - public void setType(IType type) { - this.type = type; - } - - public void setSignature(String signature) { - this.signature = signature; - arrayIndex = 0; - if(signature != null) { - for (; arrayIndex < signature.length() && (signature.charAt(arrayIndex) == Signature.C_ARRAY); arrayIndex++) {} - } - } - - public void addParameter(ParametedType p) { - parameterTypes.add(p); - } - - public List getParameters() { - return parameterTypes; - } - - public void setPositionProvider(PositionProvider p) { - provider = p; - } - - public boolean equals(Object object) { - if(!(object instanceof ParametedType)) return false; - ParametedType other = (ParametedType)object; - if(signature != null && signature.equals(other.signature)) { - return true; - } - if(type == null || other.type == null || !type.getFullyQualifiedName().equals(other.type.getFullyQualifiedName())) { - return false; - } - if(parameterTypes.size() != other.parameterTypes.size()) { - return false; - } - for (int i = 0; i < parameterTypes.size(); i++) { - if(!parameterTypes.get(i).equals(other.parameterTypes.get(i))) { - return false; - } - } - if(arrayIndex != other.arrayIndex) { - return false; - } - - return true; - } - - void buildInheritance() { - if(type == null) return; - Set inheritedTypes = new HashSet(); - try { - if(!type.isInterface() && !type.isAnnotation()) { - String sc = type.getSuperclassTypeSignature(); - boolean objectArray = false; - if(sc != null) { - sc = resolveParameters(sc); - } else if(!"java.lang.Object".equals(type.getFullyQualifiedName())) { //$NON-NLS-1$ - sc = ParametedTypeFactory.OBJECT; - } else if("java.lang.Object".equals(type.getFullyQualifiedName()) && arrayIndex > 0) { //$NON-NLS-1$ - objectArray = true; - sc = ParametedTypeFactory.OBJECT; - } - if(!objectArray && arrayIndex > 0) { - sc = getArrayPrefix() + sc; - } - - superType = getFactory().getParametedType(type, this, sc); - if(superType != null) { - if(provider != null) { - String scn = type.getSuperclassName(); - if(scn != null && provider.getRange(scn) != null) { - ISourceRange r = provider.getRange(scn); - superType = new TypeDeclaration(superType, type.getResource(), r.getOffset(), r.getLength()); - } - - } - inheritedTypes.add(superType); - } - } - String[] is = type.getSuperInterfaceTypeSignatures(); - if(is != null) for (int i = 0; i < is.length; i++) { - String p = resolveParameters(is[i]); - if(arrayIndex > 0) p = getArrayPrefix() + p; - ParametedType t = getFactory().getParametedType(type, this, p); - if(t != null) { - if(provider != null) { - String scn = type.getSuperInterfaceNames()[i]; - if(scn != null && provider.getRange(scn) != null) { - ISourceRange r = provider.getRange(scn); - t = new TypeDeclaration(t, type.getResource(), r.getOffset(), r.getLength()); - } - - } - inheritedTypes.add(t); - } - } - } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); - } - this.inheritedTypes = inheritedTypes; - inheritanceIsBuilt = true; - } - - public ParametedType getSuperType() { - if(!inheritanceIsBuilt) { - buildInheritance(); - } - return superType; - } - - public Set getInheritedTypes() { - if(!inheritanceIsBuilt) { - buildInheritance(); - } - return inheritedTypes; - } - - public String resolveParameters(String typeSignature) { - if(typeSignature == null) { - return typeSignature; - } - int i = typeSignature.indexOf(Signature.C_GENERIC_START); - if(i < 0) { - char c = typeSignature.length() == 0 ? '\0' : typeSignature.charAt(0); - char e = typeSignature.length() == 0 ? '\0' : typeSignature.charAt(typeSignature.length() - 1); - if((c == Signature.C_TYPE_VARIABLE || c == Signature.C_UNRESOLVED || c == Signature.C_RESOLVED) && e == Signature.C_SEMICOLON) { - String param = typeSignature.substring(1, typeSignature.length() - 1); - String s = findParameterSignature(param); - return s == null ? typeSignature : s; - } - return typeSignature; - } - int j = typeSignature.lastIndexOf(Signature.C_GENERIC_END); - if(j < i) { - return typeSignature; - } - boolean replaced = false; - StringBuffer newParams = new StringBuffer(); - String[] ps = Signature.getTypeArguments(typeSignature); - for (String param: ps) { - String newParam = resolveParameters( param); - if(!param.equals(newParam)) replaced = true; - newParams.append(newParam); - } - if(replaced) { - typeSignature = typeSignature.substring(0, i) - + Signature.C_GENERIC_START - + newParams.toString() - + Signature.C_GENERIC_END - + Signature.C_SEMICOLON; - } - return typeSignature; - } - - public String findParameterSignature(String paramName) { - buildParameters(); - return signaturesByName.get(paramName); - } - - Map signaturesByName = null; - Map parametersBySignature = null; - - void buildParameters() { - if(signaturesByName == null && type != null) { - Map sbn = new HashMap(); - Map pbs = new HashMap(); - ITypeParameter[] ps = null; - try { - ps = type.getTypeParameters(); - } catch (JavaModelException e) { - return; - } - if(ps != null) for (int i = 0; i < ps.length; i++) { - String paramName = ps[i].getElementName(); - if(parameterTypes.size() > i) { - ParametedType p = parameterTypes.get(i); - sbn.put(paramName, p.getSignature()); - pbs.put(p.getSignature(), p); - } - } - signaturesByName = sbn; - parametersBySignature = pbs; - } - } - - public ParametedType findParameter(String signature) { - buildParameters(); - return parametersBySignature.get(signature); - } - - public Collection getAllTypes() { - if(allInheritedTypes == null) { - allInheritedTypes = buildAllTypes(new HashSet(), this, new HashSet()); - } - return allInheritedTypes; - } - - Set buildAllTypes(Set processed, ParametedType p, Set types) { - IType t = p.getType(); - if(t != null) { - String key = p.getArrayPrefix() + t.getFullyQualifiedName(); - if(!processed.contains(key)) { - processed.add(key); - types.add(p); - Set ts = p.getInheritedTypes(); - if(ts != null) for (IParametedType pp: ts) { - buildAllTypes(processed, (ParametedType)pp, types); - } - } - } - return types; - } - - public String toString() { - return signature + ":" + super.toString(); //$NON-NLS-1$ - } - - public boolean isAssignableTo(ParametedType other, boolean checkInheritance) { - return isAssignableTo(other, checkInheritance, new HashMap()); - } - - boolean isAssignableTo(ParametedType other, boolean checkInheritance, Map resolvedVars) { - if(equals(other)) return true; - if("*".equals(other.getSignature())) { //$NON-NLS-1$ - return true; - } - if(this.type == null) { - return (isVariable && other.isVariable && other.type == null); - } - if(other.isVariable && other.type == null) { - if(type != null) { - if(resolvedVars.get(other.getSignature()) != null) { - return resolvedVars.get(other.getSignature()) == type; - } else { - resolvedVars.put(other.getSignature(), type); - } - } - return true; - } - if(this.type.equals(other.type)) { - if(areTypeParametersAssignableTo(other, resolvedVars)) return true; - } - if(checkInheritance) { - for (IParametedType t: getInheritedTypes()) { - if(((ParametedType)t).isAssignableTo(other, false, resolvedVars)) return true; - } - } - return false; - } - - boolean areTypeParametersAssignableTo(ParametedType other, Map resolvedVars) { - if(other.parameterTypes.isEmpty()) return true; - if(this.parameterTypes.size() != other.parameterTypes.size()) return false; - for (int i = 0; i < parameterTypes.size(); i++) { - ParametedType p1 = parameterTypes.get(i); - ParametedType p2 = other.parameterTypes.get(i); - if(p1.isLower() || (p1.isUpper() && !p1.isVariable)) return false; - if(p1.isVariable()) { - if(p2.isVariable()) { - if(p2.isAssignableTo(p1, true, resolvedVars)) continue; - } else if(p2.isLower()) { - if(p2.isAssignableTo(p1, true, resolvedVars)) continue; - } else if(p2.isUpper()) { - if(p2.isAssignableTo(p1, true, resolvedVars)) continue; - if(p1.isAssignableTo(p2, true, resolvedVars)) continue; - } else { - if(p2.isAssignableTo(p1, true, resolvedVars)) continue; - } - } else { - if(p2.isLower()) { - if(p2.isAssignableTo(p1, true, resolvedVars)) continue; - } else { - if(p1.isAssignableTo(p2, true, resolvedVars)) continue; - } - } - - return false; - } - return true; - } - - static Map primitives = new HashMap(); - static { - primitives.put("Integer", "int"); - primitives.put("Short", "short"); - primitives.put("Long", "long"); - primitives.put("Character", "char"); - primitives.put("Float", "float"); - primitives.put("Double", "double"); - primitives.put("Boolean", "boolean"); - } - - /* - * (non-Javadoc) - * @see org.jboss.tools.cdi.core.IParametedType#getSimpleName() - */ - public String getSimpleName() { - if(getSignature()!=null) { - if(isPrimitive()) { - int array = arrayIndex; - StringBuilder result = new StringBuilder(primitives.get(Signature.getSignatureSimpleName(getSignature().substring(array)))); - if(array > 0) { - for (int i = 0; i < array; i++) { - result.append("[]"); //$NON-NLS-1$ - } - } - return result.toString(); - } else { - return Signature.getSignatureSimpleName(getSignature()); - } - } - return ""; //$NON-NLS-1$ - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java (working copy) @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.IType; -import org.jboss.tools.common.text.ITextSourceReference; - -/** - * Hides IAnnotation and allows to subtitute another implementation than wrapper for IAnnotation. - * - * @author Viacheslav Kabanovich - * - */ -public interface IJavaAnnotation extends ITextSourceReference { - - /** - * Returns resource that declares this annotation. - * - * @return resource that declares this annotation - */ - public IResource getResource(); - - /** - * Returns fully qualified type name if resolved or element name otherwise. - * - * @return fully qualified type name if resolved or element name otherwise - */ - public String getTypeName(); - - /** - * Returns annotation type or null if it cannot be resolved. - * - * @return annotation type or null if it cannot be resolved - */ - public IType getType(); - /** - * Returns Java element on which or for which this annotation was created. - * - * @return Java element on which or for which this annotation was created - */ - public IJavaElement getParentElement(); - - /** - * Returns Java member on which or for which this annotation was created. - * - * @return Java member on which or for which this annotation was created - */ - public IMember getParentMember(); - - /** - * Returns member value pairs as IAnnotation does. - * - * @return member value pairs as IAnnotation does - */ - public IMemberValuePair[] getMemberValuePairs(); - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationType.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationType.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IAnnotationType.java (working copy) @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 - 2012 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.java; - -import java.util.List; - -import org.eclipse.jdt.core.IType; - -/** - * Common interface for an annotation interface. - * - * @author Viacheslav Kabanovich - * - */ -public interface IAnnotationType { - - /** - * Returns the corresponding IType of the annotation type. - * - * @return the corresponding IType - */ - IType getSourceType(); - - /** - * Returns all the available annotations which are declared for this - * interface. - * - * @return all the available annotations which are declared for this - * interface - */ - List getAnnotationDeclarations(); - - /** - * Returns the annotations with given type name. - * - * @param typeName - * @return the annotations with given type name - */ - IAnnotationDeclaration getAnnotationDeclaration(String typeName); - -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java (working copy) @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.log; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; - -/** - * A logging adapter that logs to a given plugin. - * - * @author Andre Dietisheim - */ -public class PluginLogger implements ILoggingAdapter { - - private Plugin plugin; - - public PluginLogger(Plugin plugin) { - this.plugin = plugin; - } - - public void error(String message) { - log(IStatus.ERROR, message); - } - - public void debug(String message) { - log(IStatus.INFO, message); - } - - private void log(int severity, String message) { - if (!isTracingEnabled()) { - return; - } - - if (plugin != null) { - IStatus status = new Status(severity, plugin.getBundle().getSymbolicName(), message); - plugin.getLog().log(status); - } - } - - protected Plugin getPlugin() { - return plugin; - } - - protected boolean isTracingEnabled() { - // defaults to always log - return true; - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java (working copy) @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.log; - -/** - * @author Andre Dietisheim - */ -public interface ILoggingAdapter { - - public void error(String errorMessage); - - public void debug(String message); - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/LogHelper.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/LogHelper.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/LogHelper.java (working copy) @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.log; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.Bundle; - -public class LogHelper { - public static void logError(Plugin plugin, Throwable t) { - logError(plugin, null, t); - } - - public static void logError(Plugin plugin, String message) { - logError(plugin, message, null); - } - - public static void logError(Plugin plugin, String message, Throwable t) { - IStatus status = StatusFactory.getInstance(IStatus.ERROR, - plugin.getBundle().getSymbolicName(), message, t); - logStatus(plugin, status); - } - - public static void logError(String pluginId, Throwable t) { - logError(pluginId, null, t); - } - - public static void logError(String pluginId, String message) { - logError(pluginId, message, null); - } - - public static void logError(String pluginId, String message, Throwable t) { - IStatus status = StatusFactory.getInstance(IStatus.ERROR, pluginId, - message, t); - logStatus(pluginId, status); - } - - public static void logWarning(Plugin plugin, Throwable t) { - logWarning(plugin, null, t); - } - - public static void logWarning(Plugin plugin, String message) { - logWarning(plugin, message, null); - } - - - public static void logWarning(Plugin plugin, String message, Throwable t) { - IStatus status = StatusFactory.getInstance(IStatus.WARNING, - plugin.getBundle().getSymbolicName(), message, t); - logStatus(plugin, status); - } - - public static void logWarning(String pluginId, Throwable t) { - logWarning(pluginId, null, t); - } - - public static void logWarning(String pluginId, String message) { - logWarning(pluginId, message, null); - } - - - public static void logWarning(String pluginId, String message, - Throwable t) { - IStatus status = StatusFactory.getInstance(IStatus.WARNING, pluginId, - message, t); - logStatus(pluginId, status); - } - - public static void logInfo(Plugin plugin, String message, - Throwable t) { - IStatus status = StatusFactory.getInstance(IStatus.INFO, - plugin.getBundle().getSymbolicName(), message, t); - logStatus(plugin, status); - } - - - public static void logInfo(Plugin plugin, String message) { - IStatus status = StatusFactory.getInstance(IStatus.INFO, - plugin.getBundle().getSymbolicName(), message); - logStatus(plugin, status); - } - - public static void logInfo(String pluginId, String message, - Throwable t) { - IStatus status = StatusFactory.getInstance(IStatus.INFO, pluginId, - message, t); - logStatus(pluginId, status); - } - - public static void logInfo(String pluginId, String message) { - IStatus status = StatusFactory.getInstance(IStatus.INFO, pluginId, - message); - logStatus(pluginId, status); - } - - public static void log(int severity, String pluginId, int code, - String message, Throwable t) { - IStatus status = StatusFactory.getInstance(severity, pluginId, code, - message, t); - logStatus(pluginId, status); - } - - public static void logStatus(Plugin plugin, IStatus status) { - plugin.getLog().log(status); - } - - public static void logStatus(String pluginId, IStatus status) { - Bundle bundle = Platform.getBundle(pluginId); - logStatus(bundle, status); - } - - public static void logStatus(Bundle bundle, IStatus status) { - ILog log = Platform.getLog(bundle); - log.log(status); - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/IPluginLog.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/IPluginLog.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/IPluginLog.java (working copy) @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.log; - -public interface IPluginLog { - public void logError(String message, Throwable t); - public void logError(String message); - public void logError(Throwable t); - - public void logWarning(String message, Throwable t); - public void logWarning(String message); - public void logWarning(Throwable t); - - public void logInfo(String message, Throwable t); - public void logInfo(String message); -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/BasePlugin.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/BasePlugin.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/BasePlugin.java (working copy) @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.log; - -import org.eclipse.core.runtime.Plugin; - -/** - * Provides an easy way to log status of events. - * - * NOTE: It is useful to make the static method getPluginLog() - * which provides the interface IPluginLog for using it in your code - * in future - * - * @author Sergey Vasilyev - * - */ - -public class BasePlugin extends Plugin implements IPluginLog { - public void logError(String message, Throwable t) { - LogHelper.logError(this, message, t); - } - - public void logError(String message) { - LogHelper.logError(this, message); - } - - public void logError(Throwable t) { - LogHelper.logError(this, t); - } - - public void logWarning(String message, Throwable t) { - LogHelper.logWarning(this, message, t); - } - - public void logWarning(String message) { - LogHelper.logWarning(this, message); - } - - public void logWarning(Throwable t) { - LogHelper.logWarning(this, t); - } - - public void logInfo(String message, Throwable t) { - LogHelper.logInfo(this, message, t); - } - - public void logInfo(String message) { - LogHelper.logInfo(this, message); - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/StatusFactory.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/StatusFactory.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/StatusFactory.java (working copy) @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.log; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; - -public class StatusFactory { - public final static int UNDEFINED_ERROR = 0; - public final static String UNSPECIFIED_MESSAGE = null; - public final static String EMPTY_MESSAGE = ""; //$NON-NLS-1$ - - public static IStatus getInstance(int severity, String pluginId, - int code, String message, Throwable t) { - return new Status(severity, pluginId, code, checkMessage(message, t), t); - } - - public static IStatus getInstance(int severity, String pluginId, - String message, Throwable t) { - return getInstance(severity, pluginId, UNDEFINED_ERROR, message, t); - } - - public static IStatus getInstance(int severity, String pluginId, - String message) { - return getInstance(severity, pluginId, UNDEFINED_ERROR, message, null); - } - - public static IStatus getInstance(int severity, String pluginId, - Throwable t) { - return getInstance(severity, pluginId, UNDEFINED_ERROR, EMPTY_MESSAGE, t); - } - - public static IStatus getInstance(int severity, String pluginId, - int code, Throwable t) { - return getInstance(severity, pluginId, code, EMPTY_MESSAGE, t); - } - - public static IStatus getInstance(int severity, String pluginId, - int code, String message) { - return getInstance(severity, pluginId, code, message, null); - } - - /** - * Returns a multi status with the given severity, plugin id, error code, - * message, cause and child status instances. - * - * @param severity - * @param pluginId - * @param message - * @param t - * @param status - * @return a multi status - */ - public static IStatus getInstance(int severity, String pluginId, String message, Throwable t, IStatus... status) { - return new MultiStatus(pluginId, UNDEFINED_ERROR, status, message, t); - } - - private static String checkMessage(String message, Throwable t) { - if (message == UNSPECIFIED_MESSAGE) { - if (t != null && t.getMessage() != null) { - return t.getMessage(); - } - return EMPTY_MESSAGE; - } - return message; - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java (working copy) @@ -1,396 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009-2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.text; - -import java.util.Comparator; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Text Proposal for Content Assist. - * @author Alexey Kazakov - */ -public class TextProposal { - - public interface PostProcessing { - public void process(TextProposal proposal, String value, int offset); - } - - public static final int R_NONE = 0; - public static final int R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE = 810; - public static final int R_JSP_ATTRIBUTE_VALUE = 830; - public static final int R_XML_ATTRIBUTE_VALUE = 850; - public static final int R_XML_ATTRIBUTE_NAME = 910; - public static final int R_TAG_INSERTION = 1210; // This value was changed from 500 to 1210 because it seems that according WTP's value was risen up to 1200 in 3.6 - public static final int R_XML_ATTRIBUTE_VALUE_TEMPLATE = 91; - public static final int R_XML_TAG_INSERTION = 91; - public static final int R_CLOSE_TAG = 1550; - - private static final long serialVersionUID = 3257007635692926512L; - - private Object source; - private String label; - private String contextInfo; - private ImageDescriptor imageDescriptor; - private boolean emptyImage = true; - private String replacementString; - private String alternateMatch = null; - private boolean emptyContextInfo = true; - private int relevance = R_NONE; - private int position = -1; - private boolean autoActivationContentAssistantAfterApplication = false; - - private String type; - private String sourceType; - - private int start = -1; - private int end = -1; - - PostProcessing postProcessing; - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public Object clone() throws CloneNotSupportedException { - TextProposal newObject = new TextProposal(); - newObject.source = this.source; - newObject.label = this.label; - newObject.contextInfo = this.contextInfo; - newObject.imageDescriptor = this.imageDescriptor; - newObject.emptyImage = this.emptyImage; - newObject.replacementString = this.replacementString; - newObject.emptyContextInfo = this.emptyContextInfo; - newObject.relevance = this.relevance; - newObject.position = this.position; - newObject.autoActivationContentAssistantAfterApplication = this.autoActivationContentAssistantAfterApplication; - newObject.type = this.type; - newObject.sourceType = this.sourceType; - newObject.start = this.start; - newObject.end = this.end; - return newObject; - } - - public String getType() { - return type; - } - - public void setType(String typeName) { - this.type = typeName; - } - - public String getSourceType() { - return sourceType; - } - - public void setSourceType(String sourceTypeName) { - this.sourceType = sourceTypeName; - } - - /** - * - * @return - */ - public int getRelevance() { - return relevance; - } - - /** - * - * @param relevance - */ - public void setRelevance(int relevance) { - this.relevance = relevance; - } - - /** - * @return - */ - public String getContextInfo() { - return contextInfo; - } - - /** - * @return - */ - public ImageDescriptor getImageDescriptor() { - return imageDescriptor; - } - -// CommonUIPlugin.getImageDescriptorRegistry().get - /** - * @return - */ - public String getLabel() { - String l = label != null ? label : getReplacementString() == null ? "" : getReplacementString(); //$NON-NLS-1$ - - StringBuffer dispLabel = new StringBuffer(l); - if (type != null) { - dispLabel.append(" : "); //$NON-NLS-1$ - dispLabel.append(type); - } - if (sourceType != null) { - dispLabel.append(" - "); //$NON-NLS-1$ - dispLabel.append(sourceType); - } - - return dispLabel.toString(); - } - - /** - * @return - */ - public String getReplacementString() { - return replacementString; - } - - /** - * @param string - */ - public void setContextInfo(String string) { - contextInfo = string; - if(contextInfo != null) { - emptyContextInfo = false; - } - } - - /** - * @param string - */ - public void setImageDescriptor(ImageDescriptor img) { - this.imageDescriptor = img; - if(this.imageDescriptor != null) { - emptyImage = false; - } - } - - /** - * @param string - */ - public void setLabel(String string) { - label = string; - } - - /** - * @param string - */ - public void setReplacementString(String string) { - replacementString = string; - } - - /** - * @return - */ - public boolean hasContextInfo() { - return !emptyContextInfo; - } - - /** - * @return - */ - public boolean hasImage() { - return !emptyImage; - } - - /** - * @return - */ - public int getPosition() { - if(position==-1 && getReplacementString()!=null) { - return getReplacementString().length(); - } - return position; - } - - /** - * @param i - */ - public void setPosition(int i) { - position = i; - } - - /** - * - * @param lowerCase - */ - public void changeCase(boolean lowerCase) { - if(lowerCase) { - if(label!=null) label = label.toLowerCase(); - if(replacementString!=null) replacementString = replacementString.toLowerCase(); - } else { - if(label!=null) label = label.toUpperCase(); - if(replacementString!=null) replacementString = replacementString.toUpperCase(); - } - } - - /** - * - * - */ - public void removeAutocompleteRequiredAttributes() { - int endAttr = replacementString.lastIndexOf('"'); - if(endAttr!=-1) { - int startAttr = replacementString.substring(0, replacementString.indexOf('"')).lastIndexOf(' '); - String newReplacementString = replacementString.substring(0, startAttr); - if(endAttr+1 KB_PROPOSAL_ORDER = new TextProposalComparator(); - - private static class TextProposalComparator implements Comparator { - public int compare(TextProposal p1, TextProposal p2) { - int n1=p1.replacementString.length(), n2=p2.replacementString.length(); - for (int i1=0, i2=0; i1 - * org.mycompany.Logger - * - * then getValue() will return "org.mycompany.Logger" - * and getStartPosition() will return the offset of the trimmed value (the index of "o") - * and getLength() will return the length of "org.mycompany.Logger" string. - * - * @author Alexey Kazakov - */ -public interface INodeReference extends ITextSourceReference { - - /** - * Returns the trimmed string representation of the value of the - * node. For example if this object is reference to - * - * org.mycompany.Logger - * - * then this method will return "org.mycompany.Logger". - * - * @return the trimmed string representation of the body of this XML - * element. - */ - String getValue(); -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/Messages.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/Messages.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/Messages.java (working copy) @@ -16,11 +16,6 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.jboss.tools.common.messages"; //$NON-NLS-1$ public static String BaseUIPlugin_ErrorDialogTitle; - public static String SAXValidator_IOExceptionMessage; - public static String SAXValidator_SAXExceptionMessage; - public static String SAXValidator_UnableToInstantiateMessage; - public static String XMLUtilities_IOExceptionMessage; - public static String XMLUtilities_SAXExceptionMessage; public static String MethodNotImplementedException_MethodIsNotImplementedYet; static { // initialize resource bundle Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/jobs/ChainedJob.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/jobs/ChainedJob.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/jobs/ChainedJob.java (working copy) @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.jboss.tools.common.jobs; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.IJobChangeListener; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; - -/** - * A Job that can start another job upon successful completion. - */ -public abstract class ChainedJob extends Job { - private Job nextJob; - private IJobChangeListener listener; - private String family; - - public ChainedJob(String name) { - this(name, null); - } - - /** - * Create a new dependent job. - * - * @param name the name of the job - * @param server the server to publish to - */ - public ChainedJob(String name, String family) { - super(name); - this.family = family; - } - - /** - * @see Job#belongsTo(java.lang.Object) - */ - public boolean belongsTo(Object family) { - if (this.family == null) { - return false; - } - return this.family.equals(family); - } - - - /** - * Create a listener for when this job finishes. - */ - protected void createListener() { - if (listener != null) - return; - - listener = new JobChangeAdapter() { - public void done(IJobChangeEvent event) { - jobDone(event.getResult()); - } - }; - - addJobChangeListener(listener); - } - - /** - * Called when this job is complete. - * - * @param status the result of the current job - */ - protected void jobDone(IStatus status) { - if (listener == null) - return; - - removeJobChangeListener(listener); - listener = null; - - if (nextJob != null && status != null && status.getSeverity() != IStatus.ERROR - && status.getSeverity() != IStatus.CANCEL) - nextJob.schedule(); - } - - /** - * Set the next job, which should be scheduled if and only if this job completes - * successfully. The next job will be run as long as the result of this job is - * not an ERROR or CANCEL status. - * This method is not thread-safe. However, the next job can be changed anytime - * up until the current job completes. - * - * @param job the next job that should be scheduled - */ - public void setNextJob(Job job) { - nextJob = job; - createListener(); - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/ErrorHandlerImpl.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/ErrorHandlerImpl.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/ErrorHandlerImpl.java (working copy) @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.xml; - -import java.util.ArrayList; -import java.util.List; - -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -class ErrorHandlerImpl implements ErrorHandler { - List errors = new ArrayList(); - - public void error(SAXParseException e) throws SAXException { - add(e); - } - - public void fatalError(SAXParseException e) throws SAXException { - add(e); - throw e; - } - - public void warning(SAXParseException e) throws SAXException { - add(e); - } - - private void add(SAXParseException e) { - errors.add("" + e.getMessage() + ":" + e.getLineNumber() + ":" + e.getColumnNumber()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - } Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java (working copy) @@ -1,427 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.xml; - -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.util.ArrayList; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.xml.serialize.LineSeparator; -import org.apache.xml.serialize.Method; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.Messages; -import org.w3c.dom.Comment; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentType; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class XMLUtilities { - - public static boolean hasAttribute(Element e, String s) { - return e.getAttributes().getNamedItem(s) != null; - } - - public static Element[] getChildren(Element parent, String name){ - ArrayList al = new ArrayList(); - NodeList nl = parent.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++){ - Node n = nl.item(i); - if(n.getNodeType() == Node.ELEMENT_NODE && - n.getNodeName().equals(name)) { - al.add((Element)n); - } - } - return al.toArray(new Element[al.size()]); - } - - public static Element getUniqueChild(Element parent, String name){ - return getFirstChild(parent, name); - } - - public static Element getFirstChild(Element parent, String name) { - NodeList nl = parent.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++){ - Node n = nl.item(i); - if(n.getNodeType() == Node.ELEMENT_NODE && - n.getNodeName().equals(name)) { - return (Element)n; - } - } - return null; - } - - public static Element getLastChild(Element parent, String name) { - Element child = null; - NodeList nl = parent.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++){ - Node n = nl.item(i); - if(n.getNodeType() == Node.ELEMENT_NODE && - n.getNodeName().equals(name)) { - child = (Element)n; - } - } - return child; - } - - public static Element[] getAncestors(Element parent, String name) { - int i = name.indexOf('.'); - if(i < 0) { - return getChildren(parent, name); - } - Element p = getUniqueChild(parent, name.substring(0, i)); - return (p == null) ? new Element[0] : getAncestors(p, name.substring(i + 1)); - } - - public static Element createElement(Element parent, String path) { - int i = path.indexOf('.'); - Element element = null; - if(i < 0) { - element = parent.getOwnerDocument().createElement(path); - parent.appendChild(element); - } else { - String p = path.substring(0, i), c = path.substring(i + 1); - Element pe = getUniqueChild(parent, p); - if(pe == null) { - pe = parent.getOwnerDocument().createElement(p); - parent.appendChild(pe); - } - element = createElement(pe, c); - } - return element; - } - - public static DocumentBuilder createDocumentBuilder() { - return createDocumentBuilder(false); - } - - public static DocumentBuilder createDocumentBuilder(boolean validate) { - try { - DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); - f.setValidating(validate); - // / f.setExpandEntityReferences(false); - DocumentBuilder d = f.newDocumentBuilder(); - if (!validate) { - d.setEntityResolver(EMPTY_RESOLVER); - } - d.setErrorHandler(new ErrorHandlerImpl()); - return d; - } catch (ParserConfigurationException e) { - CommonPlugin.getPluginLog().logError(e); - } - return null; - } - - public static final EntityResolver EMPTY_RESOLVER = createEmptyEntityResolver(); - - - - public static Element createDocumentElement(String name) { - Document d = createDocumentBuilder().newDocument(); - Element de = d.createElement(name); - d.appendChild(de); - return de; - } - - public static EntityResolver createEmptyEntityResolver() { - return new EntityResolver() { - public InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws SAXException, java.io.IOException { - if((systemId != null) && - (systemId.toLowerCase().endsWith(".dtd") || systemId.toLowerCase().endsWith(".ent"))) { // this deactivates DTD //$NON-NLS-1$ //$NON-NLS-2$ - return new InputSource(new ByteArrayInputStream("".getBytes())); //$NON-NLS-1$ - } else { - return null; - } - } - }; - } - - public static Element createDocumentElement(String name, String qName, String publicId, String systemId, String namespaceURI) { - Document d = null; - try { - DOMImplementation domImpl = createDocumentBuilder().getDOMImplementation(); - DocumentType docType = domImpl.createDocumentType(qName, publicId, systemId); - d = domImpl.createDocument(namespaceURI, name, docType); - } catch (DOMException e) { - return null; - } - Element de = d.getDocumentElement(); - if (de == null) { - de = d.createElement(name); - d.appendChild(de); - } - return de; - } - - public static Element getElement(String filename, EntityResolver resolver) { - return getElement(new File(filename), resolver); - } - - public static Element getElement(File file, EntityResolver resolver) { - if(file == null || !file.isFile()) { - return null; - } - java.io.FileReader fr = null; - try { - fr = new java.io.FileReader(file); - org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(fr); - return getElement(inSource, resolver); - } catch (FileNotFoundException e) { - CommonPlugin.getPluginLog().logError(e); - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } catch (SAXException e) { - CommonPlugin.getPluginLog().logError(e); - } finally { - try { - if (fr != null) { - fr.close(); - } - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } - } - return null; - } - - public static Element getElement(Reader reader, EntityResolver resolver) { - Document d = getDocument(reader, resolver); - return (d == null) ? null : d.getDocumentElement(); - } - - public static Document getDocument(Reader reader, EntityResolver resolver) { - try { - org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader); - return getDocument(inSource, resolver); - } catch (SAXException e) { - return null; - } catch (IOException e) { - return null; - } - } - - public static Element getElement(InputStream is, EntityResolver resolver) { - try { - org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(is); - return getElement(inSource, resolver); - } catch (SAXException e) { - return null; - } catch (IOException e) { - return null; - } - } - - public static Element getElement(InputSource is, EntityResolver resolver) throws SAXException, IOException { - return getDocument(is, resolver).getDocumentElement(); - } - - public static Document getDocument(InputSource is, EntityResolver resolver) throws SAXException, IOException{ - DocumentBuilder builder = createDocumentBuilder(false); - if(resolver != null) { - builder.setEntityResolver(resolver); - } - return builder.parse(is); - } - - public static String[] getXMLErrors(Reader reader, EntityResolver resolver) { - return getXMLErrors(reader, true, resolver); - } - - public static String[] getXMLErrors(Reader reader, boolean checkDTD, EntityResolver resolver) { - org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader); - return getXMLErrors(inSource, checkDTD, resolver); - } - - public static String[] getXMLErrors(org.xml.sax.InputSource is, EntityResolver resolver) { - return getXMLErrors(is, true, resolver); - } - - public static String[] getXMLErrors(org.xml.sax.InputSource is, boolean checkDTD, EntityResolver resolver) { - ErrorHandlerImpl h = new ErrorHandlerImpl(); - try { - DocumentBuilder builder = createDocumentBuilder(checkDTD); - if(resolver != null) { - builder.setEntityResolver(resolver); - } - builder.setErrorHandler(h); - builder.parse(is); - } catch (IOException e) { - if(h.errors.isEmpty()) { - return new String[]{Messages.XMLUtilities_IOExceptionMessage+":0:0",e.toString()}; //$NON-NLS-1$ - } - } catch (SAXException e) { - if(h.errors.isEmpty()) { - return new String[]{Messages.XMLUtilities_SAXExceptionMessage+":0:0",e.toString()}; //$NON-NLS-1$ - } - } - return h.errors.toArray(new String[h.errors.size()]); - } - - public static final void serialize(Element element, String filename) throws IOException { - File f = new File(filename); - if(f.exists() && !f.canWrite()) { - return; - } - if(!f.exists()) { - f.createNewFile(); - } - FileWriter fw = new FileWriter(f); - serialize(element, new BufferedWriter(fw)); - fw.close(); - } - static final String ENCODING = "encoding=\""; //$NON-NLS-1$ - static final String UTF8 = "UTF-8"; //$NON-NLS-1$ - - public static String getEncoding(String body) { - int i = body.indexOf(ENCODING); - if(i < 0) { - return UTF8; - } - i = i + ENCODING.length(); - int j = body.indexOf('"', i); - if(j < 0) { - return UTF8; - } - return body.substring(i, j); - - } - public static OutputFormat createOutputFormat(String encoding) { - OutputFormat format = new OutputFormat(Method.XML, encoding == null || encoding.length() == 0?null:encoding, true); - format.setLineSeparator(System.getProperty("line.separator", LineSeparator.Web)); //$NON-NLS-1$ - format.setIndent(1); - return format; - } - - public static final boolean serialize(Element element, Writer w) throws IOException { - if(element == null) { - return false; - } - serialize(element, new XMLSerializer(w, createOutputFormat(UTF8))); - w.close(); - return true; - } - - public static final boolean serialize(Element element, OutputStream w) throws IOException { - if(element == null) { - return false; - } - serialize(element, new XMLSerializer(w, createOutputFormat(UTF8))); - w.close(); - return true; - } - - public static void serialize(Element element, XMLSerializer serial) throws IOException { - serial.asDOMSerializer(); - serial.serialize(element); - } - - public static void serialize(Document document, XMLSerializer serial) throws IOException { - if(serial == null || document == null) { - return; - } - serial.asDOMSerializer(); - serial.serialize(document); - } - - public static final boolean serialize(Document document, Writer w) throws IOException { - return serialize(document, w, null); - } - - public static final boolean serialize(Document document, Writer w, String encoding) throws IOException { - if(document == null) { - return false; - } - serialize(document, new XMLSerializer(w, createOutputFormat(encoding))); - w.close(); - return true; - } - - public static final String getCDATA(Element elem) { - return getCDATA(elem, true); - } - - public static final String getCDATA(Element elem, boolean trim) { - StringBuffer sb = new StringBuffer(); - NodeList nl = elem.getChildNodes(); - for (int i = 0; i < nl.getLength(); i++) { - Node nc = nl.item(i); - if (nc.getNodeType() == Node.CDATA_SECTION_NODE) { - sb.append(((Text) nc).getData()); - } else if (nc.getNodeType() == Node.TEXT_NODE) { - String txt = ((Text) nc).getData(); - if(trim) { - txt = txt.trim(); - } - sb.append(txt); - } - } - return sb.toString(); - } - - public static final String getComment(Element elem) { - StringBuffer sb = new StringBuffer(); - Node node = elem.getPreviousSibling(); - while (node != null) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - break; - } - if (node.getNodeType() == Node.COMMENT_NODE) { - if (sb.length() > 0) { - sb.insert(0, '\n'); - sb.insert(0, ((Comment) node).getData()); - } else { - sb.append(((Comment) node).getData()); - } - } - node = node.getPreviousSibling(); - } - return sb.toString(); - } - - public static final void setCDATA(Element element, String data) { - element.appendChild(element.getOwnerDocument().createCDATASection( - data!=null?data:"")); //$NON-NLS-1$ - } - - public static final void setText(Element element, String data) { - element.appendChild(element.getOwnerDocument().createTextNode( - data!=null?data:"")); //$NON-NLS-1$ - } - - public static final void setComment(Element element, String data) { - Comment comm = element.getOwnerDocument().createComment( - data!=null?data:""); //$NON-NLS-1$ - element.getParentNode().insertBefore(comm, element); - } - -} - Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java (working copy) @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.xml; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Platform; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.util.HttpUtil; -import org.osgi.framework.Bundle; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * @author igels - */ -public class DtdResolver implements EntityResolver { - static Set unfound = new HashSet(); - - public InputStream getInputStream(String publicId, String systemId) throws SAXException, IOException { - String location = XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolvePublic(publicId, systemId); - if(location == null) { - location = XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveSystem(systemId); - } - if(location == null) { - location = XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveURI(systemId); - } - if(location == null) { - if(systemId != null && systemId.startsWith("file:") && systemId.endsWith(".xsd")) { //$NON-NLS-1$ //$NON-NLS-2$ - int i = systemId.replace('\\', '/').lastIndexOf('/'); - String systemId2 = systemId.substring(i + 1); - location = XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveURI(systemId2); - } - } - if((location == null || location.startsWith("http:")) && systemId != null) { //$NON-NLS-1$ - Bundle b = Platform.getBundle("org.eclipse.jst.standard.schemas"); //$NON-NLS-1$ - if(b != null) { - int q = systemId.lastIndexOf("/"); //$NON-NLS-1$ - String s = systemId.substring(q + 1); - URL u = b.getEntry("/dtdsAndSchemas/" + s); //$NON-NLS-1$ - try { - if(u != null) { - u = FileLocator.resolve(u); - } - } catch (IOException ee) { - u = null; - } - if(u != null) { - location = u.toString(); - } - } - } - if(location == null) { - if(systemId != null && !unfound.contains(systemId)) { - unfound.add(systemId); -// CommonPlugin.getPluginLog().logInfo("Cannot find locally: " //$NON-NLS-1$ -// + "Public ID " + publicId //$NON-NLS-1$ -// + " System ID " + systemId); //$NON-NLS-1$ - } - } - if(location!=null) { - try { - URL url = new URL(location); - File file = new File(url.getFile()); - if(file.isFile()) { - return new FileInputStream(file); - } else if("jar".equals(url.getProtocol())) { //$NON-NLS-1$ - return url.openStream(); - } - } catch(FileNotFoundException e) { - CommonPlugin.getPluginLog().logError(e); - } - } - - String resourceType = null; - if(systemId!=null) { - if(systemId.toLowerCase().endsWith(".dtd")) { //$NON-NLS-1$ - resourceType = "DTD"; //$NON-NLS-1$ - } else if(systemId.toLowerCase().endsWith(".xsd")) { //$NON-NLS-1$ - resourceType = "XSD"; //$NON-NLS-1$ - } else if(systemId.toLowerCase().endsWith(".ent")) { //$NON-NLS-1$ - resourceType = "ENT"; //$NON-NLS-1$ - } - } - InputStream is = null; - if(resourceType!=null) { // this deactivates DTD and XSD - try { - URL url = new URL(systemId); - if("http".equals(url.getProtocol())) { //$NON-NLS-1$ - is = HttpUtil.getInputStreamFromUrlByGetMethod(systemId); - } - } catch (MalformedURLException e) { - CommonPlugin.getPluginLog().logError(e); - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } - } - return is; - } - - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - InputStream is = getInputStream(publicId, systemId); - if(is!=null) { - return new InputSource(is); - } - return null; - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java (working copy) @@ -1,113 +0,0 @@ -/* - * XMLEntityResolver.java - * Created on February 21, 2003, 9:38 AM - */ - -package org.jboss.tools.common.xml; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.URL; -import java.util.Properties; - -import org.eclipse.core.runtime.FileLocator; -import org.jboss.tools.common.CommonPlugin; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * @author valera - */ -public class XMLEntityResolver implements EntityResolver { - - private static final Properties publicEntities = new Properties(); - private static final Properties systemEntities = new Properties(); - - public static void registerPublicEntity(String publicId, String url) { - publicEntities.setProperty(publicId, url); - } - - public static void registerPublicEntity(String publicId, Class loader, String resourceName) throws IOException { - URL url = resolve(loader, resourceName); - if(url != null) { - registerPublicEntity(publicId, url.toString()); - } - } - - public static void registerSystemEntity(String systemId, String url) { - systemEntities.setProperty(systemId, url); - } - - public static void registerSystemEntity(String systemId, Class loader, String resourceName) throws IOException { - URL url = resolve(loader, resourceName); - if(url != null) { - registerSystemEntity(systemId, url.toString()); - } - } - - static URL resolve(Class loader, String resourceName) throws IOException { - URL url = loader.getResource(resourceName); - return (url == null) ? null : FileLocator.resolve(url); - } - - public static XMLEntityResolver getInstance() { - return new XMLEntityResolver(); - } - - boolean deactivate = true; - - private XMLEntityResolver() {} - - public void setDeactivate(boolean b) { - deactivate = b; - } - - public boolean isResolved(String publicId, String systemId) { - if (publicId != null) { - String url = publicEntities.getProperty(publicId); - if (url != null) { - return true; - } - } else if (systemId != null) { - String url = systemEntities.getProperty(systemId); - if (url != null) { - return true; - } - } - return false; - } - - public InputSource resolveEntity(String publicId, String systemId) - throws SAXException, java.io.IOException { - InputSource source = null; - boolean ok = false; - if (publicId != null) { - String url = publicEntities.getProperty(publicId); - if (url != null) { - source = new InputSource(url); - source.setPublicId(publicId); - ok = true; - } - } - if (!ok && systemId != null) { - String url = systemEntities.getProperty(systemId); - if (url != null) { - source = new InputSource(url); - source.setSystemId(systemId); - } - } - - if(deactivate && (systemId != null) && (source == null) - // this deactivates DTD for .dtd and .ent resources - && (systemId.toLowerCase().endsWith(".dtd") || systemId.toLowerCase().endsWith(".ent")) - ) { //$NON-NLS-1$ //$NON-NLS-2$ - source = new InputSource(new ByteArrayInputStream("".getBytes())); //$NON-NLS-1$ - } - if(source == null) { - CommonPlugin.getDefault().logError("WARNING: Cannot resolve entity " + systemId); //$NON-NLS-1$ - } - // TODO study if we can always return non-null value. - return source; - } - -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java (working copy) @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.xml; - -import java.io.IOException; -import java.io.InputStream; - -import javax.xml.transform.URIResolver; - -import org.apache.xerces.xni.XMLResourceIdentifier; -import org.apache.xerces.xni.parser.XMLEntityResolver; -import org.apache.xerces.xni.parser.XMLInputSource; - -import org.jboss.tools.common.CommonPlugin; - -import org.xml.sax.SAXException; - -/** - * @author Igels - */ -public class XMLEntityResolverImpl implements XMLEntityResolver { - - private URIResolver uriResolver; - - public XMLEntityResolverImpl() { - } - - public XMLEntityResolverImpl(URIResolver uriResolver) { - this.uriResolver = uriResolver; - } - - public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws IOException { - XMLInputSource result = null; - String systemId = null; - String publicId = null; - InputStream is = null; - try { - DtdResolver resolver = new DtdResolver(); - systemId = rid.getBaseSystemId()==null?rid.getLiteralSystemId():rid.getExpandedSystemId(); - publicId = rid.getPublicId(); - - is = resolver.getInputStream(rid.getPublicId(), systemId); - if(is!=null) { - result = new XMLInputSource(rid.getPublicId(), systemId, rid.getBaseSystemId(), is, null); - } - } catch (SAXException e) { - CommonPlugin.getPluginLog().logError( "Exception publicId=" + publicId + " systemId=" + systemId + " exception=" + e.getClass().getName() + ":" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - - return result; - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java (working copy) @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.xml; - -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.net.URL; -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - -import org.apache.xerces.parsers.SAXParser; -import org.apache.xerces.util.XMLCatalogResolver; -import org.apache.xerces.xni.XMLResourceIdentifier; -import org.eclipse.core.runtime.Platform; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.Messages; -import org.jboss.tools.common.util.FileUtil; -import org.osgi.framework.Bundle; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; - -/** - * @author eskimo(dgolovin@exadel.com) - * @version $Revision:$ - */ - -public class SAXValidator { - - protected static final String FATAL_ERROR_PROCESSING_FEATURE_ID = "http://apache.org/xml/features/continue-after-fatal-error"; //$NON-NLS-1$ - protected static final String ENTITY_RESOLVER_PROPERTY_ID = "http://apache.org/xml/properties/internal/entity-resolver"; //$NON-NLS-1$ - protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces"; //$NON-NLS-1$ - protected static final String NAMESPACE_PREFIXES_FEATURE_ID = "http://xml.org/sax/features/namespace-prefixes"; //$NON-NLS-1$ - protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation"; //$NON-NLS-1$ - protected static final String VALIDATION_SCHEMA_FEATURE_ID = "http://apache.org/xml/features/validation/schema"; //$NON-NLS-1$ - protected static final String VALIDATION_SCHEMA_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking"; //$NON-NLS-1$ - protected static final String VALIDATION_DYNAMIC_FEATURE_ID = "http://apache.org/xml/features/validation/dynamic"; //$NON-NLS-1$ - - protected static final String DEFAULT_SAX_PARSER_CLASS_NAME = "org.apache.xerces.parsers.SAXParser"; //$NON-NLS-1$ - - /** - * - * @return - */ - XMLReader createParser() { - DefaultHandler handler = new DefaultHandler(); - XMLReader parserInstance = null; - - parserInstance = new SAXParser(); - //XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME); - - setFeature(parserInstance, NAMESPACES_FEATURE_ID, true); - setFeature(parserInstance, NAMESPACE_PREFIXES_FEATURE_ID, false); - setFeature(parserInstance, VALIDATION_FEATURE_ID, true); - setFeature(parserInstance, VALIDATION_SCHEMA_FEATURE_ID, true); - setFeature(parserInstance, VALIDATION_SCHEMA_CHECKING_FEATURE_ID, false); - setFeature(parserInstance, VALIDATION_DYNAMIC_FEATURE_ID, false); - setFeature(parserInstance, FATAL_ERROR_PROCESSING_FEATURE_ID, false); - - try { - parserInstance.setProperty(ENTITY_RESOLVER_PROPERTY_ID, new XMLEntityResolverImpl()); - } catch (SAXNotRecognizedException e1) { - CommonPlugin.getPluginLog().logError( e1.getMessage()+"", e1); //$NON-NLS-1$ - } catch (SAXNotSupportedException e1) { - CommonPlugin.getPluginLog().logError( e1.getMessage()+"", e1); //$NON-NLS-1$ - } - - parserInstance.setContentHandler(handler); - parserInstance.setErrorHandler(handler); - return parserInstance; - } - - /** - * - * @param parser - * @param name - * @param value - */ - public static void setFeature(XMLReader parser, String name, boolean value) { - try { - parser.setFeature(name, value); - } catch (SAXException e) { - // TODO - Move to NLS bundle - CommonPlugin.getPluginLog().logError("warning: Parser does not support feature ("+name+")", e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * - * @param parser - * @param name - * @param value - */ - public static void setProperty(XMLReader parser, String name, boolean value) { - try { - parser.setProperty(name, value); - } catch (SAXException e) { - CommonPlugin.getPluginLog().logError("warning: Parser does not support feature ("+name+")", e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * - * @param is - * @return - */ - public String[] getXMLErrors(org.xml.sax.InputSource is) { -// ClassLoader cc = Thread.currentThread().getContextClassLoader(); -// Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - ErrorHandlerImpl h = new ErrorHandlerImpl(); - try { - XMLReader parser = createParser(); - if(parser==null) { - return new String[]{ MessageFormat.format( - Messages.SAXValidator_UnableToInstantiateMessage, DEFAULT_SAX_PARSER_CLASS_NAME)}; - } - parser.setErrorHandler(h); - parser.parse(is); - } catch (SAXException e) { - if(h.errors.isEmpty()) { - return new String[]{Messages.SAXValidator_SAXExceptionMessage+":0:0",e.getMessage()}; //$NON-NLS-1$ - } - } catch (IOException e) { - if(h.errors.isEmpty()) { - return new String[]{Messages.SAXValidator_IOExceptionMessage+":0:0",e.getMessage()}; //$NON-NLS-1$ - } - } finally { -// Thread.currentThread().setContextClassLoader(cc); - } - return h.errors.toArray(new String[h.errors.size()]); - } - - /** - * - * @param reader - * @return - */ - public String[] getXMLErrors(Reader reader) { - org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader); - return getXMLErrors(inSource); - } - - /** - * - * @return - */ - String getCatalog() { - - Bundle b = Platform.getBundle(CommonPlugin.PLUGIN_ID); - String location = Platform.getStateLocation(b).toString().replace('\\', '/'); - if(!location.endsWith("/")) { //$NON-NLS-1$ - location += "/"; //$NON-NLS-1$ - } - String urlString = null; - URL url = null; - try { - url = Platform.resolve(b.getEntry("/")); //$NON-NLS-1$ - urlString = url.toString(); - if(!urlString.endsWith("/")) { //$NON-NLS-1$ - urlString += "/"; //$NON-NLS-1$ - } - urlString += "schemas"; //$NON-NLS-1$ - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } - File f1 = new File(url.getFile() + "/schemas/catalog.xml"); //$NON-NLS-1$ - File f2 = new File(location + "schemas/catalog.xml"); //$NON-NLS-1$ - if(f2.exists()) { - return "file:///" + location + "schemas/catalog.xml"; //$NON-NLS-1$ //$NON-NLS-2$ - } - FileUtil.copyDir(f1.getParentFile(), f2.getParentFile(), true); - String text = FileUtil.readFile(f2); - while(text.indexOf("%install%") >= 0) { //$NON-NLS-1$ - int i = text.indexOf("%install%"); //$NON-NLS-1$ - text = text.substring(0, i) + urlString + text.substring(i + 9); - } - FileUtil.writeFile(f2, text); - return "file:///" + location + "schemas/catalog.xml"; //$NON-NLS-1$ //$NON-NLS-2$ - } -} - -/** - * - * @author eskimo(dgolovin@exadel.com) - * - */ -class XMLCatalogResolver1 extends XMLCatalogResolver { - - /** - * - */ - static Set literals = new HashSet(); - - /** - * - */ - @Override - public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier) throws IOException { - String literal = resourceIdentifier.getLiteralSystemId(); - if(literal != null && !literals.contains(literal)) { - literals.add(literal); - } - return super.resolveIdentifier(resourceIdentifier); - } - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/preferences/SeverityPreferences.java (working copy) @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.preferences; - -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jdt.core.JavaCore; -import org.jboss.tools.common.CommonPlugin; - -/** - * Constants for names of seam preferences. - * Static accesses to seam preferences. - * - * Framework for Severity preferences. - * 1) Create a class which extends SeverityPreferences - * 2) Add constant using static method createSeverityOption(String) - * Put it under relevant section, e.g. //components, or create new section - * in the sub-class - * 3) Add in messages.properties in core plug-in of the sub-class - * error message with the same name - * 4) Add constant and property named ValidatorConfigurationBlock_pb_%name%_label, - * where %name% is produced from constant name in Preferences like AAA_BBB_CCC -> aaaBbbCcc - * to PreferencesMessages.java - * and PreferencesMessages.properties - * in UI plug-in. - * Put these entries under relevant section. For a new section add constant and property - * ValidatorConfigurationBlock_section_%newSectionName% - * 5) In class ValidatorConfigurationBlock (in UI plug-in) - * modify SectionDescription constants, according to instruction there. - * - * @author Viacheslav Kabanovich, Alexey Kazakov - */ -public abstract class SeverityPreferences { - - public static final String ENABLE_BLOCK_PREFERENCE_NAME = "enableBlock"; //$NON-NLS-1$ - public static final String MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME = CommonPlugin.PLUGIN_ID + ".validator.problem.markersBlock"; //$NON-NLS-1$ - public static final int DEFAULT_MAX_NUMBER_OF_MARKERS_PER_FILE = 20; - public static final String WRONG_BUILDER_ORDER_PREFERENCE_NAME = CommonPlugin.PLUGIN_ID + ".validator.problem.wrongBuilderOrder"; //$NON-NLS-1$ - - public static final String ERROR = "error"; //$NON-NLS-1$ - public static final String WARNING = "warning"; //$NON-NLS-1$ - public static final String IGNORE = "ignore"; //$NON-NLS-1$ - - public static final String ENABLE = JavaCore.ENABLED; - public static final String DISABLE = JavaCore.DISABLED; - - abstract protected Set getSeverityOptionNames(); - - abstract protected String createSeverityOption(String shortName); - - abstract protected String getPluginId(); - - public IEclipsePreferences getProjectPreferences(IProject project) { - return new ProjectScope(project).getNode(getPluginId()); - } - - public IEclipsePreferences getDefaultPreferences() { - return new DefaultScope().getNode(getPluginId()); - } - - public IEclipsePreferences getInstancePreferences() { - return new InstanceScope().getNode(getPluginId()); - } - - public String getProjectPreference(IProject project, String key) { - IEclipsePreferences p = getProjectPreferences(project); - if(p == null) { - return null; - } - String value = p.get(key, null); - return value != null ? value : getInstancePreference(key); - } - - public int getMaxNumberOfProblemMarkersPerResource(IProject project) { - IEclipsePreferences p = getProjectPreferences(project); - if(p == null) { - return 0; - } - String value = p.get(MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME, null); - if(value!=null) { - return p.getInt(MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME, 0); - } - p = getInstancePreferences(); - value = p == null ? null : p.get(MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME, null); - if(value!=null) { - return p.getInt(MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME, 0); - } - p = getDefaultPreferences(); - return p.getInt(MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME, 0); - } - - public boolean isEnabled(IProject project) { - IEclipsePreferences p = getProjectPreferences(project); - if(p == null) { - return false; - } - String value = p.get(ENABLE_BLOCK_PREFERENCE_NAME, null); - if(value!=null) { - return p.getBoolean(ENABLE_BLOCK_PREFERENCE_NAME, false); - } - p = getInstancePreferences(); - value = p == null ? null : p.get(ENABLE_BLOCK_PREFERENCE_NAME, null); - if(value!=null) { - return p.getBoolean(ENABLE_BLOCK_PREFERENCE_NAME, false); - } - p = getDefaultPreferences(); - return p.getBoolean(ENABLE_BLOCK_PREFERENCE_NAME, false); - } - - public String getBuilderOrderPreference(IProject project) { - IEclipsePreferences p = getProjectPreferences(project); - if(p == null) { - return null; - } - String value = p.get(WRONG_BUILDER_ORDER_PREFERENCE_NAME, null); - if(value != null) { - return value; - } - p = getInstancePreferences(); - value = p == null ? null : p.get(WRONG_BUILDER_ORDER_PREFERENCE_NAME, null); - if(value != null) { - return value; - } - p = getDefaultPreferences(); - return p.get(WRONG_BUILDER_ORDER_PREFERENCE_NAME, null); - } - - public String getInstancePreference(String key) { - IEclipsePreferences p = getInstancePreferences(); - String value = p == null ? null : p.get(key, null); - return value != null ? value : getDefaultPreference(key); - } - - public String getDefaultPreference(String key) { - IEclipsePreferences p = getDefaultPreferences(); - if(p == null) { - return null; - } - return p.get(key, null); - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/ZipArchive.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/ZipArchive.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/ZipArchive.java (working copy) @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 - 2012 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.zip; - -import java.io.File; -import java.io.IOException; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public class ZipArchive { - - File file = null; - - public ZipArchive(String file) { - this(new File(file)); - } - - public ZipArchive(File file) { - this.file = file; - } - - public void acceptVisitor(IZipEntryVisitor visitor) throws IOException{ - ZipFile zipFile = null; - zipFile = new ZipFile(this.file); - acceptVisitor(zipFile, visitor); - } - - public static void acceptVisitor(ZipFile zipFile, IZipEntryVisitor visitor) throws IOException { - try { - Enumeration entries = zipFile.entries(); - while(entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - if(entry.isDirectory()) { - visitor.visiteDirectoryEntry(zipFile, entry); - } else { - visitor.visiteFileEntry(zipFile, entry); - } - } - } finally { - if(zipFile!=null) { - try { - zipFile.close(); - } catch (IOException e) { - // Nothing to do with that - } - } - } - } - - public String getAbsolutePath() { - return file.getAbsolutePath(); - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/UnzipOperation.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/UnzipOperation.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/UnzipOperation.java (working copy) @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 - 2012 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.zip; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public class UnzipOperation { - - File zipFile; - - public static final int BUFFER_SIZE = 1024*4; - - public UnzipOperation(String zipFile) { - this(new File(zipFile)); - } - - public UnzipOperation(File zipFile) { - this.zipFile = zipFile; - } - - public void execute(File destination) throws IOException { - ZipArchive archive = new ZipArchive(zipFile); - archive.acceptVisitor(new UnzipEntryVisitor(destination)); - } - - public void execute(String destination) throws IOException { - execute(new File(destination)); - } - - public void execute(File destination,String filter) throws IOException { - ZipArchive archive = new ZipArchive(zipFile); - archive.acceptVisitor(new FilteredZipEntryVisitor(filter,new UnzipEntryVisitor(destination))); - } - - public void execute(String destination,String filter) throws IOException { - execute(new File(destination,filter)); - } - - public static class FilteredZipEntryVisitor implements IZipEntryVisitor{ - - private String filter; - private IZipEntryVisitor visitor; - - public FilteredZipEntryVisitor(String filter, IZipEntryVisitor visitor) { - this.filter = filter; - this.visitor = visitor; - } - - public void visiteDirectoryEntry(ZipFile zipFile, ZipEntry dir) throws IOException { - if(dir.getName().matches(filter)) { - visitor.visiteDirectoryEntry(zipFile, dir); - } - } - - public void visiteFileEntry(ZipFile zipFile, ZipEntry file) throws IOException { - if(file.getName().matches(filter)) { - visitor.visiteFileEntry(zipFile, file); - } - } - } - - public static class UnzipEntryVisitor implements IZipEntryVisitor { - - private File destination; - - public UnzipEntryVisitor(File destination) { - this.destination = destination; - } - - public void visiteDirectoryEntry(ZipFile zipFIle, ZipEntry dir) throws IOException { - File entryDir = new File(destination,dir.getName()); - entryDir.mkdirs(); - } - - public void visiteFileEntry(ZipFile zipFile, ZipEntry file) throws IOException { - File outputFile = new File(destination,file.getName()); - outputFile.getParentFile().mkdirs(); - outputFile.createNewFile(); - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile),BUFFER_SIZE); - BufferedInputStream in = new BufferedInputStream(zipFile.getInputStream(file)); - byte[] buff = new byte[BUFFER_SIZE]; - int n = -1; - while((n = in.read(buff,0,buff.length))>-1) { - out.write(buff, 0, n); - } - out.flush(); - } - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/DefaultZipEntryVisitor.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/DefaultZipEntryVisitor.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/DefaultZipEntryVisitor.java (working copy) @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 - 2012 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.zip; - -import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public class DefaultZipEntryVisitor implements IZipEntryVisitor { - - public void visiteDirectoryEntry(ZipFile zipFIle, ZipEntry dir) throws IOException { - } - - public void visiteFileEntry(ZipFile zipFile, ZipEntry file) throws IOException { - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/IZipEntryVisitor.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/IZipEntryVisitor.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/zip/IZipEntryVisitor.java (working copy) @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 - 2012 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.zip; - -import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -public interface IZipEntryVisitor { - void visiteDirectoryEntry (ZipFile zipFIle, ZipEntry dir) throws IOException; - void visiteFileEntry (ZipFile zipFile, ZipEntry file) throws IOException; -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/messages.properties =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/messages.properties (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/messages.properties (working copy) @@ -1,7 +1,2 @@ BaseUIPlugin_ErrorDialogTitle=Hibernate Console -SAXValidator_IOExceptionMessage=Unidentified parser error -SAXValidator_SAXExceptionMessage=Unidentified parser error -SAXValidator_UnableToInstantiateMessage=error: Unable to instantiate parser ({0}) -XMLUtilities_IOExceptionMessage=Unexpected parser error -XMLUtilities_SAXExceptionMessage=Unexpected parser error MethodNotImplementedException_MethodIsNotImplementedYet=Method is not implemented yet Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/IObservablePojo.java (working copy) @@ -1,20 +0,0 @@ -package org.jboss.tools.common.databinding; - -import java.beans.PropertyChangeListener; - -public interface IObservablePojo { - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); - - public void addPropertyChangeListener(PropertyChangeListener listener); - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); - - public void removePropertyChangeListener( - PropertyChangeListener listener); - - public void removeAllPropertyChangeListeners(); - - public void dispose(); - -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/databinding/ObservablePojo.java (working copy) @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.databinding; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -/** - * A POJO base class that may notify observers on behalf of - * {@link PropertyChangeSupport} - */ -public abstract class ObservablePojo implements IObservablePojo { - - private PropertyChangeSupport propertyChangeSupport; - - public ObservablePojo() { - this.propertyChangeSupport = new PropertyChangeSupport(this); - } - - public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { - propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue); - } - - public void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) { - propertyChangeSupport.fireIndexedPropertyChange(propertyName, index, oldValue, newValue); - } - - @Override - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - if (!contains(listener)) { - propertyChangeSupport.addPropertyChangeListener(propertyName, listener); - } - } - - @Override - public void addPropertyChangeListener(PropertyChangeListener listener) { - if (!contains(listener)) { - propertyChangeSupport.addPropertyChangeListener(listener); - } - } - - @Override - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - propertyChangeSupport.removePropertyChangeListener(propertyName, listener); - } - - @Override - public void removePropertyChangeListener( - PropertyChangeListener listener) { - propertyChangeSupport.removePropertyChangeListener(listener); - } - - @Override - public void removeAllPropertyChangeListeners() { - for (PropertyChangeListener listener : getPropertyChangeSupport().getPropertyChangeListeners()) { - getPropertyChangeSupport().removePropertyChangeListener(listener); - } - } - - protected boolean contains(PropertyChangeListener listener) { - boolean contains = false; - for (PropertyChangeListener registeredListener : propertyChangeSupport.getPropertyChangeListeners()) { - if (registeredListener == listener) { - contains = true; - break; - } - } - return contains; - } - - protected PropertyChangeSupport getPropertyChangeSupport() { - return propertyChangeSupport; - } - - @Override - public void dispose() { - removeAllPropertyChangeListeners(); - } -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/Submit.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/Submit.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/Submit.java (working copy) @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.reporting; - -import java.io.IOException; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.PostMethod; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.util.HttpUtil; - -/** - * HTTP Utility for bug reporting to RedHat. - * @author Igels - */ -public class Submit { - - public static String REPORT_DESRIPTION_PARAMETER_NAME = CommonPlugin.getMessage("%reportParameterName"); //$NON-NLS-1$ - - private static String URL = CommonPlugin.getMessage("%reportingUrl"); //$NON-NLS-1$ - private static String JOB_NAME = CommonPlugin.getMessage("%reportingJobName"); //$NON-NLS-1$ - private static String ERROR_MESSAGE = CommonPlugin.getMessage("%errorReportingMessage"); //$NON-NLS-1$ - - private static Submit INSTANCE = new Submit(); - - private Submit() { - super(); - } - - /** - * @return Instance of Submit - */ - public static Submit getInstance() { - return INSTANCE; - } - - /** - * Submit report to RedHat. - * @param reportText - * @param cleanBuffer - */ - public void submit(final String reportText, final boolean cleanBuffer) { - Job job = new Job(JOB_NAME) { - @Override - public IStatus run(IProgressMonitor monitor) { - try { - submitReport(reportText); - } catch (IOException e) { - String exceptionMessage = e.getMessage(); - String message = ERROR_MESSAGE; - if(exceptionMessage!=null && exceptionMessage.trim().length()>0) { - message = message + ".\r\n" + e.getClass().getName() + ": " + exceptionMessage; //$NON-NLS-1$ //$NON-NLS-2$ - } - Status status = new Status(IStatus.WARNING, CommonPlugin.PLUGIN_ID, IStatus.WARNING, message, e); - return status; - } - if(cleanBuffer) { - ProblemReportingHelper.buffer.clean(); - } - return Status.OK_STATUS; - } - }; - job.setUser(true); - job.schedule(); - } - - private int submitReport(String reportText) throws IOException { - HttpClient httpClient = HttpUtil.createHttpClient(URL); - PostMethod httpPost = new PostMethod(URL); - httpPost.addParameter(REPORT_DESRIPTION_PARAMETER_NAME, reportText); - int responseCode = httpClient.executeMethod(httpPost); - - return responseCode; - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/DefaultProblemReporter.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/DefaultProblemReporter.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/DefaultProblemReporter.java (working copy) @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.reporting; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; - -/** - * Default implementstion that writes problem to Eclipse log. - * @author glory - */ -public class DefaultProblemReporter implements IProblemReporter { - - public void reportProblem(IStatus status) { - if(status != null) { - Platform.getLog(Platform.getBundle("org.jboss.tools.common")).log(status); //$NON-NLS-1$ - } - } - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemReportingHelper.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemReportingHelper.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemReportingHelper.java (working copy) @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.reporting; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -/** - * Helper class for processing all exceptions caught in Red Hat code. - * @author glory - */ -public class ProblemReportingHelper { - /** - * Method for processing a throwable caught in Red Hat code. - * @param plugin - * @param throwable - */ - public static void reportProblem(String plugin, Throwable throwable) { - String message = (throwable == null) ? null : throwable.getLocalizedMessage(); - reportProblem(plugin, message, throwable); - } - - /** - * Method for processing a throwable caught in Red Hat code. - * @param plugin - * @param message (translatable) - * @param throwable - */ - public static void reportProblem(String plugin, String message, Throwable throwable) { - if(message==null) { - throw new IllegalArgumentException("Message parameter cannot be null"); //$NON-NLS-1$ - } - IStatus status = new Status(IStatus.ERROR, plugin, 0, message, throwable); - reportProblem(status); - } - - /** - * Method for processing a throwable caught in Red Hat code. - * @param status - */ - public static void reportProblem(IStatus status) { - if(status == null) { - reportProblem("org.jboss.tools.common", //$NON-NLS-1$ - new IllegalArgumentException("Parameter 'status' cannot be null")); //$NON-NLS-1$ - return; - } - IProblemReporter reporter = ProblemReporterFactory.getInstance().getProblemReporter(); - reporter.reportProblem(status); - } - - public static final ProblemBuffer buffer = new ProblemBuffer(); - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemBuffer.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemBuffer.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemBuffer.java (working copy) @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.reporting; - -import java.io.File; - -//import org.eclipse.core.internal.runtime.PlatformLogWriter; -//import org.eclipse.core.runtime.ILogListener; -//import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -//import org.eclipse.core.runtime.adaptor.EclipseLog; -//import org.eclipse.osgi.framework.log.FrameworkLog; -import org.jboss.tools.common.util.FileUtil; -import org.osgi.framework.Bundle; - -/** - * This class is intended only to be called by Report Problem Framework. - * @author glory - */ -public class ProblemBuffer { - - ProblemBuffer() {} - - //TODO remove dead commented code. - /** - * IProblemReporter implementation. - * @param status - */ -// public void writeToBuffer(IStatus status) { -// getEclipseLog(); -// writer.logging(status, "org.jboss.tools.common"); //$NON-NLS-1$ -// } - - /** - * Returns number of entries in .log file. - * @return number of entries in .log file - */ - public int getSize() { - String s = getContent(); - if(s.length() == 0) { - return 0; - } - int i = 0; - int c = 0; - while(i < s.length()) { - i = s.indexOf("!ENTRY", i); //$NON-NLS-1$ - if(i >= 0) { - ++c; - ++i; - } else { - break; - } - } - return c; - } - - /** - * Returns content of .log file. - * @return content of .log file - */ - public String getContent() { - File f = getLogFile(); - return (!f.isFile()) ? "" : FileUtil.readFile(f); //$NON-NLS-1$ - } - - public String getEclipseLogContent() { - File f = Platform.getLogFileLocation().toFile(); - return (f.isFile()) ? FileUtil.readFile(f) : ""; //$NON-NLS-1$ - } - - public void clean() { - File f = getLogFile(); - if(f.exists()) { - f.delete(); - } - } - - /** - * @param text - * @param userEMail - * @param other - */ - public void report(String text, String userEMail, String other, boolean cleanBuffer) { - StringBuffer sb = new StringBuffer(); - if(userEMail != null && userEMail.trim().length() > 0) { - sb.append("Customer e-mail=" + userEMail + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - } - if(other != null && other.length() > 0) { - sb.append("Other=" + other + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - } - if(text != null) { - sb.append(text); - } - String reportText = sb.toString(); - Submit.getInstance().submit(reportText, cleanBuffer); - } - -// FrameworkLog log; -// ILogListener writer; - -// private FrameworkLog getEclipseLog() { -// if(log == null) { -// log = new EclipseLog(getLogFile()); -// writer = new PlatformLogWriter(log); -// } -// return log; -// } - - private File getLogFile() { - Bundle b = Platform.getBundle("org.jboss.tools.common"); //$NON-NLS-1$ - String stateLocation = Platform.getStateLocation(b).toString().replace('\\', '/'); - String logLocation = stateLocation + "/.log"; //$NON-NLS-1$ - return new File(logLocation); - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemReporterFactory.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemReporterFactory.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/ProblemReporterFactory.java (working copy) @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.reporting; - -/** - * This class manages IProblemReporter implementations. - * @author glory - */ -public class ProblemReporterFactory { - private static ProblemReporterFactory instance = new ProblemReporterFactory(); - - public static ProblemReporterFactory getInstance() { - return instance; - } - IProblemReporter defaultReporter = new DefaultProblemReporter(); - IProblemReporter reporter = null; - - public void setReporter(IProblemReporter reporter) { - this.reporter = reporter; - } - - public IProblemReporter getProblemReporter() { - return reporter == null ? defaultReporter : reporter; - } - - public IProblemReporter getDefaultProblemReporter() { - return defaultReporter; - } - - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/IProblemReporter.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/IProblemReporter.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/reporting/IProblemReporter.java (working copy) @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.reporting; - -import org.eclipse.core.runtime.IStatus; - -/** - * Interface for processing all throwables caught in Red Hat code. - * @author glory - */ -public interface IProblemReporter { - public void reportProblem(IStatus status); -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/web/WebUtils.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/web/WebUtils.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/web/WebUtils.java (working copy) @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.web; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; -import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.jboss.tools.common.CommonPlugin; - -public class WebUtils { - - public static IPath[] getWebInfPaths(IProject project) { - IVirtualComponent component = ComponentCore.createComponent(project); - if(component != null && component.getRootFolder() != null) { - List ps = new ArrayList(); - IContainer[] cs = getWebRootFolders(project, true); - for (IContainer c: cs) { - if(c.exists()) { - IFolder f = c.getFolder(new Path("/WEB-INF")); //$NON-NLS-1$ - if(f.exists()) { - ps.add(f.getFullPath()); - } - } - } - return ps.toArray(new IPath[ps.size()]); - } - return new IPath[0]; - } - - public static IPath[] getWebContentPaths(IProject project) { - IVirtualComponent component = ComponentCore.createComponent(project); - if(component != null && component.getRootFolder() != null) { - - List ps = new ArrayList(); - IContainer[] cs = getWebRootFolders(project, true); - for (IContainer c: cs) { - if(c.exists()) { - ps.add(c.getFullPath()); - } - } - return ps.toArray(new IPath[ps.size()]); - } - return new IPath[0]; - } - - public static IPath getFirstWebContentPath(IProject project) { - IPath modulePath = null; - IVirtualComponent vc = ComponentCore.createComponent(project); - if (vc == null || vc.getRootFolder() == null) - return null; - IContainer[] cs = getWebRootFolders(project, true); - for (IContainer c: cs) { - if(c.exists()) { - return c.getFullPath(); - } - } - return modulePath; - } - - public static IContainer[] getWebRootFolders(IProject project, boolean ignoreDerived) { - IFacetedProject facetedProject = null; - try { - facetedProject = ProjectFacetsManager.create(project); - } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); - } - if(facetedProject!=null && facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) { - IVirtualComponent component = ComponentCore.createComponent(project); - if(component!=null) { - IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new Path("/")); //$NON-NLS-1$ - - IPath defaultPath = getDefaultDeploymentDescriptorFolder(webRootVirtFolder); - - IContainer[] folders = webRootVirtFolder.getUnderlyingFolders(); - if(folders.length > 1){ - ArrayList containers = new ArrayList(); - for(IContainer container : folders){ - if(!ignoreDerived || !container.isDerived(IResource.CHECK_ANCESTORS)) { - if(defaultPath!=null && defaultPath.equals(container.getFullPath())) { - containers.add(0, container); // Put default root folder to the first position of the list - } else { - containers.add(container); - } - } - } - return containers.toArray(new IContainer[containers.size()]); - } else { - return folders; - } - } - } - return EMPTY_ARRAY; - } - - private static final IContainer[] EMPTY_ARRAY = new IContainer[0]; - private static boolean WTP_3_3_0 = false; - - /** - * Returns all the web root folders of the project. - * If the project is not a web project then the method will return an empty array. - * All the derived resources or resources belonged to derived containers will be eliminated. - * If some folder is set as default web root source folder (available since WTP 3.3.1) then this folder will be places in the very beginning of the result array. - * @param project - * @return - */ - public static IPath getDefaultDeploymentDescriptorFolder(IVirtualFolder folder) { - if(!WTP_3_3_0) { - try { - Method getDefaultDeploymentDescriptorFolder = J2EEModuleVirtualComponent.class.getMethod("getDefaultDeploymentDescriptorFolder", IVirtualFolder.class); //$NON-NLS-1$ - return (IPath) getDefaultDeploymentDescriptorFolder.invoke(null, folder); - } catch (NoSuchMethodException nsme) { - // Not available in this WTP version, let's ignore it - WTP_3_3_0 = true; - } catch (IllegalArgumentException e) { - CommonPlugin.getDefault().logError(e); - } catch (IllegalAccessException e) { - CommonPlugin.getDefault().logError(e); - } catch (InvocationTargetException e) { - // Not available in this WTP version, let's ignore it - WTP_3_3_0 = true; - } - } - return null; - } - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java (working copy) @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.util; - -import org.eclipse.jdt.core.IMethod; - -/** - * - * @author V. Kabanovich - * - */ -public class BeanUtil { - public static final String GET = "get"; //$NON-NLS-1$ - public static final String SET = "set"; //$NON-NLS-1$ - public static final String IS = "is"; //$NON-NLS-1$ - - public static boolean isGetter(String methodName, int numberOfParameters) { - return (((methodName.startsWith(GET) && !methodName.equals(GET)) - || (methodName.startsWith(IS) && !methodName.equals(IS))) - && numberOfParameters == 0); - } - - public static boolean isSetter(String methodName, int numberOfParameters) { - return (((methodName.startsWith(SET) && !methodName.equals(SET))) - && numberOfParameters == 1); - } - - public static boolean isGetter(IMethod method) { - return method != null && isGetter(method.getElementName(), method.getNumberOfParameters()) - && checkPropertyReturnType(method); - } - - - public static boolean checkPropertyReturnType(String typeName, String methodName) { - if(typeName == null || typeName.equals("void")) { //$NON-NLS-1$ - return false; - } - if(methodName.startsWith(BeanUtil.IS)) { - if(!"boolean".equals(typeName) && !"java.lang.Boolean".equals(typeName)) { //$NON-NLS-1$ //$NON-NLS-2$ - return false; - } - } - return true; - } - - private static boolean checkPropertyReturnType(IMethod method) { - return method != null && checkPropertyReturnType(EclipseJavaUtil.getMemberTypeAsString(method), method.getElementName()); - } - - public static boolean isSetter(IMethod method) { - return method != null && isSetter(method.getElementName(), method.getNumberOfParameters()); - } - - public static String getPropertyName(String methodName) { - if(isGetter(methodName, 0) || isSetter(methodName, 1)) { - StringBuffer name = new StringBuffer(methodName); - if(methodName.startsWith(IS)) { - name.delete(0, 2); - } else { - name.delete(0, 3); - } - if(name.length() < 2 || !Character.isUpperCase(name.charAt(1))) { - name.setCharAt(0, Character.toLowerCase(name.charAt(0))); - } - return name.toString(); - } - return null; - } - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/StringUtil.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/StringUtil.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/StringUtil.java (working copy) @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ - -package org.jboss.tools.common.util; - -/** - * Miscellaneous String utility functions - * - * @author Victor V. Rubezhny - */ -public class StringUtil { -/** - * Cuts of the starting and ending quotes from a given text value - * - * @param Quoted text value - * @return Non-quoted text value - */ - public static String trimQuotes(String value) { - if(value == null) - return null; - - if(value.startsWith("'") || value.startsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$ - value = value.substring(1); - } - - if(value.endsWith("'") || value.endsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$ - value = value.substring(0, value.length() - 1); - } - return value; - } - -} Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java (working copy) @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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: - * Exadel, Inc. and Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.util; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; -import org.jboss.tools.common.CommonPlugin; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * HTTP Utilities - * @author Alexey Kazakov - */ -public class HttpUtil { - - private static IProxyService proxyService; - - /** - * @param url - * @return InputStream of responce to http GET request. Use proxy settings from preferences. - * @throws Exception - */ - public static InputStream getInputStreamFromUrlByGetMethod(String url) throws IOException { - InputStream is = executeGetMethod(url).getResponseBodyAsStream(); - return is; - } - - /** - * @param url - * @return InputStream of responce to http GET request. Use proxy settings from preferences. - * @throws Exception - */ - public static InputStream getInputStreamFromUrlByGetMethod(String url, IProxyService proxyService) throws IOException { - InputStream is = executeGetMethod(url, proxyService).getResponseBodyAsStream(); - return is; - } - - /** - * @param url - * @param proxyService - * @return Status code of responce to http GET request. Use given proxy settings. - * @throws Exception - */ - public static int getStatusCodeFromUrlByGetMethod(String url, IProxyService proxyService) throws IOException { - int code = executeGetMethod(url, proxyService).getStatusCode(); - return code; - } - - /** - * @param url - * @return Status code of responce to http GET request. Use proxy settings from preferences. - * @throws Exception - */ - public static int getStatusCodeFromUrlByGetMethod(String url) throws IOException { - int code = executeGetMethod(url).getStatusCode(); - return code; - } - - /** - * @param url - * @return InputStream of responce to http POST request. Use proxy settings from preferences. - * @throws Exception - */ - public static InputStream getInputStreamFromUrlByPostMethod(String url) throws IOException { - InputStream is = executePostMethod(url).getResponseBodyAsStream(); - return is; - } - - /** - * @param url - * @param proxyService - * @return Status code of responce to http POST request. Use given proxy settings. - * @throws Exception - */ - public static int getStatusCodeFromUrlByPostMethod(String url, IProxyService proxyService) throws IOException { - int code = executePostMethod(url, proxyService).getStatusCode(); - return code; - } - - /** - * @param url - * @return Status code of responce to http POST request. Use proxy settings from preferences. - * @throws Exception - */ - public static int getStatusCodeFromUrlByPostMethod(String url) throws IOException { - int code = executePostMethod(url).getStatusCode(); - return code; - } - - private static GetMethod executeGetMethod(String url) throws IOException { - IProxyService proxyService = getProxyService(); - return executeGetMethod(url, proxyService); - } - - private static PostMethod executePostMethod(String url) throws IOException { - IProxyService proxyService = getProxyService(); - return executePostMethod(url, proxyService); - } - - /** - * @param url - * @param proxyService - * @return - * @throws Exception - */ - public static GetMethod executeGetMethod(String url, IProxyService proxyService) throws IOException { - GetMethod httpGet = new GetMethod(url); - HttpClient httpClient = createHttpClient(url, proxyService); - httpClient.executeMethod(httpGet); - return httpGet; - } - - private static PostMethod executePostMethod(String url, IProxyService proxyService) throws IOException { - PostMethod httpPost = new PostMethod(url); - HttpClient httpClient = createHttpClient(url, proxyService); - httpClient.executeMethod(httpPost); - return httpPost; - } - - /** - * @param url - * @return HttpClient with internet proxy settings; - * @throws Exception - */ - public static HttpClient createHttpClient(String url) throws IOException { - return createHttpClient(url, getProxyService()); - } - - private static HttpClient createHttpClient(String url, IProxyService proxyService) throws IOException { - HttpClient httpClient = new HttpClient(); - - if(proxyService.isProxiesEnabled()) { - IProxyData[] proxyData = proxyService.getProxyData(); - URL netUrl = new URL(url); - String hostName = netUrl.getHost(); - String[] nonProxiedHosts = proxyService.getNonProxiedHosts(); - boolean nonProxiedHost = false; - for (int i = 0; i < nonProxiedHosts.length; i++) { - String nonProxiedHostName = nonProxiedHosts[i]; - if(nonProxiedHostName.equalsIgnoreCase(hostName)) { - nonProxiedHost = true; - break; - } - } - if(!nonProxiedHost) { - for (int i = 0; i < proxyData.length; i++) { - IProxyData proxy = proxyData[i]; - if(IProxyData.HTTP_PROXY_TYPE.equals(proxy.getType())) { - String proxyHostName = proxy.getHost(); - if(proxyHostName==null) { - break; - } - int portNumber = proxy.getPort(); - if(portNumber==-1) { - portNumber = 80; - } - httpClient.getHostConfiguration().setProxy(proxyHostName, portNumber); - if(proxy.isRequiresAuthentication()) { - String userName = proxy.getUserId(); - if(userName!=null) { - String password = proxy.getPassword(); - httpClient.getState().setProxyCredentials(new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME), new UsernamePasswordCredentials(userName, password)); - } - } - break; // Use HTTP proxy only. - } - } - } - } - - httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); - - return httpClient; - } - - private static IProxyService getProxyService() { - if(proxyService==null) { - BundleContext bundleContext = CommonPlugin.getInstance().getBundle().getBundleContext(); - ServiceReference serviceReference = bundleContext.getServiceReference(IProxyService.class.getName()); - proxyService = (IProxyService)bundleContext.getService(serviceReference); - } - return proxyService; - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java (working copy) @@ -10,42 +10,12 @@ ******************************************************************************/ package org.jboss.tools.common.util; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.IFileBuffer; import org.eclipse.core.filebuffers.ITextFileBuffer; import org.eclipse.core.filebuffers.LocationKind; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; @@ -53,686 +23,10 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.jboss.tools.common.CommonPlugin; -public final class FileUtil { +public final class FileUtil extends FileUtils { public FileUtil() {} - public static String getEncoding(IFile f) { - String encoding = null; - if(f != null && f.exists() && f.isSynchronized(0)) try { - encoding = f.getCharset(); - } catch (CoreException e) { - CommonPlugin.getPluginLog().logError(e); - } - return encoding != null ? encoding : "8859_1"; //$NON-NLS-1$ - } - - public static String readFile(File f) { - if(!f.isFile()) return ""; //$NON-NLS-1$ - ReadBytes bs = readBytes(f); - if(bs == null) return ""; //$NON-NLS-1$ - String encoding = getEncoding(bs.bs); - if(encoding == null) return new String(bs.bs, 0, bs.length); - try { - return new String(bs.bs, 0, bs.length, encoding); - } catch (UnsupportedEncodingException e) { - return new String(bs.bs, 0, bs.length); - } - } - - public static String readFileWithEncodingCheck(File f, String defaultEncoding) { - if(!f.isFile()) return ""; //$NON-NLS-1$ - ReadBytes bs = readBytes(f); - if(bs == null) return ""; //$NON-NLS-1$ - String encoding = getEncoding(bs.bs); - if(encoding == null) encoding = validateEncoding(defaultEncoding, null); - if(encoding == null) return new String(bs.bs, 0, bs.length); - try { - return new String(bs.bs, 0, bs.length, encoding); - } catch (UnsupportedEncodingException e) { - return new String(bs.bs, 0, bs.length); - } - } - - public static ReadBytes readBytes(File f) { - if(!f.isFile()) return null; - BufferedInputStream br = null; - try { - FileInputStream fr = new FileInputStream(f); - br = new BufferedInputStream(fr); - int l = (int)f.length(); - byte[] bs = new byte[l]; - l = br.read(bs, 0, l); - br.close(); - fr.close(); - return new ReadBytes(bs, l); - } catch (IOException e) { - return null; - } finally { - if(br!=null) { - try { - br.close(); - } catch (IOException e) { - //ignore - } - } - } - } - - static class ReadBytes { - byte[] bs; - int length; - - ReadBytes(byte[] bs, int l) { - this.bs = bs; - length = l; - } - } - - public static String readFile(File f, String encoding) { - ReadBytes bs = readBytes(f); - if(bs == null) return null; - try { - return new String(bs.bs, 0, bs.length, encoding); - } catch (UnsupportedEncodingException e) { - return null; - } - } - - public static boolean isTextFile(File f, int length) { - if(!f.isFile()) return false; - BufferedReader br = null; - try { - FileReader fr = new FileReader(f); - br = new BufferedReader(fr); - int l = (int)f.length(); - if(l > length) l = length; - char[] cs = new char[l]; - br.read(cs, 0, l); - br.close(); - fr.close(); - return isText(new String(cs)); - } catch (IOException e) { - return false; - } finally { - if(br!=null) { - try { - br.close(); - } catch (IOException e) { - // ignore - } - } - } - } - - public static boolean isText(String body) { - if(body == null) return false; - int l = body.length(); - for (int i = 0; i < l; i++) { - char c = body.charAt(i); - if(((int)c) < 32 && c != '\n' && c != '\r' && c != 't') return false; - } - return true; - } - - // FIXME Size of string buffer should be set to size of file by default - // to avoid StringBuffer extension on each append - public static String readStream(InputStream is) { - StringBuffer sb = new StringBuffer(""); //$NON-NLS-1$ - try { - byte[] b = new byte[4096]; - while(true) { - int l = is.read(b, 0, b.length); - if(l < 0) break; - sb.append(new String(b, 0, l)); - } - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } finally { - try { - is.close(); - } catch (IOException e) { - // Ignore - } - } - return sb.toString(); - } - - public static String readStream(IFile file) throws CoreException { - String content = null; - InputStream in = null; - try { - String charset = file.getCharset(); - if(charset != null) { - charset = validateEncoding(charset, null); - } - in = file.getContents(); - content = (charset == null) ? readStream(in) : readStream(in, charset); - } finally { - if(in!=null) { - try { - in.close(); - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } - } - } - return content; - } - - public static String readStream(InputStream is, String charset) { - StringBuffer sb = new StringBuffer(""); //$NON-NLS-1$ - try { - byte[] b = new byte[4096]; - while(true) { - int l = is.read(b, 0, b.length); - if(l < 0) break; - sb.append(new String(b, 0, l, charset)); - } - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } finally { - try { - is.close(); - } catch (IOException e) { - // Ignore - } - } - - return sb.toString(); - } - - public static void copyContent(IFile from, IFile to, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { - InputStream is = null; - try { - is = from.getContents(); - to.setContents(is, force, keepHistory, monitor); - } finally { - if(is!=null) { - try { - is.close(); - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } - } - } - } - - public static boolean writeFile(File f, String value) { - return writeFileWithEncodingCheck(f, value, null); - } - - public static boolean writeFileWithEncodingCheck(File f, String value, String defaultEncoding) { - if(value == null) return false; - String encoding = getEncoding(value); - if(encoding == null) encoding = validateEncoding(defaultEncoding, null); - if(value.startsWith(" 0) { - os.write(buffer, 0, r); - } else if (r == -1) break; - } - os.flush(); - } - - public static void clear(File f) { - if (f.isDirectory()) { - File[] fs = f.listFiles(); - for (int i = 0; i < fs.length; i++) { - remove(fs[i]); - } - } - } - - public static void remove(File f) { - if (f.isFile()) { - f.delete(); - } else if (f.isDirectory()) { - File[] fs = f.listFiles(); - for (int i = 0; i < fs.length; i++) { - remove(fs[i]); - } - f.delete(); - } - } - - public static boolean isSameFile(File f) { - if(!f.exists()) return false; - String fn = f.getName(); - try { - String cn = f.getCanonicalFile().getName(); - return fn.equals(cn); - } catch (IOException e) { - return false; - } - } - - public static void copyDir(File from, File to) { - copyDir(from, to, false); - } - - public static void copyDir(File from, File to, boolean mkdirs) { - copyDir(from, to, mkdirs, true); - } - - public static void copyDir(File from, File to, boolean mkdirs, boolean includeSubdirs) { - copyDir(from, to, includeSubdirs, mkdirs, false); - } - - public static void copyDir(File from, boolean includeSubdirs, File to) { - copyDir(from, to, includeSubdirs, false, false); - } - - public static void copyDir(File from, File to, boolean includeSubdirs, boolean mkdirs, boolean overwriteOnlyOlderFiles) { - copyDir(from, to, includeSubdirs, mkdirs, overwriteOnlyOlderFiles, null); - } - - public static void copyDir(File from, File to, boolean includeSubdirs, boolean mkdirs, boolean overwriteOnlyOlderFiles, FileFilter filter) { - if(filter != null && !filter.accept(from)) return; - if (mkdirs) to.mkdirs(); - if(from == null || !from.isDirectory() || !to.isDirectory()) return; - File[] fs = from.listFiles(); - if(fs == null) return; - for (int i = 0; i < fs.length; i++) { - String n = fs[i].getName(); - File c = new File(to, n); - if (fs[i].isDirectory() && !includeSubdirs) continue; - if(filter != null && !filter.accept(new File(from, n))) continue; - - if(fs[i].isDirectory()) { - c.mkdirs(); - copyDir(fs[i], c, includeSubdirs, mkdirs, overwriteOnlyOlderFiles, filter); - } else if (overwriteOnlyOlderFiles && fs[i].isFile() && c.isFile()) { - copyFile(fs[i], c, false, c.lastModified() < fs[i].lastModified()); - } else { - copyFile(fs[i], c); - } - } - } - - public static void unjar(File dest, String jar) throws IOException { - dest.mkdirs(); - JarFile jf = new JarFile(jar); - try { - Enumeration es = jf.entries(); - while(es.hasMoreElements()) { - JarEntry je = (JarEntry)es.nextElement(); - String n = je.getName(); - File f = new File(dest, n); - if (je.isDirectory()) { - f.mkdirs(); - } else { - if (f.exists()) { - f.delete(); - } else { - f.getParentFile().mkdirs(); - } - InputStream is = jf.getInputStream(je); - FileOutputStream os = new FileOutputStream(f); - try { - copyStream(is, os); - } finally { - os.close(); - } - } - long time = je.getTime(); - if (time != -1) f.setLastModified(time); - } - } finally { - jf.close(); - } - } - - public static void unjar(File dest, InputStream is) throws IOException { - dest.mkdirs(); - JarInputStream jis = new JarInputStream(is); - try { - while(true) { - JarEntry je = jis.getNextJarEntry(); - if (je == null) break; - String n = je.getName(); - File f = new File(dest, n); - if (je.isDirectory()) { - f.mkdirs(); - } else { - if (f.exists()) { - f.delete(); - } else { - f.getParentFile().mkdirs(); - } - FileOutputStream os = new FileOutputStream(f); - try { - copyStream(jis, os); - } finally { - os.close(); - } - } - long time = je.getTime(); - if (time != -1) f.setLastModified(time); - } - } finally { - jis.close(); - } - } - - public static void jar(File[] fs, String path) throws IOException { - jar(fs, path, null); - } - - public static void jar(File[] fs, String path, Manifest mf) throws IOException { - File f = new File(path); - FileOutputStream fos = new FileOutputStream(f); - JarOutputStream jos = mf == null ? new JarOutputStream(fos) : new JarOutputStream(fos, mf); - try { - for (int i = 0; i < fs.length; i++) add(fs[i].getParentFile(), fs[i], jos); - } finally { - jos.close(); - fos.close(); - } - } - - public static void add(File root, File f, JarOutputStream jos) throws IOException { - int l = root.getAbsolutePath().length(); - String en = f.getAbsolutePath().substring(l + 1).replace('\\', '/'); - add(f, en, jos); - } - - public static void add(File f, String name, JarOutputStream jos) throws IOException { - String en = name; - if(f.isDirectory()) en += "/"; //$NON-NLS-1$ - JarEntry entry = (en.endsWith("/")) ? null : new JarEntry(en); //$NON-NLS-1$ - if(f.isDirectory()) { - if("/".equals(en)) en = ""; //$NON-NLS-1$ //$NON-NLS-2$ - File[] fs = f.listFiles(); - if(fs != null) for (int i = 0; i < fs.length; i++) - add(fs[i], en + fs[i].getName(), jos); - } else { - try { - jos.putNextEntry(entry); - } catch (IOException e) { - return; - } - FileInputStream is = new FileInputStream(f); - byte[] b = new byte[1024]; - int q = 0; - while((q = is.available()) > 0) { - if(q > 1024) q = 1024; - q = is.read(b, 0, q); - jos.write(b, 0, q); - } - is.close(); - } - if(entry != null) jos.closeEntry(); - } - - public static void copy(InputStream f, OutputStream t) throws IOException { - try { - byte[] b = new byte[1024]; - int q = 0; - while((q = f.read(b, 0, b.length)) > 0) t.write(b, 0, q); - } finally { - f.close(); - t.close(); - } - } - - public static void unzip(File dest, String jar) throws IOException { - dest.mkdirs(); - ZipFile zf = new ZipFile(jar); - try { - Enumeration es = zf.entries(); - while(es.hasMoreElements()) { - ZipEntry je = (ZipEntry)es.nextElement(); - String n = je.getName(); - File f = new File(dest, n); - if (je.isDirectory()) { - f.mkdirs(); - } else { - if (f.exists()) { - f.delete(); - } else { - f.getParentFile().mkdirs(); - } - InputStream is = zf.getInputStream(je); - FileOutputStream os = new FileOutputStream(f); - try { - copyStream(is, os); - } finally { - os.close(); - } - } - long time = je.getTime(); - if (time != -1) f.setLastModified(time); - } - } finally { - zf.close(); - } - } - - public static String fileURLToFilePath(String url) { - if(url == null) return null; - String resultUrl = url.replace('\\', '/'); -/// if(!url.startsWith("file:/")) return url; - if(!resultUrl.startsWith("file:")) return resultUrl; //$NON-NLS-1$ - int iLast = resultUrl.lastIndexOf(':'), iFirst = resultUrl.indexOf(':'); - return (iLast == iFirst) ? resultUrl.substring(5) : resultUrl.substring(iLast - 1); - } - - //// Relative path - - public static String getRelativePath(String rootpath, String path) { - String[] r = tokenizePath(rootpath); - String[] p = tokenizePath(path); - if(r.length == 0 || p.length == 0 || !r[0].equalsIgnoreCase(p[0])) return null; - int i = 0; - while(i < r.length && i < p.length && r[i].equalsIgnoreCase(p[i])) ++i; - StringBuffer sb = new StringBuffer(); - for (int k = i; k < r.length; k++) sb.append("/.."); //$NON-NLS-1$ - for (int k = i; k < p.length; k++) sb.append("/").append(p[k]); //$NON-NLS-1$ - return sb.toString(); - } - - private static String[] tokenizePath(String path) { - String tokenizedPath = path.replace('\\', '/'); - StringTokenizer st = new StringTokenizer(tokenizedPath, "/"); //$NON-NLS-1$ - ArrayList l = new ArrayList(); - while(st.hasMoreTokens()) { - String t = st.nextToken(); - if(t.isEmpty() || ".".equals(t)) continue; //$NON-NLS-1$ - if("..".equals(t)) { //$NON-NLS-1$ - if(!l.isEmpty()) l.remove(l.size() - 1); - continue; - } - l.add(t); - } - return (String[])l.toArray(new String[l.size()]); - } - - public static boolean writeFile(File f, String value, String encoding) { - try { - try { - if(f.isFile() && !isSameFile(f)) f.delete(); - if(!f.exists()) { - f.getParentFile().mkdirs(); - f.createNewFile(); - } - } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); - } - FileOutputStream fs = new FileOutputStream(f); - OutputStreamWriter osw = new OutputStreamWriter(fs, encoding); - PrintWriter pw = new PrintWriter(osw); - pw.print(value); - pw.flush(); - pw.close(); - return true; - } catch (FileNotFoundException e) { - //ignore - return writeFileDefault(f, value); - } catch (UnsupportedEncodingException e) { - //ignore - return writeFileDefault(f, value); - } - } - - - public static String getEncoding(String s) { - if(s == null) return null; - if(s.startsWith(" getSupperTypes(IType type) throws JavaModelException { - ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor()); - IType[] superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type); - if(superTypes == null) { - return Collections.emptyList(); - } - List suppers = new ArrayList(); - for (int i = 0; i < superTypes.length; i++) { - suppers.add(superTypes[i]); - } - return suppers; - } - - public static IAnnotation findAnnotation(IType sourceType, IAnnotatable member, String qulifiedAnnotationName) throws JavaModelException{ - IAnnotation[] annotations = member.getAnnotations(); - String simpleAnnotationTypeName = qulifiedAnnotationName; - int lastDot = qulifiedAnnotationName.lastIndexOf('.'); - if(lastDot>-1) { - simpleAnnotationTypeName = simpleAnnotationTypeName.substring(lastDot + 1); - } - for (IAnnotation annotation : annotations) { - if(qulifiedAnnotationName.equals(annotation.getElementName())) { - return annotation; - } - if(simpleAnnotationTypeName.equals(annotation.getElementName())) { - String fullAnnotationclassName = EclipseJavaUtil.resolveType(sourceType, simpleAnnotationTypeName); - if(fullAnnotationclassName!=null) { - IType annotationType = sourceType.getJavaProject().findType(fullAnnotationclassName); - if(annotationType!=null && annotationType.getFullyQualifiedName().equals(qulifiedAnnotationName)) { - return annotation; - } - } - } - } - return null; - } - - /** - * Finds field declared in the given type or its super types. - * - * @param type - * @param name - * @return - * @throws CoreException - */ - public static IField findField(IType type, String name) throws CoreException { - return findField(type, name, new HashSet()); - } - private static IField findField(IType type, String name, Set processed) throws CoreException { - if(!type.exists() || processed.contains(type)) { - return null; - } - processed.add(type); - if(type.getField(name).exists()) { - return type.getField(name); - } - IField f = findField(type, type.getSuperclassName(), name, processed); - String[] is = type.getSuperInterfaceNames(); - for (int i = 0; f == null && i < is.length; i++) { - f = findField(type, is[i], name, processed); - } - if(f == null) { - IType d = type.getDeclaringType(); - if(d != null && d != type && d.exists()) { - f = findField(d, name); - } - } - - return f; - } - private static IField findField(IType context, String typeName, String fieldName, Set processed) throws CoreException { - typeName = resolveType(context, typeName); - if(typeName != null) { - IType s = findType(context.getJavaProject(), typeName); - return (s != null) ? findField(s, fieldName, processed) : null; - } - return null; - } - - /** - * Returns true if the given annotation has the given full name - * @param annotation - * @param fullName - * @return - * @throws JavaModelException - */ - public static boolean checkAnnotationByFulltName(IAnnotation annotation, String fullName) throws JavaModelException { - if(annotation.getElementName().equals(fullName)) { - return true; - } - boolean result = true; - IType sourceType = null; - IJavaElement parent = annotation.getParent(); - if(parent instanceof IMember) { - if(parent instanceof IType) { - sourceType = (IType)parent; - } else { - sourceType = ((IMember)parent).getDeclaringType(); - } - String fullAnnotationName = EclipseJavaUtil.resolveType(sourceType, annotation.getElementName()); - if(fullAnnotationName!=null) { - IType annotationType = sourceType.getJavaProject().findType(fullAnnotationName); - result = annotationType!=null && annotationType.getFullyQualifiedName().equals(fullName); - } else { - result = false; - } - } - return result; - } - - /** - * Returns annotation by the short name declared for the given java member and its parents. - * Returns null if no annotation found. - * @param member - * @param name - * @param checkParents - * @return - * @throws JavaModelException - */ - public static Set findAnnotationsByShortName(IJavaElement element, String name, boolean checkParents) throws JavaModelException { - return findAnnotationsByShortName(null, element, name, checkParents); - } - - private static Set findAnnotationsByShortName(Set result, IJavaElement element, String name, boolean checkParents) throws JavaModelException { - if(element instanceof IAnnotatable) { - IAnnotation[] annotations = ((IAnnotatable)element).getAnnotations(); - for (IAnnotation annotation : annotations) { - String aName = annotation.getElementName(); - int i = aName.lastIndexOf('.'); - if(i>-1) { - aName = aName.substring(i+1); - } - if(aName.equals(name)) { - if(result==null) { - result = new HashSet(); - } - result.add(annotation); - break; - } - } - } - if(checkParents) { - IJavaElement parent = element.getParent(); - if(parent instanceof IAnnotatable) { - return findAnnotationsByShortName(result, parent, name, true); - } - } - return result; - } -} \ No newline at end of file Index: plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/TypeResolutionCache.java =================================================================== --- plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/TypeResolutionCache.java (revision 43203) +++ plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/TypeResolutionCache.java (working copy) @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 - 2012 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is 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 - * - * Contributor: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package org.jboss.tools.common.util; - -import java.util.Hashtable; -import java.util.Map; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.jboss.tools.common.CommonPlugin; - -public class TypeResolutionCache { - private static TypeResolutionCache instance = new TypeResolutionCache(); - - public static TypeResolutionCache getInstance() { - return instance; - } - - static class Resolved { - IType type; - Map types = new Hashtable(); - Resolved(IType type) { - this.type = type; - } - - void setType(IType type) { - this.type = type; - types.clear(); - } - } - - static String NULL = ";;;"; //$NON-NLS-1$ - Map resolved = new Hashtable(); - - private TypeResolutionCache() {} - - public String resolveType(IType type, String typeName) { - if(type == null) return null; - if(type.isBinary() || typeName == null) return typeName; - - String n = getKey(type); - Resolved r = resolved.get(n); - if(r == null) { - r = new Resolved(type); - resolved.put(n, r); - } else if(r.type != type) { - r.setType(type); - } - - String result = r.types.get(typeName); - if(result != null) { - return (result == NULL) ? null : result; - } - - result = __resolveType(type, typeName); - - r.types.put(typeName, result == null ? NULL : result); - return result; - - } - - public void clean() { - resolved = new Hashtable(); - } - - private String __resolveType(IType type, String typeName) { - try { - String resolvedArray[][] = type.resolveType(typeName); -// resolvedArray == null for primitive types - if(resolvedArray == null) return typeName; - typeName = ""; //$NON-NLS-1$ - for (int i = 0; i < resolvedArray[0].length; i++) - typeName += (!"".equals(typeName) ? "." : "") + resolvedArray[0][i]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return typeName; - } catch (JavaModelException e) { - CommonPlugin.getPluginLog().logError(e); - } catch (IllegalArgumentException e) { - CommonPlugin.getPluginLog().logError(e); - } - return null; - } - - private String getKey(IType type) { - String n = type.getFullyQualifiedName(); - IJavaProject jp = type.getJavaProject(); - if(jp == null) return n; - IProject p = jp.getProject(); - if(p == null || !p.isAccessible()) return n; - return p.getName() + ":" + n; //$NON-NLS-1$ - } - -} Index: plugins/pom.xml =================================================================== --- plugins/pom.xml (revision 43203) +++ plugins/pom.xml (working copy) @@ -12,6 +12,7 @@ pom + org.jboss.tools.common.core org.jboss.tools.common org.jboss.tools.common.el.core org.jboss.tools.common.el.ui Index: plugins/org.jboss.tools.common.core/about.html =================================================================== --- plugins/org.jboss.tools.common.core/about.html (revision 0) +++ plugins/org.jboss.tools.common.core/about.html (working copy) @@ -0,0 +1,34 @@ + + + + +About + + + + + +

About This Content

+ +

©2007 - 2012 Red Hat, Inc. All rights reserved

+ +

License

+ +

Red Hat Inc., through its JBoss division, makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to you +under the terms and conditions of the Eclipse Public License Version 1.0 +("EPL"). A copy of the EPL is available at +http://www.eclipse.org/org/documents/epl-v10.php. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from Red Hat Inc., the +Content is being redistributed by another party ("Redistributor") and different +terms and conditions may apply to your use of any object code in the Content. +Check the Redistributor's license that was provided with the Content. If no such +license exists, contact the Redistributor. Unless otherwise indicated below, the +terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at + http://www.jboss.org/tools.

+ + + \ No newline at end of file Index: plugins/org.jboss.tools.common.core/.project =================================================================== --- plugins/org.jboss.tools.common.core/.project (revision 0) +++ plugins/org.jboss.tools.common.core/.project (working copy) @@ -0,0 +1,34 @@ + + + org.jboss.tools.common.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + org.eclipse.pde.api.tools.apiAnalysisNature + + Property changes on: plugins/org.jboss.tools.common.core/.project ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLUtilities.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLUtilities.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLUtilities.java (working copy) @@ -30,8 +30,8 @@ import org.apache.xml.serialize.Method; import org.apache.xml.serialize.OutputFormat; import org.apache.xml.serialize.XMLSerializer; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.Messages; +import org.jboss.tools.common.core.CommonCorePlugin; +import org.jboss.tools.common.core.Messages; import org.w3c.dom.Comment; import org.w3c.dom.DOMException; import org.w3c.dom.DOMImplementation; @@ -136,7 +136,7 @@ d.setErrorHandler(new ErrorHandlerImpl()); return d; } catch (ParserConfigurationException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } return null; } @@ -196,18 +196,18 @@ org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(fr); return getElement(inSource, resolver); } catch (FileNotFoundException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } catch (SAXException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } finally { try { if (fr != null) { fr.close(); } } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } } return null; Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/DtdResolver.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/DtdResolver.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/DtdResolver.java (working copy) @@ -23,7 +23,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Platform; import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.jboss.tools.common.util.HttpUtil; import org.osgi.framework.Bundle; import org.xml.sax.EntityResolver; @@ -72,7 +72,7 @@ if(location == null) { if(systemId != null && !unfound.contains(systemId)) { unfound.add(systemId); -// CommonPlugin.getPluginLog().logInfo("Cannot find locally: " //$NON-NLS-1$ +// CommonCorePlugin.getPluginLog().logInfo("Cannot find locally: " //$NON-NLS-1$ // + "Public ID " + publicId //$NON-NLS-1$ // + " System ID " + systemId); //$NON-NLS-1$ } @@ -87,7 +87,7 @@ return url.openStream(); } } catch(FileNotFoundException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } } @@ -109,9 +109,9 @@ is = HttpUtil.getInputStreamFromUrlByGetMethod(systemId); } } catch (MalformedURLException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } } return is; Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLEntityResolver.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLEntityResolver.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLEntityResolver.java (working copy) @@ -10,7 +10,7 @@ import java.util.Properties; import org.eclipse.core.runtime.FileLocator; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -104,7 +104,7 @@ source = new InputSource(new ByteArrayInputStream("".getBytes())); //$NON-NLS-1$ } if(source == null) { - CommonPlugin.getDefault().logError("WARNING: Cannot resolve entity " + systemId); //$NON-NLS-1$ + CommonCorePlugin.getDefault().logError("WARNING: Cannot resolve entity " + systemId); //$NON-NLS-1$ } // TODO study if we can always return non-null value. return source; Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/SAXValidator.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/SAXValidator.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/SAXValidator.java (working copy) @@ -22,16 +22,15 @@ import org.apache.xerces.util.XMLCatalogResolver; import org.apache.xerces.xni.XMLResourceIdentifier; import org.eclipse.core.runtime.Platform; -import org.jboss.tools.common.CommonPlugin; -import org.jboss.tools.common.Messages; -import org.jboss.tools.common.util.FileUtil; +import org.jboss.tools.common.core.CommonCorePlugin; +import org.jboss.tools.common.core.Messages; +import org.jboss.tools.common.util.FileUtils; import org.osgi.framework.Bundle; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; /** * @author eskimo(dgolovin@exadel.com) @@ -73,9 +72,9 @@ try { parserInstance.setProperty(ENTITY_RESOLVER_PROPERTY_ID, new XMLEntityResolverImpl()); } catch (SAXNotRecognizedException e1) { - CommonPlugin.getPluginLog().logError( e1.getMessage()+"", e1); //$NON-NLS-1$ + CommonCorePlugin.getPluginLog().logError( e1.getMessage()+"", e1); //$NON-NLS-1$ } catch (SAXNotSupportedException e1) { - CommonPlugin.getPluginLog().logError( e1.getMessage()+"", e1); //$NON-NLS-1$ + CommonCorePlugin.getPluginLog().logError( e1.getMessage()+"", e1); //$NON-NLS-1$ } parserInstance.setContentHandler(handler); @@ -94,7 +93,7 @@ parser.setFeature(name, value); } catch (SAXException e) { // TODO - Move to NLS bundle - CommonPlugin.getPluginLog().logError("warning: Parser does not support feature ("+name+")", e); //$NON-NLS-1$ //$NON-NLS-2$ + CommonCorePlugin.getPluginLog().logError("warning: Parser does not support feature ("+name+")", e); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -108,7 +107,7 @@ try { parser.setProperty(name, value); } catch (SAXException e) { - CommonPlugin.getPluginLog().logError("warning: Parser does not support feature ("+name+")", e); //$NON-NLS-1$ //$NON-NLS-2$ + CommonCorePlugin.getPluginLog().logError("warning: Parser does not support feature ("+name+")", e); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -159,7 +158,7 @@ */ String getCatalog() { - Bundle b = Platform.getBundle(CommonPlugin.PLUGIN_ID); + Bundle b = Platform.getBundle(CommonCorePlugin.PLUGIN_ID); String location = Platform.getStateLocation(b).toString().replace('\\', '/'); if(!location.endsWith("/")) { //$NON-NLS-1$ location += "/"; //$NON-NLS-1$ @@ -174,20 +173,20 @@ } urlString += "schemas"; //$NON-NLS-1$ } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } File f1 = new File(url.getFile() + "/schemas/catalog.xml"); //$NON-NLS-1$ File f2 = new File(location + "schemas/catalog.xml"); //$NON-NLS-1$ if(f2.exists()) { return "file:///" + location + "schemas/catalog.xml"; //$NON-NLS-1$ //$NON-NLS-2$ } - FileUtil.copyDir(f1.getParentFile(), f2.getParentFile(), true); - String text = FileUtil.readFile(f2); + FileUtils.copyDir(f1.getParentFile(), f2.getParentFile(), true); + String text = FileUtils.readFile(f2); while(text.indexOf("%install%") >= 0) { //$NON-NLS-1$ int i = text.indexOf("%install%"); //$NON-NLS-1$ text = text.substring(0, i) + urlString + text.substring(i + 9); } - FileUtil.writeFile(f2, text); + FileUtils.writeFile(f2, text); return "file:///" + location + "schemas/catalog.xml"; //$NON-NLS-1$ //$NON-NLS-2$ } } Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java (working copy) @@ -19,7 +19,7 @@ import org.apache.xerces.xni.parser.XMLEntityResolver; import org.apache.xerces.xni.parser.XMLInputSource; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.xml.sax.SAXException; @@ -52,7 +52,7 @@ result = new XMLInputSource(rid.getPublicId(), systemId, rid.getBaseSystemId(), is, null); } } catch (SAXException e) { - CommonPlugin.getPluginLog().logError( "Exception publicId=" + publicId + " systemId=" + systemId + " exception=" + e.getClass().getName() + ":" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + CommonCorePlugin.getPluginLog().logError( "Exception publicId=" + publicId + " systemId=" + systemId + " exception=" + e.getClass().getName() + ":" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } return result; Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/preferences/SeverityPreferences.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/preferences/SeverityPreferences.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/preferences/SeverityPreferences.java (working copy) @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jdt.core.JavaCore; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; /** * Constants for names of seam preferences. @@ -46,9 +46,9 @@ public abstract class SeverityPreferences { public static final String ENABLE_BLOCK_PREFERENCE_NAME = "enableBlock"; //$NON-NLS-1$ - public static final String MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME = CommonPlugin.PLUGIN_ID + ".validator.problem.markersBlock"; //$NON-NLS-1$ + public static final String MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME = CommonCorePlugin.PLUGIN_ID + ".validator.problem.markersBlock"; //$NON-NLS-1$ public static final int DEFAULT_MAX_NUMBER_OF_MARKERS_PER_FILE = 20; - public static final String WRONG_BUILDER_ORDER_PREFERENCE_NAME = CommonPlugin.PLUGIN_ID + ".validator.problem.wrongBuilderOrder"; //$NON-NLS-1$ + public static final String WRONG_BUILDER_ORDER_PREFERENCE_NAME = CommonCorePlugin.PLUGIN_ID + ".validator.problem.wrongBuilderOrder"; //$NON-NLS-1$ public static final String ERROR = "error"; //$NON-NLS-1$ public static final String WARNING = "warning"; //$NON-NLS-1$ Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/reporting/Submit.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/reporting/Submit.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/reporting/Submit.java (working copy) @@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.jboss.tools.common.util.HttpUtil; /** @@ -27,11 +27,11 @@ */ public class Submit { - public static String REPORT_DESRIPTION_PARAMETER_NAME = CommonPlugin.getMessage("%reportParameterName"); //$NON-NLS-1$ + public static String REPORT_DESRIPTION_PARAMETER_NAME = CommonCorePlugin.getMessage("%reportParameterName"); //$NON-NLS-1$ - private static String URL = CommonPlugin.getMessage("%reportingUrl"); //$NON-NLS-1$ - private static String JOB_NAME = CommonPlugin.getMessage("%reportingJobName"); //$NON-NLS-1$ - private static String ERROR_MESSAGE = CommonPlugin.getMessage("%errorReportingMessage"); //$NON-NLS-1$ + private static String URL = CommonCorePlugin.getMessage("%reportingUrl"); //$NON-NLS-1$ + private static String JOB_NAME = CommonCorePlugin.getMessage("%reportingJobName"); //$NON-NLS-1$ + private static String ERROR_MESSAGE = CommonCorePlugin.getMessage("%errorReportingMessage"); //$NON-NLS-1$ private static Submit INSTANCE = new Submit(); @@ -63,7 +63,7 @@ if(exceptionMessage!=null && exceptionMessage.trim().length()>0) { message = message + ".\r\n" + e.getClass().getName() + ": " + exceptionMessage; //$NON-NLS-1$ //$NON-NLS-2$ } - Status status = new Status(IStatus.WARNING, CommonPlugin.PLUGIN_ID, IStatus.WARNING, message, e); + Status status = new Status(IStatus.WARNING, CommonCorePlugin.PLUGIN_ID, IStatus.WARNING, message, e); return status; } if(cleanBuffer) { Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/reporting/ProblemBuffer.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/reporting/ProblemBuffer.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/reporting/ProblemBuffer.java (working copy) @@ -12,14 +12,14 @@ import java.io.File; +import org.eclipse.core.runtime.Platform; +import org.jboss.tools.common.util.FileUtils; +import org.osgi.framework.Bundle; //import org.eclipse.core.internal.runtime.PlatformLogWriter; //import org.eclipse.core.runtime.ILogListener; //import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; //import org.eclipse.core.runtime.adaptor.EclipseLog; //import org.eclipse.osgi.framework.log.FrameworkLog; -import org.jboss.tools.common.util.FileUtil; -import org.osgi.framework.Bundle; /** * This class is intended only to be called by Report Problem Framework. @@ -68,12 +68,12 @@ */ public String getContent() { File f = getLogFile(); - return (!f.isFile()) ? "" : FileUtil.readFile(f); //$NON-NLS-1$ + return (!f.isFile()) ? "" : FileUtils.readFile(f); //$NON-NLS-1$ } public String getEclipseLogContent() { File f = Platform.getLogFileLocation().toFile(); - return (f.isFile()) ? FileUtil.readFile(f) : ""; //$NON-NLS-1$ + return (f.isFile()) ? FileUtils.readFile(f) : ""; //$NON-NLS-1$ } public void clean() { Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/web/WebUtils.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/web/WebUtils.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/web/WebUtils.java (working copy) @@ -30,7 +30,7 @@ import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; import org.eclipse.wst.common.project.facet.core.IFacetedProject; import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; public class WebUtils { @@ -87,7 +87,7 @@ try { facetedProject = ProjectFacetsManager.create(project); } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } if(facetedProject!=null && facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) { IVirtualComponent component = ComponentCore.createComponent(project); @@ -137,9 +137,9 @@ // Not available in this WTP version, let's ignore it WTP_3_3_0 = true; } catch (IllegalArgumentException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } catch (IllegalAccessException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } catch (InvocationTargetException e) { // Not available in this WTP version, let's ignore it WTP_3_3_0 = true; Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/TypeResolutionCache.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/TypeResolutionCache.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/TypeResolutionCache.java (working copy) @@ -17,7 +17,7 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; public class TypeResolutionCache { private static TypeResolutionCache instance = new TypeResolutionCache(); @@ -83,9 +83,9 @@ typeName += (!"".equals(typeName) ? "." : "") + resolvedArray[0][i]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return typeName; } catch (JavaModelException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } catch (IllegalArgumentException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } return null; } Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/HttpUtil.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/HttpUtil.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/HttpUtil.java (working copy) @@ -21,7 +21,7 @@ import org.apache.commons.httpclient.methods.PostMethod; import org.eclipse.core.net.proxy.IProxyData; import org.eclipse.core.net.proxy.IProxyService; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -193,7 +193,7 @@ private static IProxyService getProxyService() { if(proxyService==null) { - BundleContext bundleContext = CommonPlugin.getInstance().getBundle().getBundleContext(); + BundleContext bundleContext = CommonCorePlugin.getInstance().getBundle().getBundleContext(); ServiceReference serviceReference = bundleContext.getServiceReference(IProxyService.class.getName()); proxyService = (IProxyService)bundleContext.getService(serviceReference); } Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/FileUtils.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/FileUtils.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/FileUtils.java (working copy) @@ -39,30 +39,21 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.eclipse.core.filebuffers.FileBuffers; -import org.eclipse.core.filebuffers.IFileBuffer; -import org.eclipse.core.filebuffers.ITextFileBuffer; -import org.eclipse.core.filebuffers.LocationKind; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.text.IDocument; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; -public final class FileUtil { +public class FileUtils { - public FileUtil() {} + public FileUtils() {} public static String getEncoding(IFile f) { String encoding = null; if(f != null && f.exists() && f.isSynchronized(0)) try { encoding = f.getCharset(); } catch (CoreException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } return encoding != null ? encoding : "8859_1"; //$NON-NLS-1$ } @@ -187,7 +178,7 @@ sb.append(new String(b, 0, l)); } } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } finally { try { is.close(); @@ -213,7 +204,7 @@ try { in.close(); } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } } } @@ -230,7 +221,7 @@ sb.append(new String(b, 0, l, charset)); } } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } finally { try { is.close(); @@ -252,7 +243,7 @@ try { is.close(); } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } } } @@ -284,9 +275,9 @@ if(f.isFile() && !isSameFile(f)) f.delete(); if(!f.exists()) f.createNewFile(); } catch (IOException e) { - CommonPlugin.getPluginLog().logError("Problem writing to file " + f, e); //$NON-NLS-1$ + CommonCorePlugin.getPluginLog().logError("Problem writing to file " + f, e); //$NON-NLS-1$ } catch (SecurityException e) { - CommonPlugin.getPluginLog().logError("Problem writing to file " + f, e); //$NON-NLS-1$ + CommonCorePlugin.getPluginLog().logError("Problem writing to file " + f, e); //$NON-NLS-1$ } PrintWriter pw = new PrintWriter(new FileWriter(f)); pw.print(value); @@ -316,7 +307,7 @@ try { dest.createNewFile(); } catch (IOException e1) { - CommonPlugin.getPluginLog().logError(e1); + CommonCorePlugin.getPluginLog().logError(e1); } InputStream is = null; OutputStream os = null; @@ -326,18 +317,18 @@ copyStream(is, os); return true; } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); return false; } finally { try { if (is != null) is.close(); } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } try { if (os != null) os.close(); } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } } } @@ -643,7 +634,7 @@ f.createNewFile(); } } catch (IOException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } FileOutputStream fs = new FileOutputStream(f); OutputStreamWriter osw = new OutputStreamWriter(fs, encoding); @@ -732,46 +723,4 @@ } return -1; } - - /** - * Returns the content of the file. If this file is open in an active editor - * then the content of the editor will be returned. - * - * @param file - * @return - */ - public static String getContentFromEditorOrFile(IFile file) { - IFileBuffer b = FileBuffers.getTextFileBufferManager().getFileBuffer(file.getFullPath(), LocationKind.IFILE); - if (b instanceof ITextFileBuffer) { - IDocument doc = ((ITextFileBuffer)b).getDocument(); - if(doc != null) { - return doc.get(); - } - } - ITextEditor editor = EclipseUIUtil.getActiveEditor(); - if (editor != null) { - IEditorInput editorInput = editor.getEditorInput(); - if (editorInput instanceof IFileEditorInput) { - IFileEditorInput fileInput = (IFileEditorInput) editorInput; - if (file.equals(fileInput.getFile())) { - IDocumentProvider dp = editor.getDocumentProvider(); - try { - dp.connect(fileInput); - IDocument doc = dp.getDocument(fileInput); - return doc.get(); - } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); - } finally { - dp.disconnect(fileInput); - } - } - } - } - try { - return FileUtil.readStream(file); - } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); - return null; - } - } } \ No newline at end of file Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/EclipseJavaUtil.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/EclipseJavaUtil.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/util/EclipseJavaUtil.java (working copy) @@ -32,7 +32,7 @@ import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; public class EclipseJavaUtil { @@ -48,7 +48,7 @@ String typeName = new String(Signature.toCharArray(f.getTypeSignature().toCharArray())); return resolveType(f.getDeclaringType(), typeName); } catch (JavaModelException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } return null; } @@ -58,7 +58,7 @@ try { return resolveTypeAsString(m.getDeclaringType(), m.getReturnType()); } catch (JavaModelException e) { - CommonPlugin.getPluginLog().logError(e); + CommonCorePlugin.getPluginLog().logError(e); } return null; } Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedType.java (working copy) @@ -23,7 +23,7 @@ import org.eclipse.jdt.core.ITypeParameter; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; /** * @@ -224,7 +224,7 @@ } } } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } this.inheritedTypes = inheritedTypes; inheritanceIsBuilt = true; Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/impl/AnnotationDeclaration.java (working copy) @@ -24,7 +24,7 @@ import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IMemberValuePair; import org.eclipse.jdt.core.IType; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.jboss.tools.common.java.IAnnotationDeclaration; import org.jboss.tools.common.java.IAnnotationType; import org.jboss.tools.common.java.IJavaAnnotation; @@ -159,7 +159,7 @@ } } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } } Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/impl/JavaAnnotation.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/impl/JavaAnnotation.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/impl/JavaAnnotation.java (working copy) @@ -18,7 +18,7 @@ import org.eclipse.jdt.core.ISourceRange; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.jboss.tools.common.java.IJavaAnnotation; import org.jboss.tools.common.util.EclipseJavaUtil; @@ -35,7 +35,7 @@ annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name); type = EclipseJavaUtil.findType(annotation.getJavaProject(), annotationTypeName); } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } } @@ -58,7 +58,7 @@ return range.getLength(); } } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } return 0; } @@ -70,7 +70,7 @@ return range.getOffset(); } } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } return 0; } @@ -94,7 +94,7 @@ try { return annotation.getMemberValuePairs(); } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } return new IMemberValuePair[0]; } Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedTypeFactory.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedTypeFactory.java (working copy) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/java/ParametedTypeFactory.java (working copy) @@ -21,7 +21,7 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; -import org.jboss.tools.common.CommonPlugin; +import org.jboss.tools.common.core.CommonCorePlugin; import org.jboss.tools.common.util.EclipseJavaUtil; public class ParametedTypeFactory { @@ -48,7 +48,7 @@ try { r = type.getNameRange(); } catch (CoreException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } if(r != null) { parametedType = new TypeDeclaration(parametedType, type.getResource(), r.getOffset(), r.getLength()); @@ -61,7 +61,7 @@ try { ps = type.getTypeParameterSignatures(); } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } if(ps != null && ps.length > 0) { for (int i = 0; i < ps.length; i++) { @@ -69,7 +69,7 @@ ParametedType p = getParametedTypeForParameter(type, ps[i], null); if(p != null) parametedType.addParameter(p); } catch (JavaModelException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } } } @@ -137,7 +137,7 @@ ParametedType st = getParametedTypeForParameter(context, ps[i], result); if(st != null) { if(st.getSignature().indexOf(Signature.C_COLON) >= 0) { - CommonPlugin.getDefault().logWarning("Wrong signature=" + st.getSignature()); + CommonCorePlugin.getDefault().logWarning("Wrong signature=" + st.getSignature()); } return st; } @@ -163,7 +163,7 @@ try { paramSignatures = Signature.getTypeArguments(typeSignature); } catch (IllegalArgumentException e) { - CommonPlugin.getDefault().logError(e); + CommonCorePlugin.getDefault().logError(e); } if(paramSignatures != null) for (String paramSignature: paramSignatures) { ParametedType param = getParametedType(context, basetype, paramSignature); Index: plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/core/CommonCorePlugin.java =================================================================== --- plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/core/CommonCorePlugin.java (revision 0) +++ plugins/org.jboss.tools.common.core/src/org/jboss/tools/common/core/CommonCorePlugin.java (working copy) @@ -0,0 +1,117 @@ +package org.jboss.tools.common.core; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Dictionary; +import java.util.Properties; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Platform; +import org.jboss.tools.common.log.BasePlugin; +import org.jboss.tools.common.log.IPluginLog; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +public class CommonCorePlugin extends BasePlugin { + public static final String PLUGIN_ID = "org.jboss.tools.common"; //$NON-NLS-1$ + protected static CommonCorePlugin instance; + private static String environment; + + public CommonCorePlugin() { + super(); + instance = this; + } + + public static CommonCorePlugin getInstance() { + return instance; + } + + public void start(BundleContext context) throws Exception { + super.start(context); + } + /** + * Gets message from plugin.properties + * @param key + * @return + */ + public static String getMessage(String key) { + return Platform.getResourceString(instance.getBundle(), key); + } + + /** + * @return Studio environment. + */ + public static String getEnvironment() { + if(environment == null) { + String osName = System.getProperty("os.name"); //$NON-NLS-1$ + String javaVersion = System.getProperty("java.version"); //$NON-NLS-1$ + String studioName = "unknown"; //$NON-NLS-1$ + String studioVersion = "unknown"; //$NON-NLS-1$ + String eclipseVersion = "unknown"; //$NON-NLS-1$ + String eclipseBuildId = "unknown"; //$NON-NLS-1$ + + Bundle studio = Platform.getBundle("org.jboss.tools.common"); //$NON-NLS-1$ + if(studio!=null) { + Dictionary studioDic = studio.getHeaders(); + studioName = (String)studioDic.get("Bundle-Name"); //$NON-NLS-1$ + studioVersion = (String)studioDic.get("Bundle-Version"); //$NON-NLS-1$ + } + + Bundle eclipse = Platform.getBundle("org.eclipse.platform"); //$NON-NLS-1$ + if(eclipse!=null) { + Dictionary eclipseDic = eclipse.getHeaders(); + eclipseVersion = (String)eclipseDic.get("Bundle-Version"); //$NON-NLS-1$ + FileInputStream fis = null; + try { + String path = FileLocator.resolve(eclipse.getEntry("/")).getPath(); //$NON-NLS-1$ + if(path!=null) { + File aboutMappings = new File(path, "about.mappings"); //$NON-NLS-1$ + if(aboutMappings.exists()) { + Properties properties = new Properties(); + fis = new FileInputStream(aboutMappings); + properties.load(fis); + String buildId = properties.getProperty("0"); //$NON-NLS-1$ + if(buildId!=null && buildId.length()>0) { + eclipseBuildId = buildId; + } + } + } + } catch (IOException e) { + getPluginLog().logError("Error in getting environment info: " + e.getMessage()); //$NON-NLS-1$ + } finally { + if(fis!=null) { + try { + fis.close(); + } catch (IOException e) { + // ignore + } + } + } + } + StringBuffer result = new StringBuffer(studioName).append(" ").append(studioVersion). //$NON-NLS-1$ + append(", Eclipse ").append(eclipseVersion).append(" "). //$NON-NLS-1$ //$NON-NLS-2$ + append(eclipseBuildId).append(", Java ").append(javaVersion). //$NON-NLS-1$ + append(", ").append(osName); //$NON-NLS-1$ + environment = result.toString(); + } + return environment; + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static CommonCorePlugin getDefault() { + return instance; + } + + /** + * @return IPluginLog object + */ + public static IPluginLog getPluginLog() { + return getDefault(); + } + +} Index: plugins/org.jboss.tools.common.core/plugin.properties =================================================================== --- plugins/org.jboss.tools.common.core/plugin.properties (revision 0) +++ plugins/org.jboss.tools.common.core/plugin.properties (working copy) @@ -0,0 +1,7 @@ +providerName=JBoss by Red Hat + +reportParameterName=reportDescription +reportingUrl=http://box.exadel.com/goto/bugreport.jsp +reportingJobName=Bug reporting +errorReportingMessage=Can't submit report +Bundle-Name.0 = JBoss Tools Common Core Index: plugins/org.jboss.tools.common.core/build.properties =================================================================== --- plugins/org.jboss.tools.common.core/build.properties (revision 0) +++ plugins/org.jboss.tools.common.core/build.properties (working copy) @@ -0,0 +1,7 @@ +source.. = src +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + plugin.properties,\ + about.html +source.. = src Index: plugins/org.jboss.tools.common.core/pom.xml =================================================================== --- plugins/org.jboss.tools.common.core/pom.xml (revision 0) +++ plugins/org.jboss.tools.common.core/pom.xml (working copy) @@ -0,0 +1,13 @@ + + + 4.0.0 + + org.jboss.tools.common + plugins + 3.4.0-SNAPSHOT + + org.jboss.tools.common.plugins + org.jboss.tools.common.core + + eclipse-plugin + Property changes on: plugins/org.jboss.tools.common.core/pom.xml ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: plugins/org.jboss.tools.common.core/plugin.xml =================================================================== --- plugins/org.jboss.tools.common.core/plugin.xml (revision 0) +++ plugins/org.jboss.tools.common.core/plugin.xml (working copy) @@ -0,0 +1,4 @@ + + + + \ No newline at end of file Property changes on: plugins/org.jboss.tools.common.core/plugin.xml ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: plugins/org.jboss.tools.common.core/.classpath =================================================================== --- plugins/org.jboss.tools.common.core/.classpath (revision 0) +++ plugins/org.jboss.tools.common.core/.classpath (working copy) @@ -0,0 +1,7 @@ + + + + + + + Property changes on: plugins/org.jboss.tools.common.core/.classpath ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: plugins/org.jboss.tools.common.core/META-INF/MANIFEST.MF =================================================================== --- plugins/org.jboss.tools.common.core/META-INF/MANIFEST.MF (revision 0) +++ plugins/org.jboss.tools.common.core/META-INF/MANIFEST.MF (working copy) @@ -0,0 +1,43 @@ +Manifest-Version: 1.0 +Bundle-Name: %Bundle-Name.0 +Bundle-ClassPath: . +Bundle-Activator: org.jboss.tools.common.core.CommonCorePlugin +Bundle-Vendor: %providerName +Bundle-SymbolicName: org.jboss.tools.common.core;singleton:=true +Bundle-Localization: plugin +Export-Package: org.jboss.tools.common.core, + org.jboss.tools.common.databinding, + org.jboss.tools.common.java, + org.jboss.tools.common.java.impl, + org.jboss.tools.common.jobs, + org.jboss.tools.common.log, + org.jboss.tools.common.preferences, + org.jboss.tools.common.reporting, + org.jboss.tools.common.text, + org.jboss.tools.common.util, + org.jboss.tools.common.web, + org.jboss.tools.common.xml, + org.jboss.tools.common.zip +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", + org.eclipse.wst.xml.core;bundle-version="1.1.600";visibility:=reexport, + org.eclipse.wst.common.modulecore;bundle-version="1.2.100", + org.eclipse.jst.j2ee;bundle-version="1.1.500", + org.eclipse.jst.j2ee.core;bundle-version="1.2.100", + org.eclipse.wst.common.project.facet.core;bundle-version="1.4.200", + org.eclipse.jem.util;bundle-version="2.1.2", + org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.2.100", + org.eclipse.jface;bundle-version="3.7.0", + org.eclipse.core.resources;bundle-version="3.7.100", + org.eclipse.wst.common.uriresolver;bundle-version="1.1.401";visibility:=reexport, + org.eclipse.core.net;bundle-version="1.2.100", + org.eclipse.jdt.core;bundle-version="3.7.0", + org.eclipse.jface.text;bundle-version="3.7.0", + org.apache.commons.httpclient;bundle-version="3.1.0", + org.eclipse.jpt.common.core;bundle-version="1.0.0", + org.eclipse.ltk.core.refactoring;bundle-version="3.5.200", + org.eclipse.jdt.core.manipulation;bundle-version="1.5.0", + org.eclipse.core.filebuffers;bundle-version="3.5.200" +Bundle-Version: 3.4.0.qualifier +Bundle-ActivationPolicy: lazy +Bundle-ManifestVersion: 2 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6