diff options
author | Camilo Bernal | 2012-05-30 13:50:57 +0000 |
---|---|---|
committer | Roland Grunberg | 2012-05-30 15:31:41 +0000 |
commit | 6593e16b8c5ef4774a6327fea867ac9fd0af1fc0 (patch) | |
tree | 460c7cb5cbb04c2fbd5c9a9e158fca3bf3093e8e /perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java | |
parent | ac4b8afc97ae388362c7af0daab791f6c55c506b (diff) | |
download | org.eclipse.linuxtools-6593e16b8c5ef4774a6327fea867ac9fd0af1fc0.tar.gz org.eclipse.linuxtools-6593e16b8c5ef4774a6327fea867ac9fd0af1fc0.tar.xz org.eclipse.linuxtools-6593e16b8c5ef4774a6327fea867ac9fd0af1fc0.zip |
Added ability to open perf data files in the Perf Viewer.
In the plug-in.xml file, an editor extension point is included in order
to add a launcher (PerfOpenData.java) for perf data files. In order to
properly report on the the perf file a configuration is needed. This
is done in the createDefaultConfiguration (PerfOpenData.java), which
creates a new default configuration based on the project's name.
In PerfCore.java, it is not necesssary to differentiate between default
events and multiple events, so now events are collected without having
to check this.
Changes were made to the current tests (ModelTest.java) to reflect the
new change, which specifies what the "Default Event" is, namely "cycles".
Diffstat (limited to 'perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java')
-rw-r--r-- | perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java new file mode 100644 index 0000000000..f4a27944b3 --- /dev/null +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfOpenData.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2012 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Camilo Bernal <cabernal@redhat.com> - Initial Implementation. + *******************************************************************************/ +package org.eclipse.linuxtools.internal.perf.launch; + +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.linuxtools.internal.perf.PerfCore; +import org.eclipse.linuxtools.internal.perf.PerfPlugin; +import org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut; +import org.eclipse.ui.IEditorLauncher; + +public class PerfOpenData extends ProfileLaunchShortcut implements + IEditorLauncher { + + @Override + public void open(IPath file) { + + // get project name of where the file resides. + String projectName = ResourcesPlugin.getWorkspace().getRoot() + .getFileForLocation(file).getProject().getName(); + ILaunchConfiguration config = createDefaultConfiguration(projectName); + PerfCore.Report(config, null, null, null, file.toOSString(), null); + } + + @Override + protected ILaunchConfigurationType getLaunchConfigType() { + return getLaunchManager().getLaunchConfigurationType( + PerfPlugin.LAUNCHCONF_ID); + } + + @Override + protected void setDefaultProfileAttributes( + ILaunchConfigurationWorkingCopy wc) throws CoreException { + wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false); + wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true); + } + + /** + * Create an ILaunchConfiguration instance given the project's name. + * + * @param projectName + * @return ILaunchConfiguration based on String projectName + */ + protected ILaunchConfiguration createDefaultConfiguration(String projectName) { + ILaunchConfiguration config = null; + try { + ILaunchConfigurationType configType = getLaunchConfigType(); + ILaunchConfigurationWorkingCopy wc = configType.newInstance( + null, + getLaunchManager().generateLaunchConfigurationName( + projectName)); + config = (ILaunchConfiguration) wc; + + } catch (CoreException e) { + e.printStackTrace(); + } + return config; + } +}
\ No newline at end of file |