development
Revision | fbeb67eb39c2b5f36a29f34e1d4ce28077ba0328 (tree) |
---|---|
Time | 2009-03-26 07:04:55 |
Author | Raphael Moll <> |
Commiter | The Android Open Source Project |
Automated import from //branches/cupcake/...@142586,142586
@@ -17,6 +17,7 @@ | ||
17 | 17 | |
18 | 18 | package com.android.ide.eclipse.editors.wizards; |
19 | 19 | |
20 | +import com.android.ide.eclipse.adt.AdtPlugin; | |
20 | 21 | import com.android.ide.eclipse.adt.sdk.AndroidTargetData; |
21 | 22 | import com.android.ide.eclipse.adt.sdk.Sdk; |
22 | 23 | import com.android.ide.eclipse.common.AndroidConstants; |
@@ -39,6 +40,7 @@ import org.eclipse.core.resources.IResource; | ||
39 | 40 | import org.eclipse.core.runtime.CoreException; |
40 | 41 | import org.eclipse.core.runtime.IAdaptable; |
41 | 42 | import org.eclipse.core.runtime.IPath; |
43 | +import org.eclipse.core.runtime.IStatus; | |
42 | 44 | import org.eclipse.core.runtime.Path; |
43 | 45 | import org.eclipse.jdt.core.IJavaProject; |
44 | 46 | import org.eclipse.jface.viewers.IStructuredSelection; |
@@ -745,8 +747,35 @@ class NewXmlFileCreationPage extends WizardPage { | ||
745 | 747 | // cleared above. |
746 | 748 | |
747 | 749 | // get the AndroidTargetData from the project |
748 | - IAndroidTarget target = Sdk.getCurrent().getTarget(mProject); | |
749 | - AndroidTargetData data = Sdk.getCurrent().getTargetData(target); | |
750 | + IAndroidTarget target = null; | |
751 | + AndroidTargetData data = null; | |
752 | + | |
753 | + target = Sdk.getCurrent().getTarget(mProject); | |
754 | + if (target == null) { | |
755 | + // A project should have a target. The target can be missing if the project | |
756 | + // is an old project for which a target hasn't been affected or if the | |
757 | + // target no longer exists in this SDK. Simply log the error and dismiss. | |
758 | + | |
759 | + AdtPlugin.log(IStatus.INFO, | |
760 | + "NewXmlFile wizard: no platform target for project %s", //$NON-NLS-1$ | |
761 | + mProject.getName()); | |
762 | + continue; | |
763 | + } else { | |
764 | + data = Sdk.getCurrent().getTargetData(target); | |
765 | + | |
766 | + if (data == null) { | |
767 | + // We should have both a target and its data. | |
768 | + // However if the wizard is invoked whilst the platform is still being | |
769 | + // loaded we can end up in a weird case where we have a target but it | |
770 | + // doesn't have any data yet. | |
771 | + // Lets log a warning and silently ignore this root. | |
772 | + | |
773 | + AdtPlugin.log(IStatus.INFO, | |
774 | + "NewXmlFile wizard: no data for target %s, project %s", //$NON-NLS-1$ | |
775 | + target.getName(), mProject.getName()); | |
776 | + continue; | |
777 | + } | |
778 | + } | |
750 | 779 | |
751 | 780 | IDescriptorProvider provider = data.getDescriptorProvider((Integer)rootSeed); |
752 | 781 | ElementDescriptor descriptor = provider.getDescriptor(); |