1 /**********************************************************************
2 * Copyright (c) 2013, 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 * Matthew Khouzam - Initial API and implementation
11 * Patrick Tasse - Add support for folder elements
12 **********************************************************************/
14 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.commands
;
16 import org
.eclipse
.core
.commands
.AbstractHandler
;
17 import org
.eclipse
.core
.commands
.ExecutionEvent
;
18 import org
.eclipse
.core
.runtime
.CoreException
;
19 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfOpenTraceHelper
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceFolder
;
22 import org
.eclipse
.swt
.widgets
.DirectoryDialog
;
23 import org
.eclipse
.swt
.widgets
.Shell
;
24 import org
.eclipse
.ui
.PlatformUI
;
25 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
28 * Open a directory, not a file
30 * @author Matthew Khouzam
32 public class OpenDirHandler
extends AbstractHandler
{
35 public Object
execute(ExecutionEvent event
) {
37 final Shell shell
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell();
38 DirectoryDialog dd
= new DirectoryDialog(shell
);
39 dd
.setText(Messages
.OpenDirHandler_SelectTraceDirectory
);
40 String dirPath
= dd
.open();
41 if (dirPath
== null) {
46 TmfTraceFolder destinationFolder
= TmfHandlerUtil
.getTraceFolderFromSelection(HandlerUtil
.getCurrentSelection(event
));
47 TmfOpenTraceHelper
.openTraceFromPath(destinationFolder
, dirPath
, shell
);
48 } catch (CoreException e
) {
49 Activator
.getDefault().logError(e
.getMessage(), e
);