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

COVERAGE SUMMARY FOR SOURCE FILE [SelectWorkingSetsAction.java]

nameclass, %method, %block, %line, %
SelectWorkingSetsAction.java0%   (0/4)0%   (0/11)0%   (0/212)0%   (0/55)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ConfigureWindowWorkingSetsDialog0%   (0/1)0%   (0/2)0%   (0/28)0%   (0/8)
ConfigureWindowWorkingSetsDialog (IWorkbenchWindow): void 0%   (0/1)0%   (0/19)0%   (0/5)
okPressed (): void 0%   (0/1)0%   (0/9)0%   (0/3)
     
class SelectWorkingSetsAction0%   (0/1)0%   (0/5)0%   (0/100)0%   (0/25)
SelectWorkingSetsAction (): void 0%   (0/1)0%   (0/3)0%   (0/1)
fillMenu (Menu): void 0%   (0/1)0%   (0/61)0%   (0/14)
getEnabledSets (): IWorkingSet [] 0%   (0/1)0%   (0/5)0%   (0/1)
isWorkingSetEnabled (IWorkingSet): boolean 0%   (0/1)0%   (0/21)0%   (0/5)
run (IAction): void 0%   (0/1)0%   (0/10)0%   (0/4)
     
class SelectWorkingSetsAction$ManageWorkingSetsAction0%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
SelectWorkingSetsAction$ManageWorkingSetsAction (SelectWorkingSetsAction): void 0%   (0/1)0%   (0/7)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class SelectWorkingSetsAction$ToggleWorkingSetAction0%   (0/1)0%   (0/2)0%   (0/72)0%   (0/18)
SelectWorkingSetsAction$ToggleWorkingSetAction (SelectWorkingSetsAction, IWor... 0%   (0/1)0%   (0/21)0%   (0/5)
runWithEvent (Event): void 0%   (0/1)0%   (0/51)0%   (0/13)

1/*******************************************************************************
2 * Copyright (c) 2005, 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.internal.actions;
12 
13import java.util.Arrays;
14import java.util.HashSet;
15import java.util.Set;
16 
17import org.eclipse.jface.action.Action;
18import org.eclipse.jface.action.ActionContributionItem;
19import org.eclipse.jface.action.IAction;
20import org.eclipse.jface.action.Separator;
21import org.eclipse.jface.bindings.keys.IKeyLookup;
22import org.eclipse.jface.bindings.keys.KeyLookupFactory;
23import org.eclipse.jface.window.Window;
24import org.eclipse.swt.widgets.Event;
25import org.eclipse.swt.widgets.Menu;
26import org.eclipse.ui.IWorkbenchWindow;
27import org.eclipse.ui.IWorkingSet;
28import org.eclipse.ui.internal.WorkbenchMessages;
29import org.eclipse.ui.internal.dialogs.SimpleWorkingSetSelectionDialog;
30 
31/**
32 * Action to select the visible working sets for a given workbench page.
33 * 
34 * @since 3.2
35 */
36public class SelectWorkingSetsAction extends AbstractWorkingSetPulldownDelegate  {
37 
38        private class ManageWorkingSetsAction extends Action {
39 
40                ManageWorkingSetsAction() {
41                        super(WorkbenchMessages.Edit);
42                }
43 
44                public void run() {
45                        SelectWorkingSetsAction.this.run(this);
46                }
47        }
48 
49        private class ToggleWorkingSetAction extends Action {
50                private IWorkingSet set;
51 
52                ToggleWorkingSetAction(IWorkingSet set) {
53                        super(set.getLabel(), IAction.AS_CHECK_BOX);
54                        setImageDescriptor(set.getImageDescriptor());
55                        this.set = set;
56                        setChecked(isWorkingSetEnabled(set));
57                }
58 
59                public void runWithEvent(Event event) {
60                        
61                        Set newList = new HashSet(Arrays.asList(getWindow().getActivePage()
62                                        .getWorkingSets()));
63 
64                        if (isChecked()) {
65                                // if the primary modifier key is down then clear the list
66                                // first. this makes the selection exclusive rather than
67                                // additive.
68                                boolean modified = (event.stateMask & KeyLookupFactory
69                                                .getDefault().formalModifierLookup(IKeyLookup.M1_NAME)) != 0;
70                                
71                                if (modified) 
72                                        newList.clear();
73                                newList.add(set);
74                        } else {
75                                newList.remove(set);
76                        }
77 
78                        getWindow().getActivePage().setWorkingSets(
79                                        (IWorkingSet[]) newList.toArray(new IWorkingSet[newList
80                                                        .size()]));
81                }
82        }
83 
84        protected void fillMenu(Menu menu) {
85                IWorkingSet[][] typedSets = splitSets();
86 
87                for (int i = 0; i < typedSets.length; i++) {
88                        IWorkingSet[] sets = typedSets[i];
89                        for (int j = 0; j < sets.length; j++) {
90                                IWorkingSet set = sets[j];
91 
92                                // only add visible sets
93                                // if (set.isVisible()) {
94                                ActionContributionItem item = new ActionContributionItem(
95                                                new ToggleWorkingSetAction(set));
96                                item.fill(menu, -1);
97                                // }
98                        }
99                        Separator separator = new Separator();
100                        separator.fill(menu, -1);
101                }
102 
103                ActionContributionItem item = new ActionContributionItem(
104                                new ManageWorkingSetsAction());
105                item.fill(menu, -1);
106 
107        }
108 
109        private IWorkingSet[] getEnabledSets() {
110                return getWindow().getActivePage().getWorkingSets();
111        }
112 
113        private boolean isWorkingSetEnabled(IWorkingSet set) {
114                IWorkingSet[] enabledSets = getEnabledSets();
115                for (int i = 0; i < enabledSets.length; i++) {
116                        if (enabledSets[i].equals(set)) {
117                                return true;
118                        }
119                }
120                return false;
121        }
122 
123        public void run(IAction action) {
124                ConfigureWindowWorkingSetsDialog dialog = new ConfigureWindowWorkingSetsDialog(
125                                getWindow());
126                if (dialog.open() == Window.OK) {
127 
128                }
129 
130        }
131}
132 
133class ConfigureWindowWorkingSetsDialog extends SimpleWorkingSetSelectionDialog {
134 
135        private IWorkbenchWindow window;
136        
137        protected ConfigureWindowWorkingSetsDialog(IWorkbenchWindow window) {
138                super(window.getShell(), null, window.getActivePage().getWorkingSets(), true);
139                this.window = window;
140                setTitle(WorkbenchMessages.WorkingSetSelectionDialog_title_multiSelect);
141                setMessage(WorkbenchMessages.WorkingSetSelectionDialog_message_multiSelect);
142        }
143        
144        protected void okPressed() {
145                super.okPressed();
146                window.getActivePage().setWorkingSets(getSelection());
147        }
148}

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