aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-02-01 17:21:26 -0800
committerXavier Ducrohet <xav@android.com>2011-02-01 17:31:54 -0800
commitc8596f7a4719c2f6aac3e0aec86676da0cd6bbaa (patch)
treec024e2bd8ebdb82d3c63a14f1058104fe01de51d /eclipse
parent48ff0d8b70e56c987ac1de45bbef31dd222d9525 (diff)
downloadsdk-c8596f7a4719c2f6aac3e0aec86676da0cd6bbaa.zip
sdk-c8596f7a4719c2f6aac3e0aec86676da0cd6bbaa.tar.gz
sdk-c8596f7a4719c2f6aac3e0aec86676da0cd6bbaa.tar.bz2
Let the Traceview plug-in open the trace file created through DDMS.
New DDMS extension: traceviewLauncher. This allows another plug-in (traceview) to provide a way to open traceview file. If this doesn't work it revert to the default behavior of DDMS which is to open the external traceview program. also reverted the extension of traceview file from .atv to .trace because earlier versions of Android would automatically create those files using this extension. Change-Id: I2605ad47e501770ae100da2ace781b1d5d8cebc5
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/schema/traceviewLauncher.exsd100
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java52
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/ITraceviewLauncher.java25
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java18
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/plugin.xml8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/src/com/android/ide/eclipse/traceview/TraceviewLauncher.java75
-rw-r--r--eclipse/sites/internal/site.xml1
9 files changed, 274 insertions, 11 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml
index 02d570e..9bc5a0c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml
@@ -4,6 +4,7 @@
<extension-point id="toolsLocator" name="Tools Locator" schema="schema/toolsLocator.exsd"/>
<extension-point id="debuggerConnector" name="Debugger Connector" schema="schema/debuggerConnector.exsd"/>
<extension-point id="sourceRevealer" name="Source Revealer" schema="schema/sourceRevealer.exsd"/>
+ <extension-point id="traceviewLauncher" name="TraceView Launcher" schema="schema/traceviewLauncher.exsd"/>
<extension
point="org.eclipse.ui.views">
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/traceviewLauncher.exsd b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/traceviewLauncher.exsd
new file mode 100644
index 0000000..daca83a
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/traceviewLauncher.exsd
@@ -0,0 +1,100 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.android.ide.eclipse.ddms" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="com.android.ide.eclipse.ddms" id="traceviewLauncher" name="Traceview Launcher"/>
+ </appInfo>
+ <documentation>
+ Extension Point to launch Traceview.
+ </documentation>
+ </annotation>
+
+ <element name="launcher">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":com.android.ide.eclipse.ddms.ITraceviewLauncher"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="launcher"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 10.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;extension point=&quot;com.android.ide.eclipse.ddms.traceviewLauncher&quot;&gt;
+ &lt;launcher class=&quot;com.android.ide.eclipse.adt.Launcher&quot;/&gt;
+&lt;/extension&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ The class must implement com.android.ide.ddms.ITraceviewLauncher.
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (C) 2011 The Android Open Source Project
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
index 182f91d..298953a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
@@ -82,6 +82,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
*/
private IDebuggerConnector[] mDebuggerConnectors;
private ISourceRevealer[] mSourceRevealers;
+ private ITraceviewLauncher[] mTraceviewLaunchers;
/** Console for DDMS log message */
@@ -253,6 +254,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
// get the other configElements and instantiante them in a Job.
new Job("DDMS post-create init") {
+
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
@@ -295,6 +297,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
elements = findConfigElements("com.android.ide.eclipse.ddms.sourceRevealer"); //$NON-NLS-1$
mSourceRevealers = instantiateSourceRevealers(elements);
+ // get the available Traceview Launchers.
+ elements = findConfigElements("com.android.ide.eclipse.ddms.traceviewLauncher"); //$NON-NLS-1$
+ mTraceviewLaunchers = instantiateTraceviewLauncher(elements);
+
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
@@ -329,7 +335,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
// only use the first one, ignore the others.
IConfigurationElement configElement = configElements[0];
- // instantiate the clas
+ // instantiate the class
Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$
if (obj instanceof IToolsLocator) {
list.add((IToolsLocator) obj);
@@ -352,7 +358,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
// only use the first one, ignore the others.
IConfigurationElement configElement = configElements[0];
- // instantiate the clas
+ // instantiate the class
Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$
if (obj instanceof IDebuggerConnector) {
list.add((IDebuggerConnector) obj);
@@ -375,7 +381,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
// only use the first one, ignore the others.
IConfigurationElement configElement = configElements[0];
- // instantiate the clas
+ // instantiate the class
Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$
if (obj instanceof ISourceRevealer) {
list.add((ISourceRevealer) obj);
@@ -385,6 +391,30 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
return list.toArray(new ISourceRevealer[list.size()]);
}
+ /**
+ * Finds if any other plug-in is extending the exposed Extension Point called traceviewLauncher.
+ *
+ * @return an array of all locators found, or an empty array if none were found.
+ */
+ private ITraceviewLauncher[] instantiateTraceviewLauncher(
+ IConfigurationElement[] configElements)
+ throws CoreException {
+ ArrayList<ITraceviewLauncher> list = new ArrayList<ITraceviewLauncher>();
+
+ if (configElements.length > 0) {
+ // only use the first one, ignore the others.
+ IConfigurationElement configElement = configElements[0];
+
+ // instantiate the class
+ Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$
+ if (obj instanceof ITraceviewLauncher) {
+ list.add((ITraceviewLauncher) obj);
+ }
+ }
+
+ return list.toArray(new ITraceviewLauncher[list.size()]);
+ }
+
public static Display getDisplay() {
IWorkbench bench = sPlugin.getWorkbench();
if (bench != null) {
@@ -733,4 +763,20 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
}
}
}
+
+ public boolean launchTraceview(String osPath) {
+ if (mTraceviewLaunchers != null) {
+ for (ITraceviewLauncher launcher : mTraceviewLaunchers) {
+ try {
+ if (launcher.openFile(osPath)) {
+ return true;
+ }
+ } catch (Throwable t) {
+ // ignore, we'll just not use this implementation.
+ }
+ }
+ }
+
+ return false;
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/ITraceviewLauncher.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/ITraceviewLauncher.java
new file mode 100644
index 0000000..7542b88
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/ITraceviewLauncher.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2011 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.ddms;
+
+/**
+ * Classes which implement this interface provides a way to open a traceview file.
+ */
+public interface ITraceviewLauncher {
+
+ boolean openFile(String osPath);
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
index 0fa33d2..4ecee92 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
@@ -201,7 +201,9 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
if (ACTION_OPEN.equals(value)) {
try {
- File tempFile = saveTempFile(data);
+ // no need to give an extension since we're going to convert the
+ // file anyway after.
+ File tempFile = saveTempFile(data, null /*extension*/);
open(tempFile.getAbsolutePath());
} catch (Exception e) {
String errorMsg = e.getMessage();
@@ -252,14 +254,11 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
}
}
- IDE.openEditorOnFileStore(
- getSite().getWorkbenchWindow().getActivePage(),
- fileStore);
+ IDE.openEditorOnFileStore(page, fileStore);
}
}
}
-
public DeviceView() {
// the view is declared with allowMultiple="false" so we
// can safely do this.
@@ -455,7 +454,14 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
ClientData.setHprofDumpHandler(new HProfHandler(mParentShell));
AndroidDebugBridge.addClientChangeListener(this);
- ClientData.setMethodProfilingHandler(new MethodProfilingHandler(mParentShell));
+ ClientData.setMethodProfilingHandler(new MethodProfilingHandler(mParentShell) {
+ @Override
+ protected void open(String tempPath) {
+ if (DdmsPlugin.getDefault().launchTraceview(tempPath) == false) {
+ super.open(tempPath);
+ }
+ }
+ });
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF
index 0459a07..623076a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF
@@ -6,7 +6,10 @@ Bundle-Version: 10.0.0.qualifier
Bundle-Activator: com.android.ide.eclipse.traceview.TraceviewPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.ui.ide
+ org.eclipse.ui.ide,
+ com.android.ide.eclipse.ddms;bundle-version="10.0.0",
+ org.eclipse.core.filesystem,
+ org.eclipse.core.resources
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
libs/traceview.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.traceview/plugin.xml
index a6ab5d4..042a630 100644
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/plugin.xml
@@ -6,11 +6,17 @@
<editor
class="com.android.ide.eclipse.traceview.editors.TraceviewEditor"
default="true"
- extensions="atv"
+ extensions="trace"
icon="icons/android.png"
id="com.android.ide.eclipse.traceview.editors.TraceviewEditor"
name="Traceview">
</editor>
</extension>
+ <extension
+ point="com.android.ide.eclipse.ddms.traceviewLauncher">
+ <launcher
+ class="com.android.ide.eclipse.traceview.TraceviewLauncher">
+ </launcher>
+ </extension>
</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/src/com/android/ide/eclipse/traceview/TraceviewLauncher.java b/eclipse/plugins/com.android.ide.eclipse.traceview/src/com/android/ide/eclipse/traceview/TraceviewLauncher.java
new file mode 100644
index 0000000..502084f
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/src/com/android/ide/eclipse/traceview/TraceviewLauncher.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 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.traceview;
+
+import com.android.ide.eclipse.ddms.ITraceviewLauncher;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.widgets.Display;
+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.ide.IDE;
+
+public class TraceviewLauncher implements ITraceviewLauncher {
+
+ public boolean openFile(String osPath) {
+ final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(osPath));
+ if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
+ // before we open the file in an editor window, we make sure the current
+ // workbench page has an editor area (typically the ddms perspective doesn't).
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ Display display = workbench.getDisplay();
+ final boolean[] result = new boolean[] { false };
+ display.syncExec(new Runnable() {
+ public void run() {
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ if (page.isEditorAreaVisible() == false) {
+ IAdaptable input;
+ if (page != null)
+ input= page.getInput();
+ else
+ input= ResourcesPlugin.getWorkspace().getRoot();
+ try {
+ workbench.showPerspective("org.eclipse.debug.ui.DebugPerspective",
+ window, input);
+ } catch (WorkbenchException e) {
+ }
+ }
+
+ try {
+ result[0] = IDE.openEditorOnFileStore(page, fileStore) != null;
+ } catch (PartInitException e) {
+ // return false below
+ }
+ }
+ });
+
+ return result[0];
+ }
+
+ return false;
+ }
+}
diff --git a/eclipse/sites/internal/site.xml b/eclipse/sites/internal/site.xml
index afdccb2..40abd3b 100644
--- a/eclipse/sites/internal/site.xml
+++ b/eclipse/sites/internal/site.xml
@@ -21,6 +21,7 @@
<category name="platform"/>
</feature>
<feature url="features/com.android.ide.eclipse.traceview_10.0.0.qualifier.jar" id="com.android.ide.eclipse.traceview" version="10.0.0.qualifier">
+ <category name="developer"/>
<category name="platform"/>
</feature>
<category-def name="developer" label="Application Developer Tools">