plugins/org.wso2.developerstudio.eclipse.distribution.project/src/org/wso2/developerstudio/eclipse/distribution/project/ui/wizard/ProjectsImportPage.java
/**
	 * Update the list of projects based on path. Method declared public only for
	 * test suite.
	 * 
	 * @param path
	 */
Update the list of projects based on path. Method declared public only for
test suite.

@param path
Update the list of projects based on path . Method declared public only for test suite . @param path
public void updateProjectsList(final String path) {
		if (path == null || path.length() == 0) {
			setMessage(DataTransferMessages.WizardProjectsImportPage_ImportProjectsDescription);
			selectedProjects = new ProjectRecord[0];
			projectsList.refresh(true);
			projectsList.setCheckedElements(selectedProjects);
			setPageComplete(projectsList.getCheckedElements().length > 0);
			lastPath = path;
			return;
		}
		final File directory = new File(path);
		long modified = directory.lastModified();
		if (path.equals(lastPath) && lastModified == modified) {
			return;
		}
		lastPath = path;
		lastModified = modified;
		final boolean dirSelected = this.projectFromDirectoryRadio.getSelection();
		try {
			getContainer().run(true, true, new IRunnableWithProgress() {
				public void run(IProgressMonitor monitor) {
					monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100);
					selectedProjects = new ProjectRecord[0];
					Collection files = new ArrayList();
					monitor.worked(10);
					if (!dirSelected && ArchiveFileManipulations.isTarFile(path)) {
						TarFile sourceTarFile = getSpecifiedTarSourceFile(path);
						if (sourceTarFile == null) {
							return;
						}
						structureProvider = new TarLeveledStructureProvider(sourceTarFile);
						Object child = structureProvider.getRoot();
						if (!collectProjectFilesFromProvider(files, child, 0, monitor)) {
							return;
						}
						Iterator filesIterator = files.iterator();
						selectedProjects = new ProjectRecord[files.size()];
						int index = 0;
						monitor.worked(50);
						monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
						while (filesIterator.hasNext()) {
							selectedProjects[index++] = (ProjectRecord) filesIterator.next();
						}
					} else if (!dirSelected && ArchiveFileManipulations.isZipFile(path)) {
						sourceFile = getSpecifiedZipSourceFile(path);
						if (sourceFile == null) {
							return;
						}
						structureProvider = new ZipLeveledStructureProvider(sourceFile);
						Object child = structureProvider.getRoot();
						if (!collectProjectFilesFromProvider(files, child, 0, monitor)) {
							return;
						}
						Iterator filesIterator = files.iterator();
						selectedProjects = new ProjectRecord[files.size()];
						int index = 0;
						monitor.worked(50);
						monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
						while (filesIterator.hasNext()) {
							selectedProjects[index++] = (ProjectRecord) filesIterator.next();
						}
					}
					else if (dirSelected && directory.isDirectory()) {
						if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) {
							return;
						}
						Iterator filesIterator = files.iterator();
						selectedProjects = new ProjectRecord[files.size()];
						int index = 0;
						monitor.worked(50);
						monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage);
						while (filesIterator.hasNext()) {
							File file = (File) filesIterator.next();
							selectedProjects[index] = new ProjectRecord(file);
							index++;
						}
					} else {
						monitor.worked(60);
					}
					monitor.done();
				}
			});
		} catch (InvocationTargetException e) {
			IDEWorkbenchPlugin.log(e.getMessage(), e);
		} catch (InterruptedException e) {
		}
		projectsList.refresh(true);
		ProjectRecord[] projects = getProjectRecords();
		boolean displayWarning = false;
		for (int i = 0; i < projects.length; i++) {
			if (projects[i].hasConflicts) {
				displayWarning = true;
				projectsList.setGrayed(projects[i], true);
			} else {
				projectsList.setChecked(projects[i], true);
			}
		}
		if (displayWarning) {
			setMessage(DataTransferMessages.WizardProjectsImportPage_projectsInWorkspace, WARNING);
		} else {
			setMessage(DataTransferMessages.WizardProjectsImportPage_ImportProjectsDescription);
		}
		setPageComplete(projectsList.getCheckedElements().length > 0);
		if (selectedProjects.length == 0) {
			setMessage(DataTransferMessages.WizardProjectsImportPage_noProjectsToImport, WARNING);
		}
	}
