aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.pdt
diff options
context:
space:
mode:
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.pdt')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/.classpath7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/.project28
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF21
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/build.properties5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml30
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java146
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java155
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java140
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java180
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java41
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java63
12 files changed, 914 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/.classpath b/eclipse/plugins/com.android.ide.eclipse.pdt/.classpath
new file mode 100644
index 000000000..751c8f2e5
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/.project b/eclipse/plugins/com.android.ide.eclipse.pdt/.project
new file mode 100644
index 000000000..091b01328
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>plugin-pdt</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs b/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..ea661960a
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,98 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
+org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..a888ae462
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Pdt
+Bundle-SymbolicName: com.android.ide.eclipse.pdt;singleton:=true
+Bundle-Version: 24.3.3.qualifier
+Bundle-Vendor: The Android Open Source Project
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ com.android.ide.eclipse.ddms,
+ org.eclipse.core.resources,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.jdt.launching,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.ui.ide
+Bundle-Activator: com.android.ide.eclipse.pdt.PdtPlugin
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/build.properties b/eclipse/plugins/com.android.ide.eclipse.pdt/build.properties
new file mode 100644
index 000000000..e9863e281
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml
new file mode 100644
index 000000000..b2d622a6d
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/plugin.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="com.android.ide.eclipse.pdt.internal.preferences.PrefPage"
+ id="com.android.ide.eclipse.preferences.main"
+ name="Android"/>
+ </extension>
+ <extension
+ point="com.android.ide.eclipse.ddms.toolsLocator">
+ <locator
+ class="com.android.ide.eclipse.pdt.internal.ToolsLocator">
+ </locator>
+ </extension>
+ <extension
+ point="com.android.ide.eclipse.ddms.debuggerConnector">
+ <connector
+ class="com.android.ide.eclipse.pdt.internal.DebuggerConnector">
+ </connector>
+ </extension>
+ <extension
+ point="com.android.ide.eclipse.ddms.sourceRevealer">
+ <revealer
+ class="com.android.ide.eclipse.pdt.internal.SourceRevealer">
+ </revealer>
+ </extension>
+
+</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java
new file mode 100644
index 000000000..3b538505d
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/PdtPlugin.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.pdt;
+
+import com.android.ide.eclipse.ddms.DdmsPlugin;
+import com.android.ide.eclipse.pdt.internal.preferences.PrefPage;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class PdtPlugin extends AbstractUIPlugin {
+
+ public final static String PLUGIN_ID = "com.android.ide.eclipse.pdt"; //$NON-NLS-1$
+ private static PdtPlugin sPlugin;
+
+ public PdtPlugin() {
+ sPlugin = this;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static synchronized PdtPlugin getDefault() {
+ return sPlugin;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+
+ // set the listener for the preference change
+ getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ // if the SDK changed, we have to do some extra work
+ if (PrefPage.PREFS_DEVTREE_DIR.equals(event.getProperty())) {
+ // restart adb, in case it's a different version
+ DdmsPlugin.setToolsLocation(getAdbLocation(), true /* startAdb */,
+ getHprofConvLocation(), getTraceViewLocation());
+ }
+ }
+ });
+ }
+
+ /**
+ * Returns the location of the dev tree or <code>null</code> if unknown.
+ */
+ public static String getDevTree() {
+ // this always return a store, even a temp one if an error occurred.
+ IPreferenceStore store = sPlugin.getPreferenceStore();
+
+ // returns an empty, non-null, string if the preference is not found.
+ String devTree = store.getString(PrefPage.PREFS_DEVTREE_DIR);
+
+ if (devTree.length() == 0) {
+ devTree = System.getenv("ANDROID_BUILD_TOP"); //$NON-NLS-1$
+ }
+
+ return devTree;
+ }
+
+ /**
+ * Returns the location of adb or <code>null</code> if unknown.
+ */
+ public static String getAdbLocation() {
+ String devTreeBin = getDevTreeOutBin();
+
+ if (devTreeBin != null && devTreeBin.length() > 0) {
+ return devTreeBin + "adb"; //$NON-NLS-1$
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the location of hprof-conv or <code>null</code> if unknown.
+ */
+ public static String getHprofConvLocation() {
+ String devTreeBin = getDevTreeOutBin();
+
+ if (devTreeBin != null && devTreeBin.length() > 0) {
+ return devTreeBin + "hprof-conv"; //$NON-NLS-1$
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the location of traceview or <code>null</code> if unknown.
+ */
+ public static String getTraceViewLocation() {
+ String devTreeBin = getDevTreeOutBin();
+
+ if (devTreeBin != null && devTreeBin.length() > 0) {
+ return devTreeBin + "traceview"; //$NON-NLS-1$
+ }
+
+ return null;
+ }
+
+ private static String getDevTreeOutBin() {
+ String devTree = getDevTree();
+
+ if (devTree != null && devTree.length() > 0) {
+ return devTree + "/out/host/" + currentPlatform() + "/bin/"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the current platform name as used by the Android build system
+ *
+ */
+ private static String currentPlatform() {
+ String os = System.getProperty("os.name"); //$NON-NLS-1$
+ if (os.startsWith("Mac OS")) { //$NON-NLS-1$
+ return "darwin-x86"; //$NON-NLS-1$
+ } else if (os.startsWith("Windows")) { //$NON-NLS-1$
+ return "windows"; //$NON-NLS-1$
+ } else if (os.startsWith("Linux")) { //$NON-NLS-1$
+ return "linux-x86"; //$NON-NLS-1$
+ }
+
+ return ""; //$NON-NLS-1$
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java
new file mode 100644
index 000000000..238cad32f
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DebuggerConnector.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.pdt.internal;
+
+import com.android.ide.eclipse.ddms.IDebuggerConnector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Implementation of the com.android.ide.ddms.debuggerConnector extension point.
+ */
+public class DebuggerConnector extends DevTreeProjectProvider implements IDebuggerConnector {
+
+ private final static String ATTR_CONNECT_MAP_PORT = "port"; //$NON-NLS-1$
+ private final static String ATTR_CONNECT_MAP_HOSTNAME = "hostname"; //$NON-NLS-1$
+
+ @Override
+ public boolean isWorkspaceApp(String appName) {
+ return getProject() != null;
+ }
+
+ @Override
+ public boolean connectDebugger(String appName, int appPort, int selectedPort) {
+ IProject project = getProject();
+
+ if (project != null) {
+ // get the launch manager
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+
+ // get the config for the remote launch config.
+ ILaunchConfigurationType configType = manager.getLaunchConfigurationType(
+ IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION);
+
+ String projectName = project.getName();
+
+ // look for an existing launch config
+ ILaunchConfiguration config = findConfig(manager, configType, projectName,
+ selectedPort);
+
+ if (config == null) {
+ // Didn't find a matching config, so we make one.
+ // It'll be made in the "working copy" object first.
+ ILaunchConfigurationWorkingCopy wc = null;
+
+ try {
+ // make the working copy object with a unique name
+ wc = configType.newInstance(null,
+ manager.generateUniqueLaunchConfigurationNameFrom(projectName));
+
+ // set the project name
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ projectName);
+
+ // set the connect map info
+ Map<String, String> connectMap = new HashMap<String, String>();
+ connectMap.put(ATTR_CONNECT_MAP_PORT, Integer.toString(selectedPort));
+ connectMap.put(ATTR_CONNECT_MAP_HOSTNAME, "localhost"); //$NON-NLS-1$
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, connectMap);
+
+ // set the VM connector ID
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR,
+ IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR);
+
+ // save the working copy to get the launch config object which we return.
+ config = wc.doSave();
+
+ } catch (CoreException e) {
+
+ }
+
+ }
+
+ if (config != null) {
+ DebugUITools.launch(config, ILaunchManager.DEBUG_MODE);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Looks for and returns an existing {@link ILaunchConfiguration} object for a
+ * specified project and connection port.
+ * @param manager The {@link ILaunchManager}.
+ * @param type The {@link ILaunchConfigurationType}.
+ * @param projectName The name of the project
+ * @param connectionPort the remote connection port.
+ * @return an existing <code>ILaunchConfiguration</code> object matching the project, or
+ * <code>null</code>.
+ */
+ private static ILaunchConfiguration findConfig(ILaunchManager manager,
+ ILaunchConfigurationType type,
+ String projectName, int connectionPort) {
+ try {
+ ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
+
+ // look for one set up for the project with a debug equal to the selected debug port.
+ for (ILaunchConfiguration config : configs) {
+
+ Map<?, ?> attributes = config.getAttributes();
+
+ String name = (String) attributes.get(
+ IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME);
+
+ if (name == null || name.equals(projectName) == false) {
+ continue;
+ }
+
+ Map<?, ?> connectMap = (Map<?, ?>) attributes.get(
+ IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP);
+
+ if (connectMap != null) {
+ String portStr = (String) connectMap.get(ATTR_CONNECT_MAP_PORT);
+ if (portStr != null) {
+ Integer port = Integer.valueOf(portStr);
+ if (connectionPort == port) {
+ return config;
+ }
+ }
+ }
+
+ }
+ } catch (CoreException e) {
+ }
+
+ // didn't find anything that matches. Return null
+ return null;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java
new file mode 100644
index 000000000..b44d2cb49
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/DevTreeProjectProvider.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.pdt.internal;
+
+import com.android.ide.eclipse.pdt.PdtPlugin;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ListDialog;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Base class providing a {@link #getProject()} method to find the project matching the dev tree.
+ *
+ */
+class DevTreeProjectProvider {
+ protected IProject getProject() {
+ // Get the list of project for the current workspace
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ List<IProject> projects = Arrays.asList(workspace.getRoot().getProjects());
+ if (projects.size() == 0) {
+ return null;
+ }
+
+ // get the location of the Dev tree
+ String devTree = PdtPlugin.getDevTree();
+ IPath devTreePath = null;
+ if (devTree != null) {
+ devTreePath = new Path(devTree);
+ }
+
+ // filter the list of projects in workspace by 2 conditions:
+ // 1. Only look at Java projects
+ // 2. If dev tree location is set, only look at projects within the dev tree
+
+ List<IProject> devTreeProjects = new ArrayList<IProject>(projects.size());
+
+ for (IProject p: projects) {
+ if (!p.isOpen()) {
+ continue;
+ }
+
+ if (!hasJavaNature(p)) {
+ continue;
+ }
+
+ if (devTreePath == null || devTreePath.isPrefixOf(p.getLocation())) {
+ devTreeProjects.add(p);
+ }
+ }
+
+ return selectProject(devTreeProjects);
+ }
+
+ private IProject selectProject(List<IProject> devTreeProjects) {
+ if (devTreeProjects.size() == 0) {
+ return null;
+ }
+
+ if (devTreeProjects.size() == 1) {
+ return devTreeProjects.get(0);
+ }
+
+ // if there are multiple choices, prompt the user
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return null;
+ }
+
+ ListDialog dlg = new ListDialog(window.getShell());
+ dlg.setMessage("Select Project");
+ dlg.setInput(devTreeProjects);
+ dlg.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return ((List<?>) inputElement).toArray();
+ }
+ });
+ dlg.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((IProject) element).getName();
+ }
+ });
+ dlg.setHelpAvailable(false);
+
+ if (dlg.open() == Window.OK) {
+ Object[] selectedMatches = dlg.getResult();
+ if (selectedMatches.length > 0) {
+ return (IProject) selectedMatches[0];
+ }
+ }
+
+ return null;
+ }
+
+ private boolean hasJavaNature(IProject p) {
+ try {
+ return p.hasNature(JavaCore.NATURE_ID);
+ } catch (CoreException e) {
+ return false;
+ }
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java
new file mode 100644
index 000000000..51011e119
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/SourceRevealer.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.pdt.internal;
+
+import com.android.ide.eclipse.ddms.ISourceRevealer;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.core.search.SearchMatch;
+import org.eclipse.jdt.core.search.SearchParticipant;
+import org.eclipse.jdt.core.search.SearchPattern;
+import org.eclipse.jdt.core.search.SearchRequestor;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.actions.OpenJavaPerspectiveAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPerspectiveRegistry;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Implementation of the com.android.ide.ddms.sourceRevealer extension point.
+ * This implementation is a copy of com.android.ide.eclipse.adt.SourceRevealer.
+ */
+public class SourceRevealer extends DevTreeProjectProvider implements ISourceRevealer {
+
+ @Override
+ public boolean reveal(String applicationName, String className, int line) {
+ IProject project = getProject();
+
+ if (project != null) {
+ // Inner classes are pointless: All we need is the enclosing type to find the file,
+ // and the line number.
+ // Since the anonymous ones will cause IJavaProject#findType to fail, we remove
+ // all of them.
+ int pos = className.indexOf('$');
+ if (pos != -1) {
+ className = className.substring(0, pos);
+ }
+
+ // get the java project
+ IJavaProject javaProject = JavaCore.create(project);
+
+ try {
+ // look for the IType matching the class name.
+ IType result = javaProject.findType(className);
+ if (result != null && result.exists()) {
+ // before we show the type in an editor window, we make sure the current
+ // workbench page has an editor area (typically the ddms perspective doesn't).
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ if (page.isEditorAreaVisible() == false) {
+ // no editor area? we open the java perspective.
+ new OpenJavaPerspectiveAction().run();
+ }
+
+ IEditorPart editor = JavaUI.openInEditor(result);
+ if (editor instanceof ITextEditor) {
+ // get the text editor that was just opened.
+ ITextEditor textEditor = (ITextEditor)editor;
+
+ IEditorInput input = textEditor.getEditorInput();
+
+ // get the location of the line to show.
+ IDocumentProvider documentProvider = textEditor.getDocumentProvider();
+ IDocument document = documentProvider.getDocument(input);
+ IRegion lineInfo = document.getLineInformation(line - 1);
+
+ // select and reveal the line.
+ textEditor.selectAndReveal(lineInfo.getOffset(), lineInfo.getLength());
+ }
+
+ return true;
+ }
+ } catch (JavaModelException e) {
+ } catch (PartInitException e) {
+ } catch (BadLocationException e) {
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean revealMethod(String fqmn, String fileName, int lineNumber, String perspective) {
+ SearchEngine se = new SearchEngine();
+ SearchPattern searchPattern = SearchPattern.createPattern(
+ fqmn,
+ IJavaSearchConstants.METHOD,
+ IJavaSearchConstants.DECLARATIONS,
+ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE);
+ MethodSearchRequestor requestor = new MethodSearchRequestor(perspective);
+ try {
+ se.search(searchPattern,
+ new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
+ SearchEngine.createWorkspaceScope(),
+ requestor,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ return false;
+ }
+
+ return requestor.didMatch();
+ }
+
+ private static class MethodSearchRequestor extends SearchRequestor {
+ private boolean mFoundMatch = false;
+ private final String mPerspective;
+
+ public MethodSearchRequestor(String perspective) {
+ mPerspective = perspective;
+ }
+
+ public boolean didMatch() {
+ return mFoundMatch;
+ }
+
+ @Override
+ public void acceptSearchMatch(SearchMatch match) throws CoreException {
+ Object element = match.getElement();
+ if (element instanceof IMethod && !mFoundMatch) {
+ if (mPerspective != null) {
+ SourceRevealer.switchToPerspective(mPerspective);
+ }
+
+ IMethod method = (IMethod) element;
+ JavaUI.openInEditor(method);
+ mFoundMatch = true;
+ }
+ }
+ }
+
+ public static void switchToPerspective(String perspectiveId) {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ IPerspectiveRegistry perspectiveRegistry = workbench.getPerspectiveRegistry();
+ if (perspectiveId != null
+ && perspectiveId.length() > 0
+ && perspectiveRegistry.findPerspectiveWithId(perspectiveId) != null) {
+ try {
+ workbench.showPerspective(perspectiveId, window);
+ } catch (WorkbenchException e) {
+ // ignore exception, perspective won't be switched
+ }
+ }
+ }
+
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java
new file mode 100644
index 000000000..a7291cbc7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/ToolsLocator.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.pdt.internal;
+
+import com.android.ide.eclipse.ddms.IToolsLocator;
+import com.android.ide.eclipse.pdt.PdtPlugin;
+
+/**
+ * Implementation of the com.android.ide.ddms.adbLocator extension point.
+ */
+public class ToolsLocator implements IToolsLocator {
+
+ @Override
+ public String getAdbLocation() {
+ return PdtPlugin.getAdbLocation();
+ }
+
+ @Override
+ public String getHprofConvLocation() {
+ return PdtPlugin.getHprofConvLocation();
+ }
+
+ @Override
+ public String getTraceViewLocation() {
+ return PdtPlugin.getTraceViewLocation();
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java
new file mode 100644
index 000000000..565b6adbe
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/src/com/android/ide/eclipse/pdt/internal/preferences/PrefPage.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.pdt.internal.preferences;
+
+import com.android.ide.eclipse.pdt.PdtPlugin;
+
+import org.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class PrefPage extends FieldEditorPreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public final static String PREFS_DEVTREE_DIR = PdtPlugin.PLUGIN_ID + ".devtree"; //$NON-NLS-1$
+
+ private DirectoryFieldEditor mDirectoryField;
+
+ public PrefPage() {
+ super(GRID);
+ IPreferenceStore store = PdtPlugin.getDefault().getPreferenceStore();
+ setPreferenceStore(store);
+ setDescription("Android Preferences");
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ mDirectoryField = new DirectoryFieldEditor(PREFS_DEVTREE_DIR,
+ "Dev Tree Location:", getFieldEditorParent());
+
+ addField(mDirectoryField);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+
+ if (mDirectoryField != null) {
+ mDirectoryField.dispose();
+ mDirectoryField = null;
+ }
+ }
+
+}