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

COVERAGE SUMMARY FOR SOURCE FILE [GenericEMFPropertySection.java]

nameclass, %method, %block, %line, %
GenericEMFPropertySection.java0%   (0/1)0%   (0/3)0%   (0/107)0%   (0/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GenericEMFPropertySection0%   (0/1)0%   (0/3)0%   (0/107)0%   (0/32)
GenericEMFPropertySection (): void 0%   (0/1)0%   (0/8)0%   (0/2)
createControls (Composite, TabbedPropertySheetPage): void 0%   (0/1)0%   (0/48)0%   (0/16)
setInput (IWorkbenchPart, ISelection): void 0%   (0/1)0%   (0/51)0%   (0/14)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcmbench.tabs;
5 
6import java.util.ArrayList;
7import java.util.Collection;
8import java.util.Iterator;
9 
10import org.eclipse.core.runtime.Assert;
11import org.eclipse.emf.ecore.EClass;
12import org.eclipse.emf.ecore.EObject;
13import org.eclipse.gef.GraphicalEditPart;
14import org.eclipse.gmf.runtime.notation.View;
15import org.eclipse.jface.viewers.ISelection;
16import org.eclipse.jface.viewers.IStructuredSelection;
17import org.eclipse.swt.widgets.Composite;
18import org.eclipse.ui.IWorkbenchPart;
19import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
20import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
21 
22/**
23 * @author Snowball
24 * A tabbed property sheet section which can be configured to display 
25 * a set of generic EMFPropertTextEditField (and maybe other later on).
26 * It uses a template method pattern to get a list of characterising objects
27 * describing the fields to be displayed in this sheet section
28 */
29 
30public abstract class GenericEMFPropertySection extends AbstractPropertySection {
31 
32        private ArrayList<EMFPropertyTextEdit> editFields = new ArrayList<EMFPropertyTextEdit>();
33        
34        /**
35         * This method sets up the property sheet section using a template method
36         * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
37         */
38        @Override
39        public void createControls(
40                Composite parent,
41                TabbedPropertySheetPage tabbedPropertySheetPage) {
42                super.createControls(parent, tabbedPropertySheetPage);
43                
44                // Call the template method
45                Collection<EMFPropertySectionFieldInfo> editFieldsInfo = getEditableTextFields();
46                
47                EMFPropertyTextEdit predecessor = null;
48                Composite composite =
49                        getWidgetFactory().createFlatFormComposite(parent);
50                for(Iterator<EMFPropertySectionFieldInfo> it = editFieldsInfo.iterator(); it.hasNext(); )
51                {
52                        EMFPropertySectionFieldInfo info = it.next();
53                        EMFPropertyTextEdit newField = 
54                                new EMFPropertyTextEdit(composite, info.getLabel(), 
55                                                getEClassToEdit().
56                                                        getEStructuralFeature(info.getFeatureID()), 
57                                                        getWidgetFactory(),
58                                                        predecessor);
59                        predecessor = newField;
60                        editFields.add(newField);
61                }
62        }        
63        
64        /**
65         * Returns a list of edit fields which are used to display features of EMF meta-model 
66         * classes 
67         * @return A list of EMF features which should be editable in this property sheet section
68         */
69        protected abstract Collection<EMFPropertySectionFieldInfo> getEditableTextFields();
70        
71        /**
72         * The EClass of the objects which can be displayed in this property sheet.
73         * A single model object is edited in the property sheet. The features which are
74         * diplayed on the sheet are set using the getEditableTextFields method
75         * @return
76         */
77        protected abstract EClass getEClassToEdit();
78        
79        /**
80         * The model object which should be edited in the tab sheet is passed in here
81         * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
82         */
83        @Override
84        public void setInput(IWorkbenchPart part, ISelection selection) {
85                super.setInput(part, selection);
86                Assert.isTrue(selection instanceof IStructuredSelection);
87                Object input = ((IStructuredSelection)selection).getFirstElement();
88                if (input instanceof GraphicalEditPart)
89                {
90                        GraphicalEditPart ep = (GraphicalEditPart)input;
91                        input = ep.getModel();
92                }
93                if (input instanceof View){
94                        input = ((View)input).getElement();
95                }
96                Assert.isTrue(input instanceof EObject);
97                EObject inputEObject = (EObject)input;
98                for(Iterator<EMFPropertyTextEdit> it = editFields.iterator(); it.hasNext(); )
99                {
100                        EMFPropertyTextEdit editField = it.next();
101                        editField.setEObject(inputEObject);
102                }
103        }
104 
105}

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