diff options
Diffstat (limited to 'eclipse')
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) { |