ruper2/src/java/eclipse/org/krysalis/ruper2/eclipse/util RuperEclipseConstants.java,NONE,1.1 RuperEclipseHelper.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/eclipse/org/krysalis/ruper2/eclipse/util
In directory sc8-pr-cvs1:/tmp/cvs-serv23328/src/java/eclipse/org/krysalis/ruper2/eclipse/util

Added Files:
	RuperEclipseConstants.java RuperEclipseHelper.java 
Log Message:
Changed the ResourceUpdater to ResourceUpdaterEngine and the ResourceAPI 
ResourceUpdater

--- NEW FILE: RuperEclipseConstants.java ---
/*
 * Created on Oct 7, 2003
  */
package org.krysalis.ruper2.eclipse.util;

/**
 * @author anou_mana
 */
public class RuperEclipseConstants {
	public static final String JRE_LIB						= "JRE_LIB";
	public static final String ECLIPSE_HOME					= "ECLIPSE_HOME";

}

--- NEW FILE: RuperEclipseHelper.java ---
/*
 * Created on Jul 7, 2003
 *
 */
 
package org.krysalis.ruper2.eclipse.util;
 
import java.util.ArrayList;
import java.util.Iterator;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.pde.internal.core.PDECore;

/**
 * @author Anou Manavalan
 */
public class RuperEclipseHelper
{
	private String 						m_eclipsePathStr	= null;

	/**
	 * 
	 */
	public RuperEclipseHelper()
	{
		super();
	}
	
	public void setEclipsePathString()
	{
		Preferences preferences = PDECore.getDefault().getPluginPreferences();
		String PLATFORM_PATH = "platform_path";

		IPath eclipsePath = new Path(preferences.getString(PLATFORM_PATH));
		
		//IPath eclipsePath = JavaCore.getClasspathVariable(TSConstants.ECLIPSE_HOME); 
		
		StringBuffer buff = new StringBuffer();
		buff.append(eclipsePath.toOSString());
		buff.append("\\plugins\\");
		m_eclipsePathStr = buff.toString();
		
	}
	
	public ArrayList getBuildTimeLibraries(IProject project) throws JavaModelException
	{
		setEclipsePathString();
		
		IPath jreLibPath = JavaCore.getClasspathVariable(RuperEclipseConstants.JRE_LIB); 
		String jreLibPathStr = jreLibPath.toOSString();
		String jrePath = jreLibPathStr.substring(0,jreLibPathStr.lastIndexOf("\\"));
		//TSHelperLog.traceMessage("JRE Path :[" + jrePath + "]");	
		
		//TSHelperLog.traceMessage("Eclipse Path :[" + m_eclipsePathStr + "]");	
		 
		IJavaElement jElement = JavaCore.create((IResource) (project));
		IJavaProject jProject = jElement.getJavaProject();
		
		IClasspathEntry cpEntries[];
		cpEntries = jProject.getResolvedClasspath(true);
		
		ArrayList requiredJars = null;
		
		String pathString, pluginName,jarString,jarName,tmp;
		
		for (int i = 0; i < cpEntries.length; i++)
		{
			int cpEntryKind = cpEntries[i].getEntryKind();
			IPath path = cpEntries[i].getPath();
			pathString = path.toOSString();
						
			if( cpEntryKind == IClasspathEntry.CPE_LIBRARY )
			{
				if(! pathString.startsWith(jrePath))
				{
					if(requiredJars == null)
						requiredJars = new ArrayList();
					requiredJars.add(pathString);
				}
			}
		}
		return requiredJars;
	}	

	public ArrayList getBuildTimeJarNames(IProject project) throws JavaModelException
	{
		ArrayList requiredJars = null;
		ArrayList libraries = getBuildTimeLibraries(project);
		
		for(Iterator iterator = libraries.iterator(); iterator.hasNext();){
			if(requiredJars == null)
				requiredJars = new ArrayList();
			
			String pathString = (String)iterator.next();
			String jarString = pathString.substring(
											pathString.lastIndexOf("\\")+1,
											pathString.length() );
										
			String jarName = jarString.substring(0,jarString.indexOf(".jar"));
			
			// get the requiredEclipsePlugins
			if(pathString.startsWith(m_eclipsePathStr))
			{
				String tmp = pathString.substring(m_eclipsePathStr.length(),
										pathString.length() );
				
				// remove the eclipse version part from the project names xyz_1.2
				String[] pluginNames = tmp.split("_\\d");	
				if(pluginNames != null)
				{
					//requiredEclipsePlugins.add(pluginNames[0]);
					requiredJars.add(pluginNames[0]);
				}
								
			}
			else 
			{
				// remove the version part xyz-1.2
				String[]jars = jarName.split("-\\d");
				jarName = jars[0];
				//TSHelperLog.traceMessage("version removed jar name [" + jarName + "]");
			}
				
			requiredJars.add(jarName);
		}
		return requiredJars;
	}
	
	public String getProjectDirectory(IProject project)
	{
		String projectDir = project.getLocation().toOSString();
		return projectDir;
	}

	public static void main(String[] args)
	{
	}
}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.