EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.tcfmoop.views]

COVERAGE SUMMARY FOR SOURCE FILE [TerminationCriteriaView.java]

nameclass, %method, %block, %line, %
TerminationCriteriaView.java0%   (0/11)0%   (0/45)0%   (0/651)0%   (0/141)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TerminationCriteriaView0%   (0/1)0%   (0/21)0%   (0/367)0%   (0/94)
TerminationCriteriaView (): void 0%   (0/1)0%   (0/16)0%   (0/5)
access$0 (TerminationCriteriaView): Map 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (TerminationCriteriaView, IMenuManager): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$2 (TerminationCriteriaView): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$3 (TerminationCriteriaView): TreeViewer 0%   (0/1)0%   (0/3)0%   (0/1)
access$4 (TerminationCriteriaView): Action 0%   (0/1)0%   (0/3)0%   (0/1)
addRequestManualTerminationListener (IRequestManualTerminationListener): void 0%   (0/1)0%   (0/6)0%   (0/2)
contributeToActionBars (): void 0%   (0/1)0%   (0/13)0%   (0/4)
createPartControl (Composite): void 0%   (0/1)0%   (0/51)0%   (0/11)
fillContextMenu (IMenuManager): void 0%   (0/1)0%   (0/27)0%   (0/7)
fillLocalPullDown (IMenuManager): void 0%   (0/1)0%   (0/17)0%   (0/5)
fillLocalToolBar (IToolBarManager): void 0%   (0/1)0%   (0/27)0%   (0/7)
fireRequestManualTerminationEvent (): void 0%   (0/1)0%   (0/19)0%   (0/4)
handleOptimizationTerminatedListener (TerminationCriteriaManager): void 0%   (0/1)0%   (0/11)0%   (0/4)
handleOutputChangedEvent (Tree): void 0%   (0/1)0%   (0/8)0%   (0/2)
handleTerminationCriteriaManagerInitializedEvent (ITerminationCriteriaManager... 0%   (0/1)0%   (0/11)0%   (0/4)
hookContextMenu (): void 0%   (0/1)0%   (0/32)0%   (0/7)
hookDoubleClickAction (): void 0%   (0/1)0%   (0/8)0%   (0/2)
makeActions (): void 0%   (0/1)0%   (0/93)0%   (0/22)
removeRequestManualTerminationListener (IRequestManualTerminationListener): void 0%   (0/1)0%   (0/6)0%   (0/2)
setFocus (): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class TerminationCriteriaView$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
TerminationCriteriaView$1 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
menuAboutToShow (IMenuManager): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class TerminationCriteriaView$20%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
TerminationCriteriaView$2 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class TerminationCriteriaView$30%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
TerminationCriteriaView$3 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class TerminationCriteriaView$40%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
TerminationCriteriaView$4 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class TerminationCriteriaView$50%   (0/1)0%   (0/2)0%   (0/35)0%   (0/7)
TerminationCriteriaView$5 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/29)0%   (0/5)
     
class TerminationCriteriaView$60%   (0/1)0%   (0/2)0%   (0/34)0%   (0/7)
TerminationCriteriaView$6 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/28)0%   (0/5)
     
class TerminationCriteriaView$70%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
TerminationCriteriaView$7 (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/2)
doubleClick (DoubleClickEvent): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class TerminationCriteriaView$80%   (0/1)0%   (0/2)0%   (0/19)0%   (0/5)
TerminationCriteriaView$8 (TerminationCriteriaView, Tree): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/10)0%   (0/3)
     
