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

COVERAGE SUMMARY FOR SOURCE FILE [ModelElementSelectionPage.java]

nameclass, %method, %block, %line, %
ModelElementSelectionPage.java0%   (0/2)0%   (0/9)0%   (0/205)0%   (0/61)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ModelElementSelectionPage0%   (0/1)0%   (0/7)0%   (0/192)0%   (0/56)
ModelElementSelectionPage (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
createControl (Composite): void 0%   (0/1)0%   (0/112)0%   (0/29)
getModelElement (): EObject 0%   (0/1)0%   (0/3)0%   (0/1)
getSelectionTitle (): String 0%   (0/1)0%   (0/2)0%   (0/1)
setModelElement (EObject): void 0%   (0/1)0%   (0/33)0%   (0/9)
updateSelection (IStructuredSelection): void 0%   (0/1)0%   (0/36)0%   (0/13)
validatePage (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
     
class ModelElementSelectionPage$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/6)
ModelElementSelectionPage$1 (ModelElementSelectionPage): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/7)0%   (0/4)

1/*
2 * Copyright 2009, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.resource.part;
5 
6import org.eclipse.emf.ecore.EObject;
7import org.eclipse.emf.ecore.util.FeatureMap;
8import org.eclipse.emf.edit.provider.IWrapperItemProvider;
9import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
10import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
11import org.eclipse.jface.viewers.ISelectionChangedListener;
12import org.eclipse.jface.viewers.IStructuredSelection;
13import org.eclipse.jface.viewers.SelectionChangedEvent;
14import org.eclipse.jface.viewers.StructuredSelection;
15import org.eclipse.jface.viewers.TreeViewer;
16import org.eclipse.jface.wizard.WizardPage;
17import org.eclipse.swt.SWT;
18import org.eclipse.swt.layout.GridData;
19import org.eclipse.swt.layout.GridLayout;
20import org.eclipse.swt.widgets.Composite;
21import org.eclipse.swt.widgets.Label;
22 
23/**
24 * Wizard page that allows to select element from model.
25 * @generated
26 */
27public class ModelElementSelectionPage extends WizardPage {
28        /**
29         * @generated
30         */
31        protected EObject selectedModelElement;
32 
33        /**
34         * @generated
35         */
36        private TreeViewer modelViewer;
37 
38        /**
39         * @generated
40         */
41        public ModelElementSelectionPage(String pageName) {
42                super(pageName);
43        }
44 
45        /**
46         * @generated
47         */
48        public EObject getModelElement() {
49                return selectedModelElement;
50        }
51 
52        /**
53         * @generated
54         */
55        public void setModelElement(EObject modelElement) {
56                selectedModelElement = modelElement;
57                if (modelViewer != null) {
58                        if (selectedModelElement != null) {
59                                modelViewer.setInput(selectedModelElement.eResource());
60                                modelViewer.setSelection(new StructuredSelection(
61                                                selectedModelElement));
62                        } else {
63                                modelViewer.setInput(null);
64                        }
65                        setPageComplete(validatePage());
66                }
67        }
68 
69        /**
70         * @generated
71         */
72        public void createControl(Composite parent) {
73                initializeDialogUnits(parent);
74 
75                Composite plate = new Composite(parent, SWT.NONE);
76                plate.setLayoutData(new GridData(GridData.FILL_BOTH));
77                GridLayout layout = new GridLayout();
78                layout.marginWidth = 0;
79                plate.setLayout(layout);
80                setControl(plate);
81 
82                Label label = new Label(plate, SWT.NONE);
83                label.setText(getSelectionTitle());
84                label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
85 
86                modelViewer = new TreeViewer(plate, SWT.SINGLE | SWT.H_SCROLL
87                                | SWT.V_SCROLL | SWT.BORDER);
88                GridData layoutData = new GridData(GridData.FILL_BOTH);
89                layoutData.heightHint = 300;
90                layoutData.widthHint = 300;
91                modelViewer.getTree().setLayoutData(layoutData);
92                modelViewer.setContentProvider(new AdapterFactoryContentProvider(
93                                PalladioComponentModelDiagramEditorPlugin.getInstance()
94                                                .getItemProvidersAdapterFactory()));
95                modelViewer.setLabelProvider(new AdapterFactoryLabelProvider(
96                                PalladioComponentModelDiagramEditorPlugin.getInstance()
97                                                .getItemProvidersAdapterFactory()));
98                if (selectedModelElement != null) {
99                        modelViewer.setInput(selectedModelElement.eResource());
100                        modelViewer.setSelection(new StructuredSelection(
101                                        selectedModelElement));
102                }
103                modelViewer
104                                .addSelectionChangedListener(new ISelectionChangedListener() {
105                                        public void selectionChanged(SelectionChangedEvent event) {
106                                                ModelElementSelectionPage.this
107                                                                .updateSelection((IStructuredSelection) event
108                                                                                .getSelection());
109                                        }
110                                });
111 
112                setPageComplete(validatePage());
113        }
114 
115        /**
116         * Override to provide custom model element description.
117         * @generated
118         */
119        protected String getSelectionTitle() {
120                return Messages.ModelElementSelectionPageMessage;
121        }
122 
123        /**
124         * @generated
125         */
126        protected void updateSelection(IStructuredSelection selection) {
127                selectedModelElement = null;
128                if (selection.size() == 1) {
129                        Object selectedElement = selection.getFirstElement();
130                        if (selectedElement instanceof IWrapperItemProvider) {
131                                selectedElement = ((IWrapperItemProvider) selectedElement)
132                                                .getValue();
133                        }
134                        if (selectedElement instanceof FeatureMap.Entry) {
135                                selectedElement = ((FeatureMap.Entry) selectedElement)
136                                                .getValue();
137                        }
138                        if (selectedElement instanceof EObject) {
139                                selectedModelElement = (EObject) selectedElement;
140                        }
141                }
142                setPageComplete(validatePage());
143        }
144 
145        /**
146         * Override to provide specific validation of the selected model element.
147         * @generated
148         */
149        protected boolean validatePage() {
150                return true;
151        }
152 
153}

[all classes][de.uka.ipd.sdq.pcm.gmf.resource.part]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov