aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorJosiah Gaskin <josiahgaskin@google.com>2014-01-30 00:20:04 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-01-30 00:20:04 +0000
commitdaf99f612d06fe45e06fd2d83a01cad99ae61d6e (patch)
treec610a2a8528e2484ecd638189f6f07022ba984aa /eclipse/plugins
parent257434c85b18acd1f5e586ed81a99c04cd317a7b (diff)
parent12b441aa553fcf823c4e2746fe6a6bc8a89fd603 (diff)
downloadsdk-daf99f612d06fe45e06fd2d83a01cad99ae61d6e.zip
sdk-daf99f612d06fe45e06fd2d83a01cad99ae61d6e.tar.gz
sdk-daf99f612d06fe45e06fd2d83a01cad99ae61d6e.tar.bz2
Merge "Fix Dependency Project Creation" into idea133
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java18
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java21
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java6
3 files changed, 37 insertions, 8 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
index 98e43ab..37559e9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
@@ -93,6 +93,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
private static final String ANDROID_SUPPORT_V4_JAR = "android-support-v4.jar"; //$NON-NLS-1$
private static final String ANDROID_SUPPORT_V13_JAR = "android-support-v13.jar";//$NON-NLS-1$
private static final String APPCOMPAT_V7_JAR = "android-support-v7-appcompat.jar";//$NON-NLS-1$
+ private static final String APP_COMPAT_LIB_NAME = "appcompat_v7"; //$NON-NLS-1$
private ISelection mSelection;
/**
@@ -310,6 +311,18 @@ public class AddSupportJarAction implements IObjectActionDelegate {
final IJavaProject javaProject = JavaCore.create(project);
if (javaProject != null) {
+ // Don't add in the library if it already exists
+ ProjectState state = Sdk.getProjectState(project);
+ ProjectPropertiesWorkingCopy copy = state.getProperties().makeWorkingCopy();
+ for (String property : copy.keySet()) {
+ if (property.startsWith(ProjectProperties.PROPERTY_LIB_REF)) {
+ String libraryReference = copy.getProperty(property);
+ if (libraryReference != null && libraryReference.contains(APP_COMPAT_LIB_NAME)) {
+ return true;
+ }
+ }
+ }
+
File supportPath = getSupportPackageDir();
if (!supportPath.isDirectory()) {
File path = installSupport(7);
@@ -331,7 +344,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
// Create workspace copy of the project and add library dependency
IProject libraryProject = createLibraryProject(libraryPath, project,
- "appcompat_v7", waitForFinish); // $NON-NLS-1$
+ APP_COMPAT_LIB_NAME, waitForFinish);
if (libraryProject != null) {
return addLibraryDependency(libraryProject, project, waitForFinish);
}
@@ -460,7 +473,8 @@ public class AddSupportJarAction implements IObjectActionDelegate {
ProjectState state = Sdk.getProjectState(project);
String target = state.getProperties().getProperty(ProjectProperties.PROPERTY_TARGET);
if (target != null && target.length() > 0) {
- ProjectProperties properties = ProjectProperties.load(libraryPath.getPath(),
+ ProjectProperties properties = ProjectProperties.load(
+ destDir.toLocalFile(EFS.NONE, new NullProgressMonitor()).getPath(),
PropertyType.PROJECT);
ProjectPropertiesWorkingCopy copy = properties.makeWorkingCopy();
copy.setProperty(ProjectProperties.PROPERTY_TARGET, target);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
index 535aa1e..d1ecebf 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
@@ -20,18 +20,25 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectW
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_MIN_API_LEVEL;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_PACKAGE_NAME;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_TARGET_API;
+import static org.eclipse.core.resources.IResource.DEPTH_INFINITE;
import com.android.annotations.NonNull;
+import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ui.IWorkbench;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Set;
@@ -132,6 +139,20 @@ public class NewActivityWizard extends TemplateWizard {
}
@Override
+ public boolean performFinish(IProgressMonitor monitor) throws InvocationTargetException {
+ boolean success = super.performFinish(monitor);
+
+ if (success) {
+ List<Runnable> finalizingTasks = getFinalizingActions();
+ for (Runnable r : finalizingTasks) {
+ r.run();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
@NonNull
protected IProject getProject() {
return mActivityValues.project;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
index 6331720..56bc955 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
@@ -359,16 +359,10 @@ public class NewProjectWizard extends TemplateWizard {
AdtPlugin.log(e, null);
}
- // Run finalizing actions
- // Display.getDefault().asyncExec(new Runnable() {
- // @Override
- // public void run() {
List<Runnable> finalizingTasks = getFinalizingActions();
for (Runnable r : finalizingTasks) {
r.run();
}
- // }
- // });
return true;
} catch (Exception ioe) {