merge from donut

This commit is contained in:
Jean-Baptiste Queru
2009-08-03 07:45:28 -07:00
2998 changed files with 82025 additions and 16091 deletions

View File

@@ -12,5 +12,6 @@
<classpathentry kind="lib" path="ninepatch.jar"/>
<classpathentry kind="lib" path="sdklib.jar" sourcepath="/SdkLib"/>
<classpathentry kind="lib" path="sdkuilib.jar" sourcepath="/SdkUiLib"/>
<classpathentry kind="lib" path="commons-compress-1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Android Development Toolkit
Bundle-SymbolicName: com.android.ide.eclipse.adt;singleton:=true
Bundle-Version: 0.9.1.qualifier
Bundle-Version: 0.9.2.qualifier
Bundle-ClassPath: .,
jarutils.jar,
androidprefs.jar,
@@ -12,7 +12,8 @@ Bundle-ClassPath: .,
ninepatch.jar,
layoutlib_utils.jar,
sdklib.jar,
sdkuilib.jar
sdkuilib.jar,
commons-compress-1.0.jar
Bundle-Activator: com.android.ide.eclipse.adt.AdtPlugin
Bundle-Vendor: The Android Open Source Project
Require-Bundle: com.android.ide.eclipse.ddms,
@@ -97,8 +98,11 @@ Export-Package: com.android.ide.eclipse.adt;x-friends:="com.android.ide.eclipse.
com.android.sdklib.internal.project;x-friends:="com.android.ide.eclipse.tests",
com.android.sdklib.internal.repository;x-friends:="com.android.ide.eclipse.tests",
com.android.sdklib.repository;x-friends:="com.android.ide.eclipse.tests",
com.android.sdklib.xml;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkstats;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.repository;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.repository.icons;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.tasks;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.internal.widgets;x-friends:="com.android.ide.eclipse.tests",
com.android.sdkuilib.repository;x-friends:="com.android.ide.eclipse.tests"

View File

@@ -12,6 +12,7 @@ bin.includes = plugin.xml,\
layoutlib_utils.jar,\
ninepatch.jar,\
sdklib.jar,\
sdkuilib.jar
sdkuilib.jar,\
commons-compress-1.0.jar
source.. = src/
output.. = bin/

View File

