1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 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 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Remove enable check
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.handlers
;
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
.swt
.widgets
.Shell
;
22 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.model
.TmfExperimentElement
;
23 import org
.eclipse
.tracecompass
.tmf
.ui
.project
.wizards
.CopyExperimentDialog
;
24 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
27 * <b><u>CopyExperimentHandler</u></b>
30 public class CopyExperimentHandler
extends AbstractHandler
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 // Get selection already validated by handler in plugin.xml
40 ISelection selection
= HandlerUtil
.getCurrentSelectionChecked(event
);
41 if (!(selection
instanceof IStructuredSelection
)) {
44 TmfExperimentElement experiment
= (TmfExperimentElement
) ((IStructuredSelection
) selection
).getFirstElement();
46 // Fire the Copy Experiment dialog
47 Shell shell
= HandlerUtil
.getActiveShellChecked(event
);
48 CopyExperimentDialog dialog
= new CopyExperimentDialog(shell
, experiment
);