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
.tmf
.ui
.views
.project
.handlers
;
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
.StructuredSelection
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.project
.ProjectView
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.project
.model
.TmfProjectNode
;
22 import org
.eclipse
.ui
.IWorkbenchPage
;
23 import org
.eclipse
.ui
.IWorkbenchWindow
;
24 import org
.eclipse
.ui
.PlatformUI
;
27 * <b><u>CloseProjectHandler</u></b>
29 * TODO: Implement me. Please.
31 public class CloseProjectHandler
extends AbstractHandler
{
33 private TmfProjectNode fProject
= null;
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 public boolean isEnabled() {
42 // Check if we are closing down
43 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
47 // Check if we are in the Project View
48 IWorkbenchPage page
= window
.getActivePage();
49 if (page
== null || !(page
.getActivePart() instanceof ProjectView
))
52 // Check if a project is selected
53 ISelection selection
= page
.getSelection(ProjectView
.ID
);
54 if (selection
instanceof StructuredSelection
) {
55 Object element
= ((StructuredSelection
) selection
).getFirstElement();
56 fProject
= (element
instanceof TmfProjectNode
) ?
(TmfProjectNode
) element
: null;
58 return (fProject
!= null && fProject
.isOpen());
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
66 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
68 if (fProject
!= null) {
69 fProject
.closeProject();
This page took 0.03127 seconds and 5 git commands to generate.