public void updateProjectsList ( final String path ) { if ( path == null || path . length ( ) == 0 ) { setMessage ( DataTransferMessages . WizardProjectsImportPage_ImportProjectsDescription ) ; selectedProjects = new ProjectRecord [ 0 ] ; projectsList . refresh ( true ) ; projectsList . setCheckedElements ( selectedProjects ) ; setPageComplete ( projectsList . getCheckedElements ( ) . length > 0 ) ; lastPath = path ; return ; } final File directory = new File ( path ) ; long modified = directory . lastModified ( ) ; if ( path . equals ( lastPath ) && lastModified == modified ) { return ; } lastPath = path ; lastModified = modified ; final boolean dirSelected = this . projectFromDirectoryRadio . getSelection ( ) ; try { getContainer ( ) . run ( true , true , new IRunnableWithProgress ( ) { public void run ( IProgressMonitor monitor ) { monitor . beginTask ( DataTransferMessages . WizardProjectsImportPage_SearchingMessage , 100 ) ; selectedProjects = new ProjectRecord [ 0 ] ; Collection files = new ArrayList ( ) ; monitor . worked ( 10 ) ; if ( ! dirSelected && ArchiveFileManipulations . isTarFile ( path ) ) { TarFile sourceTarFile = getSpecifiedTarSourceFile ( path ) ; if ( sourceTarFile == null ) { return ; } structureProvider = new TarLeveledStructureProvider ( sourceTarFile ) ; Object child = structureProvider . getRoot ( ) ; if ( ! collectProjectFilesFromProvider ( files , child , 0 , monitor ) ) { return ; } Iterator filesIterator = files . iterator ( ) ; selectedProjects = new ProjectRecord [ files . size ( ) ] ; int index = 0 ; monitor . worked ( 50 ) ; monitor . subTask ( DataTransferMessages . WizardProjectsImportPage_ProcessingMessage ) ; while ( filesIterator . hasNext ( ) ) { selectedProjects [ index ++ ] = ( ProjectRecord ) filesIterator . next ( ) ; } } else if ( ! dirSelected && ArchiveFileManipulations . isZipFile ( path ) ) { sourceFile = getSpecifiedZipSourceFile ( path ) ; if ( sourceFile == null ) { return ; } structureProvider = new ZipLeveledStructureProvider ( sourceFile ) ; Object child = structureProvider . getRoot ( ) ; if ( ! collectProjectFilesFromProvider ( files , child , 0 , monitor ) ) { return ; } Iterator filesIterator = files . iterator ( ) ; selectedProjects = new ProjectRecord [ files . size ( ) ] ; int index = 0 ; monitor . worked ( 50 ) ; monitor . subTask ( DataTransferMessages . WizardProjectsImportPage_ProcessingMessage ) ; while ( filesIterator . hasNext ( ) ) { selectedProjects [ index ++ ] = ( ProjectRecord ) filesIterator . next ( ) ; } } else if ( dirSelected && directory . isDirectory ( ) ) { if ( ! collectProjectFilesFromDirectory ( files , directory , null , monitor ) ) { return ; } Iterator filesIterator = files . iterator ( ) ; selectedProjects = new ProjectRecord [ files . size ( ) ] ; int index = 0 ; monitor . worked ( 50 ) ; monitor . subTask ( DataTransferMessages . WizardProjectsImportPage_ProcessingMessage ) ; while ( filesIterator . hasNext ( ) ) { File file = ( File ) filesIterator . next ( ) ; selectedProjects [ index ] = new ProjectRecord ( file ) ; index ++ ; } } else { monitor . worked ( 60 ) ; } monitor . done ( ) ; } } ) ; } catch ( InvocationTargetException e ) { IDEWorkbenchPlugin . log ( e . getMessage ( ) , e ) ; } catch ( InterruptedException e ) { } projectsList . refresh ( true ) ; ProjectRecord [ ] projects = getProjectRecords ( ) ; boolean displayWarning = false ; for ( int i = 0 ; i < projects . length ; i ++ ) { if ( projects [ i ] . hasConflicts ) { displayWarning = true ; projectsList . setGrayed ( projects [ i ] , true ) ; } else { projectsList . setChecked ( projects [ i ] , true ) ; } } if ( displayWarning ) { setMessage ( DataTransferMessages . WizardProjectsImportPage_projectsInWorkspace , WARNING ) ; } else { setMessage ( DataTransferMessages . WizardProjectsImportPage_ImportProjectsDescription ) ; } setPageComplete ( projectsList . getCheckedElements ( ) . length > 0 ) ; if ( selectedProjects . length == 0 ) { setMessage ( DataTransferMessages . WizardProjectsImportPage_noProjectsToImport , WARNING ) ; } }
Update the list of projects based on path.
Update the list of projects based on path .
// on an empty path empty selectedProjects // since the file/folder was not modified and the path did not // change, no refreshing is required // We can't access the radio button from the inner class so get the // status beforehand // Nothing to do if the user interrupts.