tmf: Copy ResourceTreeAndListGroup from platform to keep compatibility
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / commands / OpenDirHandler.java
1 /**********************************************************************
2 * Copyright (c) 2013, 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 * Matthew Khouzam - Initial API and implementation
11 * Patrick Tasse - Add support for folder elements
12 **********************************************************************/
13
14 package org.eclipse.linuxtools.internal.tmf.ui.commands;
15
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;
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);
39 dd.setText(Messages.OpenDirHandler_SelectTraceDirectory);
40 String dirPath = dd.open();
41 if (dirPath == null) {
42 return null;
43 }
44
45 try {
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);
50 }
51 return null;
52 }
53 }
This page took 0.031066 seconds and 5 git commands to generate.