tmf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / handlers / CopyTraceHandler.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 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 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Remove enable check
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
15
16 import org.eclipse.core.commands.AbstractHandler;
17 import org.eclipse.core.commands.ExecutionEvent;
18 import org.eclipse.core.commands.ExecutionException;
19 import org.eclipse.jface.viewers.ISelection;
20 import org.eclipse.jface.viewers.IStructuredSelection;
21 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
22 import org.eclipse.linuxtools.tmf.ui.project.wizards.CopyTraceDialog;
23 import org.eclipse.swt.widgets.Shell;
24 import org.eclipse.ui.handlers.HandlerUtil;
25
26 /**
27 * <b><u>CopyTraceHandler</u></b>
28 * <p>
29 */
30 public class CopyTraceHandler extends AbstractHandler {
31
32 // ------------------------------------------------------------------------
33 // Execution
34 // ------------------------------------------------------------------------
35
36 @Override
37 public Object execute(ExecutionEvent event) throws ExecutionException {
38
39 // Get selection already validated by handler in plugin.xml
40 ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
41 if (!(selection instanceof IStructuredSelection)) {
42 return null;
43 }
44 TmfTraceElement trace = (TmfTraceElement) ((IStructuredSelection) selection).getFirstElement();
45
46 // Fire the Copy Trace dialog
47 Shell shell = HandlerUtil.getActiveShellChecked(event);
48 CopyTraceDialog dialog = new CopyTraceDialog(shell, trace);
49 dialog.open();
50
51 return null;
52 }
53
54 }
This page took 0.034148 seconds and 5 git commands to generate.