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

COVERAGE SUMMARY FOR SOURCE FILE [CompletionSelectionPage.java]

nameclass, %method, %block, %line, %
CompletionSelectionPage.java0%   (0/4)0%   (0/20)0%   (0/303)0%   (0/86)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CompletionSelectionPage0%   (0/1)0%   (0/6)0%   (0/185)0%   (0/51)
CompletionSelectionPage (String): void 0%   (0/1)0%   (0/28)0%   (0/8)
canFinish (): boolean 0%   (0/1)0%   (0/27)0%   (0/9)
canFlipToNextPage (): boolean 0%   (0/1)0%   (0/36)0%   (0/13)
createControl (Composite): void 0%   (0/1)0%   (0/81)0%   (0/17)
getNextPage (): IWizardPage 0%   (0/1)0%   (0/3)0%   (0/1)
getSelection (): Object 0%   (0/1)0%   (0/10)0%   (0/3)
     
class CompletionSelectionPage$CompletionTypeSelectionListener0%   (0/1)0%   (0/3)0%   (0/16)0%   (0/3)
CompletionSelectionPage$CompletionTypeSelectionListener (CompletionSelectionP... 0%   (0/1)0%   (0/6)0%   (0/1)
CompletionSelectionPage$CompletionTypeSelectionListener (CompletionSelectionP... 0%   (0/1)0%   (0/4)0%   (0/1)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class CompletionSelectionPage$CompletionTypeTreeContentProvider0%   (0/1)0%   (0/8)0%   (0/39)0%   (0/13)
CompletionSelectionPage$CompletionTypeTreeContentProvider (CompletionSelectio... 0%   (0/1)0%   (0/6)0%   (0/1)
CompletionSelectionPage$CompletionTypeTreeContentProvider (CompletionSelectio... 0%   (0/1)0%   (0/4)0%   (0/1)
dispose (): void 0%   (0/1)0%   (0/1)0%   (0/1)
getChildren (Object): Object [] 0%   (0/1)0%   (0/9)0%   (0/3)
getElements (Object): Object [] 0%   (0/1)0%   (0/9)0%   (0/3)
getParent (Object): Object 0%   (0/1)0%   (0/2)0%   (0/1)
hasChildren (Object): boolean 0%   (0/1)0%   (0/7)0%   (0/3)
inputChanged (Viewer, Object, Object): void 0%   (0/1)0%   (0/1)0%   (0/1)
     
class CompletionSelectionPage$CompletionTypeTreeLabelProvider0%   (0/1)0%   (0/3)0%   (0/63)0%   (0/19)
CompletionSelectionPage$CompletionTypeTreeLabelProvider (CompletionSelectionP... 0%   (0/1)0%   (0/6)0%   (0/1)
getImage (Object): Image 0%   (0/1)0%   (0/27)0%   (0/9)
getText (Object): String 0%   (0/1)0%   (0/30)0%   (0/9)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.cip.runtime.wizards;
5 
6import java.util.ArrayList;
7import java.util.List;
8 
9import org.eclipse.core.runtime.CoreException;
10import org.eclipse.jface.viewers.ILabelProvider;
11import org.eclipse.jface.viewers.ISelectionChangedListener;
12import org.eclipse.jface.viewers.IStructuredSelection;
13import org.eclipse.jface.viewers.ITreeContentProvider;
14import org.eclipse.jface.viewers.LabelProvider;
15import org.eclipse.jface.viewers.SelectionChangedEvent;
16import org.eclipse.jface.viewers.TreeViewer;
17import org.eclipse.jface.viewers.Viewer;
18import org.eclipse.jface.wizard.IWizardPage;
19import org.eclipse.jface.wizard.WizardPage;
20import org.eclipse.swt.SWT;
21import org.eclipse.swt.graphics.Image;
22import org.eclipse.swt.layout.GridData;
23import org.eclipse.swt.layout.GridLayout;
24import org.eclipse.swt.widgets.Composite;
25import org.eclipse.ui.dialogs.FilteredTree;
26import org.eclipse.ui.dialogs.PatternFilter;
27 
28import de.uka.ipd.sdq.cip.completions.RegisteredCompletion;
29import de.uka.ipd.sdq.cip.ConstantsContainer;
30import de.uka.ipd.sdq.cip.runtime.RunConfigImages;
31import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.FeatureConfig;
32import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.UserDefined;
33import de.uka.ipd.sdq.cip.runtime.wizards.CompletionConfigNode.UserDefinedID;
34 
35/**
36 * @author thomass
37 *
38 */
39public class CompletionSelectionPage extends WizardPage/* implements SelectionListener*/{
40 
41 
42        private FilteredTree completionTree;
43        private TreeViewer completionTreeViewer;
44        private List<CompletionConfigNode> completionConfigNodes;
45 
46        protected CompletionSelectionPage(String pageName) {
47                super(pageName);
48                completionConfigNodes = new ArrayList<CompletionConfigNode>();
49                try {
50                        completionConfigNodes.add(CompletionConfigNode.createWorkspaceNode());
51                } catch (CoreException e) {
52                        e.printStackTrace();
53                }
54                completionConfigNodes.add(CompletionConfigNode.createRegisteredNode());
55                completionConfigNodes.add(CompletionConfigNode.createUserDefinedNode());
56        }
57 
58        /* (non-Javadoc)
59         * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
60         */
61        @Override
62        public void createControl(Composite parent) {
63                Composite mainComponent = new Composite(parent, SWT.NONE);
64                
65                GridLayout mainlayout = new GridLayout();
66                mainComponent.setLayout(mainlayout);
67                
68                completionTree = new FilteredTree(mainComponent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, new PatternFilter(), true);
69                GridData gd = new GridData();
70                gd.grabExcessHorizontalSpace = true;
71                gd.grabExcessVerticalSpace = true;
72                gd.verticalAlignment = SWT.FILL;
73                gd.horizontalAlignment = SWT.FILL;
74                completionTree.setLayoutData(gd);
75                completionTreeViewer = completionTree.getViewer();
76                
77                completionTreeViewer.setContentProvider(new CompletionTypeTreeContentProvider());
78                completionTreeViewer.setLabelProvider(new CompletionTypeTreeLabelProvider());
79                completionTreeViewer.addSelectionChangedListener(new CompletionTypeSelectionListener());
80                completionTreeViewer.setInput(completionConfigNodes);
81                setControl(mainComponent);
82 
83        }
84        
85        @Override
86        public IWizardPage getNextPage() {
87                return super.getNextPage();
88        }
89        
90        @Override
91        public boolean canFlipToNextPage() {
92                IStructuredSelection selection = (IStructuredSelection) completionTreeViewer.getSelection();
93                Object element = selection.getFirstElement();
94                
95                if(element == null)
96                        return false;
97                
98                if(element instanceof FeatureConfig) 
99                        return false;
100                
101                if(element instanceof RegisteredCompletion) {
102                        RegisteredCompletion completion = (RegisteredCompletion) element;
103                        if(!completion.containsCategory(ConstantsContainer.PLAIN_COMPLETION)) {
104                                return true;
105                        }
106                }
107                
108                if(element instanceof UserDefined) {
109                        return true;
110                }
111                
112                return false;
113        }
114        
115        public boolean canFinish() {
116                IStructuredSelection selection = (IStructuredSelection) completionTreeViewer.getSelection();
117                Object element = selection.getFirstElement();
118                
119                if(element instanceof FeatureConfig)
120                        return true;
121                
122                if(element instanceof RegisteredCompletion) {
123                        RegisteredCompletion completion = (RegisteredCompletion) element;
124                        if(completion.containsCategory(ConstantsContainer.PLAIN_COMPLETION)) {
125                                return true;
126                        }
127                }
128                
129                return false;
130        }        
131        
132        Object getSelection() {
133                IStructuredSelection selection = (IStructuredSelection) completionTreeViewer.getSelection();
134                Object element = selection.getFirstElement();
135                
136                return element;
137        }
138 
139        private class CompletionTypeSelectionListener implements ISelectionChangedListener {
140 
141                @Override
142                public void selectionChanged(SelectionChangedEvent event) {
143                        getWizard().getContainer().updateButtons();
144                }
145                
146        }
147        
148        private class CompletionTypeTreeContentProvider implements ITreeContentProvider{
149                
150                @Override
151                public Object[] getChildren(Object parentElement) {
152                        if(parentElement instanceof CompletionConfigNode)
153                                return ((CompletionConfigNode)parentElement).getChildren();
154                        return null;
155                }
156        
157                @Override
158                public Object getParent(Object element) {
159                                return null; 
160                }
161        
162                @Override
163                public boolean hasChildren(Object element) {
164                        if(element instanceof CompletionConfigNode)
165                                return true;
166                        return false;
167                }
168        
169                @Override
170                public Object[] getElements(Object inputElement) {
171                        if(inputElement instanceof List<?>)
172                                return ((List<?>) inputElement).toArray();
173                        return null;
174                }
175        
176                @Override
177                public void dispose() {                        
178                }
179        
180                @Override
181                public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
182                }
183        }
184        
185        /**
186         * @author thomass
187         *
188         */
189        public class CompletionTypeTreeLabelProvider extends LabelProvider implements ILabelProvider{
190 
191                /* (non-Javadoc)
192                 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
193                 */
194                @Override
195                public Image getImage(Object element) {
196                        if(element instanceof CompletionConfigNode)
197                                return RunConfigImages.getFolderIcon();
198                        if(element instanceof RegisteredCompletion) {
199                                if(((RegisteredCompletion)element).containsCategory(ConstantsContainer.MARK_COMPLETION))
200                                        return RunConfigImages.getAnnotationIcon();
201                        }
202                        if(element instanceof UserDefined) {
203                                if(((UserDefined)element).getID() == UserDefinedID.ANNOTATED)
204                                        return RunConfigImages.getAnnotationNewIcon();
205                        }
206                        return null;
207                }
208 
209                /* (non-Javadoc)
210                 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
211                 */
212                @Override
213                public String getText(Object element) {
214                        if(element instanceof CompletionConfigNode)
215                                return ((CompletionConfigNode) element).getCaption();
216                        else if(element instanceof FeatureConfig)
217                                return ((FeatureConfig) element).getName();
218                        else if(element instanceof RegisteredCompletion)
219                                return ((RegisteredCompletion) element).getName();
220                        else if(element instanceof UserDefined)
221                                return ((UserDefined) element).getCaption();
222                        return null;
223                }
224 
225 
226        }
227 
228}

[all classes][de.uka.ipd.sdq.cip.runtime.wizards]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov