From 7641cd7668c2dda9d198cc660d58d845de677029 Mon Sep 17 00:00:00 2001
From: Xavier Ducrohet mActivities
.
*
* First activity is selected by default if present.
- *
+ *
* @param project The project to load the activities from.
*/
private void loadActivities(IProject project) {
@@ -412,14 +414,14 @@ public class MainLaunchConfigTab extends AbstractLaunchConfigurationTab {
mActivities.clear();
mActivityCombo.removeAll();
-
+
for (Activity activity : activities) {
if (activity.isExported() && activity.hasAction()) {
mActivities.add(activity);
mActivityCombo.add(activity.getName());
}
}
-
+
if (mActivities.size() > 0) {
if (mLaunchAction == LaunchConfigDelegate.ACTION_ACTIVITY) {
mActivityCombo.setEnabled(true);
@@ -427,11 +429,11 @@ public class MainLaunchConfigTab extends AbstractLaunchConfigurationTab {
} else {
mActivityCombo.setEnabled(false);
}
-
+
// the selection will be set when we update the ui from the current
// config object.
mActivityCombo.clearSelection();
-
+
return;
}
@@ -440,13 +442,13 @@ public class MainLaunchConfigTab extends AbstractLaunchConfigurationTab {
// already so there's nothing to do.
}
}
-
+
// if we reach this point, either project is null, or we got an exception during
// the parsing. In either case, we empty the activity list.
mActivityCombo.removeAll();
mActivities.clear();
}
-
+
/**
* Checks the parameters for correctness, and update the error message and buttons.
* @return the current IProject of this launch config.
@@ -467,22 +469,22 @@ public class MainLaunchConfigTab extends AbstractLaunchConfigurationTab {
found = javaProject.getProject();
break;
}
-
+
}
-
+
if (found != null) {
setErrorMessage(null);
} else {
setErrorMessage(String.format("There is no android project named '%1$s'",
text));
}
-
+
return found;
}
} finally {
updateLaunchConfigurationDialog();
}
-
+
return null;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java
index 8f162a6..5656011 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchConfigurationTab.java
@@ -100,7 +100,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
private Label mProjLabel;
private Text mProjText;
private Button mProjButton;
-
+
// Test class UI widgets
private Text mTestText;
private Button mSearchButton;
@@ -113,7 +113,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
private Button mContainerSearchButton;
private Button mTestContainerRadioButton;
private Button mTestRadioButton;
- private Label mTestLabel;
+ private Label mTestLabel;
// Android specific members
private Image mTabIcon = null;
@@ -128,27 +128,27 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
- mProjectChooserHelper = new ProjectChooserHelper(parent.getShell());
+ mProjectChooserHelper = new ProjectChooserHelper(parent.getShell(), null /*filter*/);
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
GridLayout topLayout = new GridLayout();
topLayout.numColumns = 3;
- comp.setLayout(topLayout);
-
+ comp.setLayout(topLayout);
+
createSingleTestSection(comp);
createTestContainerSelectionGroup(comp);
-
+
createSpacer(comp);
-
+
createInstrumentationGroup(comp);
createSpacer(comp);
-
+
Dialog.applyDialogFont(comp);
// TODO: add help link here when available
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+ //PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
// IJUnitHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_JUNIT_MAIN_TAB);
validatePage();
}
@@ -160,41 +160,41 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
gd.horizontalSpan = 3;
label.setLayoutData(gd);
}
-
+
private void createSingleTestSection(Composite comp) {
mTestRadioButton = new Button(comp, SWT.RADIO);
- mTestRadioButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_oneTest);
+ mTestRadioButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_oneTest);
GridData gd = new GridData();
gd.horizontalSpan = 3;
- mTestRadioButton.setLayoutData(gd);
+ mTestRadioButton.setLayoutData(gd);
mTestRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (mTestRadioButton.getSelection()) {
testModeChanged();
- }
+ }
}
});
-
+
mProjLabel = new Label(comp, SWT.NONE);
- mProjLabel.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_project);
+ mProjLabel.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_project);
gd = new GridData();
gd.horizontalIndent = 25;
mProjLabel.setLayoutData(gd);
-
+
mProjText = new Text(comp, SWT.SINGLE | SWT.BORDER);
mProjText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mProjText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
validatePage();
- updateLaunchConfigurationDialog();
- mSearchButton.setEnabled(mTestRadioButton.getSelection() &&
+ updateLaunchConfigurationDialog();
+ mSearchButton.setEnabled(mTestRadioButton.getSelection() &&
mProjText.getText().length() > 0);
}
});
-
+
mProjButton = new Button(comp, SWT.PUSH);
- mProjButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_browse);
+ mProjButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_browse);
mProjButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
@@ -202,14 +202,14 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
});
setButtonGridData(mProjButton);
-
+
mTestLabel = new Label(comp, SWT.NONE);
gd = new GridData();
gd.horizontalIndent = 25;
mTestLabel.setLayoutData(gd);
- mTestLabel.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_test);
-
-
+ mTestLabel.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_test);
+
+
mTestText = new Text(comp, SWT.SINGLE | SWT.BORDER);
mTestText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mTestText.addModifyListener(new ModifyListener() {
@@ -218,10 +218,10 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
updateLaunchConfigurationDialog();
}
});
-
+
mSearchButton = new Button(comp, SWT.PUSH);
mSearchButton.setEnabled(mProjText.getText().length() > 0);
- mSearchButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_search);
+ mSearchButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_search);
mSearchButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
@@ -229,9 +229,9 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
});
setButtonGridData(mSearchButton);
-
+
new Label(comp, SWT.NONE);
-
+
mTestMethodLabel = new Label(comp, SWT.NONE);
mTestMethodLabel.setText(""); //$NON-NLS-1$
gd = new GridData();
@@ -242,7 +242,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
private void createTestContainerSelectionGroup(Composite comp) {
mTestContainerRadioButton = new Button(comp, SWT.RADIO);
mTestContainerRadioButton.setText(
- "Run all tests in the selected project, or package");
+ "Run all tests in the selected project, or package");
GridData gd = new GridData();
gd.horizontalSpan = 3;
mTestContainerRadioButton.setLayoutData(gd);
@@ -268,23 +268,23 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
});
mContainerSearchButton = new Button(comp, SWT.PUSH);
- mContainerSearchButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_search);
+ mContainerSearchButton.setText(JUnitMessages.JUnitLaunchConfigurationTab_label_search);
mContainerSearchButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
handleContainerSearchButtonSelected();
}
});
- setButtonGridData(mContainerSearchButton);
+ setButtonGridData(mContainerSearchButton);
}
-
+
private void createInstrumentationGroup(Composite comp) {
Label loaderLabel = new Label(comp, SWT.NONE);
loaderLabel.setText("Instrumentation runner:");
GridData gd = new GridData();
gd.horizontalIndent = 0;
loaderLabel.setLayoutData(gd);
-
+
mInstrumentationCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
mInstrumentationCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -302,7 +302,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
IJavaElement javaElement = chooseContainer(mContainerElement);
if (javaElement != null) {
setContainerElement(javaElement);
- }
+ }
}
private void setContainerElement(IJavaElement javaElement) {
@@ -324,17 +324,17 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
} catch (CoreException ce) {
// ignore
}
-
+
if (containerHandle.length() > 0) {
updateTestContainerFromConfig(config);
} else {
updateTestTypeFromConfig(config);
- }
+ }
IProject proj = mProjectChooserHelper.getAndroidProject(projectName);
loadInstrumentations(proj);
updateInstrumentationFromConfig(config);
-
+
validatePage();
}
@@ -358,7 +358,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
if (!found) {
mInstrumentationCombo.clearSelection();
- }
+ }
}
private String updateProjectFromConfig(ILaunchConfiguration config) {
@@ -386,18 +386,18 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
mTestRadioButton.setSelection(true);
setEnableSingleTestGroup(true);
- setEnableContainerTestGroup(false);
+ setEnableContainerTestGroup(false);
mTestContainerRadioButton.setSelection(false);
mTestText.setText(testTypeName);
- mContainerText.setText(EMPTY_STRING);
+ mContainerText.setText(EMPTY_STRING);
setTestMethodLabel(mOriginalTestMethodName);
}
private void setTestMethodLabel(String testMethodName) {
if (!EMPTY_STRING.equals(testMethodName)) {
mTestMethodLabel.setText(
- JUnitMessages.JUnitLaunchConfigurationTab_label_method +
- mOriginalTestMethodName);
+ JUnitMessages.JUnitLaunchConfigurationTab_label_method +
+ mOriginalTestMethodName);
} else {
mTestMethodLabel.setText(EMPTY_STRING);
}
@@ -417,14 +417,14 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
if (containerElement != null) {
mContainerElement = containerElement;
- }
+ }
mTestContainerRadioButton.setSelection(true);
setEnableSingleTestGroup(false);
- setEnableContainerTestGroup(true);
+ setEnableContainerTestGroup(true);
mTestRadioButton.setSelection(false);
if (mContainerElement != null) {
mContainerText.setText(getPresentationName(mContainerElement));
- }
+ }
mTestText.setText(EMPTY_STRING);
}
@@ -434,9 +434,9 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
*/
public void performApply(ILaunchConfigurationWorkingCopy config) {
if (mTestContainerRadioButton.getSelection() && mContainerElement != null) {
- config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
mContainerElement.getJavaProject().getElementName());
- config.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER,
+ config.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER,
mContainerElement.getHandleIdentifier());
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
EMPTY_STRING);
@@ -460,14 +460,14 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
AdtPlugin.log(e, "Error occurred saving configuration"); //$NON-NLS-1$
}
AndroidJUnitLaunchConfigDelegate.setJUnitDefaults(config);
-
+
config.setAttribute(AndroidJUnitLaunchConfigDelegate.ATTR_INSTR_NAME,
getSelectedInstrumentation());
}
private void mapResources(ILaunchConfigurationWorkingCopy config) throws CoreException {
JUnitMigrationDelegate.mapResources(config);
- }
+ }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#dispose()
@@ -510,9 +510,9 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
// remember the selected radio button
radioSetting[0] = mTestRadioButton.getSelection();
radioSetting[1] = mTestContainerRadioButton.getSelection();
-
+
types = TestSearchEngine.findTests(getLaunchConfigurationDialog(), javaProject,
- getTestKind());
+ getTestKind());
} catch (InterruptedException e) {
setErrorMessage(e.getMessage());
return;
@@ -525,8 +525,8 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
SelectionDialog dialog = new TestSelectionDialog(shell, types);
- dialog.setTitle(JUnitMessages.JUnitLaunchConfigurationTab_testdialog_title);
- dialog.setMessage(JUnitMessages.JUnitLaunchConfigurationTab_testdialog_message);
+ dialog.setTitle(JUnitMessages.JUnitLaunchConfigurationTab_testdialog_title);
+ dialog.setMessage(JUnitMessages.JUnitLaunchConfigurationTab_testdialog_message);
if (dialog.open() == Window.CANCEL) {
return;
}
@@ -534,7 +534,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
Object[] results = dialog.getResult();
if ((results == null) || (results.length < 1)) {
return;
- }
+ }
IType type = (IType) results[0];
if (type != null) {
@@ -562,7 +562,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
String projectName = project.getElementName();
mProjText.setText(projectName);
- loadInstrumentations(project.getProject());
+ loadInstrumentations(project.getProject());
}
/**
@@ -571,7 +571,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
*/
private IJavaProject getJavaProject() {
String projectName = getProjectName();
- return getJavaModel().getJavaProject(projectName);
+ return getJavaModel().getJavaProject(projectName);
}
/**
@@ -618,14 +618,14 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
IJavaProject javaProject = getJavaModel().getJavaProject(projText);
if (javaProject != null && javaProject.exists()) {
setContainerElement(javaProject);
- }
+ }
}
}
validatePage();
updateLaunchConfigurationDialog();
}
- private void validatePage() {
+ private void validatePage() {
setErrorMessage(null);
setMessage(null);
@@ -648,7 +648,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
IResource.PROJECT);
if (!status.isOK() || !Path.ROOT.isValidSegment(projectName)) {
setErrorMessage(Messages.format(
- JUnitMessages.JUnitLaunchConfigurationTab_error_invalidProjectName,
+ JUnitMessages.JUnitLaunchConfigurationTab_error_invalidProjectName,
projectName));
return;
}
@@ -676,7 +676,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
JUnitMessages.JUnitLaunchConfigurationTab_error_test_class_not_found,
new String[] { className, projectName }));
return;
- }
+ }
} catch (CoreException e) {
AdtPlugin.log(e, "validatePage failed"); //$NON-NLS-1$
}
@@ -686,8 +686,8 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
private void validateJavaProject(IJavaProject javaProject) {
if (!TestSearchEngine.hasTestCaseType(javaProject)) {
- setErrorMessage(JUnitMessages.JUnitLaunchConfigurationTab_error_testcasenotonpath);
- return;
+ setErrorMessage(JUnitMessages.JUnitLaunchConfigurationTab_error_testcasenotonpath);
+ return;
}
}
@@ -706,7 +706,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
private String getSelectedInstrumentation() {
int selectionIndex = mInstrumentationCombo.getSelectionIndex();
- if (mInstrumentations != null && selectionIndex >= 0 &&
+ if (mInstrumentations != null && selectionIndex >= 0 &&
selectionIndex < mInstrumentations.length) {
return mInstrumentations[selectionIndex];
}
@@ -750,11 +750,11 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
private void initializeTestAttributes(IJavaElement javaElement,
ILaunchConfigurationWorkingCopy config) {
- if (javaElement != null && javaElement.getElementType() < IJavaElement.COMPILATION_UNIT) {
+ if (javaElement != null && javaElement.getElementType() < IJavaElement.COMPILATION_UNIT) {
initializeTestContainer(javaElement, config);
} else {
initializeTestType(javaElement, config);
- }
+ }
}
private void initializeTestContainer(IJavaElement javaElement,
@@ -792,14 +792,14 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
testKindId = testKind.getId();
IType[] types = TestSearchEngine.findTests(getLaunchConfigurationDialog(),
- javaElement, testKind);
+ javaElement, testKind);
if ((types == null) || (types.length < 1)) {
return;
}
// Simply grab the first main type found in the searched element
name = types[0].getFullyQualifiedName('.');
-
- }
+
+ }
} catch (InterruptedException ie) {
// ignore
} catch (InvocationTargetException ite) {
@@ -809,7 +809,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
if (testKindId != null) {
config.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_RUNNER_KIND,
testKindId);
- }
+ }
initializeName(config, name);
}
@@ -817,7 +817,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
public String getName() {
- return JUnitMessages.JUnitLaunchConfigurationTab_tab_label;
+ return JUnitMessages.JUnitLaunchConfigurationTab_tab_label;
}
@SuppressWarnings("unchecked")
@@ -837,7 +837,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
ViewerFilter filter = new TypedViewerFilter(acceptedClasses) {
@Override
public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IPackageFragmentRoot &&
+ if (element instanceof IPackageFragmentRoot &&
((IPackageFragmentRoot) element).isArchive()) {
return false;
}
@@ -851,17 +851,17 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
}
return super.select(viewer, parent, element);
}
- };
+ };
AndroidJavaElementContentProvider provider = new AndroidJavaElementContentProvider();
ILabelProvider labelProvider = new JavaElementLabelProvider(
- JavaElementLabelProvider.SHOW_DEFAULT);
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
+ JavaElementLabelProvider.SHOW_DEFAULT);
+ ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
labelProvider, provider);
dialog.setValidator(validator);
dialog.setComparator(new JavaElementComparator());
- dialog.setTitle(JUnitMessages.JUnitLaunchConfigurationTab_folderdialog_title);
- dialog.setMessage(JUnitMessages.JUnitLaunchConfigurationTab_folderdialog_message);
+ dialog.setTitle(JUnitMessages.JUnitLaunchConfigurationTab_folderdialog_title);
+ dialog.setMessage(JUnitMessages.JUnitLaunchConfigurationTab_folderdialog_message);
dialog.addFilter(filter);
dialog.setInput(JavaCore.create(getWorkspaceRoot()));
dialog.setInitialSelection(initElement);
@@ -881,7 +881,7 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
/**
* Returns the current Java element context from which to initialize
* default settings, or null
if none.
- *
+ *
* @return Java element context.
*/
private IJavaElement getContext() {
@@ -948,13 +948,13 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
/**
* Loads the UI with the instrumentations of the specified project, and stores the
* instrumentations in mInstrumentations
.
- *
+ *
* @param project the {@link IProject} to load the instrumentations from.
*/
private void loadInstrumentations(IProject project) {
try {
mInstrValidator = new InstrumentationRunnerValidator(project);
- mInstrumentations = (mInstrValidator == null ? null :
+ mInstrumentations = (mInstrValidator == null ? null :
mInstrValidator.getInstrumentationNames());
if (mInstrumentations != null) {
mInstrumentationCombo.removeAll();
@@ -983,13 +983,13 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat
extends StandardJavaElementContentProvider {
/**
- * Override parent to return only Android projects if at the root. Otherwise, use parent
+ * Override parent to return only Android projects if at the root. Otherwise, use parent
* functionality.
*/
@Override
public Object[] getChildren(Object element) {
if (element instanceof IJavaModel) {
- return BaseProjectHelper.getAndroidProjects((IJavaModel) element);
+ return BaseProjectHelper.getAndroidProjects((IJavaModel) element, null /*filter*/);
}
return super.getChildren(element);
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java
index 7724700..3712dc4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseProjectHelper.java
@@ -64,6 +64,13 @@ public final class BaseProjectHelper {
public static final String TEST_CLASS_OK = null;
/**
+ * Project filter to be used with {@link BaseProjectHelper#getAndroidProjects(IProjectFilter)}.
+ */
+ public static interface IProjectFilter {
+ boolean accept(IProject project);
+ }
+
+ /**
* returns a list of source classpath for a specified project
* @param javaProject
* @return a list of path relative to the workspace root.
@@ -360,13 +367,14 @@ public final class BaseProjectHelper {
/**
* Returns the list of android-flagged projects. This list contains projects that are opened
* in the workspace and that are flagged as android project (through the android nature)
+ * @param filter an optional filter to control which android project are returned. Can be null.
* @return an array of IJavaProject, which can be empty if no projects match.
*/
- public static IJavaProject[] getAndroidProjects() {
+ public static IJavaProject[] getAndroidProjects(IProjectFilter filter) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IJavaModel javaModel = JavaCore.create(workspaceRoot);
- return getAndroidProjects(javaModel);
+ return getAndroidProjects(javaModel, filter);
}
/**
@@ -374,9 +382,10 @@ public final class BaseProjectHelper {
* This list contains projects that are opened in the workspace and that are flagged as android
* project (through the android nature)
* @param javaModel the Java Model object corresponding for the current workspace root.
+ * @param filter an optional filter to control which android project are returned. Can be null.
* @return an array of IJavaProject, which can be empty if no projects match.
*/
- public static IJavaProject[] getAndroidProjects(IJavaModel javaModel) {
+ public static IJavaProject[] getAndroidProjects(IJavaModel javaModel, IProjectFilter filter) {
// get the java projects
IJavaProject[] javaProjectList = null;
try {
@@ -397,7 +406,9 @@ public final class BaseProjectHelper {
// check if it's an android project based on its nature
try {
if (project.hasNature(AndroidConstants.NATURE)) {
- androidProjectList.add(javaProject);
+ if (filter == null || filter.accept(project)) {
+ androidProjectList.add(javaProject);
+ }
}
} catch (CoreException e) {
// this exception, thrown by IProject.hasNature(), means the project either doesn't
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectChooserHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectChooserHelper.java
index e6cac8a..e549d58 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectChooserHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectChooserHelper.java
@@ -16,6 +16,9 @@
package com.android.ide.eclipse.adt.internal.project;
+import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper.IProjectFilter;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -35,6 +38,7 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
public class ProjectChooserHelper {
private final Shell mParentShell;
+ private final IProjectChooserFilter mFilter;
/**
* List of current android projects. Since the dialog is modal, we'll just get
@@ -42,9 +46,57 @@ public class ProjectChooserHelper {
*/
private IJavaProject[] mAndroidProjects;
- public ProjectChooserHelper(Shell parentShell) {
+ /**
+ * Interface to filter out some project displayed by {@link ProjectChooserHelper}.
+ *
+ * @see IProjectFilter
+ */
+ public interface IProjectChooserFilter extends IProjectFilter {
+ /**
+ * Whether the Project Chooser can compute the project list once and cache the result.
+ *
null
if not found.
*/
@@ -123,7 +177,7 @@ public class ProjectChooserHelper {
break;
}
}
- }
+ }
return iproject;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectState.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectState.java
index 50ddc9c..a4c7f15 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectState.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectState.java
@@ -19,16 +19,21 @@ package com.android.ide.eclipse.adt.internal.project;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.IAndroidTarget;
+import com.android.sdklib.SdkConstants;
import com.android.sdklib.internal.project.ApkSettings;
import com.android.sdklib.internal.project.ProjectProperties;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -290,6 +295,15 @@ public final class ProjectState {
}
/**
+ * Returns the list of {@link LibraryState}.
+ */
+ public Listtrue
if there was actually new data saved in the project state, false
+ * otherwise.
+ */
+ boolean save(boolean isLibrary) {
+ boolean mustSave = mMustSave || (isLibrary && mState.getLibraries().size() > 0);
+ if (mustSave) {
+ // remove all previous library dependencies.
+ ProjectProperties props = mState.getProperties();
+ Setnull
to not change the current target.
- * @param settings a new {@link ApkSettings} object to set or null
to not change
- * the current settings.
- */
- public void setProject(IProject project, IAndroidTarget target,
- ApkSettings settings) {
- if (target == null && settings == null) {
- return;
- }
-
- synchronized (sLock) {
- boolean resolveProject = false;
-
- ProjectState state = getProjectState(project);
- if (state == null) {
- return;
- }
-
- ProjectProperties properties = state.getProperties();
-
- if (target != null) {
- // look for the current target of the project
- IAndroidTarget previousTarget = state.getTarget();
-
- if (target != previousTarget) {
- // save the target hash string in the project persistent property
- properties.setProperty(ProjectProperties.PROPERTY_TARGET, target.hashString());
-
- // put it in a local map for easy access.
- state.setTarget(target);
-
- resolveProject = true;
- }
- }
-
- if (settings != null) {
- state.setApkSettings(settings);
-
- // save the project settings into the project persistent property
- settings.write(properties);
- }
-
- // we are done with the modification. Save the property file.
- try {
- properties.save();
- } catch (IOException e) {
- AdtPlugin.log(e, "Failed to save default.properties for project '%s'",
- project.getName());
- }
-
- if (resolveProject) {
- // force a resolve of the project by updating the classpath container.
- // This will also force a recompile.
- IJavaProject javaProject = JavaCore.create(project);
- AndroidClasspathContainerInitializer.updateProjects(
- new IJavaProject[] { javaProject });
- } else {
- // always do a full clean/build.
- try {
- project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
- } catch (CoreException e) {
- // failed to build? force resolve instead.
- IJavaProject javaProject = JavaCore.create(project);
- AndroidClasspathContainerInitializer.updateProjects(
- new IJavaProject[] { javaProject });
- }
- }
-
- // finally, update the opened editors.
- if (resolveProject) {
- AdtPlugin.getDefault().updateTargetListeners(project);
- }
- }
- }
-
- /**
* Returns the {@link ProjectState} object associated with a given project.
*
* This method is the only way to properly get the project's {@link ProjectState}
@@ -968,9 +888,11 @@ public final class Sdk {
// reload the libraries if needed
if (diff.hasDiff()) {
for (LibraryState removedState : diff.removed) {
- unlinkLibrary(state,
- removedState.getProjectState().getProject(),
- false /*doInJob*/);
+ ProjectState removePState = removedState.getProjectState();
+ if (removePState != null) {
+ unlinkLibrary(state, removePState.getProject(),
+ false /*doInJob*/);
+ }
}
if (diff.added) {
@@ -989,7 +911,7 @@ public final class Sdk {
}
// need to force a full recompile.
- iProject.build( IncrementalProjectBuilder.FULL_BUILD, monitor);
+ iProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
}
// apply the new target if needed.
@@ -1000,6 +922,9 @@ public final class Sdk {
AndroidClasspathContainerInitializer.updateProjects(
new IJavaProject[] { javaProject });
}
+
+ // update the editors to reload with the new target
+ AdtPlugin.getDefault().updateTargetListeners(iProject);
}
} catch (CoreException e) {
// This can't happen as it's only for closed project (or non existing)
@@ -1291,7 +1216,7 @@ public final class Sdk {
* @param base the IPath to base the relative path on.
* @return the relative IPath
*/
- private static IPath makeRelativeTo(IPath target, IPath base) {
+ public static IPath makeRelativeTo(IPath target, IPath base) {
//can't make relative if devices are not equal
if (target.getDevice() != base.getDevice() && (target.getDevice() == null ||
!target.getDevice().equalsIgnoreCase(base.getDevice())))
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java
index 4b8cb69..11a40e5 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ProjectCheckPage.java
@@ -22,6 +22,7 @@ import com.android.ide.eclipse.adt.internal.project.AndroidManifestParser;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
import com.android.ide.eclipse.adt.internal.project.ProjectChooserHelper;
import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
+import com.android.ide.eclipse.adt.internal.project.ProjectChooserHelper.NonLibraryProjectOnlyFilter;
import com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.ExportWizardPage;
import org.eclipse.core.resources.IFolder;
@@ -45,7 +46,7 @@ import org.eclipse.swt.widgets.Text;
import java.io.File;
/**
- * First Export Wizard Page. Display warning/errors.
+ * First Export Wizard Page. Display warning/errors.
*/
final class ProjectCheckPage extends ExportWizardPage {
private final static String IMG_ERROR = "error.png"; //$NON-NLS-1$
@@ -71,7 +72,8 @@ final class ProjectCheckPage extends ExportWizardPage {
}
public void createControl(Composite parent) {
- mProjectChooserHelper = new ProjectChooserHelper(parent.getShell());
+ mProjectChooserHelper = new ProjectChooserHelper(parent.getShell(),
+ new NonLibraryProjectOnlyFilter());
mDisplay = parent.getDisplay();
GridLayout gl = null;
@@ -80,7 +82,7 @@ final class ProjectCheckPage extends ExportWizardPage {
mTopComposite = new Composite(parent, SWT.NONE);
mTopComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
mTopComposite.setLayout(new GridLayout(1, false));
-
+
// composite for the project selection.
Composite projectComposite = new Composite(mTopComposite, SWT.NONE);
projectComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -130,11 +132,11 @@ final class ProjectCheckPage extends ExportWizardPage {
if (project != null) {
mProjectText.setText(project.getName());
}
-
+
mFirstOnShow = false;
}
}
-
+
private void buildErrorUi(IProject project) {
// Show description the first time
setErrorMessage(null);
@@ -163,14 +165,14 @@ final class ProjectCheckPage extends ExportWizardPage {
if (ProjectHelper.hasError(project, true)) {
addError(mErrorComposite, "Project has compilation error(s)");
}
-
+
// check the project output
IFolder outputIFolder = BaseProjectHelper.getOutputFolder(project);
if (outputIFolder != null) {
String outputOsPath = outputIFolder.getLocation().toOSString();
String apkFilePath = outputOsPath + File.separator + project.getName() +
AndroidConstants.DOT_ANDROID_PACKAGE;
-
+
File f = new File(apkFilePath);
if (f.isFile() == false) {
addError(mErrorComposite,
@@ -191,12 +193,12 @@ final class ProjectCheckPage extends ExportWizardPage {
true /* gatherData */, false /* markErrors */);
Boolean debuggable = manifestParser.getDebuggable();
-
+
if (debuggable != null && debuggable == Boolean.TRUE) {
addWarning(mErrorComposite,
- "The manifest 'debuggable' attribute is set to true.\nYou should set it to false for applications that you release to the public.");
+ "The manifest 'debuggable' attribute is set to true.\nYou should set it to false for applications that you release to the public.");
}
-
+
// check for mapview stuff
}
} catch (CoreException e) {
@@ -204,7 +206,7 @@ final class ProjectCheckPage extends ExportWizardPage {
addError(mErrorComposite, "Unable to get project nature");
}
}
-
+
if (mHasMessage == false) {
Label label = new Label(mErrorComposite, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -212,10 +214,10 @@ final class ProjectCheckPage extends ExportWizardPage {
label.setLayoutData(gd);
label.setText("No errors found. Click Next.");
}
-
+
mTopComposite.layout();
}
-
+
/**
* Adds an error label to a {@link Composite} object.
* @param parent the Composite parent.
@@ -225,17 +227,17 @@ final class ProjectCheckPage extends ExportWizardPage {
if (mError == null) {
mError = AdtPlugin.getImageLoader().loadImage(IMG_ERROR, mDisplay);
}
-
+
new Label(parent, SWT.NONE).setImage(mError);
Label label = new Label(parent, SWT.NONE);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label.setText(message);
-
+
setErrorMessage("Application cannot be exported due to the error(s) below.");
setPageComplete(false);
mHasMessage = true;
}
-
+
/**
* Adds a warning label to a {@link Composite} object.
* @param parent the Composite parent.
@@ -245,26 +247,26 @@ final class ProjectCheckPage extends ExportWizardPage {
if (mWarning == null) {
mWarning = AdtPlugin.getImageLoader().loadImage(IMG_WARNING, mDisplay);
}
-
+
new Label(parent, SWT.NONE).setImage(mWarning);
Label label = new Label(parent, SWT.NONE);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label.setText(message);
-
+
mHasMessage = true;
}
-
+
/**
* 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);
@@ -282,12 +284,12 @@ final class ProjectCheckPage extends ExportWizardPage {
found = javaProject.getProject();
break;
}
-
+
}
-
+
if (found != null) {
setErrorMessage(null);
-
+
// update the wizard with the new project
mWizard.setProject(found);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewTestProjectCreationPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewTestProjectCreationPage.java
index 28855a2..ce6e118 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewTestProjectCreationPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewTestProjectCreationPage.java
@@ -523,7 +523,7 @@ public class NewTestProjectCreationPage extends WizardPage {
}
});
- mProjectChooserHelper = new ProjectChooserHelper(parent.getShell());
+ mProjectChooserHelper = new ProjectChooserHelper(parent.getShell(), null /*filter*/);
} else {
// Part of NPW mode: no selection.
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
index 4cedff2..dc4d852 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newxmlfile/NewXmlFileCreationPage.java
@@ -536,7 +536,7 @@ class NewXmlFileCreationPage extends WizardPage {
onProjectBrowse();
}
});
- mProjectChooserHelper = new ProjectChooserHelper(parent.getShell());
+ mProjectChooserHelper = new ProjectChooserHelper(parent.getShell(), null /*filter*/);
++col;
col = padWithEmptyCells(parent, col);
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java
index b73c863..2fbaadd 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectProperties.java
@@ -24,7 +24,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.Map.Entry;
/**
@@ -236,6 +238,14 @@ public final class ProjectProperties {
}
/**
+ * Returns a set of the property keys. Unlike {@link Map#keySet()} this is not a view of the
+ * map keys. Modifying the returned {@link Set} will not impact the underlying {@link Map}.
+ */
+ public synchronized Set