JBoss Tools SVN: r7038 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-20 08:46:00 -0400 (Thu, 20 Mar 2008)
New Revision: 7038
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/TypeInfoCollector.java
Log:
JBIDE-1750 TypeInfoCollector moved to common plugin.
Copied: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/TypeInfoCollector.java (from rev 7037, trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java)
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/TypeInfoCollector.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/TypeInfoCollector.java 2008-03-20 12:46:00 UTC (rev 7038)
@@ -0,0 +1,941 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.model.util;
+
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
+
+/**
+ * This class helps to collect information of java elements used in Seam EL.
+ * @author Viktor Rubezhny, Alexey Kazakov
+ */
+public class TypeInfoCollector {
+ IType fType;
+ MemberInfo fMember;
+ List<MethodInfo> fMethods;
+ List<FieldInfo> fFields;
+
+ public static class Type {
+ private String fName;
+ private String fQualifiedName;
+ private Type[] fParameters;
+ private IType fSource;
+ private String fSignature;
+ private boolean fIsArray;
+ private Type fTypeOfArrayElement;
+ private String fQualifiedTypeNameOfArrayElement;
+
+ private Type() {
+ }
+
+ public static Type valueOf(String name) {
+ Type instance = new Type();
+ instance.setName(name);
+ instance.setParameters(new Type[0]);
+ return instance;
+ }
+
+ public Type(String signature, IType source) {
+ String erasureSignature = Signature.getTypeErasure(signature);
+ String typeOfArraySiganture = Signature.getElementType(erasureSignature);
+ fName = String.valueOf(Signature.toString(erasureSignature));
+ if(!erasureSignature.equals(typeOfArraySiganture)) {
+ // this is an array
+ fIsArray = true;
+ fTypeOfArrayElement = new Type(typeOfArraySiganture, source);
+ }
+ String[] signaturesOfParametersOfType = Signature.getTypeArguments(signature);
+ fParameters = new Type[signaturesOfParametersOfType.length];
+ for (int i = 0; i < signaturesOfParametersOfType.length; i++) {
+ fParameters[i] = new Type(signaturesOfParametersOfType[i], source);
+ }
+ fSource = source;
+ }
+
+ public void initializeParameters(Map<String, Type> parameters) {
+ Type type = parameters.get(fName);
+ if(type!=null) {
+ fName = type.getName();
+ fParameters = type.getParameters();
+ fSource = type.getSource();
+ fIsArray = type.isArray();
+ fTypeOfArrayElement = type.getTypeOfArrayElement();
+ }
+ for (int i = 0; i < fParameters.length; i++) {
+ fParameters[i].initializeParameters(parameters);
+ }
+ }
+
+ public Type getParameter(int index) {
+ if(fParameters.length>index) {
+ return fParameters[index];
+ }
+ return null;
+ }
+
+ public String getQualifiedTypeNameOfArrayElement() {
+ if(fQualifiedTypeNameOfArrayElement==null && fSource!=null) {
+ fQualifiedTypeNameOfArrayElement = EclipseJavaUtil.resolveType(fSource, fTypeOfArrayElement.getName());
+ }
+ return fQualifiedTypeNameOfArrayElement;
+ }
+
+ public String getQualifiedName() {
+ if(fQualifiedName == null && fSource!=null) {
+ fQualifiedName = EclipseJavaUtil.resolveType(fSource, fName);
+ }
+ return fQualifiedName;
+ }
+
+ public boolean isArray() {
+ return fIsArray;
+ }
+
+ public void setArray(boolean array) {
+ fIsArray = array;
+ }
+
+ public Type getTypeOfArrayElement() {
+ return fTypeOfArrayElement;
+ }
+
+ public void setTypeOfArrayElement(Type typeOfArrayElement) {
+ fTypeOfArrayElement = typeOfArrayElement;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ public void setName(String name) {
+ fName = name;
+ }
+
+ public Type[] getParameters() {
+ return fParameters;
+ }
+
+ public void setParameters(Type[] parameters) {
+ this.fParameters = parameters;
+ }
+
+ public IType getSource() {
+ return fSource;
+ }
+
+ public void setSource(IType source) {
+ this.fSource = source;
+ }
+
+ public String getSignature() {
+ return fSignature;
+ }
+
+ public void setSignature(String signature) {
+ this.fSignature = signature;
+ }
+ }
+
+ public abstract static class MemberInfo {
+ private String fDeclaringTypeQualifiedName;
+ private String fName;
+ private int fModifiers;
+ private IType fSourceType;
+ private MemberInfo fParentMember;
+ private String[] fParametersNamesOfDeclaringType;
+ private IType fMemberType;
+ private boolean isDataModel;
+ private Type fType;
+
+ TypeInfoCollector typeInfo;
+
+ protected MemberInfo (
+ IType sourceType,
+ String declaringTypeQualifiedName, String name, int modifiers, MemberInfo parentMember, boolean dataModel, Type type) {
+ setSourceType(sourceType);
+ setDeclaringTypeQualifiedName(declaringTypeQualifiedName);
+ setName(name);
+ setModifiers(modifiers);
+ setParentMember(parentMember);
+ setDataModel(dataModel);
+ setType(type);
+ }
+
+ protected void initializeParametersOfDeclaringType() {
+ if(fParametersNamesOfDeclaringType!=null && fParametersNamesOfDeclaringType.length>0 && getParentMember()!=null) {
+ Map<String, Type> parametersOfDeclaringType = new HashMap<String, Type>();
+ for (int i = 0; i < fParametersNamesOfDeclaringType.length; i++) {
+ String parameterName = getParameterNameFromType(fParametersNamesOfDeclaringType[i]);
+ Type paramType = getParentMember().getType().getParameter(i);
+ if(paramType!=null) {
+ parametersOfDeclaringType.put(parameterName, paramType);
+ }
+ }
+ getType().initializeParameters(parametersOfDeclaringType);
+ }
+ }
+
+ protected void setType(Type type) {
+ fType = type;
+ }
+
+ public Type getType() {
+ return fType;
+ }
+
+ public void setSourceType(IType sourceType) {
+ fSourceType = sourceType;
+ }
+
+ public IType getSourceType() {
+ return fSourceType;
+ }
+
+ protected void setName (String name) {
+ this.fName = name;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ protected void setDeclaringTypeQualifiedName(String declaringTypeQualifiedName) {
+ this.fDeclaringTypeQualifiedName = declaringTypeQualifiedName;
+ }
+
+ public String getDeclaringTypeQualifiedName() {
+ return fDeclaringTypeQualifiedName;
+ }
+
+ protected void setModifiers (int modifiers) {
+ this.fModifiers = modifiers;
+ }
+
+ public int getModifiers() {
+ return fModifiers;
+ }
+
+ public boolean isPublic() {
+ return Modifier.isPublic(fModifiers);
+ }
+
+ public boolean isStatic() {
+ return Modifier.isStatic(fModifiers);
+ }
+
+ public boolean isJavaLangObject() {
+ return "java.lang.Object".equals(getDeclaringTypeQualifiedName());
+ }
+
+ public MemberInfo getParentMember() {
+ return fParentMember;
+ }
+
+ void setParentMember(MemberInfo parentMember) {
+ fParentMember = parentMember;
+ }
+
+ public String[] getParametersNamesOfDeclaringType() {
+ return fParametersNamesOfDeclaringType;
+ }
+
+ void setParametersNamesOfDeclaringType(
+ String[] parametersNamesOfDeclaringType) {
+ fParametersNamesOfDeclaringType = parametersNamesOfDeclaringType;
+ }
+
+ public IType getMemberType() {
+ if(fMemberType==null) {
+ initializeParametersOfDeclaringType();
+ try {
+ if(isDataModel() && getType().isArray()) {
+ fMemberType = getSourceType().getJavaProject().findType(getType().getQualifiedTypeNameOfArrayElement());
+ } else {
+ fMemberType = getSourceType().getJavaProject().findType(getType().getQualifiedName());
+ }
+ } catch (JavaModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ }
+ return fMemberType;
+ }
+
+ public boolean isDataModel() {
+ return isDataModel;
+ }
+
+ void setDataModel(boolean isDataModel) {
+ this.isDataModel = isDataModel;
+ }
+
+ public TypeInfoCollector getTypeCollector() {
+ if(typeInfo == null) {
+ typeInfo = new TypeInfoCollector(this);
+ typeInfo.collectInfo();
+ }
+ return typeInfo;
+ }
+
+ abstract public IJavaElement getJavaElement();
+ }
+
+ public static class TypeInfo extends MemberInfo {
+ private IType fType;
+
+ public TypeInfo(IType type, MemberInfo parentMember, boolean dataModel) throws JavaModelException {
+ super(type.getDeclaringType(), (type.getDeclaringType() == null ? null : type.getDeclaringType().getFullyQualifiedName()), type.getFullyQualifiedName(), type.getFlags(), parentMember, dataModel, Type.valueOf(type.getFullyQualifiedName()));
+ this.fType = type;
+ }
+
+ @Override
+ public IType getMemberType() {
+ return fType;
+ }
+
+ @Override
+ public IJavaElement getJavaElement() {
+ return fType;
+ }
+ }
+
+ public static class FieldInfo extends MemberInfo {
+ private IJavaElement fJavaElement;
+
+ public FieldInfo(IField field, MemberInfo parentMember, boolean dataModel) throws JavaModelException {
+ super(field.getDeclaringType(),
+ (field.getDeclaringType() == null ? null : field.getDeclaringType().getFullyQualifiedName()),
+ field.getElementName(),
+ field.getFlags(),
+ parentMember,
+ dataModel,
+ new Type(field.getTypeSignature(),
+ field.getDeclaringType()));
+
+ setParametersNamesOfDeclaringType(getTypeErasureFromSignatureArray(field.getDeclaringType().getTypeParameterSignatures()));
+ }
+
+ public IJavaElement getJavaElement () {
+ if(fJavaElement == null) {
+ try {
+ IType declType = getSourceType().getJavaProject().findType(getDeclaringTypeQualifiedName());
+ fJavaElement = (declType == null ? null : declType.getField(getName()));
+ } catch (JavaModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ }
+ return fJavaElement;
+ }
+ }
+
+ public static class MethodInfo extends MemberInfo {
+ private String[] fParameterTypeNames;
+ private String[] fParameterTypeQualifiedNames;
+ private String[] fParameterNames;
+ private IJavaElement fJavaElement;
+
+ public MethodInfo(IType sourceType, String declaringTypeQualifiedName, String name,
+ int modifiers, String[] parameterTypeQualifiedNames,
+ String[] parameterNames,
+ String returnTypeQualifiedName,
+ MemberInfo parentMember,
+ boolean dataModel) {
+ super(sourceType, declaringTypeQualifiedName, name, modifiers, parentMember, dataModel, Type.valueOf(name));
+ setParameterTypeNames(parameterTypeQualifiedNames);
+ setParameterNames(parameterNames);
+ }
+
+ public MethodInfo(IMethod method, MemberInfo parentMember, boolean dataModel) throws JavaModelException {
+ super(method.getDeclaringType(),
+ (method.getDeclaringType() == null ? null : method.getDeclaringType().getFullyQualifiedName()),
+ method.getElementName(),
+ method.getFlags(),
+ parentMember,
+ dataModel,
+ new Type(method.getReturnType(),
+ method.getDeclaringType()));
+
+ setParameterNames(method.getParameterNames());
+ setParameterTypeNames(resolveSignatures(method.getDeclaringType(), method.getParameterTypes()));
+ setParametersNamesOfDeclaringType(getTypeErasureFromSignatureArray(method.getDeclaringType().getTypeParameterSignatures()));
+ }
+
+ protected void setParameterTypeNames(String[] parameterTypeNames) {
+ fParameterTypeNames = (parameterTypeNames == null ?
+ new String[0] : parameterTypeNames);
+ }
+
+ public String[] getParameterTypeQualifiedNames() {
+ if(fParameterTypeQualifiedNames==null) {
+ fParameterTypeQualifiedNames = new String[fParameterTypeNames.length];
+ for (int i = 0; i < fParameterTypeQualifiedNames.length; i++) {
+ fParameterTypeQualifiedNames[i] = EclipseJavaUtil.resolveType(getSourceType(), fParameterTypeNames[i]);
+ }
+ }
+ return fParameterTypeQualifiedNames;
+ }
+
+ public String[] getParameterTypeNames() {
+ return fParameterTypeNames;
+ }
+
+ protected void setParameterNames(String[] parameterNames) {
+ fParameterNames = (parameterNames == null ?
+ new String[0] : parameterNames);
+ }
+
+ public String[] getParameterNames() {
+ return fParameterNames;
+ }
+
+ public int getNumberOfParameters() {
+ return (getParameterNames() == null ? 0 : getParameterNames().length);
+ }
+
+ public IType getReturnType() {
+ return getMemberType();
+ }
+
+ public boolean isConstructor () {
+ return getDeclaringTypeQualifiedName().equals(getName());
+ }
+
+ public boolean isGetter() {
+ return (getName().startsWith("get") && !getName().equals("get")) || getName().startsWith("is");
+ }
+
+ public boolean isSetter() {
+ return (getName().startsWith("set") && !getName().equals("set"));
+ }
+
+ @Override
+ public IJavaElement getJavaElement () {
+ if(fJavaElement == null) {
+ try {
+ IType declType = getSourceType().getJavaProject().findType(getDeclaringTypeQualifiedName());
+
+ IMethod[] allMethods = declType.getMethods();
+
+ // filter methods by name
+ List<IMethod> methods = new ArrayList<IMethod>();
+ for (int i = 0; allMethods != null && i < allMethods.length; i++) {
+ if (allMethods[i].getElementName().equals(getName())) {
+ methods.add(allMethods[i]);
+ }
+ }
+ if (!methods.isEmpty()) {
+ if (methods.size() == 1) {
+ fJavaElement = methods.get(0);
+ } else {
+ // filter methods by number of parameters
+ List<IMethod> filteredMethods = new ArrayList<IMethod>();
+ for (IMethod method : methods) {
+ if (method.getNumberOfParameters() == getNumberOfParameters()) {
+ filteredMethods.add(method);
+ }
+ }
+ if (!filteredMethods.isEmpty()) {
+ if (filteredMethods.size() == 1) {
+ fJavaElement = filteredMethods.get(0);
+ } else {
+ methods = filteredMethods;
+
+ // filter methods by parameter types
+ for(IMethod method : methods) {
+ String[] methodParameterTypes =
+ resolveSignatures(method.getDeclaringType(),
+ method.getParameterTypes());
+ String[] parameterTypes = getParameterTypeQualifiedNames();
+
+ boolean equal = true;
+ for (int i = 0; parameterTypes != null && i < parameterTypes.length; i++) {
+ // simple types must be equal, but complex types may not
+ if (!parameterTypes[i].equals(methodParameterTypes[i])) {
+ // sure - it's Complex Type
+ if (! (parameterTypes[i].indexOf('.') != -1)
+ && (methodParameterTypes[i].indexOf('.') == -1)) {
+ equal = false;
+ break;
+ }
+ }
+ }
+ if (equal) {
+ fJavaElement = method;
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (JavaModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ }
+ return fJavaElement;
+ }
+ }
+
+ public TypeInfoCollector(MemberInfo member) {
+ this.fMember = member;
+ this.fType = member.getMemberType();
+ }
+
+ public IType getType() {
+ return this.fType;
+ }
+
+ public void collectInfo() {
+ if (fMethods == null) {
+ fMethods = new ArrayList<MethodInfo>();
+ } else {
+ fMethods.clear();
+ }
+
+ if (fFields == null) {
+ fFields = new ArrayList<FieldInfo>();
+ } else {
+ fFields.clear();
+ }
+
+ if (fType == null)
+ return;
+ try {
+ IType binType = fType;
+ while (binType != null) {
+ IMethod[] binMethods = binType.getMethods();
+ for (int i = 0; binMethods != null && i < binMethods.length; i++) {
+ if (binMethods[i].isConstructor()) continue;
+ fMethods.add(new MethodInfo(binMethods[i], fMember, false));
+ }
+ binType = getSuperclass(binType);
+ }
+
+ // !!!!!!!
+ // This inserts here methods "public int size()" and "public boolean isEmpty()" for javax.faces.model.DataModel
+ // as requested by Gavin in JBIDE-1256
+ // !!!!!!!
+ if(isDataModelObject(fType)) {
+ addInfoForDataModelObject();
+ }
+ // This inserts here methods "public int getRowCount()" for @DataModel variables.
+ if(fMember.isDataModel) {
+ addInfoForDataModelVariable();
+ }
+ } catch (JavaModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ }
+
+ boolean isDataModelObject(IType type) throws JavaModelException {
+ return isInstanceofType(type, "javax.faces.model.DataModel");
+ }
+
+ public static boolean isResourceBundle(IType type) {
+ try {
+ return isInstanceofType(type, "java.util.ResourceBundle");
+ } catch (JavaModelException e) {
+ return false;
+ }
+ }
+
+ public static boolean isNotParameterizedCollection(TypeInfoCollector.MemberInfo mbr) {
+ try {
+ if(mbr.getType().getParameters()!=null && mbr.getType().getParameters().length>0) {
+ return false;
+ }
+ IType type = mbr.getMemberType();
+ if(type!=null) {
+ return isInstanceofType(type, "java.util.Map") || isInstanceofType(type, "java.util.Collection");
+ }
+ return false;
+ } catch (JavaModelException e) {
+ return false;
+ }
+ }
+
+ public static class SuperTypeInfo {
+ IType type;
+ Set<String> names = new HashSet<String>();
+ IType[] superTypes = new IType[0];
+
+ SuperTypeInfo(IType type) throws JavaModelException {
+ this.type = type;
+ superTypesCache.put(type, this);
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
+ superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type);
+ if(superTypes != null) for (int i = 0; i < superTypes.length; i++) {
+ names.add(superTypes[i].getFullyQualifiedName());
+ }
+ if(superTypes == null) superTypes = new IType[0];
+ }
+
+ public Set<String> getNames() {
+ return names;
+ }
+
+ public IType[] getSuperTypes() {
+ return superTypes;
+ }
+ }
+
+ static Map<IType, SuperTypeInfo> superTypesCache = new HashMap<IType, SuperTypeInfo>();
+
+ public static SuperTypeInfo getSuperTypes(IType type) throws JavaModelException {
+ if(type == null) return null;
+ SuperTypeInfo ts = superTypesCache.get(type);
+ if(ts == null) {
+ ts = new SuperTypeInfo(type);
+ }
+ return ts;
+ }
+
+ public static boolean isInstanceofType(IType type, String qualifiedTypeName) throws JavaModelException {
+ if (qualifiedTypeName == null || type == null) return false;
+ boolean isInstanceofType = qualifiedTypeName.equals(type.getFullyQualifiedName());
+ if (!isInstanceofType) {
+ SuperTypeInfo ts = getSuperTypes(type);
+ if(ts != null && ts.getNames().contains(qualifiedTypeName)) {
+ return true;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ void addInfoForDataModelVariable() {
+ fMethods.add(new MethodInfo(fType,
+ fType.getFullyQualifiedName(),
+ "getRowCount", Modifier.PUBLIC,
+ new String[0],
+ new String[0],
+ "int",
+ fMember,
+ false));
+ }
+
+ void addInfoForDataModelObject() {
+ fMethods.add(new MethodInfo(fType,
+ fType.getFullyQualifiedName(),
+ "size", Modifier.PUBLIC,
+ new String[0],
+ new String[0],
+ "int",
+ fMember,
+ false));
+ fMethods.add(new MethodInfo(fType,
+ fType.getFullyQualifiedName(),
+ "isEmpty", Modifier.PUBLIC,
+ new String[0],
+ new String[0],
+ "boolean",
+ fMember,
+ false));
+ }
+
+ private static IType getSuperclass(IType type) throws JavaModelException {
+ String superclassName = type.getSuperclassName();
+ if(superclassName!=null) {
+ String fullySuperclassName = EclipseJavaUtil.resolveType(type, superclassName);
+ if(fullySuperclassName!=null&&!fullySuperclassName.equals("java.lang.Object")) { //$NON-NLS-1$
+ if(fullySuperclassName.equals(type.getFullyQualifiedName())) {
+ //FIX JBIDE-1642
+ return null;
+ }
+ IType superType = type.getJavaProject().findType(fullySuperclassName);
+ return superType;
+ }
+ }
+ return null;
+ }
+
+ public MethodInfo[] findMethodInfos(IMethod iMethod) {
+ List<MethodInfo> methods = new ArrayList<MethodInfo>();
+
+ // filter methods by name
+ for (MethodInfo info : fMethods) {
+ if (info.getName().equals(iMethod.getElementName())) {
+ methods.add(info);
+ }
+ }
+ if (methods.isEmpty())
+ return new MethodInfo[0];
+
+ EclipseJavaUtil.getMemberTypeAsString(iMethod);
+
+ if (methods.size() == 1)
+ return methods.toArray(new MethodInfo[0]);
+
+ // filter methods by number of parameters
+ List<MethodInfo> filteredMethods = new ArrayList<MethodInfo>();
+ for (MethodInfo method : methods) {
+ if (method.getNumberOfParameters() == iMethod.getNumberOfParameters())
+ filteredMethods.add(method);
+ }
+ if (filteredMethods.isEmpty())
+ return new MethodInfo[0];
+ if (filteredMethods.size() == 1)
+ return filteredMethods.toArray(new MethodInfo[0]);
+
+ methods = filteredMethods;
+
+ // filter methods by parameter types
+ filteredMethods = new ArrayList<MethodInfo>();
+ for(MethodInfo method : methods) {
+ String[] methodParameterTypes =
+ resolveSignatures(iMethod.getDeclaringType(),
+ iMethod.getParameterTypes());
+ String[] parameterTypes = method.getParameterTypeQualifiedNames();
+
+ boolean equal = true;
+ for (int i = 0; equal && parameterTypes != null && i < parameterTypes.length; i++) {
+ // simple types must be equal, but complex types may not
+ if (!parameterTypes[i].equals(methodParameterTypes[i])) {
+ // sure - it's Complex Type
+ if ((parameterTypes[i].indexOf('.') != -1)
+ && (methodParameterTypes[i].indexOf('.') == -1)) {
+ equal = false;
+ }
+ }
+ }
+ if (equal) {
+ filteredMethods.add(method);
+ }
+ }
+ return filteredMethods.toArray(new MethodInfo[0]);
+ }
+
+ /**
+ * Returns the methods for the type specified
+ *
+ * @return
+ */
+ public List<MemberInfo> getMethods() {
+ List<MemberInfo> methods = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor()
+ && !info.isStatic() && !info.isJavaLangObject()
+ && !info.isGetter() && !info.isSetter())
+ methods.add(info);
+ }
+ return methods;
+ }
+
+ /**
+ * Returns the method presentation strings for the type specified
+ *
+ * @param type
+ * @return
+ */
+ public Set<String> getMethodPresentations() {
+ Set<String> methods = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ List<MemberInfo> mthds = getMethods();
+ for (MemberInfo info : mthds) {
+ if (!(info instanceof MethodInfo))
+ continue;
+
+ MethodInfo method = (MethodInfo)info;
+
+ StringBuffer name = new StringBuffer(method.getName());
+
+ // Add method as 'foo'
+ methods.add(name.toString());
+
+ // Add method as 'foo(param1,param2)'
+ name.append('(');
+ String[] mParams = method.getParameterNames();
+ for (int j = 0; mParams != null && j < mParams.length; j++) {
+ if (j > 0) name.append(", "); //$NON-NLS-1$
+ name.append(mParams[j]);
+ }
+ name.append(')');
+
+ methods.add(name.toString());
+ }
+ return methods;
+ }
+
+ /**
+ * Returns the properties for the type specified
+ *
+ * @return
+ */
+ public List<MemberInfo> getProperties() {
+ List<MemberInfo> properties = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor()
+ && !info.isStatic() && !info.isJavaLangObject()
+ && (info.isGetter() || info.isSetter()))
+ properties.add(info);
+ }
+
+ /*
+ * The following code was excluded due to the following issue:
+ *
+ * http://jira.jboss.com/jira/browse/JBIDE-1203#action_12385823
+ *
+ *
+ for (FieldInfo info : fFields) {
+ if (info.isPublic()
+ && !info.isStatic() && !info.isJavaLangObject())
+ properties.add(info);
+ }
+ */
+
+ return properties;
+ }
+
+ /**
+ * Returns the property presentation strings for the type specified
+ *
+ * @return
+ */
+ public Set<String> getPropertyPresentations() {
+ return getPropertyPresentations(null);
+ }
+
+ /**
+ * Returns the property presentation strings for the type specified
+ *
+ * @param unpairedGettersOrSetters - map of unpaired getters or setters of type's properties. 'key' is property name.
+ * @return
+ */
+ public Set<String> getPropertyPresentations(Map<String, MethodInfo> unpairedGettersOrSetters) {
+ Set<String> properties = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ List<MemberInfo> props = getProperties();
+ HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
+ HashMap<String, MethodInfo> setters = new HashMap<String, MethodInfo>();
+ for (MemberInfo info : props) {
+ if (info instanceof MethodInfo) {
+ MethodInfo m = (MethodInfo)info;
+
+ if (m.isGetter() || m.isSetter()) {
+ StringBuffer name = new StringBuffer(m.getName());
+ if(m.getName().startsWith("i")) { //$NON-NLS-1$
+ name.delete(0, 2);
+ } else {
+ name.delete(0, 3);
+ }
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ String propertyName = name.toString();
+ if(!properties.contains(propertyName)) {
+ properties.add(propertyName);
+ }
+ if(unpairedGettersOrSetters!=null) {
+ MethodInfo previousGetter = getters.get(propertyName);
+ MethodInfo previousSetter = setters.get(propertyName);
+ if((previousGetter!=null && m.isSetter())||(previousSetter!=null && m.isGetter())) {
+ // We have both Getter and Setter
+ unpairedGettersOrSetters.remove(propertyName);
+ } else if(m.isSetter()) {
+ setters.put(propertyName, m);
+ unpairedGettersOrSetters.put(propertyName, m);
+ } else if(m.isGetter()) {
+ getters.put(propertyName, m);
+ unpairedGettersOrSetters.put(propertyName, m);
+ }
+ }
+ }
+ } else {
+ properties.add(info.getName());
+ }
+ }
+ return properties;
+ }
+
+ static Map<IMember, MemberInfo> memberInfoCacheFalse = new HashMap<IMember, MemberInfo>();
+ static Map<IMember, MemberInfo> memberInfoCacheTrue = new HashMap<IMember, MemberInfo>();
+
+ public static void cleanCache() {
+ memberInfoCacheFalse.clear();
+ memberInfoCacheTrue.clear();
+ superTypesCache.clear();
+ }
+
+ public static MemberInfo createMemberInfo(IMember member, boolean dataModel) {
+ Map<IMember, MemberInfo> cache = dataModel ? memberInfoCacheTrue : memberInfoCacheFalse;
+ MemberInfo result = cache.get(member);
+ if(result != null) return result;
+ try {
+ if (member instanceof IType)
+ result = new TypeInfo((IType)member, null, dataModel);
+ else if (member instanceof IField)
+ result = new FieldInfo((IField)member, null, dataModel);
+ else if (member instanceof IMethod)
+ result = new MethodInfo((IMethod)member, null, dataModel);
+ } catch (JavaModelException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ if(result != null) {
+ cache.put(member, result);
+ }
+
+ return result;
+ }
+
+ public static MemberInfo createMemberInfo(IMember member) {
+ return createMemberInfo(member, false);
+ }
+
+ static String[] resolveSignatures (IType type, String[] signatures) {
+ if (signatures == null || signatures.length == 0)
+ return new String[0];
+
+ String[] resolvedSignatures = new String[signatures.length];
+ for (int i = 0; i < signatures.length; i++) {
+ resolvedSignatures[i] = EclipseJavaUtil.resolveTypeAsString(type, signatures[i]);
+ }
+ return resolvedSignatures;
+ }
+
+ static String[] convertToStringArray(char[][] names) {
+ if (names == null || names.length == 0)
+ return new String[0];
+ String[] sNames = new String[names.length];
+ for (int i = 0; i < sNames.length; i++) {
+ sNames[i] = String.valueOf(names[i]);
+ }
+ return sNames;
+ }
+
+ static String[] getTypeErasureFromSignatureArray(String[] signatures) {
+ if (signatures == null || signatures.length == 0)
+ return new String[0];
+ String[] result = new String[signatures.length];
+ for (int i = 0; i < signatures.length; i++) {
+ result[i] = Signature.getTypeErasure(signatures[i]);
+ }
+ return result;
+ }
+
+ static String getParameterNameFromType(String typeSignatures) {
+ if(typeSignatures==null) {
+ return null;
+ }
+ return Signature.getTypeVariable(typeSignatures);
+ }
+}
\ No newline at end of file
18 years
JBoss Tools SVN: r7037 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-20 08:30:06 -0400 (Thu, 20 Mar 2008)
New Revision: 7037
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
Log:
JBIDE-1750
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2008-03-20 12:16:14 UTC (rev 7036)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2008-03-20 12:30:06 UTC (rev 7037)
@@ -84,6 +84,11 @@
private static List<ISeamContextVariable> internalResolveVariables(ISeamProject project, String name, boolean onlyEqualNames, Set<ISeamContextVariable> variables) {
List<ISeamContextVariable> resolvedVariables = new ArrayList<ISeamContextVariable>();
+ if(onlyEqualNames) {
+ variables = project.getVariablesByName(name);
+ if(variables != null) resolvedVariables.addAll(variables);
+ return resolvedVariables;
+ }
for (ISeamContextVariable variable : variables) {
String n = variable.getName();
if(onlyEqualNames) {
@@ -225,8 +230,6 @@
}
public static TypeInfoCollector collectTypeInfo(TypeInfoCollector.MemberInfo member) {
- TypeInfoCollector typeInfo = new TypeInfoCollector(member);
- typeInfo.collectInfo();
- return typeInfo;
+ return member.getTypeCollector();
}
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java 2008-03-20 12:16:14 UTC (rev 7036)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java 2008-03-20 12:30:06 UTC (rev 7037)
@@ -14,6 +14,7 @@
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -172,6 +173,8 @@
private IType fMemberType;
private boolean isDataModel;
private Type fType;
+
+ TypeInfoCollector typeInfo;
protected MemberInfo (
IType sourceType,
@@ -291,6 +294,14 @@
void setDataModel(boolean isDataModel) {
this.isDataModel = isDataModel;
}
+
+ public TypeInfoCollector getTypeCollector() {
+ if(typeInfo == null) {
+ typeInfo = new TypeInfoCollector(this);
+ typeInfo.collectInfo();
+ }
+ return typeInfo;
+ }
abstract public IJavaElement getJavaElement();
}
@@ -567,17 +578,50 @@
return false;
}
}
-
+
+ public static class SuperTypeInfo {
+ IType type;
+ Set<String> names = new HashSet<String>();
+ IType[] superTypes = new IType[0];
+
+ SuperTypeInfo(IType type) throws JavaModelException {
+ this.type = type;
+ superTypesCache.put(type, this);
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
+ superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type);
+ if(superTypes != null) for (int i = 0; i < superTypes.length; i++) {
+ names.add(superTypes[i].getFullyQualifiedName());
+ }
+ if(superTypes == null) superTypes = new IType[0];
+ }
+
+ public Set<String> getNames() {
+ return names;
+ }
+
+ public IType[] getSuperTypes() {
+ return superTypes;
+ }
+ }
+
+ static Map<IType, SuperTypeInfo> superTypesCache = new HashMap<IType, SuperTypeInfo>();
+
+ public static SuperTypeInfo getSuperTypes(IType type) throws JavaModelException {
+ if(type == null) return null;
+ SuperTypeInfo ts = superTypesCache.get(type);
+ if(ts == null) {
+ ts = new SuperTypeInfo(type);
+ }
+ return ts;
+ }
+
public static boolean isInstanceofType(IType type, String qualifiedTypeName) throws JavaModelException {
if (qualifiedTypeName == null || type == null) return false;
boolean isInstanceofType = qualifiedTypeName.equals(type.getFullyQualifiedName());
if (!isInstanceofType) {
- ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
- IType[] superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type);
- for (int i = 0; !isInstanceofType && superTypes != null && i < superTypes.length; i++) {
- if (qualifiedTypeName.equals(superTypes[i].getFullyQualifiedName())) {
- return true;
- }
+ SuperTypeInfo ts = getSuperTypes(type);
+ if(ts != null && ts.getNames().contains(qualifiedTypeName)) {
+ return true;
}
return false;
}
@@ -823,20 +867,35 @@
}
return properties;
}
+
+ static Map<IMember, MemberInfo> memberInfoCacheFalse = new HashMap<IMember, MemberInfo>();
+ static Map<IMember, MemberInfo> memberInfoCacheTrue = new HashMap<IMember, MemberInfo>();
+
+ public static void cleanCache() {
+ memberInfoCacheFalse.clear();
+ memberInfoCacheTrue.clear();
+ superTypesCache.clear();
+ }
public static MemberInfo createMemberInfo(IMember member, boolean dataModel) {
+ Map<IMember, MemberInfo> cache = dataModel ? memberInfoCacheTrue : memberInfoCacheFalse;
+ MemberInfo result = cache.get(member);
+ if(result != null) return result;
try {
if (member instanceof IType)
- return new TypeInfo((IType)member, null, dataModel);
+ result = new TypeInfo((IType)member, null, dataModel);
else if (member instanceof IField)
- return new FieldInfo((IField)member, null, dataModel);
+ result = new FieldInfo((IField)member, null, dataModel);
else if (member instanceof IMethod)
- return new MethodInfo((IMethod)member, null, dataModel);
+ result = new MethodInfo((IMethod)member, null, dataModel);
} catch (JavaModelException e) {
SeamCorePlugin.getPluginLog().logError(e);
}
+ if(result != null) {
+ cache.put(member, result);
+ }
- return null;
+ return result;
}
public static MemberInfo createMemberInfo(IMember member) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-03-20 12:16:14 UTC (rev 7036)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-03-20 12:30:06 UTC (rev 7037)
@@ -60,6 +60,7 @@
import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.SeamTextSourceReference;
+import org.jboss.tools.seam.internal.core.el.TypeInfoCollector;
/**
* Validator for Java and XML files.
@@ -365,8 +366,7 @@
validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath());
// Save link between component name and all supers of java declaration.
try {
- ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
- IType[] superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type);
+ IType[] superTypes = TypeInfoCollector.getSuperTypes(type).getSuperTypes();
for (int i = 0; superTypes != null && i < superTypes.length; i++) {
if(!superTypes[i].isBinary()) {
IPath path = superTypes[i].getResource().getFullPath();
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2008-03-20 12:16:14 UTC (rev 7036)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2008-03-20 12:30:06 UTC (rev 7037)
@@ -21,6 +21,7 @@
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.internal.core.SeamProject;
+import org.jboss.tools.seam.internal.core.el.TypeInfoCollector;
/**
* This Manager invokes all dependent seam validators that should be invoked in one job.
@@ -46,6 +47,8 @@
* @see org.eclipse.wst.validation.internal.provisional.core.IValidatorJob#validateInJob(org.eclipse.wst.validation.internal.provisional.core.IValidationContext, org.eclipse.wst.validation.internal.provisional.core.IReporter)
*/
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException {
+ TypeInfoCollector.cleanCache();
+
SeamValidationHelper coreHelper = (SeamValidationHelper)helper;
ISeamProject project = coreHelper.getSeamProject();
if(project==null) {
18 years
JBoss Tools SVN: r7036 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-20 08:16:14 -0400 (Thu, 20 Mar 2008)
New Revision: 7036
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java
Log:
JBIDE-1933
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java 2008-03-20 11:47:13 UTC (rev 7035)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/operation/WebNatureOperation.java 2008-03-20 12:16:14 UTC (rev 7036)
@@ -219,7 +219,7 @@
// create Red Hat Web Nature
preCreateWebNature();
// createWebNature();
- monitor.worked(4);
+// monitor.worked(4);
// create Java Nature
JavaCore.create(getProject());
// createJavaNature(); // create java nature now migrate into create WTP nature @see createWTPNature()
@@ -228,10 +228,15 @@
// updateVersion();
monitor.worked(1);
// refresh project resource
- getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- monitor.worked(3);
+// getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+// monitor.worked(3);
// update model
createWebNature();
+ monitor.worked(4);
+
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ monitor.worked(3);
+
updateJavaNature(); // create java nature now migrate into create WTP nature @see createWTPNature()
updateVersion();
18 years
JBoss Tools SVN: r7035 - trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-03-20 07:47:13 -0400 (Thu, 20 Mar 2008)
New Revision: 7035
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteAdapter.java
Log:
JBIDE-1935
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteAdapter.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteAdapter.java 2008-03-20 11:46:45 UTC (rev 7034)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.ui.palette/src/org/jboss/tools/vpe/ui/palette/PaletteAdapter.java 2008-03-20 11:47:13 UTC (rev 7035)
@@ -78,7 +78,9 @@
}
public void setEnabled(boolean enabled) {
- viewer.setEnabled(enabled);
+ if(viewer != null) {
+ viewer.setEnabled(enabled);
+ }
}
public void dispose() {
@@ -86,6 +88,8 @@
dropManager.dispose();
descriptionManager.dispose();
viewPart.getViewSite().getActionBars().getToolBarManager().removeAll();
+ viewer = null;
+ viewPart = null;
}
public void setPaletteContents(PaletteContents contents) {
@@ -96,6 +100,9 @@
}
private void reload(XModelObject lastAddedXCat) {
+ if(viewer != null) {
+ viewer.deselectAll();
+ }
model.load(lastAddedXCat);
setEnabled(true);
/// setEnabled(viewPart.idEnabled());
@@ -185,7 +192,7 @@
isDirty = true;
} else {
reload(lastAddedCat);
- lastAddedCat = null;
+ lastAddedCat = null;
}
}
}
18 years
JBoss Tools SVN: r7034 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2008-03-20 07:46:45 -0400 (Thu, 20 Mar 2008)
New Revision: 7034
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1697, css style classes added and updated, code adjustment
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-20 09:40:52 UTC (rev 7033)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-20 11:46:45 UTC (rev 7034)
@@ -28,9 +28,18 @@
public class RichFacesTabPanelTemplate extends VpeAbstractTemplate implements VpeToggableTemplate {
- final static String RICH_FACES_TAB_PANEL = "richFacesTabPanel"; //$NON-NLS-1$
- final static String CSS_FILE_PATH = "tabPanel/tabPanel.css"; //$NON-NLS-1$
- final static String SPACER_FILE_PATH = "common/spacer.gif"; //$NON-NLS-1$
+ public static final String CSS_PANEL = "rich-tabpanel"; //$NON-NLS-1$
+ public static final String CSS_CONTENT = "rich-tabpanel-content"; //$NON-NLS-1$
+ public static final String CSS_CONTENT_POSITION = "rich-tabpanel-content-position"; //$NON-NLS-1$
+ public static final String CSS_SIDE_BORDER = "rich-tabhdr-side-border"; //$NON-NLS-1$
+ public static final String CSS_SIDE_CELL = "rich-tabhdr-side-cell"; //$NON-NLS-1$
+ public static final String CSS_CELL_ACTIVE = "rich-tabhdr-cell-active"; //$NON-NLS-1$
+ public static final String CSS_CELL_INACTIVE = "rich-tabhdr-cell-inactive"; //$NON-NLS-1$
+ public static final String CSS_CELL_DISABLED = "rich-tabhdr-cell-disabled"; //$NON-NLS-1$
+
+ private static final String RICH_FACES_TAB_PANEL = "richFacesTabPanel"; //$NON-NLS-1$
+ private static final String CSS_FILE_PATH = "tabPanel/tabPanel.css"; //$NON-NLS-1$
+ private static final String SPACER_FILE_PATH = "common/spacer.gif"; //$NON-NLS-1$
private final String HEADER_ALINGMENT = "headerAlignment"; //$NON-NLS-1$
private final String HEADER_SPACING = "headerSpacing"; //$NON-NLS-1$
@@ -43,11 +52,6 @@
private final String INACTIVE_TAB_CLASS = "inactiveTabClass"; //$NON-NLS-1$
private final String DISABLED_TAB_CLASS = "disabledTabClass"; //$NON-NLS-1$
- private final String CSS_PANEL = "rich-tabpanel"; //$NON-NLS-1$
- private final String CSS_CONTENT = "rich-tabpanel-content"; //$NON-NLS-1$
- private final String CSS_CONTENT_POSITION = "rich-tabpanel-content-position"; //$NON-NLS-1$
- private final String CSS_SIDE_BORDER = "rich-tabhdr-side-border"; //$NON-NLS-1$
- private final String CSS_SIDE_CELL = "rich-tabhdr-side-cell"; //$NON-NLS-1$
private final String ZERO = "0"; //$NON-NLS-1$
private final String ONE = "1"; //$NON-NLS-1$
@@ -68,7 +72,11 @@
VpeCreationData creationData = new VpeCreationData(table);
ComponentUtil.setCSSLink(pageContext, CSS_FILE_PATH, RICH_FACES_TAB_PANEL);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_PANEL + SPACE + ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR));
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR)
+ + SPACE + CSS_PANEL
+ + SPACE + CSS_CONTENT
+ + SPACE + CSS_CONTENT_POSITION);
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
@@ -108,12 +116,14 @@
if(child.getNodeName().endsWith(TAB)) {
RichFacesTabTemplate.encodeHeader((Element) child,
- visualDocument, inerTr, active, ComponentUtil
- .getAttribute(sourceElement, ACTIVE_TAB_CLASS),
+ visualDocument, inerTr, active,
+ ComponentUtil.getAttribute(sourceElement,
+ ACTIVE_TAB_CLASS),
ComponentUtil.getAttribute(sourceElement,
INACTIVE_TAB_CLASS),
ComponentUtil.getAttribute(sourceElement,
- DISABLED_TAB_CLASS), String.valueOf(i));
+ DISABLED_TAB_CLASS),
+ String.valueOf(i));
i++;
// Add <td><img src="#{spacer}" height="1" alt="" border="0" style="#{this:encodeHeaderSpacing(context, component)}"/></td>
nsIDOMElement spaceTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
@@ -152,15 +162,24 @@
if (active) {
RichFacesTabTemplate.encodeBody(creationData,
(Element) child, visualDocument, inerTr, true,
+ ComponentUtil.getAttribute(sourceElement,
+ TAB_CLASS)
+ + SPACE + CSS_SIDE_CELL
+ + SPACE + CSS_SIDE_BORDER,
+ ComponentUtil.getAttribute(sourceElement,
+ ACTIVE_TAB_CLASS)
+ + SPACE + CSS_CELL_ACTIVE,
ComponentUtil.getAttribute(sourceElement,
- TAB_CLASS), ComponentUtil.getAttribute(
- sourceElement, ACTIVE_TAB_CLASS),
+ INACTIVE_TAB_CLASS)
+ + SPACE + CSS_CELL_INACTIVE,
ComponentUtil.getAttribute(sourceElement,
- INACTIVE_TAB_CLASS), ComponentUtil
- .getAttribute(sourceElement,
- DISABLED_TAB_CLASS),
+ DISABLED_TAB_CLASS)
+ + SPACE + CSS_CELL_DISABLED,
ComponentUtil.getAttribute(sourceElement,
- CONTENT_CLASS),
+ CONTENT_CLASS)
+ + SPACE + CSS_PANEL
+ + SPACE + CSS_CONTENT
+ + SPACE + CSS_CONTENT_POSITION,
ComponentUtil.getAttribute(sourceElement,
CONTENT_STYLE));
break;
@@ -259,4 +278,15 @@
public void stopToggling(Node sourceNode) {
toggleMap.remove(sourceNode);
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext, org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument, org.mozilla.interfaces.nsIDOMElement, java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ return true;
+ }
+
}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-20 09:40:52 UTC (rev 7033)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-20 11:46:45 UTC (rev 7034)
@@ -13,6 +13,7 @@
import java.util.List;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
@@ -24,12 +25,33 @@
public class RichFacesTabTemplate extends VpeAbstractTemplate {
+ private final static String SPACER_FILE_PATH = "common/spacer.gif"; //$NON-NLS-1$
+ private final static String ACTIVE_BKG_FILE_PATH = "tabPanel/activeBackground.gif"; //$NON-NLS-1$
+ private final static String INACTIVE_BKG_FILE_PATH = "tabPanel/inactiveBackground.gif"; //$NON-NLS-1$
+ private final static String BORDER_FILE_PATH = "tabPanel/border.gif"; //$NON-NLS-1$
+
+ private final static String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$
+
+ private static final String DISABLED = "disabled"; //$NON-NLS-1$
+ private static final String LABEL = "label"; //$NON-NLS-1$
+
+ private static final String CSS_HEADER = "rich-tab-header"; //$NON-NLS-1$
+ private static final String CSS_LABEL = "rich-tab-label"; //$NON-NLS-1$
+ private static final String CSS_ACTIVE = "rich-tab-active"; //$NON-NLS-1$
+ private static final String CSS_INACTIVE = "rich-tab-inactive"; //$NON-NLS-1$
+ private static final String CSS_DISABLED = "rich-tab-disabled"; //$NON-NLS-1$
+
+ private static final String ZERO = "0"; //$NON-NLS-1$
+ private static final String ONE = "1"; //$NON-NLS-1$
+ private static final String SPACE = " "; //$NON-NLS-1$
+ private static final String EMPTY = ""; //$NON-NLS-1$
+
/**
* Encode body of tab
* @param creationData
* @param sourceElement
* @param visualDocument
- * @param parentVisualElement
+ * @param parentTr
* @param active
* @param tabClass
* @param activeTabClass
@@ -39,44 +61,53 @@
* @param contentStyle
* @return
*/
- public static VpeCreationData encodeBody(VpeCreationData creationData, Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement parentVisualElement, boolean active,
+ public static VpeCreationData encodeBody(VpeCreationData creationData,
+ Element sourceElement,
+ nsIDOMDocument visualDocument,
+ nsIDOMElement parentTr,
+ boolean active,
String tabClass,
String activeTabClass,
String inactiveTabClass,
String disabledTabClass,
String contentClass,
String contentStyle) {
-
- nsIDOMElement td = visualDocument.createElement("td");
+ nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
+
if(creationData==null) {
creationData = new VpeCreationData(td);
} else {
- parentVisualElement.appendChild(td);
+ parentTr.appendChild(td);
}
if(!active) {
return creationData;
}
// td.setAttribute("style", "position: relative;");
- td.setAttribute("height", "100%");
+ td.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
- nsIDOMElement table = visualDocument.createElement("table");
+ nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(table);
- table.setAttribute("border", "0");
- table.setAttribute("cellpadding", "10");
- table.setAttribute("cellspacing", "0");
- table.setAttribute("width", "100%");
- table.setAttribute("class", "dr-tbpnl-cntnt-pstn rich-tabpanel-content-position");
- table.setAttribute("style", "position: relative; z-index: 1;");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "10");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-cntnt-pstn" + SPACE + RichFacesTabPanelTemplate.CSS_CONTENT_POSITION);
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "position: relative; z-index: 1;");
- nsIDOMElement tr = visualDocument.createElement("tr");
+ nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tr);
- td = visualDocument.createElement("td");
+ td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(td);
- td.setAttribute("class", "dr-tbpnl-cntnt rich-tabpanel-content " + contentClass + " " + ComponentUtil.getAttribute(sourceElement, "styleClass"));
- td.setAttribute("style", ComponentUtil.getAttribute(sourceElement, "contentStyle") + "; " + ComponentUtil.getAttribute(sourceElement, "style"));
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR)
+ + SPACE + "dr-tbpnl-cntnt"
+ + SPACE + contentClass);
+ td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLE_ATTR)
+ + "; " + contentStyle);
List<Node> children = ComponentUtil.getChildren(sourceElement, true);
VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td);
@@ -89,7 +120,7 @@
}
public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
- return encodeBody(null, (Element)sourceNode, visualDocument, null, true, "", "", "", "", "", "");
+ return encodeBody(null, (Element)sourceNode, visualDocument, null, true, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY);
}
/**
@@ -102,76 +133,96 @@
* @param inactiveTabClass
* @param disabledTabClass
*/
- public static void encodeHeader(Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement parentDiv, boolean active,
+ public static void encodeHeader(Element sourceElement,
+ nsIDOMDocument visualDocument,
+ nsIDOMElement parentDiv,
+ boolean active,
String activeTabClass,
String inactiveTabClass,
- String disabledTabClass, String toggleId) {
+ String disabledTabClass,
+ String toggleId) {
- nsIDOMElement td = visualDocument.createElement("td");
+ nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentDiv.appendChild(td);
- td.setAttribute("style", "height: 100%; vertical-align: bottom;");
+ td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%; vertical-align: bottom;");
String styleClass = "dr-tbpnl-tbcell-dsbl rich-tabhdr-cell-dsbl";
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute("disabled"))) {
+ if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
if(active) {
- styleClass = "dr-tbpnl-tbcell-act rich-tabhdr-cell-active";
+ styleClass = "dr-tbpnl-tbcell-act"
+ + SPACE + RichFacesTabPanelTemplate.CSS_CELL_ACTIVE;
} else {
- styleClass = "dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive";
+ styleClass = "dr-tbpnl-tbcell-inact"
+ + SPACE + RichFacesTabPanelTemplate.CSS_CELL_INACTIVE;
}
}
- td.setAttribute("class", styleClass);
- td.setAttribute("vpe-user-toggle-id", toggleId);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
+ td.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
- nsIDOMElement table = visualDocument.createElement("table");
+ nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(table);
- table.setAttribute("border", "0");
- table.setAttribute("cellpadding", "0");
- table.setAttribute("cellspacing", "0");
- table.setAttribute("style", "height : 100%; position : relative; z-index : 2;");
- table.setAttribute("vpe-user-toggle-id", toggleId);
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height : 100%; position : relative; z-index : 2;");
+ table.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
- nsIDOMElement mainTr = visualDocument.createElement("tr");
+ nsIDOMElement mainTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(mainTr);
encodeSpacer(mainTr, visualDocument);
- td = visualDocument.createElement("td");
+ td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
mainTr.appendChild(td);
- td.setAttribute("class", "dr-tbpnl-tbtopbrdr rich-tabhdr-side-cell");
- td.setAttribute("style", "width: " + ComponentUtil.getAttribute(sourceElement, "labelWidth") + ";");
- td.setAttribute("vpe-user-toggle-id", toggleId);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbtopbrdr"
+ + SPACE + RichFacesTabPanelTemplate.CSS_SIDE_CELL);
+ td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "width: "
+ + ComponentUtil.getAttribute(sourceElement,"labelWidth") + ";");
+ td.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
- table = visualDocument.createElement("table");
+ table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(table);
- table.setAttribute("style", "height: 100%; width: 100%;");
- table.setAttribute("border", "0");
- table.setAttribute("cellpadding", "0");
- table.setAttribute("cellspacing", "0");
- table.setAttribute("vpe-user-toggle-id", toggleId);
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%; width: 100%;");
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ table.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
- nsIDOMElement tr = visualDocument.createElement("tr");
+ nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tr);
- td = visualDocument.createElement("td");
+ td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(td);
- styleClass = "dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-dsbl rich-tab-disabled " + disabledTabClass;
- String bgImgPath = ComponentUtil.getAbsoluteResourcePath("tabPanel/inactiveBackground.gif");
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-dsbl"
+ + SPACE + CSS_HEADER
+ + SPACE + CSS_LABEL
+ + SPACE + CSS_DISABLED
+ + SPACE + disabledTabClass;
+ String bgImgPath = ComponentUtil.getAbsoluteResourcePath(INACTIVE_BKG_FILE_PATH);
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute("disabled"))) {
+ if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
if(active) {
- styleClass = "dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-act rich-tab-active " + activeTabClass;
- bgImgPath = ComponentUtil.getAbsoluteResourcePath("tabPanel/activeBackground.gif");
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-act"
+ + SPACE + CSS_HEADER
+ + SPACE + CSS_LABEL
+ + SPACE + CSS_ACTIVE
+ + SPACE + activeTabClass;
+ bgImgPath = ComponentUtil.getAbsoluteResourcePath(ACTIVE_BKG_FILE_PATH);
} else {
- styleClass = "dr-tbpnl-tb rich-tab-header dr-tbpnl-tb-inact rich-tab-inactive " + inactiveTabClass;
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-inact"
+ + SPACE + CSS_HEADER
+ + SPACE + CSS_LABEL
+ + SPACE + CSS_INACTIVE
+ + SPACE + inactiveTabClass;
}
}
- td.setAttribute("class", styleClass);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
String style = "background-image: url(file:///" + bgImgPath.replace('\\', '/') + ");";
- td.setAttribute("style", style);
- td.setAttribute("vpe-user-toggle-id", toggleId);
- String label = sourceElement.getAttribute("label");
+ td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
+ td.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
+ String label = sourceElement.getAttribute(LABEL);
if(label==null) {
char space = 160;
- label = "" + space;
+ label = EMPTY + space;
}
td.appendChild(visualDocument.createTextNode(label));
encodeSpacer(mainTr, visualDocument);
@@ -181,17 +232,20 @@
* Add <td class="dr-tbpnl-tbbrdr rich-tabhdr-side-border"><img src="#{spacer}" width="1" height="1" alt="" border="0" /></td>
*/
private static void encodeSpacer(nsIDOMElement parentTr, nsIDOMDocument visualDocument) {
- nsIDOMElement td = visualDocument.createElement("td");
+ nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(td);
- td.setAttribute("class", "dr-tbpnl-tbbrdr rich-tabhdr-side-border");
- String borderImgPath = ComponentUtil.getAbsoluteResourcePath("tabPanel/border.gif");
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbbrdr"
+ + SPACE + RichFacesTabPanelTemplate.CSS_SIDE_BORDER);
+ String borderImgPath = ComponentUtil.getAbsoluteResourcePath(BORDER_FILE_PATH);
String style = "background-image: url(file:///" + borderImgPath.replace('\\', '/') + ");";
- td.setAttribute("style", style);
- nsIDOMElement img = visualDocument.createElement("img");
+ td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
+ nsIDOMElement img = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
td.appendChild(img);
- ComponentUtil.setImg(img, "common/spacer.gif");
- img.setAttribute("width", "1");
- img.setAttribute("height", "1");
- img.setAttribute("border", "0");
+ ComponentUtil.setImg(img, SPACER_FILE_PATH);
+ img.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, ONE);
+ img.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, ONE);
+ img.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+
}
+
}
\ No newline at end of file
18 years
JBoss Tools SVN: r7033 - trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-03-20 05:40:52 -0400 (Thu, 20 Mar 2008)
New Revision: 7033
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.properties
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/DebugJavaCompletionProposalComputer.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1668
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java 2008-03-20 09:40:45 UTC (rev 7032)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/CriteriaQuickAssistProcessor.java 2008-03-20 09:40:52 UTC (rev 7033)
@@ -69,7 +69,7 @@
};
}
catch (BadLocationException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage( "Could not get document contents for CriteriaQuickAssist", e );
+ HibernateConsolePlugin.getDefault().logErrorMessage( JdtUIMessages.CriteriaQuickAssistProcessor_errorMessage, e );
}
return result;
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/DebugJavaCompletionProposalComputer.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/DebugJavaCompletionProposalComputer.java 2008-03-20 09:40:45 UTC (rev 7032)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/DebugJavaCompletionProposalComputer.java 2008-03-20 09:40:52 UTC (rev 7033)
@@ -86,7 +86,7 @@
}
public String getDisplayString() {
- return "I wanna show a dialog!";
+ return JdtUIMessages.DebugJavaCompletionProposalComputer_displayString;
}
public Image getImage() {
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java 2008-03-20 09:40:45 UTC (rev 7032)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/HQLJavaCompletionProposalComputer.java 2008-03-20 09:40:52 UTC (rev 7033)
@@ -87,10 +87,10 @@
proposals = eclipseHQLCompletionCollector.getCompletionProposals();
}
} catch(RuntimeException re) {
- HibernateConsolePlugin.getDefault().logErrorMessage( "Error while performing HQL completion in java", re );
+ HibernateConsolePlugin.getDefault().logErrorMessage( JdtUIMessages.HQLJavaCompletionProposalComputer_errorMessage, re );
}
catch (BadLocationException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage( "Error while performing HQL completion in java", e );
+ HibernateConsolePlugin.getDefault().logErrorMessage( JdtUIMessages.HQLJavaCompletionProposalComputer_errorMessage, e );
}
return proposals;
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.java 2008-03-20 09:40:52 UTC (rev 7033)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 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.hibernate.eclipse.jdt.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class JdtUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME= "org.hibernate.eclipse.jdt.ui.internal.JdtUIMessages";//$NON-NLS-1$
+
+ public static String SaveQueryEditorListener_replaceQuestion;
+
+ public static String SaveQueryEditorListener_replaceTitle;
+
+ public static String SaveQueryEditorListener_replaceQuestion_confirm;
+
+ public static String SaveQueryEditorListener_replaceTitle_confirm;
+
+ public static String CriteriaQuickAssistProcessor_errorMessage;
+
+ public static String DebugJavaCompletionProposalComputer_displayString;
+
+ public static String HQLJavaCompletionProposalComputer_errorMessage;
+
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JdtUIMessages.class);
+ }
+
+ private JdtUIMessages(){
+ // Do not instantiate
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.properties (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.properties 2008-03-20 09:40:52 UTC (rev 7033)
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2007-2008 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
+##############################################################################/
+
+
+SaveQueryEditorListener_replaceQuestion= Do you want to replace old query ''{0}'' in the {1} editor with new one ''{2}'' ?
+SaveQueryEditorListener_replaceTitle= Query replace
+
+SaveQueryEditorListener_replaceTitle_confirm= Query replace
+SaveQueryEditorListener_replaceQuestion_confirm= Query ''{0}'' changed it place in the {1} editor. Impossible to replace.
+
+CriteriaQuickAssistProcessor_errorMessage= Could not get document contents for CriteriaQuickAssist
+
+DebugJavaCompletionProposalComputer_displayString= I wanna show a dialog!
+
+HQLJavaCompletionProposalComputer_errorMessage= Error while performing HQL completion in java
\ No newline at end of file
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUIMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java 2008-03-20 09:40:45 UTC (rev 7032)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/SaveQueryEditorListener.java 2008-03-20 09:40:52 UTC (rev 7033)
@@ -10,16 +10,24 @@
******************************************************************************/
package org.hibernate.eclipse.jdt.ui.internal;
+import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.hibernate.eclipse.console.AbstractQueryEditor;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.jdt.ui.Activator;
/**
* @author Dmitry Geraskov
@@ -27,6 +35,8 @@
*/
public class SaveQueryEditorListener implements IPropertyListener {
+ public static final String id = "AbstractQueryEditor.ReplaceString";
+
public static final int HQLEditor = 0;
public static final int CriteriaEditor = 1;
@@ -36,7 +46,7 @@
private String query;
private Point position;
- public SaveQueryEditorListener(ITextEditor fromEditorPart, String consoleName,
+ public SaveQueryEditorListener(final ITextEditor fromEditorPart, String consoleName,
String query, Point position, int editorNum){
this.fromEditorPart = fromEditorPart;
this.query = query;
@@ -44,14 +54,36 @@
switch (editorNum) {
case HQLEditor:
editor = (AbstractQueryEditor) HibernateConsolePlugin.getDefault()
- .openScratchHQLEditor( consoleName, query );
+ .openScratchHQLEditor( consoleName, query );
break;
default:
editor = (AbstractQueryEditor) HibernateConsolePlugin.getDefault()
- .openCriteriaEditor( consoleName, query );
+ .openCriteriaEditor( consoleName, query );
}
editor.addPropertyListener(this);
+ editor.showConnected(fromEditorPart);
+ final IWorkbenchPart fromWorkbenchPart = fromEditorPart.getEditorSite().getPart();
+ IPartListener pl = new IPartListener(){
+
+ public void partActivated(IWorkbenchPart part) {}
+
+ public void partBroughtToTop(IWorkbenchPart part) {}
+
+ public void partClosed(IWorkbenchPart part) {
+ if (fromWorkbenchPart == part){
+ fromEditorPart.getEditorSite().getPage().removePartListener(this);
+ editor.removePropertyListener(SaveQueryEditorListener.this);
+ editor.showDisconnected();
+ }
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {}
+
+ public void partOpened(IWorkbenchPart part) {}
+
+ };
+ fromEditorPart.getEditorSite().getPage().addPartListener(pl);
}
@@ -59,14 +91,29 @@
* @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object, int)
*/
public void propertyChanged(Object source, int propId) {
+
+ String editorTitle = fromEditorPart.getTitle();
+
if (IEditorPart.PROP_DIRTY == propId && !editor.isDirty()){
String newQuery = editor.getQueryString();
-
- IDocumentProvider docProvider = fromEditorPart.getDocumentProvider();
- if (docProvider == null){ // editor was disposed
- editor.removePropertyListener(this);
+ String question = NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion, new String[]{query, editorTitle, newQuery});
+
+ int ans = OptionalMessageDialog.open(id, null, JdtUIMessages.SaveQueryEditorListener_replaceTitle, null, question,
+ MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
+ if (OptionalMessageDialog.NOT_SHOWN != ans){
+ //write previous answer
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setValue(id, ans == Window.OK);
+ } else {
+ //read previous answer
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ if (!store.getBoolean(id)) return;
+ }
+ if (Window.CANCEL == ans){
return;
}
+
+ IDocumentProvider docProvider = fromEditorPart.getDocumentProvider();
IDocument doc = docProvider.getDocument( fromEditorPart.getEditorInput() );
boolean isDocChanged = true;
@@ -79,9 +126,8 @@
}
if (isDocChanged){
- String title = "Document was changed";
- String question = "Document was changed. Can't find string to replace.";
- MessageDialog.openConfirm( null, title, question);
+ String confirm_changed = NLS.bind(JdtUIMessages.SaveQueryEditorListener_replaceQuestion_confirm, query, editorTitle);
+ MessageDialog.openConfirm( null, JdtUIMessages.SaveQueryEditorListener_replaceTitle_confirm, confirm_changed);
return;
}
@@ -93,7 +139,7 @@
} catch (BadLocationException e) {
HibernateConsolePlugin.getDefault().log(e);
}
- }
+ }
}
}
18 years
JBoss Tools SVN: r7032 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console: src/org/hibernate/eclipse/console and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-03-20 05:40:45 -0400 (Thu, 20 Mar 2008)
New Revision: 7032
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/connected.gif
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1668
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/connected.gif
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/connected.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java 2008-03-20 09:39:21 UTC (rev 7031)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/AbstractQueryEditor.java 2008-03-20 09:40:45 UTC (rev 7032)
@@ -1,6 +1,5 @@
package org.hibernate.eclipse.console;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.ActionContributionItem;
@@ -9,21 +8,19 @@
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.TextEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IShowEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.editors.text.TextEditor;
@@ -40,6 +37,11 @@
private ExecuteQueryAction execAction = null;
final private QueryInputModel queryInputModel;
+ private String defPartName;
+ private Image defTitleImage;
+ private Image connectedTitleImage;
+ private String connectedImageFilePath = "icons/images/connected.gif";
+
// to enable execution of queries from files - hack for HBX-744
private String consoleConfigurationName;
@@ -239,4 +241,24 @@
public QueryInputModel getQueryInputModel() {
return queryInputModel;
}
+
+ public void showConnected(IEditorPart editor){
+ defPartName = getPartName();
+ defTitleImage = getTitleImage();
+ setPartName(defPartName + "->" + editor.getTitle());
+ if (connectedTitleImage == null){
+ connectedTitleImage = HibernateConsolePlugin.getImageDescriptor(connectedImageFilePath).createImage();
+ }
+ setTitleImage(connectedTitleImage);
+ }
+
+ public void showDisconnected(){
+ setPartName(defPartName);
+ if (defTitleImage != null && !defTitleImage.isDisposed()){
+ setTitleImage(defTitleImage);
+ } else {
+ setTitleImage(null);
+ }
+ connectedTitleImage.dispose();
+ }
}
18 years
JBoss Tools SVN: r7031 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console: src/org/hibernate/eclipse/console/actions and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-03-20 05:39:21 -0400 (Thu, 20 Mar 2008)
New Revision: 7031
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/java.gif
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/mapping.gif
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/open_mapping.gif
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/open_source.gif
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1908
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/java.gif
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/java.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/mapping.gif
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/mapping.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/open_mapping.gif
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/icons/images/open_source.gif
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2008-03-20 09:39:14 UTC (rev 7030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenMappingAction.java 2008-03-20 09:39:21 UTC (rev 7031)
@@ -50,7 +50,7 @@
private static final String HIBERNATE_TAG_NAME = "name";
private static final String HIBERNATE_TAG_ENTITY_NAME = "entity-name";
- private String imageFilePath = "icons/images/open_mapping.gif";
+ private String imageFilePath = "icons/images/mapping.gif";
public OpenMappingAction() {
super("Open Mapping File");
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java 2008-03-20 09:39:14 UTC (rev 7030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/OpenSourceAction.java 2008-03-20 09:39:21 UTC (rev 7031)
@@ -12,13 +12,10 @@
import java.io.FileNotFoundException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.debug.ui.JavaDebugImages;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -28,11 +25,8 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.SelectionListenerAction;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.ImageConstants;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.console.utils.EclipseImages;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
@@ -44,7 +38,7 @@
public class OpenSourceAction extends SelectionListenerAction {
- private String imageFilePath = "icons/images/open_source.gif";
+ private String imageFilePath = "icons/images/java.gif";
public OpenSourceAction() {
super("Open Source File");
18 years
JBoss Tools SVN: r7030 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor: src/org/jboss/tools/hibernate/ui/veditor/editors/actions and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-03-20 05:39:14 -0400 (Thu, 20 Mar 2008)
New Revision: 7030
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/java.gif
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/mapping.gif
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/open_mapping.gif
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/open_source.gif
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1908
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/java.gif
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/java.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/mapping.gif
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/mapping.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/open_mapping.gif
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/icons/open_source.gif
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2008-03-20 08:38:50 UTC (rev 7029)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenMappingAction.java 2008-03-20 09:39:14 UTC (rev 7030)
@@ -14,10 +14,7 @@
import java.util.Set;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.mapping.Property;
@@ -37,7 +34,7 @@
super(part);
setId(ACTION_ID);
setText("Open Mapping File");
- setImageDescriptor(VisualEditorPlugin.getImageDescriptor("icons/open_mapping.gif"));
+ setImageDescriptor(VisualEditorPlugin.getImageDescriptor("icons/mapping.gif"));
}
public void run() {
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2008-03-20 08:38:50 UTC (rev 7029)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/actions/OpenSourceAction.java 2008-03-20 09:39:14 UTC (rev 7030)
@@ -29,7 +29,7 @@
super(part);
setId(ACTION_ID);
setText("Open Source File");
- setImageDescriptor(VisualEditorPlugin.getImageDescriptor("icons/open_source.gif"));
+ setImageDescriptor(VisualEditorPlugin.getImageDescriptor("icons/java.gif"));
}
public void run() {
18 years
JBoss Tools SVN: r7029 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces: templates and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2008-03-20 04:38:50 -0400 (Thu, 20 Mar 2008)
New Revision: 7029
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-1697, code adjustment, width and height attributes updated.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-20 03:07:31 UTC (rev 7028)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-20 08:38:50 UTC (rev 7029)
@@ -15,6 +15,7 @@
import java.util.Map;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
@@ -27,47 +28,77 @@
public class RichFacesTabPanelTemplate extends VpeAbstractTemplate implements VpeToggableTemplate {
+ final static String RICH_FACES_TAB_PANEL = "richFacesTabPanel"; //$NON-NLS-1$
+ final static String CSS_FILE_PATH = "tabPanel/tabPanel.css"; //$NON-NLS-1$
+ final static String SPACER_FILE_PATH = "common/spacer.gif"; //$NON-NLS-1$
+
+ private final String HEADER_ALINGMENT = "headerAlignment"; //$NON-NLS-1$
+ private final String HEADER_SPACING = "headerSpacing"; //$NON-NLS-1$
+ private final String SELECTED_TAB = "selectedTab"; //$NON-NLS-1$
+
+ private final String CONTENT_CLASS = "contentClass"; //$NON-NLS-1$
+ private final String CONTENT_STYLE = "contentStyle"; //$NON-NLS-1$
+ private final String TAB_CLASS = "tabClass"; //$NON-NLS-1$
+ private final String ACTIVE_TAB_CLASS = "activeTabClass"; //$NON-NLS-1$
+ private final String INACTIVE_TAB_CLASS = "inactiveTabClass"; //$NON-NLS-1$
+ private final String DISABLED_TAB_CLASS = "disabledTabClass"; //$NON-NLS-1$
+
+ private final String CSS_PANEL = "rich-tabpanel"; //$NON-NLS-1$
+ private final String CSS_CONTENT = "rich-tabpanel-content"; //$NON-NLS-1$
+ private final String CSS_CONTENT_POSITION = "rich-tabpanel-content-position"; //$NON-NLS-1$
+ private final String CSS_SIDE_BORDER = "rich-tabhdr-side-border"; //$NON-NLS-1$
+ private final String CSS_SIDE_CELL = "rich-tabhdr-side-cell"; //$NON-NLS-1$
+
+ private final String ZERO = "0"; //$NON-NLS-1$
+ private final String ONE = "1"; //$NON-NLS-1$
+ private final String TWO = "2"; //$NON-NLS-1$
+ private final String SPACE = " "; //$NON-NLS-1$
+ private final String EMPTY = ""; //$NON-NLS-1$
+
+ private final String TAB = ":tab"; //$NON-NLS-1$
+ private final String NAME = "name"; //$NON-NLS-1$
+
private static Map toggleMap = new HashMap();
public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
Element sourceElement = (Element)sourceNode;
- nsIDOMElement table = visualDocument.createElement("table");
+ nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
VpeCreationData creationData = new VpeCreationData(table);
- ComponentUtil.setCSSLink(pageContext, "tabPanel/tabPanel.css", "richFacesTabPanel");
- table.setAttribute("class", "rich-tabpanel " + ComponentUtil.getAttribute(sourceElement, "styleClass"));
- table.setAttribute("border", "0");
- table.setAttribute("cellpadding", "0");
- table.setAttribute("cellspacing", "0");
- table.setAttribute("style", getStyle(sourceElement));
+ ComponentUtil.setCSSLink(pageContext, CSS_FILE_PATH, RICH_FACES_TAB_PANEL);
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_PANEL + SPACE + ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR));
+ table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, getStyle(sourceElement));
- nsIDOMElement tbody = visualDocument.createElement("tbody");
+ nsIDOMElement tbody = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TBODY);
table.appendChild(tbody);
- nsIDOMElement tr = visualDocument.createElement("tr");
+ nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
tbody.appendChild(tr);
- nsIDOMElement td = visualDocument.createElement("td");
+ nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(td);
- td.setAttribute("align", getHeaderAlignment(sourceElement));
+ td.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR, getHeaderAlignment(sourceElement));
- nsIDOMElement inerTable = visualDocument.createElement("table");
+ nsIDOMElement inerTable = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(inerTable);
- inerTable.setAttribute("border", "0");
- inerTable.setAttribute("cellpadding", "0");
- inerTable.setAttribute("cellspacing", "0");
+ inerTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ inerTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ inerTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
// Encode header
- nsIDOMElement inerTr = visualDocument.createElement("tr");
+ nsIDOMElement inerTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
inerTable.appendChild(inerTr);
- nsIDOMElement inerTd = visualDocument.createElement("td");
+ nsIDOMElement inerTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
inerTr.appendChild(inerTd);
- nsIDOMElement img = visualDocument.createElement("img");
+ nsIDOMElement img = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
inerTd.appendChild(img);
- ComponentUtil.setImg(img, "common/spacer.gif");
- img.setAttribute("width", "2");
- img.setAttribute("height", "1");
- img.setAttribute("border", "0");
+ ComponentUtil.setImg(img, SPACER_FILE_PATH);
+ img.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, TWO);
+ img.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, ONE);
+ img.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
List<Node> children = ComponentUtil.getChildren(sourceElement);
int activeId = getActiveId(sourceElement, children);
@@ -75,45 +106,63 @@
for (Node child : children) {
boolean active = (i == activeId);
- if(child.getNodeName().endsWith(":tab")) {
- RichFacesTabTemplate.encodeHeader((Element)child, visualDocument, inerTr, active, ComponentUtil.getAttribute(sourceElement, "activeTabClass"), ComponentUtil.getAttribute(sourceElement, "inactiveTabClass"), ComponentUtil.getAttribute(sourceElement, "disabledTabClass"), String.valueOf(i));
+ if(child.getNodeName().endsWith(TAB)) {
+ RichFacesTabTemplate.encodeHeader((Element) child,
+ visualDocument, inerTr, active, ComponentUtil
+ .getAttribute(sourceElement, ACTIVE_TAB_CLASS),
+ ComponentUtil.getAttribute(sourceElement,
+ INACTIVE_TAB_CLASS),
+ ComponentUtil.getAttribute(sourceElement,
+ DISABLED_TAB_CLASS), String.valueOf(i));
i++;
// Add <td><img src="#{spacer}" height="1" alt="" border="0" style="#{this:encodeHeaderSpacing(context, component)}"/></td>
- nsIDOMElement spaceTd = visualDocument.createElement("td");
+ nsIDOMElement spaceTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
inerTr.appendChild(spaceTd);
- nsIDOMElement spaceImg = visualDocument.createElement("img");
+ nsIDOMElement spaceImg = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
spaceTd.appendChild(spaceImg);
- ComponentUtil.setImg(spaceImg, "common/spacer.gif");
- spaceImg.setAttribute("height", "1");
- spaceImg.setAttribute("border", "0");
- String headerSpacing = sourceElement.getAttribute("headerSpacing");
+ ComponentUtil.setImg(spaceImg, SPACER_FILE_PATH);
+ spaceImg.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, ONE);
+ spaceImg.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ String headerSpacing = sourceElement.getAttribute(HEADER_SPACING);
if(headerSpacing==null) {
- headerSpacing = "1";
+ headerSpacing = ONE;
}
- spaceImg.setAttribute("style", "width: " + headerSpacing + "px");
+ spaceImg.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "width: " + headerSpacing + "px"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- inerTd = visualDocument.createElement("td");
+ inerTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
inerTr.appendChild(inerTd);
- img = visualDocument.createElement("img");
+ img = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
inerTd.appendChild(img);
- ComponentUtil.setImg(img, "common/spacer.gif");
- img.setAttribute("width", "1");
- img.setAttribute("height", "1");
- img.setAttribute("border", "0");
+ ComponentUtil.setImg(img, SPACER_FILE_PATH);
+ img.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, ONE);
+ img.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, ONE);
+ img.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
// Encode first child tab
- inerTr = visualDocument.createElement("tr");
+ inerTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
tbody.appendChild(inerTr);
children = ComponentUtil.getChildren(sourceElement);
i = 0;
for (Node child : children) {
boolean active = (i == activeId);
- if(child.getNodeName().endsWith(":tab")) {
+ if(child.getNodeName().endsWith(TAB)) {
i++;
if (active) {
- RichFacesTabTemplate.encodeBody(creationData, (Element)child, visualDocument, inerTr, true, ComponentUtil.getAttribute(sourceElement, "tabClass"), ComponentUtil.getAttribute(sourceElement, "activeTabClass"), ComponentUtil.getAttribute(sourceElement, "inactiveTabClass"), ComponentUtil.getAttribute(sourceElement, "disabledTabClass"), ComponentUtil.getAttribute(sourceElement, "contentClass"), ComponentUtil.getAttribute(sourceElement, "contentStyle"));
+ RichFacesTabTemplate.encodeBody(creationData,
+ (Element) child, visualDocument, inerTr, true,
+ ComponentUtil.getAttribute(sourceElement,
+ TAB_CLASS), ComponentUtil.getAttribute(
+ sourceElement, ACTIVE_TAB_CLASS),
+ ComponentUtil.getAttribute(sourceElement,
+ INACTIVE_TAB_CLASS), ComponentUtil
+ .getAttribute(sourceElement,
+ DISABLED_TAB_CLASS),
+ ComponentUtil.getAttribute(sourceElement,
+ CONTENT_CLASS),
+ ComponentUtil.getAttribute(sourceElement,
+ CONTENT_STYLE));
break;
}
}
@@ -131,7 +180,7 @@
}
if (activeId == -1) {
- activeId = getTabId(children, sourceElement.getAttribute("selectedTab"));
+ activeId = getTabId(children, sourceElement.getAttribute(SELECTED_TAB));
}
if (activeId == -1)
@@ -148,7 +197,7 @@
private int getChildrenCount(List<Node> children) {
int count = 0;
for (Node child : children) {
- if (child.getNodeName().endsWith(":tab")) {
+ if (child.getNodeName().endsWith(TAB)) {
count++;
}
}
@@ -159,11 +208,11 @@
if (tabName == null) return -1;
int count = 0;
for (Node child : children) {
- if (child.getNodeName().endsWith(":tab")) {
+ if (child.getNodeName().endsWith(TAB)) {
if (!(child instanceof Element))
continue;
- String name = ((Element)child).getAttribute("name");
+ String name = ((Element)child).getAttribute(NAME);
if (tabName.equals(name))
return count;
@@ -175,20 +224,20 @@
private String getStyle(Element sourceElement) {
- String widthAttrValue = sourceElement.getAttribute("width");
- String heightAttrValue = sourceElement.getAttribute("height");
- String styleAttrValue = sourceElement.getAttribute("style");
- String style = styleAttrValue != null ? styleAttrValue : "";
+ String widthAttrValue = sourceElement.getAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR);
+ String heightAttrValue = sourceElement.getAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR);
+ String styleAttrValue = sourceElement.getAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ String style = styleAttrValue != null ? styleAttrValue : EMPTY;
- if (!ComponentUtil.parameterPresent(styleAttrValue, "width")) {
- String width = (widthAttrValue != null && widthAttrValue.length() > 0) ? widthAttrValue : "100%";
- style = ComponentUtil.addParameter(style, "width:" + width);
+ if (!ComponentUtil.parameterPresent(styleAttrValue, HtmlComponentUtil.HTML_WIDTH_ATTR)) {
+ String width = (widthAttrValue != null && widthAttrValue.length() > 0) ? widthAttrValue : "100%"; //$NON-NLS-1$
+ style = ComponentUtil.addParameter(style, "width:" + width); //$NON-NLS-1$
}
- if (!ComponentUtil.parameterPresent(styleAttrValue, "height")) {
- String height = (heightAttrValue != null && heightAttrValue.length() > 0) ? heightAttrValue : "";
+ if (!ComponentUtil.parameterPresent(styleAttrValue, HtmlComponentUtil.HTML_HEIGHT_ATTR)) {
+ String height = (heightAttrValue != null && heightAttrValue.length() > 0) ? heightAttrValue : EMPTY;
if (height.length() > 0) {
- style =ComponentUtil.addParameter(style, "height:" + height);
+ style =ComponentUtil.addParameter(style, "height:" + height); //$NON-NLS-1$
}
}
@@ -196,9 +245,9 @@
}
private String getHeaderAlignment(Element sourceElement) {
- String headerAlignment = sourceElement.getAttribute("headerAlignment");
+ String headerAlignment = sourceElement.getAttribute(HEADER_ALINGMENT);
if(headerAlignment==null) {
- headerAlignment = "left";
+ headerAlignment = HtmlComponentUtil.HTML_ALIGN_LEFT_VALUE;
}
return headerAlignment;
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2008-03-20 03:07:31 UTC (rev 7028)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2008-03-20 08:38:50 UTC (rev 7029)
@@ -502,8 +502,8 @@
<vpe:tag name="rich:tabPanel" case-sensitive="yes">
<vpe:template children="yes" modify="yes" class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTabPanelTemplate">
<vpe:resize>
- <vpe:width width-attr="style.width" />
- <vpe:height height-attr="style.height" />
+ <vpe:width width-attr="width" />
+ <vpe:height height-attr="height" />
</vpe:resize>
<vpe:drag start-enable="yes"/>
<vpe:drop container="no"/>
18 years