Introduce GDB Tracepoint Analysis feature
[deliverable/tracecompass.git] / org.eclipse.linuxtools.gdbtrace.ui / src / org / eclipse / linuxtools / internal / gdbtrace / ui / views / project / handlers / SelectTraceExecutableHandler.java
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.gdbtrace.ui.views.project.handlers;
14
15 import org.eclipse.core.commands.AbstractHandler;
16 import org.eclipse.core.commands.ExecutionEvent;
17 import org.eclipse.core.commands.ExecutionException;
18 import org.eclipse.core.resources.IResource;
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.core.runtime.IPath;
21 import org.eclipse.jface.viewers.ISelection;
22 import org.eclipse.jface.viewers.IStructuredSelection;
23 import org.eclipse.jface.window.Window;
24 import org.eclipse.linuxtools.internal.gdbtrace.trace.GdbTrace;
25 import org.eclipse.linuxtools.internal.gdbtrace.ui.views.project.dialogs.SelectTraceExecutableDialog;
26 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
27 import org.eclipse.swt.widgets.MessageBox;
28 import org.eclipse.swt.widgets.Shell;
29 import org.eclipse.ui.PlatformUI;
30 import org.eclipse.ui.handlers.HandlerUtil;
31
32 /**
33 * Handler for the Select Trace Excecutable command
34 * @author Patrick Tasse
35 */
36 public class SelectTraceExecutableHandler extends AbstractHandler {
37
38 @Override
39 public Object execute(ExecutionEvent event) throws ExecutionException {
40 Shell shell = HandlerUtil.getActiveShell(event);
41 SelectTraceExecutableDialog dialog = new SelectTraceExecutableDialog(shell);
42 dialog.open();
43 if (dialog.getReturnCode() != Window.OK) {
44 return null;
45 }
46 IPath tracedExecutable = dialog.getExecutablePath();
47
48 ISelection selection = HandlerUtil.getCurrentSelection(event);
49 if (selection instanceof IStructuredSelection) {
50 for (Object o : ((IStructuredSelection) selection).toList()) {
51 TmfTraceElement traceElement = (TmfTraceElement) o;
52 IResource resource = traceElement.getResource();
53 try {
54 resource.setPersistentProperty(GdbTrace.EXEC_KEY, tracedExecutable.toString());
55 } catch (CoreException e) {
56 final MessageBox mb = new MessageBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
57 mb.setText(e.getClass().getName());
58 mb.setMessage(e.getMessage());
59 mb.open();
60 }
61 }
62 }
63 return null;
64 }
65
66 }
This page took 0.035611 seconds and 6 git commands to generate.