Commit | Line | Data |
---|---|---|
76fccfb0 | 1 | /********************************************************************** |
977ca87f | 2 | * Copyright (c) 2013, 2014 Ericsson |
76fccfb0 MK |
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 | * Matthew Khouzam - Initial API and implementation | |
977ca87f | 11 | * Patrick Tasse - Add support for folder elements |
76fccfb0 MK |
12 | **********************************************************************/ |
13 | ||
c0c7c656 | 14 | package org.eclipse.linuxtools.internal.tmf.ui.commands; |
76fccfb0 MK |
15 | |
16 | import org.eclipse.core.commands.AbstractHandler; | |
17 | import org.eclipse.core.commands.ExecutionEvent; | |
18 | import org.eclipse.core.runtime.CoreException; | |
c0c7c656 | 19 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
76fccfb0 | 20 | import org.eclipse.linuxtools.tmf.ui.project.model.TmfOpenTraceHelper; |
977ca87f | 21 | import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder; |
76fccfb0 MK |
22 | import org.eclipse.swt.widgets.DirectoryDialog; |
23 | import org.eclipse.swt.widgets.Shell; | |
24 | import org.eclipse.ui.PlatformUI; | |
c0c7c656 | 25 | import org.eclipse.ui.handlers.HandlerUtil; |
76fccfb0 MK |
26 | |
27 | /** | |
28 | * Open a directory, not a file | |
29 | * | |
30 | * @author Matthew Khouzam | |
31 | */ | |
32 | public class OpenDirHandler extends AbstractHandler{ | |
33 | ||
34 | @Override | |
35 | public Object execute(ExecutionEvent event) { | |
36 | // Open a directory | |
37 | final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); | |
38 | DirectoryDialog dd = new DirectoryDialog(shell); | |
c0c7c656 | 39 | dd.setText(Messages.OpenDirHandler_SelectTraceDirectory); |
977ca87f PT |
40 | String dirPath = dd.open(); |
41 | if (dirPath == null) { | |
76fccfb0 MK |
42 | return null; |
43 | } | |
34c8c664 | 44 | |
977ca87f PT |
45 | try { |
46 | TmfTraceFolder destinationFolder = TmfHandlerUtil.getTraceFolderFromSelection(HandlerUtil.getCurrentSelection(event)); | |
47 | TmfOpenTraceHelper.openTraceFromPath(destinationFolder, dirPath, shell); | |
76fccfb0 | 48 | } catch (CoreException e) { |
c0c7c656 | 49 | Activator.getDefault().logError(e.getMessage(), e); |
76fccfb0 MK |
50 | } |
51 | return null; | |
52 | } | |
53 | } |