@@ -313,16 +313,7 @@ public class AdtPlugin extends AbstractUIPlugin {
if (checkSdkLocationAndId()) {
// if sdk if valid, reparse it
// add all the opened Android projects to the list of projects to be updated
// after the SDK is reloaded
synchronized (getSdkLockObject()) {
// get the project to refresh.
IJavaProject[] androidProjects = BaseProjectHelper.getAndroidProjects();
mPostLoadProjectsToResolve.addAll(Arrays.asList(androidProjects));
}
// parse the SDK resources at the new location
parseSdkContent();
reparseSdk();
}
} else if (PREFS_BUILD_VERBOSITY.equals(property)) {
mBuildVerbosity = BuildPreferencePage.getBuildLevel(
@@ -1388,6 +1379,22 @@ public class AdtPlugin extends AbstractUIPlugin {
SdkStatsService.ping("adt", versionString, getDisplay()); //$NON-NLS-1$
}
/**
* Reparses the content of the SDK and updates opened projects.
*/
public void reparseSdk() {
// add all the opened Android projects to the list of projects to be updated
// after the SDK is reloaded
synchronized (getSdkLockObject()) {
// get the project to refresh.
IJavaProject[] androidProjects = BaseProjectHelper.getAndroidProjects();
mPostLoadProjectsToResolve.addAll(Arrays.asList(androidProjects));
}
// parse the SDK resources at the new location
parseSdkContent();
}
/**
* Prints messages, associated with a project to the specified stream
* @param stream The stream to write to

View File

@@ -27,6 +27,7 @@ import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.AndroidVersion;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.SdkConstants;
import com.android.sdklib.xml.ManifestConstants;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -332,7 +333,7 @@ public class PreCompilerBuilder extends BaseBuilder {
// integer minSdk when the target is a preview => fatal error
String msg = String.format(
"Platform %1$s is a preview and requires appication manifests to set %2$s to '%3$s'",
codename, AndroidManifestParser.ATTRIBUTE_MIN_SDK_VERSION,
codename, ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION,
codename);
AdtPlugin.printErrorToConsole(project, msg);
BaseProjectHelper.addMarker(manifest, AdtConstants.MARKER_ADT, msg,
@@ -355,7 +356,7 @@ public class PreCompilerBuilder extends BaseBuilder {
// platform is not a preview => fatal error
String msg = String.format(
"Manifest attribute '%1$s' is set to '%2$s'. Integer is expected.",
AndroidManifestParser.ATTRIBUTE_MIN_SDK_VERSION, codename);
ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION, codename);
AdtPlugin.printErrorToConsole(project, msg);
BaseProjectHelper.addMarker(manifest, AdtConstants.MARKER_ADT, msg,
IMarker.SEVERITY_ERROR);
@@ -364,7 +365,7 @@ public class PreCompilerBuilder extends BaseBuilder {
// platform and manifest codenames don't match => fatal error.
String msg = String.format(
"Value of manifest attribute '%1$s' does not match platform codename '%2$s'",
AndroidManifestParser.ATTRIBUTE_MIN_SDK_VERSION, codename);
ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION, codename);
AdtPlugin.printErrorToConsole(project, msg);
BaseProjectHelper.addMarker(manifest, AdtConstants.MARKER_ADT, msg,
IMarker.SEVERITY_ERROR);

View File

@@ -27,10 +27,10 @@ import com.android.ide.eclipse.adt.internal.editors.manifest.pages.OverviewPage;
import com.android.ide.eclipse.adt.internal.editors.manifest.pages.PermissionPage;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceMonitor;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceMonitor.IFileListener;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.sdklib.xml.AndroidXPathFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;

View File

@@ -21,8 +21,8 @@ import com.android.ide.eclipse.adt.AndroidConstants;
import com.android.ide.eclipse.adt.internal.editors.AndroidEditor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.sdklib.xml.AndroidXPathFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.IEditorInput;

View File

@@ -22,7 +22,7 @@ import com.android.ide.eclipse.adt.internal.editors.AndroidEditor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor;
import com.android.ide.eclipse.adt.internal.editors.resources.descriptors.ResourcesDescriptors;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
import com.android.sdklib.xml.AndroidXPathFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IStatus;

View File

@@ -20,6 +20,7 @@ import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AndroidConstants;
import com.android.ide.eclipse.adt.internal.project.XmlErrorHandler.XmlErrorListener;
import com.android.sdklib.SdkConstants;
import com.android.sdklib.xml.ManifestConstants;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -47,26 +48,6 @@ import javax.xml.parsers.SAXParserFactory;
public class AndroidManifestParser {
private final static String ATTRIBUTE_PACKAGE = "package"; //$NON-NLS-1$
private final static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
private final static String ATTRIBUTE_PROCESS = "process"; //$NON-NLS-$
private final static String ATTRIBUTE_DEBUGGABLE = "debuggable"; //$NON-NLS-$
public final static String ATTRIBUTE_MIN_SDK_VERSION = "minSdkVersion"; //$NON-NLS-$
private final static String ATTRIBUTE_TARGET_PACKAGE = "targetPackage"; //$NON-NLS-1$
private final static String ATTRIBUTE_EXPORTED = "exported"; //$NON-NLS-1$
private final static String NODE_MANIFEST = "manifest"; //$NON-NLS-1$
private final static String NODE_APPLICATION = "application"; //$NON-NLS-1$
private final static String NODE_ACTIVITY = "activity"; //$NON-NLS-1$
private final static String NODE_SERVICE = "service"; //$NON-NLS-1$
private final static String NODE_RECEIVER = "receiver"; //$NON-NLS-1$
private final static String NODE_PROVIDER = "provider"; //$NON-NLS-1$
private final static String NODE_INTENT = "intent-filter"; //$NON-NLS-1$
private final static String NODE_ACTION = "action"; //$NON-NLS-1$
private final static String NODE_CATEGORY = "category"; //$NON-NLS-1$
private final static String NODE_USES_SDK = "uses-sdk"; //$NON-NLS-1$
private final static String NODE_INSTRUMENTATION = "instrumentation"; //$NON-NLS-1$
private final static String NODE_USES_LIBRARY = "uses-library"; //$NON-NLS-1$
private final static int LEVEL_MANIFEST = 0;
private final static int LEVEL_APPLICATION = 1;
private final static int LEVEL_ACTIVITY = 2;
@@ -304,50 +285,55 @@ public class AndroidManifestParser {
String value;
switch (mValidLevel) {
case LEVEL_MANIFEST:
if (NODE_MANIFEST.equals(localName)) {
if (ManifestConstants.NODE_MANIFEST.equals(localName)) {
// lets get the package name.
mPackage = getAttributeValue(attributes, ATTRIBUTE_PACKAGE,
mPackage = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_PACKAGE,
false /* hasNamespace */);
mValidLevel++;
}
break;
case LEVEL_APPLICATION:
if (NODE_APPLICATION.equals(localName)) {
value = getAttributeValue(attributes, ATTRIBUTE_PROCESS,
if (ManifestConstants.NODE_APPLICATION.equals(localName)) {
value = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_PROCESS,
true /* hasNamespace */);
if (value != null) {
addProcessName(value);
}
value = getAttributeValue(attributes, ATTRIBUTE_DEBUGGABLE,
value = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_DEBUGGABLE,
true /* hasNamespace*/);
if (value != null) {
mDebuggable = Boolean.parseBoolean(value);
}
mValidLevel++;
} else if (NODE_USES_SDK.equals(localName)) {
} else if (ManifestConstants.NODE_USES_SDK.equals(localName)) {
mApiLevelRequirement = getAttributeValue(attributes,
ATTRIBUTE_MIN_SDK_VERSION, true /* hasNamespace */);
} else if (NODE_INSTRUMENTATION.equals(localName)) {
ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION,
true /* hasNamespace */);
} else if (ManifestConstants.NODE_INSTRUMENTATION.equals(localName)) {
processInstrumentationNode(attributes);
}
break;
case LEVEL_ACTIVITY:
if (NODE_ACTIVITY.equals(localName)) {
if (ManifestConstants.NODE_ACTIVITY.equals(localName)) {
processActivityNode(attributes);
mValidLevel++;
} else if (NODE_SERVICE.equals(localName)) {
} else if (ManifestConstants.NODE_SERVICE.equals(localName)) {
processNode(attributes, AndroidConstants.CLASS_SERVICE);
mValidLevel++;
} else if (NODE_RECEIVER.equals(localName)) {
} else if (ManifestConstants.NODE_RECEIVER.equals(localName)) {
processNode(attributes, AndroidConstants.CLASS_BROADCASTRECEIVER);
mValidLevel++;
} else if (NODE_PROVIDER.equals(localName)) {
} else if (ManifestConstants.NODE_PROVIDER.equals(localName)) {
processNode(attributes, AndroidConstants.CLASS_CONTENTPROVIDER);
mValidLevel++;
} else if (NODE_USES_LIBRARY.equals(localName)) {
value = getAttributeValue(attributes, ATTRIBUTE_NAME,
} else if (ManifestConstants.NODE_USES_LIBRARY.equals(localName)) {
value = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_NAME,
true /* hasNamespace */);
if (value != null) {
mLibraries.add(value);
@@ -356,24 +342,27 @@ public class AndroidManifestParser {
break;
case LEVEL_INTENT_FILTER:
// only process this level if we are in an activity
if (mCurrentActivity != null && NODE_INTENT.equals(localName)) {
if (mCurrentActivity != null &&
ManifestConstants.NODE_INTENT.equals(localName)) {
mCurrentActivity.resetIntentFilter();
mValidLevel++;
}
break;
case LEVEL_CATEGORY:
if (mCurrentActivity != null) {
if (NODE_ACTION.equals(localName)) {
if (ManifestConstants.NODE_ACTION.equals(localName)) {
// get the name attribute
String action = getAttributeValue(attributes, ATTRIBUTE_NAME,
String action = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_NAME,
true /* hasNamespace */);
if (action != null) {
mCurrentActivity.setHasAction(true);
mCurrentActivity.setHasMainAction(
ACTION_MAIN.equals(action));
}
} else if (NODE_CATEGORY.equals(localName)) {
String category = getAttributeValue(attributes, ATTRIBUTE_NAME,
} else if (ManifestConstants.NODE_CATEGORY.equals(localName)) {
String category = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_NAME,
true /* hasNamespace */);
if (CATEGORY_LAUNCHER.equals(category)) {
mCurrentActivity.setHasLauncherCategory(true);
@@ -473,13 +462,14 @@ public class AndroidManifestParser {
*/
private void processActivityNode(Attributes attributes) {
// lets get the activity name, and add it to the list
String activityName = getAttributeValue(attributes, ATTRIBUTE_NAME,
String activityName = getAttributeValue(attributes, ManifestConstants.ATTRIBUTE_NAME,
true /* hasNamespace */);
if (activityName != null) {
activityName = combinePackageAndClassName(mPackage, activityName);
// get the exported flag.
String exportedStr = getAttributeValue(attributes, ATTRIBUTE_EXPORTED, true);
String exportedStr = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_EXPORTED, true);
boolean exported = exportedStr == null ||
exportedStr.toLowerCase().equals("true"); // $NON-NLS-1$
mCurrentActivity = new Activity(activityName, exported);
@@ -495,7 +485,7 @@ public class AndroidManifestParser {
mCurrentActivity = null;
}
String processName = getAttributeValue(attributes, ATTRIBUTE_PROCESS,
String processName = getAttributeValue(attributes, ManifestConstants.ATTRIBUTE_PROCESS,
true /* hasNamespace */);
if (processName != null) {
addProcessName(processName);
@@ -510,7 +500,7 @@ public class AndroidManifestParser {
*/
private void processNode(Attributes attributes, String superClassName) {
// lets get the class name, and check it if required.
String serviceName = getAttributeValue(attributes, ATTRIBUTE_NAME,
String serviceName = getAttributeValue(attributes, ManifestConstants.ATTRIBUTE_NAME,
true /* hasNamespace */);
if (serviceName != null) {
serviceName = combinePackageAndClassName(mPackage, serviceName);
@@ -520,7 +510,7 @@ public class AndroidManifestParser {
}
}
String processName = getAttributeValue(attributes, ATTRIBUTE_PROCESS,
String processName = getAttributeValue(attributes, ManifestConstants.ATTRIBUTE_PROCESS,
true /* hasNamespace */);
if (processName != null) {
addProcessName(processName);
@@ -534,11 +524,13 @@ public class AndroidManifestParser {
*/
private void processInstrumentationNode(Attributes attributes) {
// lets get the class name, and check it if required.
String instrumentationName = getAttributeValue(attributes, ATTRIBUTE_NAME,
String instrumentationName = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_NAME,
true /* hasNamespace */);
if (instrumentationName != null) {
String instrClassName = combinePackageAndClassName(mPackage, instrumentationName);
String targetPackage = getAttributeValue(attributes, ATTRIBUTE_TARGET_PACKAGE,
String targetPackage = getAttributeValue(attributes,
ManifestConstants.ATTRIBUTE_TARGET_PACKAGE,
true /* hasNamespace */);
mInstrumentations.add(new Instrumentation(instrClassName, targetPackage));
if (mMarkErrors) {

View File

@@ -1,89 +0,0 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.eclipse.org/org/documents/epl-v10.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.ide.eclipse.adt.internal.project;
import com.android.sdklib.SdkConstants;
import java.util.Iterator;
import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
/**
* XPath factory with automatic support for the android namespace.
*/
public class AndroidXPathFactory {
public final static String DEFAULT_NS_PREFIX = "android"; //$NON-NLS-1$
private final static XPathFactory sFactory = XPathFactory.newInstance();
/** Namespace context for Android resource XML files. */
private static class AndroidNamespaceContext implements NamespaceContext {
private String mAndroidPrefix;
/**
* Construct the context with the prefix associated with the android namespace.
* @param androidPrefix the Prefix
*/
public AndroidNamespaceContext(String androidPrefix) {
mAndroidPrefix = androidPrefix;
}
public String getNamespaceURI(String prefix) {
if (prefix != null) {
if (prefix.equals(mAndroidPrefix)) {
return SdkConstants.NS_RESOURCES;
}
}
return XMLConstants.NULL_NS_URI;
}
public String getPrefix(String namespaceURI) {
// This isn't necessary for our use.
assert false;
return null;
}
public Iterator<?> getPrefixes(String namespaceURI) {
// This isn't necessary for our use.
assert false;
return null;
}
}
/**
* Creates a new XPath object, specifying which prefix in the query is used for the
* android namespace.
* @param androidPrefix The namespace prefix.
*/
public static XPath newXPath(String androidPrefix) {
XPath xpath = sFactory.newXPath();
xpath.setNamespaceContext(new AndroidNamespaceContext(androidPrefix));
return xpath;
}
/**
* Creates a new XPath object using the default prefix for the android namespace.
* @see #DEFAULT_NS_PREFIX
*/
public static XPath newXPath() {
return newXPath(DEFAULT_NS_PREFIX);
}
}

View File

@@ -16,7 +16,7 @@
package com.android.ide.eclipse.adt.internal.refactorings.extractstring;
import com.android.ide.eclipse.adt.internal.project.AndroidXPathFactory;
import com.android.sdklib.xml.AndroidXPathFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;

View File

@@ -49,6 +49,11 @@ public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObject
null /*sdk log*/,
sdk.getSdkLocation(),
false /*userCanChangeSdkRoot*/);
window.addListeners(new UpdaterWindow.ISdkListener() {
public void onSdkChange() {
AdtPlugin.getDefault().reparseSdk();
}
});
window.open();
}
}