private void initializeList() { ProjectChooserHelper helper = new ProjectChooserHelper(getShell(), null /*filter*/); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IJavaModel javaModel = JavaCore.create(workspaceRoot); IJavaProject[] androidProjects = helper.getAndroidProjects(javaModel); mProjectList.setElements(androidProjects); if (mValues.testedProject != null) { for (IJavaProject project : androidProjects) { if (project.getProject() == mValues.testedProject) { mProjectList.setSelection(new Object[] {project}); break; } } } else { // No initial selection: force the user to choose mProjectList.setSelection(new int[0]); } }
/** Checks the parameters for correctness, and update the error message and buttons. */ private void handleProjectNameChange() { setPageComplete(false); if (mErrorComposite != null) { mErrorComposite.dispose(); mErrorComposite = null; } // update the wizard with the new project mWizard.setProject(null); // test the project name first! String text = mProjectText.getText().trim(); if (text.length() == 0) { setErrorMessage("Select project to export."); } else if (text.matches("[a-zA-Z0-9_ \\.-]+") == false) { setErrorMessage("Project name contains unsupported characters!"); } else { IJavaProject[] projects = mProjectChooserHelper.getAndroidProjects(null); IProject found = null; for (IJavaProject javaProject : projects) { if (javaProject.getProject().getName().equals(text)) { found = javaProject.getProject(); break; } } if (found != null) { setErrorMessage(null); // update the wizard with the new project mWizard.setProject(found); // now rebuild the error ui. buildErrorUi(found); } else { setErrorMessage(String.format("There is no android project named '%1$s'", text)); } } }