aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins/com.android.ide.eclipse.traceview/src
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.traceview/src
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/plugins/com.android.ide.eclipse.traceview/src')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/src/com/android/ide/eclipse/traceview/TraceviewLauncher.java75
1 files changed, 75 insertions, 0 deletions
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;
+ }
+}