Methods Summary |
---|
public org.eclipse.jdt.core.IJavaProject | chooseJavaProject(java.lang.String projectName)Displays a project chooser dialog which lists all available projects with the Android nature.
The list of project is built from Android flagged projects currently opened in the workspace.
ILabelProvider labelProvider = new JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_DEFAULT);
ElementListSelectionDialog dialog = new ElementListSelectionDialog(
mParentShell, labelProvider);
dialog.setTitle("Project Selection");
dialog.setMessage("Select a project to constrain your search.");
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IJavaModel javaModel = JavaCore.create(workspaceRoot);
// set the elements in the dialog. These are opened android projects.
dialog.setElements(getAndroidProjects(javaModel));
// look for the project matching the given project name
IJavaProject javaProject = null;
if (projectName != null && projectName.length() > 0) {
javaProject = javaModel.getJavaProject(projectName);
}
// if we found it, we set the initial selection in the dialog to this one.
if (javaProject != null) {
dialog.setInitialSelections(new Object[] { javaProject });
}
// open the dialog and return the object selected if OK was clicked, or null otherwise
if (dialog.open() == Window.OK) {
return (IJavaProject) dialog.getFirstResult();
}
return null;
|
public org.eclipse.core.resources.IProject | getAndroidProject(java.lang.String projectName)Helper method to get the Android project with the given name
IProject iproject = null;
IJavaProject[] javaProjects = getAndroidProjects(null);
if (javaProjects != null) {
for (IJavaProject javaProject : javaProjects) {
if (javaProject.getElementName().equals(projectName)) {
iproject = javaProject.getProject();
break;
}
}
}
return iproject;
|
public org.eclipse.jdt.core.IJavaProject[] | getAndroidProjects(org.eclipse.jdt.core.IJavaModel javaModel)Returns the list of Android projects.
Because this list can be time consuming, this class caches the list of project.
It is recommended to call this method instead of
{@link BaseProjectHelper#getAndroidProjects()}.
if (mAndroidProjects == null) {
if (javaModel == null) {
mAndroidProjects = BaseProjectHelper.getAndroidProjects();
} else {
mAndroidProjects = BaseProjectHelper.getAndroidProjects(javaModel);
}
}
return mAndroidProjects;
|