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

COVERAGE SUMMARY FOR SOURCE FILE [ResourceNavigatorRenameAction.java]

nameclass, %method, %block, %line, %
ResourceNavigatorRenameAction.java100% (1/1)33%  (1/3)26%  (14/54)31%  (5/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceNavigatorRenameAction100% (1/1)33%  (1/3)26%  (14/54)31%  (5/16)
handleKeyReleased (KeyEvent): void 0%   (0/1)0%   (0/13)0%   (0/3)
runWithNewPath (IPath, IResource): void 0%   (0/1)0%   (0/27)0%   (0/8)
ResourceNavigatorRenameAction (Shell, TreeViewer): void 100% (1/1)100% (14/14)100% (5/5)

1/*******************************************************************************
2 * Copyright (c) 2000, 2007 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.IResource;
14import org.eclipse.core.resources.IWorkspaceRoot;
15import org.eclipse.core.runtime.IPath;
16import org.eclipse.jface.viewers.StructuredSelection;
17import org.eclipse.jface.viewers.TreeViewer;
18import org.eclipse.swt.SWT;
19import org.eclipse.swt.events.KeyEvent;
20import org.eclipse.swt.widgets.Shell;
21import org.eclipse.ui.PlatformUI;
22import org.eclipse.ui.actions.RenameResourceAction;
23 
24/**
25 * The ResourceNavigatorRenameAction is the rename action used by the
26 * ResourceNavigator that also allows updating after rename.
27 * @since 2.0
28 */
29public class ResourceNavigatorRenameAction extends RenameResourceAction {
30    private TreeViewer viewer;
31 
32    /**
33     * Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
34     * for editing.
35     * @param shell Shell
36     * @param treeViewer TreeViewer
37     */
38    public ResourceNavigatorRenameAction(Shell shell, TreeViewer treeViewer) {
39        super(shell, treeViewer.getTree());
40        PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
41                INavigatorHelpContextIds.RESOURCE_NAVIGATOR_RENAME_ACTION);
42        this.viewer = treeViewer;
43    }
44 
45    /* (non-Javadoc)
46     * Run the action to completion using the supplied path.
47     */
48    protected void runWithNewPath(IPath path, IResource resource) {
49        IWorkspaceRoot root = resource.getProject().getWorkspace().getRoot();
50        super.runWithNewPath(path, resource);
51        if (this.viewer != null) {
52            IResource newResource = root.findMember(path);
53            if (newResource != null) {
54                                this.viewer.setSelection(new StructuredSelection(newResource),
55                        true);
56                        }
57        }
58    }
59 
60    /**
61     * Handle the key release
62     */
63    public void handleKeyReleased(KeyEvent event) {
64        if (event.keyCode == SWT.F2 && event.stateMask == 0 && isEnabled()) {
65            run();
66        }
67    }
68}

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