[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model ...

Marshall Culpepper mculpepper at jboss.com
Wed Feb 28 18:20:51 EST 2007


  User: mculpepper
  Date: 07/02/28 18:20:51

  Modified:    core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model 
                        PackagesCore.java
  Log:
  refactored common "getPackageRelativePath" function into PackagesCore (being used from 3 different node types)
  
  Revision  Changes    Path
  1.22      +40 -0     jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/PackagesCore.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PackagesCore.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/PackagesCore.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- PackagesCore.java	27 Feb 2007 18:50:35 -0000	1.21
  +++ PackagesCore.java	28 Feb 2007 23:20:50 -0000	1.22
  @@ -312,6 +312,46 @@
   	}
   	
   	/**
  +	 * @param node An IPackageNode
  +	 * @return The package-relative path of the passed-in node
  +	 */
  +	public static IPath getPackageRelativePath (IPackageNode node) {
  +
  +		String path = "";
  +		if (node.getNodeType() == IPackageNode.TYPE_PACKAGE || node.getNodeType() == IPackageNode.TYPE_PACKAGE_REFERENCE)
  +		{
  +			if (node.getParent() == null) return null;
  +			
  +			path = ((IPackage)node).getName();
  +		}
  +		else if (node.getNodeType() == IPackageNode.TYPE_PACKAGE_FOLDER)
  +		{
  +			path = ((IPackageFolder)node).getName();
  +		}
  +		
  +		IPackageNode parent = node.getParent(), save = null;
  +		while (true) {
  +			if (parent.getNodeType() == IPackageNode.TYPE_PACKAGE)
  +				path = ((IPackage)parent).getName() + "/" + path;
  +			else
  +				path = ((IPackageFolder)parent).getName() + "/" + path;
  +			
  +			save = parent;
  +			parent = parent.getParent();
  +			if (parent == null) { 
  +				parent = save;
  +				break;
  +			}
  +		}
  +		
  +		if (path.charAt(path.length()-1) == '/')
  +		{
  +			path = path.substring(0, path.length() - 1);
  +		}
  +		return new Path(path);
  +	}
  +	
  +	/**
   	 * Returns the IPackage represented by the passed-in file.
   	 * This will return null if the passed-in file does not represent an IPackage. Note that this will
   	 * return an IPackage that's destination matches, but it may not actually exist yet.
  
  
  



More information about the jboss-cvs-commits mailing list