1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.gdbtrace
.ui
.views
.project
.handlers
;
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
;
33 * Handler for the Select Trace Excecutable command
34 * @author Patrick Tasse
36 public class SelectTraceExecutableHandler
extends AbstractHandler
{
39 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
40 Shell shell
= HandlerUtil
.getActiveShell(event
);
41 SelectTraceExecutableDialog dialog
= new SelectTraceExecutableDialog(shell
);
43 if (dialog
.getReturnCode() != Window
.OK
) {
46 IPath tracedExecutable
= dialog
.getExecutablePath();
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();
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());