EMMA Coverage Report (generated Mon Sep 29 15:05:28 EDT 2008)
[all classes][org.eclipse.ui.views.navigator]

COVERAGE SUMMARY FOR SOURCE FILE [GotoActionGroup.java]

nameclass, %method, %block, %line, %
GotoActionGroup.java100% (1/1)80%  (4/5)74%  (118/159)71%  (37/52)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GotoActionGroup100% (1/1)80%  (4/5)74%  (118/159)71%  (37/52)
fillContextMenu (IMenuManager): void 0%   (0/1)0%   (0/39)0%   (0/14)
updateActionBars (): void 100% (1/1)94%  (34/36)92%  (12/13)
GotoActionGroup (IResourceNavigator): void 100% (1/1)100% (4/4)100% (2/2)
fillActionBars (IActionBars): void 100% (1/1)100% (43/43)100% (15/15)
makeActions (): void 100% (1/1)100% (37/37)100% (8/8)

1/*******************************************************************************
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.ui.views.navigator;
12 
13import org.eclipse.core.resources.IFolder;
14import org.eclipse.core.resources.IProject;
15import org.eclipse.core.resources.IResource;
16import org.eclipse.jface.action.IMenuManager;
17import org.eclipse.jface.action.IToolBarManager;
18import org.eclipse.jface.viewers.IStructuredSelection;
19import org.eclipse.ui.IActionBars;
20import org.eclipse.ui.IWorkbenchActionConstants;
21import org.eclipse.ui.actions.ActionContext;
22import org.eclipse.ui.actions.ActionFactory;
23import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
24import org.eclipse.ui.views.framelist.BackAction;
25import org.eclipse.ui.views.framelist.ForwardAction;
26import org.eclipse.ui.views.framelist.FrameList;
27import org.eclipse.ui.views.framelist.GoIntoAction;
28import org.eclipse.ui.views.framelist.UpAction;
29 
30/**
31 * This is the action group for the goto actions.
32 */
33public class GotoActionGroup extends ResourceNavigatorActionGroup {
34 
35    private BackAction backAction;
36 
37    private ForwardAction forwardAction;
38 
39    private GoIntoAction goIntoAction;
40 
41    private UpAction upAction;
42 
43    private GotoResourceAction goToResourceAction;
44 
45    public GotoActionGroup(IResourceNavigator navigator) {
46        super(navigator);
47    }
48 
49    public void fillContextMenu(IMenuManager menu) {
50        IStructuredSelection selection = (IStructuredSelection) getContext()
51                .getSelection();
52        if (selection.size() == 1) {
53            if (ResourceSelectionUtil.allResourcesAreOfType(selection,
54                    IResource.FOLDER)) {
55                menu.add(goIntoAction);
56            } else {
57                IStructuredSelection resourceSelection = ResourceSelectionUtil
58                        .allResources(selection, IResource.PROJECT);
59                if (resourceSelection != null && !resourceSelection.isEmpty()) {
60                    IProject project = (IProject) resourceSelection
61                            .getFirstElement();
62                    if (project.isOpen()) {
63                                                menu.add(goIntoAction);
64                                        }
65                }
66            }
67        }
68    }
69 
70    public void fillActionBars(IActionBars actionBars) {
71        actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO,
72                goIntoAction);
73        actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(),
74                backAction);
75        actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(),
76                forwardAction);
77        actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP,
78                upAction);
79        actionBars.setGlobalActionHandler(
80                IWorkbenchActionConstants.GO_TO_RESOURCE, goToResourceAction);
81 
82        IToolBarManager toolBar = actionBars.getToolBarManager();
83        toolBar.add(backAction);
84        toolBar.add(forwardAction);
85        toolBar.add(upAction);
86    }
87 
88    protected void makeActions() {
89        FrameList frameList = navigator.getFrameList();
90        goIntoAction = new GoIntoAction(frameList);
91        backAction = new BackAction(frameList);
92        forwardAction = new ForwardAction(frameList);
93        upAction = new UpAction(frameList);
94        goToResourceAction = new GotoResourceAction(navigator,
95                ResourceNavigatorMessages.GoToResource_label);
96    }
97 
98    public void updateActionBars() {
99        ActionContext context = getContext();
100        boolean enable = false;
101 
102        // Fix for bug 26126. Resource change listener could call
103        // updateActionBars without a context being set.
104        // This should never happen because resource navigator sets
105        // context immediately after this group is created.
106        if (context != null) {
107            IStructuredSelection selection = (IStructuredSelection) context
108                    .getSelection();
109 
110            if (selection.size() == 1) {
111                Object object = selection.getFirstElement();
112                if (object instanceof IProject) {
113                    enable = ((IProject) object).isOpen();
114                } else if (object instanceof IFolder) {
115                    enable = true;
116                }
117            }
118        }
119        goIntoAction.setEnabled(enable);
120        // the rest of the actions update by listening to frame list changes
121    }
122}

[all classes][org.eclipse.ui.views.navigator]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov