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

COVERAGE SUMMARY FOR SOURCE FILE [MarkCompletedAction.java]

nameclass, %method, %block, %line, %
MarkCompletedAction.java0%   (0/1)0%   (0/3)0%   (0/100)0%   (0/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MarkCompletedAction0%   (0/1)0%   (0/3)0%   (0/100)0%   (0/27)
MarkCompletedAction (TaskList, String): void 0%   (0/1)0%   (0/10)0%   (0/4)
run (): void 0%   (0/1)0%   (0/60)0%   (0/14)
shouldEnable (IStructuredSelection): boolean 0%   (0/1)0%   (0/30)0%   (0/9)

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 *******************************************************************************/
11 
12package org.eclipse.ui.views.tasklist;
13 
14import java.util.ArrayList;
15import java.util.HashMap;
16import java.util.Iterator;
17import java.util.Map;
18 
19import org.eclipse.core.commands.operations.IUndoableOperation;
20import org.eclipse.core.resources.IMarker;
21import org.eclipse.jface.viewers.ISelection;
22import org.eclipse.jface.viewers.IStructuredSelection;
23import org.eclipse.ui.PlatformUI;
24import org.eclipse.ui.ide.undo.UpdateMarkersOperation;
25 
26class MarkCompletedAction extends TaskAction {
27 
28    /**
29     * Create a MarkCompletedAction.
30     * @param tasklist
31     * @param id
32     */
33    protected MarkCompletedAction(TaskList tasklist, String id) {
34        super(tasklist, id);
35        PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
36                ITaskListHelpContextIds.MARK_COMPLETED_ACTION);
37    }
38 
39    /**
40     * Sets the completed value of the currently selected
41     * actions.
42     */
43    public void run() {
44        ISelection selectedMarkers = getTaskList().getSelection();
45        if (selectedMarkers instanceof IStructuredSelection) {
46            Iterator selections = ((IStructuredSelection) selectedMarkers).iterator();
47            ArrayList markers = new ArrayList();
48            while (selections.hasNext()) {
49                Object marker = selections.next();
50                if (marker instanceof IMarker) {
51                        markers.add(marker);
52                }
53            }
54                    Map attrs = new HashMap();
55                    attrs.put(IMarker.DONE, Boolean.TRUE);
56                    IUndoableOperation op = new UpdateMarkersOperation((IMarker [])markers.toArray(new IMarker [markers.size()]), 
57                                    attrs, getText(), true);
58                    execute(op, getText(), null, null);
59 
60        }
61        
62    }
63 
64    /**
65     * Returns whether this action should be enabled for the given selection.
66     * 
67     * @param selection the selection
68     * @return enablement
69     */
70    public boolean shouldEnable(IStructuredSelection selection) {
71        if (selection.isEmpty()) {
72                        return false;
73                }
74        for (Iterator i = selection.iterator(); i.hasNext();) {
75            IMarker marker = (IMarker) i.next();
76            if (!(MarkerUtil.isMarkerType(marker, IMarker.TASK)
77                    && !MarkerUtil.isComplete(marker) && MarkerUtil
78                    .isEditable(marker))) {
79                return false;
80            }
81        }
82        return true;
83    }
84 
85}

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