import com.android.sdklib.internal.avd.AvdManager;\r
import com.android.sdklib.internal.repository.AddonPackage;\r
import com.android.sdklib.internal.repository.Archive;\r
-import com.android.sdklib.internal.repository.DocPackage;\r
-import com.android.sdklib.internal.repository.ExtraPackage;\r
import com.android.sdklib.internal.repository.ITask;\r
import com.android.sdklib.internal.repository.ITaskFactory;\r
import com.android.sdklib.internal.repository.ITaskMonitor;\r
import com.android.sdklib.internal.repository.LocalSdkParser;\r
import com.android.sdklib.internal.repository.Package;\r
-import com.android.sdklib.internal.repository.PlatformPackage;\r
-import com.android.sdklib.internal.repository.PlatformToolPackage;\r
import com.android.sdklib.internal.repository.RepoSource;\r
import com.android.sdklib.internal.repository.RepoSources;\r
-import com.android.sdklib.internal.repository.SamplePackage;\r
import com.android.sdklib.internal.repository.ToolPackage;\r
import com.android.sdklib.repository.SdkRepository;\r
import com.android.sdkuilib.internal.repository.icons.ImageFactory;\r
* @param dryMode True to check what would be updated/installed but do not actually\r
* download or install anything.\r
*/\r
+ @SuppressWarnings("unchecked")\r
public void updateOrInstallAll_NoGUI(\r
Collection<String> pkgFilter,\r
boolean includeObsoletes,\r
// Map filter types to an SdkRepository Package type.\r
HashMap<String, Class<? extends Package>> pkgMap =\r
new HashMap<String, Class<? extends Package>>();\r
- pkgMap.put(SdkRepository.NODE_PLATFORM, PlatformPackage.class);\r
- pkgMap.put(SdkRepository.NODE_ADD_ON, AddonPackage.class);\r
- pkgMap.put(SdkRepository.NODE_TOOL, ToolPackage.class);\r
- pkgMap.put(SdkRepository.NODE_PLATFORM_TOOL, PlatformToolPackage.class);\r
- pkgMap.put(SdkRepository.NODE_DOC, DocPackage.class);\r
- pkgMap.put(SdkRepository.NODE_SAMPLE, SamplePackage.class);\r
- pkgMap.put(SdkRepository.NODE_EXTRA, ExtraPackage.class);\r
+\r
+ // Automatically find the classes matching the node names\r
+ ClassLoader classLoader = getClass().getClassLoader();\r
+ String basePackage = Package.class.getPackage().getName();\r
+ for (String node : SdkRepository.NODES) {\r
+ // Capitalize the name\r
+ String name = node.substring(0, 1).toUpperCase() + node.substring(1);\r
+\r
+ // We can have one dash at most in a name. If it's present, we'll try\r
+ // with the dash or with the next letter capitalized.\r
+ int dash = name.indexOf('-');\r
+ if (dash > 0) {\r
+ name = name.replaceFirst("-", "");\r
+ }\r
+\r
+ for (int alternatives = 0; alternatives < 2; alternatives++) {\r
+\r
+ String fqcn = basePackage + "." + name + "Package"; //$NON-NLS-1$ //$NON-NLS-2$\r
+ try {\r
+ Class<? extends Package> clazz =\r
+ (Class<? extends Package>) classLoader.loadClass(fqcn);\r
+ if (clazz != null) {\r
+ pkgMap.put(node, clazz);\r
+ continue;\r
+ }\r
+ } catch (Throwable ignore) {\r
+ }\r
+\r
+ if (alternatives == 0 && dash > 0) {\r
+ // Try an alternative where the next letter after the dash\r
+ // is converted to an upper case.\r
+ name = name.substring(0, dash) +\r
+ name.substring(dash, dash + 1).toUpperCase() +\r
+ name.substring(dash + 1);\r
+ } else {\r
+ break;\r
+ }\r
+ }\r
+ }\r
\r
if (SdkRepository.NODES.length != pkgMap.size()) {\r
- // Sanity check in case we forget to update this package map.\r
+ // Sanity check in case we forget to update this node array.\r
// We don't cancel the operation though.\r
- mSdkLog.error(null,\r
- "Filter Mismatch!\nThe package filter list has changed. Please report this.");\r
+ mSdkLog.printf(\r
+ "*** Filter Mismatch! ***\n" +\r
+ "*** The package filter list has changed. Please report this.");\r
}\r
\r
// Now make a set of the types that are allowed by the filter.\r