[jbpm-cvs] jbpm.3/designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/properties ...

Koen Aers <[email protected]> Tue, 24 Feb 2009 13:24:32 -0500
Newsgroups gmane.comp.jbpm.cvs
Message-ID <[email protected]>
  User: kaers   
  Date: 09/02/24 13:24:32

  Modified:    designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/properties 
                        Tag: branch_jbpm_jpdl_gpd_3_1_x
                        DelegationConfigurationComposite.java
  Log:
  GPD-65
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.4.1   +73 -10    jbpm.3/designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/properties/Attic/DelegationConfigurationComposite.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DelegationConfigurationComposite.java
  ===================================================================
  RCS file: /cvsroot/jbpm/jbpm.3/designer/jpdl/org.jbpm.gd.jpdl/src/org/jbpm/gd/jpdl/properties/Attic/DelegationConfigurationComposite.java,v
  retrieving revision 1.4
  retrieving revision 1.4.4.1
  diff -u -b -r1.4 -r1.4.4.1
  --- DelegationConfigurationComposite.java	7 Aug 2007 13:02:44 -0000	1.4
  +++ DelegationConfigurationComposite.java	24 Feb 2009 18:24:32 -0000	1.4.4.1
  @@ -6,8 +6,11 @@
   import java.util.List;
   
   import org.eclipse.jdt.core.Flags;
  +import org.eclipse.jdt.core.ICompilationUnit;
   import org.eclipse.jdt.core.IField;
  +import org.eclipse.jdt.core.IImportDeclaration;
   import org.eclipse.jdt.core.IMethod;
  +import org.eclipse.jdt.core.IPackageDeclaration;
   import org.eclipse.jdt.core.IType;
   import org.eclipse.jdt.core.JavaModelException;
   import org.eclipse.jface.viewers.ColumnWeightData;
  @@ -344,10 +347,17 @@
   	private List getFields(IType type) {
   		List result = new ArrayList();
   		try {
  -			IField[] fields = type.getFields();
  -			for (int i = 0; i < fields.length; i++) {
  -				if (!Flags.isStatic(fields[i].getFlags())) {
  -					result.add(fields[i].getElementName());
  +			List types = getTypes(type);
  +			for (int i = 0; i < types.size(); i++) {
  +				IType subType = (IType)types.get(i);
  +				IField[] fields = subType.getFields();
  +				for (int j = 0; j < fields.length; j++) {
  +					if (!Flags.isStatic(fields[j].getFlags())) {
  +						String fieldName = fields[j].getElementName();
  +						if (!result.contains(fieldName)) {
  +							result.add(fieldName);
  +						}
  +					}
   				}
   			}
   		} catch (JavaModelException  e) {
  @@ -356,6 +366,52 @@
   		return result;
   	}
   
  +	private IType getSupertype(IType targetType) throws JavaModelException {
  +		if (targetType == null) return null;
  +		String name = targetType.getSuperclassName();
  +		if (name == null) return null;
  +		IType result = getClassFor(name);
  +		if (result != null) return result;
  +		ICompilationUnit compilationUnit = targetType.getCompilationUnit();
  +		if (compilationUnit == null) return null;
  +		IPackageDeclaration[] packageDeclarations = compilationUnit.getPackageDeclarations();
  +		if (packageDeclarations != null && packageDeclarations.length > 0) {
  +			String qualifiedName = packageDeclarations[0].getElementName() + "." + name;
  +			result = getClassFor(qualifiedName);
  +			if (result != null) return result;
  +		}
  +		IImportDeclaration[] importDeclarations = compilationUnit.getImports();
  +		if (importDeclarations == null) return null;
  +		for (int i = 0; i < importDeclarations.length; i++) {
  +			String declaration = importDeclarations[i].getElementName();
  +			if (declaration.endsWith(name)) {
  +				result = getClassFor(declaration);
  +				if (result != null) return result;
  +			} else if (declaration.endsWith(".*")) {
  +				String qualifiedName = declaration.substring(0, declaration.length() - 1) + name;
  +				result = getClassFor(qualifiedName);
  +				if (result != null) return result;
  +			}
  +		}
  +		return null;
  +	}
  +	
  +	
  +	private List getTypes(IType targetType) {
  +		List types = new ArrayList();
  +		IType type = targetType;
  +		while (type != null && !"java.lang.Object".equals(type.getFullyQualifiedName())) {
  +			try {
  +				types.add(type);
  +				type = getSupertype(type);
  +			}
  +			catch (JavaModelException e) {
  +				Logger.logError("Error while looking up the supertypes of " + targetType.getFullyQualifiedName() + ".", e);
  +			}
  +		}
  +		return types;
  +	}
  +
   	private void handleBeanConfigType() {
   		if (beanTableComposite.table.getItemCount() == 0) {
   			messageLabel.setText("The class does not have any setters");
  @@ -369,12 +425,19 @@
   	private List getSetters(IType type) {
   		List result = new ArrayList();
   		try {
  -			IMethod[] methods = type.getMethods();
  -			for (int i = 0; i < methods.length; i++) {
  -				if (methods[i].getElementName().startsWith("set")) {
  -					StringBuffer buff = new StringBuffer(methods[i].getElementName().substring(3));
  +			List types = getTypes(type);
  +			for (int i = 0; i < types.size(); i++) {
  +				IType subType = (IType)types.get(i);
  +				IMethod[] methods = subType.getMethods();
  +				for (int j = 0; j < methods.length; j++) {
  +					if (methods[j].getElementName().startsWith("set")) {
  +						StringBuffer buff = new StringBuffer(methods[j].getElementName().substring(3));
   					buff.setCharAt(0, Character.toLowerCase(buff.charAt(0)));
  -					result.add(buff.toString());
  +						String methodName = buff.toString();
  +						if (!result.contains(methodName)) {
  +							result.add(methodName);
  +						}
  +					}
   				}
   			}
   		} catch (JavaModelException  e) {
  
  
  

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H