Rebase NewLTTngProjectWizard on TMF
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / project / handlers / NewProjectHandler.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.ui.views.project.handlers;
14
15 import org.eclipse.core.commands.ExecutionEvent;
16 import org.eclipse.core.commands.ExecutionException;
17 import org.eclipse.core.commands.IHandler;
18 import org.eclipse.core.commands.IHandlerListener;
19 import org.eclipse.core.resources.IProject;
20 import org.eclipse.jface.window.Window;
21 import org.eclipse.jface.wizard.WizardDialog;
22 import org.eclipse.linuxtools.lttng.ui.views.project.ProjectView;
23 import org.eclipse.linuxtools.lttng.ui.views.project.dialogs.NewLTTngProjectWizard;
24 import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProjectRoot;
25 import org.eclipse.swt.widgets.Shell;
26 import org.eclipse.ui.IWorkbenchPart;
27 import org.eclipse.ui.IWorkbenchWindow;
28 import org.eclipse.ui.PlatformUI;
29
30 /**
31 * <b><u>NewProjectHandler</u></b>
32 * <p>
33 * TODO: Implement me. Please.
34 */
35 public class NewProjectHandler implements IHandler {
36
37 private LTTngProjectRoot fProjectRoot = null;
38
39 // ------------------------------------------------------------------------
40 // Validation
41 // ------------------------------------------------------------------------
42
43 @Override
44 public boolean isEnabled() {
45
46 // Check if we are closing down
47 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
48 if (window == null)
49 return false;
50
51 // Check if we are in the Project View
52 IWorkbenchPart part = window.getActivePage().getActivePart();
53 if (!(part instanceof ProjectView))
54 return false;
55
56 fProjectRoot = ((ProjectView) part).getRoot();
57
58 return (fProjectRoot != null);
59 }
60
61 // Always handled
62 @Override
63 public boolean isHandled() {
64 return true;
65 }
66
67 // ------------------------------------------------------------------------
68 // Execution
69 // ------------------------------------------------------------------------
70
71 @Override
72 public Object execute(ExecutionEvent event) throws ExecutionException {
73
74 // Fire the New Project Wizard
75 Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
76 NewLTTngProjectWizard wizard = new NewLTTngProjectWizard();
77 WizardDialog dialog = new WizardDialog(shell, wizard);
78 dialog.open();
79
80 // Update the project model
81 if (dialog.getReturnCode() == Window.OK) {
82 IProject project = wizard.getProject();
83 if (project != null && fProjectRoot != null) {
84 fProjectRoot.refreshChildren();
85 fProjectRoot.refresh();
86 }
87 }
88
89 return null;
90 }
91
92 @Override
93 public void dispose() {
94 // TODO Auto-generated method stub
95 }
96
97 // ------------------------------------------------------------------------
98 // IHandlerListener
99 // ------------------------------------------------------------------------
100
101 @Override
102 public void addHandlerListener(IHandlerListener handlerListener) {
103 // TODO Auto-generated method stub
104 }
105
106 @Override
107 public void removeHandlerListener(IHandlerListener handlerListener) {
108 // TODO Auto-generated method stub
109 }
110
111 }
This page took 0.033647 seconds and 5 git commands to generate.