1 /*******************************************************************************
2 * Copyright (c) 2013 Kalray
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 * Xavier Raynaud - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
;
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
.jface
.util
.LocalSelectionTransfer
;
19 import org
.eclipse
.jface
.viewers
.ISelection
;
20 import org
.eclipse
.ui
.IWorkbenchPage
;
21 import org
.eclipse
.ui
.IWorkbenchPart
;
22 import org
.eclipse
.ui
.IWorkbenchWindow
;
23 import org
.eclipse
.ui
.PlatformUI
;
26 * Handler for copy command in filter view
27 * @author Xavier Raynaud <xavier.raynaud@kalray.eu>
30 public class CopyHandler
extends AbstractHandler
{
33 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
34 // Check if we are closing down
35 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
39 IWorkbenchPage page
= window
.getActivePage();
40 FilterView part
= (FilterView
) page
.getActivePart();
41 ISelection selection
= getSelection(part
);
43 LocalSelectionTransfer
.getTransfer().setSelection(selection
);
44 LocalSelectionTransfer
.getTransfer().setSelectionSetTime(System
.currentTimeMillis());
49 * Retrieve the current selection
53 * @return the current selection in the FilterView
55 protected ISelection
getSelection(FilterView tcv
) {
56 return tcv
.getViewSite().getSelectionProvider().getSelection();
60 public boolean isEnabled() {
61 // Check if we are closing down
62 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
68 IWorkbenchPage page
= window
.getActivePage();
69 IWorkbenchPart part
= page
.getActivePart();
70 if (part
instanceof FilterView
) {
71 FilterView tcv
= (FilterView
) part
;
72 ISelection selection
= tcv
.getSite().getSelectionProvider().getSelection();
73 if (!selection
.isEmpty()) {
This page took 0.035489 seconds and 6 git commands to generate.