analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / internal / tmf / ui / project / handlers / NewFolderHandler.java
CommitLineData
339d539c
PT
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
2bdf0193 13package org.eclipse.tracecompass.internal.tmf.ui.project.handlers;
339d539c
PT
14
15import org.eclipse.core.commands.AbstractHandler;
16import org.eclipse.core.commands.ExecutionEvent;
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.jface.viewers.ISelection;
19import org.eclipse.jface.viewers.IStructuredSelection;
339d539c 20import org.eclipse.swt.widgets.Shell;
2bdf0193
AM
21import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
22import org.eclipse.tracecompass.tmf.ui.project.wizards.NewFolderDialog;
339d539c
PT
23import org.eclipse.ui.IWorkbenchWindow;
24import org.eclipse.ui.PlatformUI;
25import org.eclipse.ui.handlers.HandlerUtil;
26
27/**
28 * Handler for the New Folder command.
29 */
30public 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.055248 seconds and 5 git commands to generate.