class TerminationCriteriaView$NameSorter0%   (0/1)0%   (0/3)0%   (0/11)0%   (0/2)
TerminationCriteriaView$NameSorter (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/1)
TerminationCriteriaView$NameSorter (TerminationCriteriaView, TerminationCrite... 0%   (0/1)0%   (0/4)0%   (0/1)
sort (Viewer, Object []): void 0%   (0/1)0%   (0/1)0%   (0/1)
     
class TerminationCriteriaView$ViewLabelProvider0%   (0/1)0%   (0/5)0%   (0/131)0%   (0/21)
$SWITCH_TABLE$de$uka$ipd$sdq$tcfmoop$outputtree$Node$NodeType (): int [] 0%   (0/1)0%   (0/62)0%   (0/1)
TerminationCriteriaView$ViewLabelProvider (TerminationCriteriaView): void 0%   (0/1)0%   (0/6)0%   (0/1)
TerminationCriteriaView$ViewLabelProvider (TerminationCriteriaView, Terminati... 0%   (0/1)0%   (0/4)0%   (0/1)
getImage (Object): Image 0%   (0/1)0%   (0/56)0%   (0/19)
getText (Object): String 0%   (0/1)0%   (0/3)0%   (0/1)

1package de.uka.ipd.sdq.tcfmoop.views;
2 
3import java.util.ArrayList;
4import java.util.HashMap;
5import java.util.List;
6import java.util.Map;
7 
8import org.eclipse.swt.widgets.Composite;
9import org.eclipse.swt.widgets.Display;
10import org.eclipse.swt.widgets.Menu;
11import org.eclipse.ui.part.*;
12import org.eclipse.jface.resource.ImageDescriptor;
13import org.eclipse.jface.viewers.*;
14import org.eclipse.swt.dnd.Clipboard;
15import org.eclipse.swt.dnd.TextTransfer;
16import org.eclipse.swt.dnd.Transfer;
17import org.eclipse.swt.graphics.Image;
18import org.eclipse.jface.action.*;
19import org.eclipse.ui.*;
20import org.eclipse.swt.SWT;
21 
22import de.uka.ipd.sdq.tcfmoop.Activator;
23import de.uka.ipd.sdq.tcfmoop.outputtree.Node;
24import de.uka.ipd.sdq.tcfmoop.outputtree.Tree;
25import de.uka.ipd.sdq.tcfmoop.tcmanager.IOptimizationTerminatedListener;
26import de.uka.ipd.sdq.tcfmoop.tcmanager.IOutputChangedListener;
27import de.uka.ipd.sdq.tcfmoop.tcmanager.IRequestManualTerminationListener;
28import de.uka.ipd.sdq.tcfmoop.tcmanager.IRequestManualTerminationProvider;
29import de.uka.ipd.sdq.tcfmoop.tcmanager.ITerminationCriteriaManager;
30import de.uka.ipd.sdq.tcfmoop.tcmanager.ITerminationCriteriaManagerInitializedListener;
31import de.uka.ipd.sdq.tcfmoop.tcmanager.TerminationCriteriaManager;
32 
33public class TerminationCriteriaView extends ViewPart implements IOutputChangedListener,
34                                                                                                                                 ITerminationCriteriaManagerInitializedListener,
35                                                                                                                                 IOptimizationTerminatedListener,
36                                                                                                                                 IRequestManualTerminationProvider{
37 
38        /**
39         * The ID of the view as specified by the extension.
40         */
41        public static final String ID = "de.uka.ipd.sdq.tcfmoop.views.TerminationCriteriaView";
42        public Tree terminationCriteriaManagerOutput;
43        private List<IRequestManualTerminationListener> requestManualTerminationListeners = new ArrayList<IRequestManualTerminationListener>();
44        
45        private TreeViewer viewer;
46        //private DrillDownAdapter drillDownAdapter;
47        private Action requestTerminationAction;
48        private Action expandAllaction;
49        private Action colapseAllAction;
50        private Action copyAllAction;
51        private Action doubleClickAction;
52        private Map<ImageDescriptor, Image> imageCache = new HashMap<ImageDescriptor, Image>(11);
53 
54        private class ViewLabelProvider extends LabelProvider {
55 
56                public String getText(Object obj) {
57                        return obj.toString();
58                }
59                public Image getImage(Object obj) {
60                        ImageDescriptor descriptor = null;
61                        if (obj instanceof Node){
62                                switch(((Node)obj).type){
63                                case EXPRESSION: 
64                                        descriptor = Activator.getImageDescriptor("icons/expression.gif");
65                                break;
66                                case MANAGER:
67                                        descriptor = Activator.getImageDescriptor("icons/manager.gif");
68                                break;
69                                case PARAMETER:
70                                        descriptor = Activator.getImageDescriptor("icons/parameter.gif");
71                                break;
72                                case PARAMETER_GROUP:
73                                        descriptor = Activator.getImageDescriptor("icons/parameterGroup.gif");
74                                break;
75                                case TERMINATION_CRITERIA:
76                                        descriptor = Activator.getImageDescriptor("icons/terminationCriteria.gif");
77                                break;
78                                case WARNING:
79                                        descriptor = Activator.getImageDescriptor("icons/warning.gif");
80                                break;
81                                default: 
82                                }
83                        }
84                        
85                        Image image = (Image)imageCache.get(descriptor);
86                        if (image == null) {
87                                image = descriptor.createImage();
88                                imageCache.put(descriptor, image);
89                        }
90                        return image;
91                }
92                
93        }
94        
95        private class NameSorter extends ViewerSorter {                
96                @Override
97                public void sort(Viewer viewer, Object[] elements){
98                        /*
99                         * Leave the sorting job to the TerminationCriteriaManager
100                         * and don't sort anything here
101                         */
102                };
103        }
104 
105        /**
106         * The constructor.
107         */
108        public TerminationCriteriaView() {
109                TerminationCriteriaManager.addTerminationCriteriaManagerInitializedListener(this);
110        }
111 
112        /**
113         * This is a callback that will allow us
114         * to create the viewer and initialize it.
115         */
116        @Override
117        public void createPartControl(Composite parent) {
118                viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
119                viewer.setContentProvider(new TerminationCriteriaViewContentProvider(this));
120                viewer.setLabelProvider(new ViewLabelProvider());
121                viewer.setSorter(new NameSorter());
122                viewer.setInput(getViewSite());
123 
124                // Create the help context id for the viewer's control
125                PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "de.uka.ipd.sdq.tcfmoop.viewer");
126                makeActions();
127                hookContextMenu();
128                hookDoubleClickAction();
129                contributeToActionBars();
130                
131        }
132 
133        private void hookContextMenu() {
134                MenuManager menuMgr = new MenuManager("#PopupMenu");
135                menuMgr.setRemoveAllWhenShown(true);
136                menuMgr.addMenuListener(new IMenuListener() {
137                        public void menuAboutToShow(IMenuManager manager) {
138                                TerminationCriteriaView.this.fillContextMenu(manager);
139                        }
140                });
141                Menu menu = menuMgr.createContextMenu(viewer.getControl());
142                viewer.getControl().setMenu(menu);
143                getSite().registerContextMenu(menuMgr, viewer);
144        }
145 
146        private void contributeToActionBars() {
147                IActionBars bars = getViewSite().getActionBars();
148                fillLocalPullDown(bars.getMenuManager());
149                fillLocalToolBar(bars.getToolBarManager());
150        }
151 
152        private void fillLocalPullDown(IMenuManager manager) {
153                manager.add(requestTerminationAction);
154                manager.add(copyAllAction);
155                manager.add(colapseAllAction);
156                manager.add(expandAllaction);
157        }
158 
159        private void fillContextMenu(IMenuManager manager) {
160                manager.add(requestTerminationAction);
161                manager.add(new Separator());
162                manager.add(copyAllAction);
163                manager.add(new Separator());
164                manager.add(expandAllaction);
165                manager.add(colapseAllAction);
166        }
167        
168        private void fillLocalToolBar(IToolBarManager manager) {
169                manager.add(requestTerminationAction);
170                manager.add(new Separator());
171                manager.add(copyAllAction);
172                manager.add(new Separator());
173                manager.add(expandAllaction);
174                manager.add(colapseAllAction);
175        }
176 
177        private void makeActions() {
178                requestTerminationAction = new Action() {
179                        public void run() {
180                                fireRequestManualTerminationEvent();
181                        }
182                };
183                requestTerminationAction.setText("Request Manual Stop");
184                requestTerminationAction.setToolTipText("Request Manual Stop: Stops the optimization after the execution of the current iteration.");
185                requestTerminationAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
186                        getImageDescriptor(ISharedImages.IMG_ELCL_STOP));
187                requestTerminationAction.setEnabled(false);
188                
189                expandAllaction = new Action() {
190                        public void run() {
191                                viewer.expandAll();
192                        }
193                };
194                expandAllaction.setText("Expand All");
195                expandAllaction.setToolTipText("Expand All Nodes");
196                expandAllaction.setImageDescriptor(Activator.getImageDescriptor("icons/expandall.gif"));
197                
198                colapseAllAction = new Action() {
199                        public void run() {
200                                viewer.collapseAll();
201                        }
202                };
203                colapseAllAction.setText("Colapse All");
204                colapseAllAction.setToolTipText("Colapse All Nodes");
205                colapseAllAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
206                                getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
207                
208                copyAllAction = new Action() {
209                        public void run() {
210                                Clipboard cb = new Clipboard(Display.getDefault());
211                                
212                                String clipBoardText = terminationCriteriaManagerOutput.subTreeToString("\t", 0);
213                        
214                                TextTransfer textTransfer = TextTransfer.getInstance();
215                                cb.setContents(new Object[] { clipBoardText }, new Transfer[] { textTransfer });
216                        }
217                };
218                copyAllAction.setText("Copy to Clipboard");
219                copyAllAction.setToolTipText("Copy the content of this view to the clipboard in a suitable Tree representation.");
220                copyAllAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
221                                getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
222                
223                doubleClickAction = new Action() {
224                        public void run() {
225                                Object obj = ((IStructuredSelection)(viewer.getSelection())).iterator().next();
226                                if(viewer.getExpandedState(obj)){
227                                        viewer.collapseToLevel(obj, 1);
228                                }else{
229                                           viewer.expandToLevel(obj, 1);
230                                }
231                        }
232                };
233        }
234 
235        private void hookDoubleClickAction() {
236                viewer.addDoubleClickListener(new IDoubleClickListener() {
237                        public void doubleClick(DoubleClickEvent event) {
238                                doubleClickAction.run();
239                        }
240                });
241        }
242 
243        /**
244         * Passing the focus request to the viewer's control.
245         */
246        @Override
247        public void setFocus() {
248                viewer.getControl().setFocus();
249        }
250 
251        @Override
252        public void handleTerminationCriteriaManagerInitializedEvent(
253                        ITerminationCriteriaManager instance) {
254                instance.addOutputChangedListener(this);
255                instance.addOptimizationTerminatedListener(this);
256                
257                this.requestTerminationAction.setEnabled(true);
258        }
259        
260        @Override
261        public void handleOutputChangedEvent(final Tree outPut) {
262                Display.getDefault().syncExec(new Runnable() {
263                        public void run() {
264                                terminationCriteriaManagerOutput = outPut;
265                                viewer.refresh();
266                        }
267                });        
268        }
269 
270        @Override
271        public void handleOptimizationTerminatedListener(TerminationCriteriaManager instance) {
272                instance.removeOutputChangedListener(this);
273                instance.removeOptimizationTerminatedListener(this);
274                
275                this.requestTerminationAction.setEnabled(false);
276        }
277        
278        private void fireRequestManualTerminationEvent(){
279                for(IRequestManualTerminationListener listener : this.requestManualTerminationListeners){
280                        listener.handleManualTerminationRequest();
281                }
282                this.requestTerminationAction.setEnabled(false);
283        }
284 
285        @Override
286        public void addRequestManualTerminationListener(
287                        IRequestManualTerminationListener listener) {
288                this.requestManualTerminationListeners.add(listener);
289                
290        }
291 
292        @Override
293        public void removeRequestManualTerminationListener(
294                        IRequestManualTerminationListener listener) {
295                this.requestManualTerminationListeners.remove(listener);
296                
297        }
298}

[all classes][de.uka.ipd.sdq.tcfmoop.views]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov