aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android
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/plugins/com.android.ide.eclipse.ddms/src/com/android
parent48ff0d8b70e56c987ac1de45bbef31dd222d9525 (diff)
downloadsdk-c8596f7a4719c2f6aac3e0aec86676da0cd6bbaa.tar.gz
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/plugins/com.android.ide.eclipse.ddms/src/com/android')
-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
3 files changed, 86 insertions, 9 deletions
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 182f91d2e..298953a73 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 000000000..7542b8838
--- /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 0fa33d293..4ecee926a 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