blob: f4a27944b3f71d836386495b425113182b661f58 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
}
}
|