ruper2/src/java/eclipse/org/krysalis/ruper2/eclipse EclipseFileUpdater.java,1.3,1.4

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

Modified Files:
	EclipseFileUpdater.java 
Log Message:
Eclipse plugin start

Index: EclipseFileUpdater.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/eclipse/org/krysalis/ruper2/eclipse/EclipseFileUpdater.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EclipseFileUpdater.java	12 Oct 2003 18:12:07 -0000	1.3
--- EclipseFileUpdater.java	13 Oct 2003 21:14:01 -0000	1.4
***************
*** 12,15 ****
--- 12,16 ----
  import org.eclipse.core.internal.resources.File;
  import org.eclipse.core.resources.IResource;
+ import org.eclipse.jdt.internal.core.PackageFragmentRoot;
  import org.krysalis.ruper2.ResourceUpdater;
  import org.krysalis.ruper2.RuperException;
***************
*** 18,21 ****
--- 19,23 ----
  import org.krysalis.ruper2.repository.DefaultRepository;
  import org.krysalis.ruper2.resource.Resource;
+ import org.krysalis.ruper2.util.FileHelper;
  import org.krysalis.ruper2.util.net.VirtualResourceLocator;
  
***************
*** 27,37 ****
  	private RuperEclipseHelper m_ruperEclipseHelper;
  	private ResourceUpdater m_ruper;
! 	DefaultResourceFilenameAnalyzer m_fileNameAnalyzer;
! 
  	/**
  	 * 
  	 */
  	public EclipseFileUpdater() throws RuperException {
! 		super();
  		m_ruperEclipseHelper = new RuperEclipseHelper();
  		m_fileNameAnalyzer =
--- 29,39 ----
  	private RuperEclipseHelper m_ruperEclipseHelper;
  	private ResourceUpdater m_ruper;
! 	private DefaultResourceFilenameAnalyzer m_fileNameAnalyzer;
! 	
  	/**
  	 * 
  	 */
  	public EclipseFileUpdater() throws RuperException {
! 		m_ruper = new ResourceUpdater();
  		m_ruperEclipseHelper = new RuperEclipseHelper();
  		m_fileNameAnalyzer =
***************
*** 48,57 ****
  	}
  
! 	public void updateFile(File file) throws RuperException {
! 		List resources = getResourceList(file, true);
  		if (resources != null)
  			m_ruper.updateResources(resources);
  	}
  
  	public void updateFile(String baseDir, String fileName)
  		throws RuperException {
--- 50,76 ----
  	}
  
! 	public void updateResource(IResource resource) throws RuperException {
! 		List resources = getResourceList(resource, true);
  		if (resources != null)
  			m_ruper.updateResources(resources);
  	}
  
+ 	public void updateFile(Object object) throws RuperException {
+ 		if(object != null){
+ 			if(object instanceof PackageFragmentRoot){
+ 				PackageFragmentRoot packageFragmentRoot = (PackageFragmentRoot)object;
+ 				IResource resource = packageFragmentRoot.getResource();
+ 				updateResource(resource);
+ 			}
+ 			else if(object instanceof IResource){
+ 				IResource resource = (IResource)object;
+ 				updateResource(resource);
+ 			}
+ 		}
+ 		else{
+ 			// TODO null object error message, throw exp
+ 		}
+ 	}
+ 
  	public void updateFile(String baseDir, String fileName)
  		throws RuperException {
***************
*** 126,136 ****
  	}
  	
! 	private List getResourceList(File file, boolean setTargetRepository)
  		throws RuperException {
  		List resourceList = null;
! 		if (file != null) {
  			try {
  
! 				switch (file.getType()) {
  					case IResource.FILE :
  						{
--- 145,157 ----
  	}
  	
! 	private List getResourceList(IResource e_resource, boolean setTargetRepository)
  		throws RuperException {
  		List resourceList = null;
! 		if (e_resource != null) {
! 			
! 			resourceList = new ArrayList();
  			try {
  
! 				switch (e_resource.getType()) {
  					case IResource.FILE :
  						{
***************
*** 138,142 ****
  							Resource resource =
  								getResource(
! 									file.getRawLocation().toFile(),
  									setTargetRepository);
  
--- 159,163 ----
  							Resource resource =
  								getResource(
! 									e_resource.getRawLocation().toFile(),
  									setTargetRepository);
  
***************
*** 150,154 ****
  							// get the files from the folder
  							java.io.File folder =
! 								file.getRawLocation().toFile();
  							if (folder.isDirectory()) {
  								java.io.File[] stdFiles = folder.listFiles();
--- 171,175 ----
  							// get the files from the folder
  							java.io.File folder =
! 							e_resource.getRawLocation().toFile();
  							if (folder.isDirectory()) {
  								java.io.File[] stdFiles = folder.listFiles();
***************
*** 170,174 ****
  							ArrayList buildLibs =
  								m_ruperEclipseHelper.getBuildTimeLibraries(
! 									file.getProject());
  
  							// convert to resources
--- 191,195 ----
  							ArrayList buildLibs =
  								m_ruperEclipseHelper.getBuildTimeLibraries(
! 							e_resource.getProject());
  
  							// convert to resources
***************
*** 213,224 ****
  
  				// get the absolute file path
! 				String path = file.getCanonicalPath();
  
  				if (path != null) {
  					int baseIndex = path.lastIndexOf("/");
! 					String base = path.substring(0, baseIndex);
! 
! 					String fileName = path.substring(baseIndex, path.length());
! 					resource = getResource(base, fileName, true);
  				}
  			}
--- 234,250 ----
  
  				// get the absolute file path
! 				String path = FileHelper.createURLForPath(file.getCanonicalPath());
  
  				if (path != null) {
  					int baseIndex = path.lastIndexOf("/");
! 					String base = null;
! 					String fileName = path;
! 					
! 					if(baseIndex != -1){
! 						base = path.substring(0, baseIndex);
! 						fileName = path.substring(baseIndex+1, path.length());
! 					}
! 					
! 					resource = getResource(base, fileName, setTargetRepository);
  				}
  			}




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
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.