use of org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.PathEditorInput in project linuxtools by eclipse.
the class SystemTapScriptLaunchConfigurationTab method getSelectedScriptPath.
private String getSelectedScriptPath() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
// $NON-NLS-1$
String pathString = "";
if (window != null) {
ISelection selection = window.getSelectionService().getSelection();
// Figure out the selected systemtap script
if (selection instanceof TreeSelection) {
Object selectedElement = ((TreeSelection) selection).getFirstElement();
if (selectedElement instanceof IFile) {
IPath path = ((IFile) selectedElement).getLocation();
pathString = path.toOSString();
}
}
// If it is a text selection use the path from the active editor.
if (selection instanceof TextSelection) {
IEditorPart ed = window.getActivePage().getActiveEditor();
if (ed.getEditorInput() instanceof PathEditorInput) {
pathString = ((PathEditorInput) ed.getEditorInput()).getPath().toString();
} else {
pathString = ResourceUtil.getFile(ed.getEditorInput()).getLocation().toString();
}
}
}
if (pathString.endsWith(".stp")) {
// $NON-NLS-1$
return pathString;
}
// $NON-NLS-1$
return "";
}
use of org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.PathEditorInput in project linuxtools by eclipse.
the class SystemTapScriptLaunchShortcut method launch.
@Override
public void launch(IEditorPart editor, String mode) {
String path;
String project = null;
if (editor.getEditorInput() instanceof PathEditorInput) {
path = ((PathEditorInput) editor.getEditorInput()).getPath().toString();
} else {
IFile file = ResourceUtil.getFile(editor.getEditorInput());
path = file.getLocation().toString();
project = file.getProject().getName();
}
this.searchAndLaunch(path, project);
}
Aggregations