1 /**********************************************************************
2 * Copyright (c) 2013 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 **********************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tracing
.rcp
.ui
.commands
;
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
.FileDialog
;
22 import org
.eclipse
.swt
.widgets
.Shell
;
23 import org
.eclipse
.ui
.PlatformUI
;
26 * Open file handler, used to open files (not directories)
28 * @author Matthew Khouzam
30 public class OpenFileHandler
extends AbstractHandler
{
33 public Object
execute(ExecutionEvent event
) {
34 final Shell shell
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell();
35 FileDialog fd
= new FileDialog(shell
);
36 fd
.setText(Messages
.OpenFileHandler_SelectTraceFile
);
37 String filePath
= fd
.open();
38 if (filePath
== null) {
41 TmfOpenTraceHelper oth
= new TmfOpenTraceHelper();
43 oth
.openTraceFromPath(Messages
.ApplicationWorkbenchWindowAdvisor_DefaultProjectName
,filePath
, shell
);
44 } catch (CoreException e
) {
45 TracingRcpPlugin
.getDefault().logError(e
.getMessage(), e
);