ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / handlers / NewFolderHandler.java
1 /*******************************************************************************
2 * Copyright (c) 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
14
15 import org.eclipse.core.commands.AbstractHandler;
16 import org.eclipse.core.commands.ExecutionEvent;
17 import org.eclipse.core.commands.ExecutionException;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.jface.viewers.IStructuredSelection;
20 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
21 import org.eclipse.linuxtools.tmf.ui.project.wizards.NewFolderDialog;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.ui.IWorkbenchWindow;
24 import org.eclipse.ui.PlatformUI;
25 import org.eclipse.ui.handlers.HandlerUtil;
26
27 /**
28 * Handler for the New Folder command.
29 */
30 public class NewFolderHandler extends AbstractHandler {
31
32 // ------------------------------------------------------------------------
33 // Execution
34 // ------------------------------------------------------------------------
35
36 @Override
37 public Object execute(ExecutionEvent event) throws ExecutionException {
38
39 // Check if we are closing down
40 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
41 if (window == null) {
42 return null;
43 }
44
45 ISelection selection = HandlerUtil.getCurrentSelection(event);
46 if (!(selection instanceof IStructuredSelection)) {
47 return null;
48 }
49 final Object element = ((IStructuredSelection) selection).getFirstElement();
50 if (!(element instanceof TmfTraceFolder)) {
51 return null;
52 }
53 TmfTraceFolder parent = (TmfTraceFolder) element;
54
55 // Fire the New Folder dialog
56 Shell shell = window.getShell();
57 NewFolderDialog dialog = new NewFolderDialog(shell, parent);
58 dialog.open();
59
60 return null;
61 }
62
63 }
This page took 0.031716 seconds and 5 git commands to generate.