plugins/org.wso2.developerstudio.eclipse.distribution.project/src/org/wso2/developerstudio/eclipse/distribution/project/ui/wizard/ProjectsImportPage.java
/**
	 * Collect the list of .project files that are under directory into files.
	 * 
	 * @param files
	 * @param directory
	 * @param directoriesVisited
	 *            Set of canonical paths of directories, used as recursion guard
	 * @param monitor
	 *            The monitor to report to
	 * @return boolean <code>true</code> if the operation was completed.
	 */
Collect the list of .project files that are under directory into files.


Collect the list of . project files that are under directory into files .
private boolean collectProjectFilesFromDirectory(Collection files, File directory, Set directoriesVisited,
			IProgressMonitor monitor) {
		if (monitor.isCanceled()) {
			return false;
		}
		monitor.subTask(NLS.bind(DataTransferMessages.WizardProjectsImportPage_CheckingMessage, directory.getPath()));
		File[] contents = directory.listFiles();
		if (contents == null)
			return false;
		if (directoriesVisited == null) {
			directoriesVisited = new HashSet();
			try {
				directoriesVisited.add(directory.getCanonicalPath());
			} catch (IOException exception) {
				StatusManager.getManager()
						.handle(StatusUtil.newStatus(IStatus.ERROR, exception.getLocalizedMessage(), exception));
			}
		}
		final String dotProject = IProjectDescription.DESCRIPTION_FILE_NAME;
		for (int i = 0; i < contents.length; i++) {
			File file = contents[i];
			if (file.isFile() && file.getName().equals(dotProject)) {
				files.add(file);
				paths.add(file.getParentFile().getName());
			}
		}
		for (int i = 0; i < contents.length; i++) {
			if (contents[i].isDirectory()) {
				if (!contents[i].getName().equals(METADATA_FOLDER)) {
					try {
						String canonicalPath = contents[i].getCanonicalPath();
						if (!directoriesVisited.add(canonicalPath)) {
							continue;
						}
					} catch (IOException exception) {
						StatusManager.getManager().handle(
								StatusUtil.newStatus(IStatus.ERROR, exception.getLocalizedMessage(), exception));
					}
					collectProjectFilesFromDirectory(files, contents[i], directoriesVisited, monitor);
				}
			}
		}
		return true;
	}
private boolean collectProjectFilesFromDirectory ( Collection files , File directory , Set directoriesVisited , IProgressMonitor monitor ) { if ( monitor . isCanceled ( ) ) { return false ; } monitor . subTask ( NLS . bind ( DataTransferMessages . WizardProjectsImportPage_CheckingMessage , directory . getPath ( ) ) ) ; File [ ] contents = directory . listFiles ( ) ; if ( contents == null ) return false ; if ( directoriesVisited == null ) { directoriesVisited = new HashSet ( ) ; try { directoriesVisited . add ( directory . getCanonicalPath ( ) ) ; } catch ( IOException exception ) { StatusManager . getManager ( ) . handle ( StatusUtil . newStatus ( IStatus . ERROR , exception . getLocalizedMessage ( ) , exception ) ) ; } } final String dotProject = IProjectDescription . DESCRIPTION_FILE_NAME ; for ( int i = 0 ; i < contents . length ; i ++ ) { File file = contents [ i ] ; if ( file . isFile ( ) && file . getName ( ) . equals ( dotProject ) ) { files . add ( file ) ; paths . add ( file . getParentFile ( ) . getName ( ) ) ; } } for ( int i = 0 ; i < contents . length ; i ++ ) { if ( contents [ i ] . isDirectory ( ) ) { if ( ! contents [ i ] . getName ( ) . equals ( METADATA_FOLDER ) ) { try { String canonicalPath = contents [ i ] . getCanonicalPath ( ) ; if ( ! directoriesVisited . add ( canonicalPath ) ) { continue ; } } catch ( IOException exception ) { StatusManager . getManager ( ) . handle ( StatusUtil . newStatus ( IStatus . ERROR , exception . getLocalizedMessage ( ) , exception ) ) ; } collectProjectFilesFromDirectory ( files , contents [ i ] , directoriesVisited , monitor ) ; } } } return true ; }
Collect the list of .project files that are under directory into files.
Collect the list of . project files that are under directory into files .
// Initialize recursion guard for recursive symbolic links // first look for project description files // don't search sub-directories since we can't have nested // projects // return true; // no project description found, so recurse into sub-directories // already been here --> do not recurse