1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.handlers
;
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
;
31 * <b><u>NewProjectHandler</u></b>
33 * TODO: Implement me. Please.
35 public class NewProjectHandler
implements IHandler
{
37 private LTTngProjectRoot fProjectRoot
= null;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 public boolean isEnabled() {
46 // Check if we are closing down
47 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
51 // Check if we are in the Project View
52 IWorkbenchPart part
= window
.getActivePage().getActivePart();
53 if (!(part
instanceof ProjectView
))
56 fProjectRoot
= ((ProjectView
) part
).getRoot();
58 return (fProjectRoot
!= null);
63 public boolean isHandled() {
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
72 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
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
);
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();
93 public void dispose() {
94 // TODO Auto-generated method stub
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
102 public void addHandlerListener(IHandlerListener handlerListener
) {
103 // TODO Auto-generated method stub
107 public void removeHandlerListener(IHandlerListener handlerListener
) {
108 // TODO Auto-generated method stub