lttng rcp: add tracing rcp "file->open" buttons
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tracing.rcp.ui / src / org / eclipse / linuxtools / internal / tracing / rcp / ui / commands / OpenDirHandler.java
1 /**********************************************************************
2 * Copyright (c) 2013 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 **********************************************************************/
12
13 package org.eclipse.linuxtools.internal.tracing.rcp.ui.commands;
14
15 import org.eclipse.core.commands.AbstractHandler;
16 import org.eclipse.core.commands.ExecutionEvent;
17 import org.eclipse.core.runtime.CoreException;
18 import org.eclipse.linuxtools.internal.tracing.rcp.ui.TracingRcpPlugin;
19 import org.eclipse.linuxtools.internal.tracing.rcp.ui.messages.Messages;
20 import org.eclipse.linuxtools.tmf.ui.project.model.TmfOpenTraceHelper;
21 import org.eclipse.swt.widgets.DirectoryDialog;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.ui.PlatformUI;
24
25 /**
26 * Open a directory, not a file
27 *
28 * @author Matthew Khouzam
29 */
30 public class OpenDirHandler extends AbstractHandler{
31
32 @Override
33 public Object execute(ExecutionEvent event) {
34 // Open a directory
35 final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
36 DirectoryDialog dd = new DirectoryDialog(shell);
37 dd.setText(Messages.OpenDirHandler_SelectTraceType);
38 String dir = dd.open();
39 if (dir == null) {
40 return null;
41 }
42 TmfOpenTraceHelper oth = new TmfOpenTraceHelper();
43 try {
44 oth.openTraceFromPath(Messages.ApplicationWorkbenchWindowAdvisor_DefaultProjectName, dir, shell);
45 } catch (CoreException e) {
46 TracingRcpPlugin.getDefault().logError(e.getMessage(), e);
47 }
48 return null;
49 }
50 }
This page took 0.043995 seconds and 5 git commands to generate.