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

COVERAGE SUMMARY FOR SOURCE FILE [ModelElementSelectionPage.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ModelElementSelectionPage0%   (0/1)0%   (0/7)0%   (0/192)0%   (0/54)
ModelElementSelectionPage (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
createControl (Composite): void 0%   (0/1)0%   (0/112)0%   (0/27)
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 2007, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.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 * 
26 * @generated
27 */
28public class ModelElementSelectionPage extends WizardPage {
29 
30        /**
31         * @generated
32         */
33        protected EObject selectedModelElement;
34 
35        /**
36         * @generated
37         */
38        private TreeViewer modelViewer;
39 
40        /**
41         * @generated
42         */
43        public ModelElementSelectionPage(String pageName) {
44                super(pageName);
45        }
46 
47        /**
48         * @generated
49         */
50        public EObject getModelElement() {
51                return selectedModelElement;
52        }
53 
54        /**
55         * @generated
56         */
57        public void setModelElement(EObject modelElement) {
58                selectedModelElement = modelElement;
59                if (modelViewer != null) {
60                        if (selectedModelElement != null) {
61                                modelViewer.setInput(selectedModelElement.eResource());
62                                modelViewer.setSelection(new StructuredSelection(
63                                                selectedModelElement));
64                        } else {
65                                modelViewer.setInput(null);
66                        }
67                        setPageComplete(validatePage());
68                }
69        }
70 
71        /**
72         * @generated
73         */
74        public void createControl(Composite parent) {
75                initializeDialogUnits(parent);
76 
77                Composite plate = new Composite(parent, SWT.NONE);
78                plate.setLayoutData(new GridData(GridData.FILL_BOTH));
79                GridLayout layout = new GridLayout();
80                layout.marginWidth = 0;
81                plate.setLayout(layout);
82                setControl(plate);
83 
84                Label label = new Label(plate, SWT.NONE);
85                label.setText(getSelectionTitle());
86                label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
87 
88                modelViewer = new TreeViewer(plate, SWT.SINGLE | SWT.H_SCROLL
89                                | SWT.V_SCROLL | SWT.BORDER);
90                GridData layoutData = new GridData(GridData.FILL_BOTH);
91                layoutData.heightHint = 300;
92                layoutData.widthHint = 300;
93                modelViewer.getTree().setLayoutData(layoutData);
94                modelViewer.setContentProvider(new AdapterFactoryContentProvider(
95                                PalladioComponentModelRepositoryDiagramEditorPlugin
96                                                .getInstance().getItemProvidersAdapterFactory()));
97                modelViewer.setLabelProvider(new AdapterFactoryLabelProvider(
98                                PalladioComponentModelRepositoryDiagramEditorPlugin
99                                                .getInstance().getItemProvidersAdapterFactory()));
100                if (selectedModelElement != null) {
101                        modelViewer.setInput(selectedModelElement.eResource());
102                        modelViewer.setSelection(new StructuredSelection(
103                                        selectedModelElement));
104                }
105                modelViewer
106                                .addSelectionChangedListener(new ISelectionChangedListener() {
107                                        public void selectionChanged(SelectionChangedEvent event) {
108                                                ModelElementSelectionPage.this
109                                                                .updateSelection((IStructuredSelection) event
110                                                                                .getSelection());
111                                        }
112                                });
113 
114                setPageComplete(validatePage());
115        }
116 
117        /**
118         * Override to provide custom model element description.
119         * 
120         * @generated
121         */
122        protected String getSelectionTitle() {
123                return Messages.ModelElementSelectionPageMessage;
124        }
125 
126        /**
127         * @generated
128         */
129        protected void updateSelection(IStructuredSelection selection) {
130                selectedModelElement = null;
131                if (selection.size() == 1) {
132                        Object selectedElement = selection.getFirstElement();
133                        if (selectedElement instanceof IWrapperItemProvider) {
134                                selectedElement = ((IWrapperItemProvider) selectedElement)
135                                                .getValue();
136                        }
137                        if (selectedElement instanceof FeatureMap.Entry) {
138                                selectedElement = ((FeatureMap.Entry) selectedElement)
139                                                .getValue();
140                        }
141                        if (selectedElement instanceof EObject) {
142                                selectedModelElement = (EObject) selectedElement;
143                        }
144                }
145                setPageComplete(validatePage());
146        }
147 
148        /**
149         * Override to provide specific validation of the selected model element.
150         * 
151         * @generated
152         */
153        protected boolean validatePage() {
154                return true;
155        }
156}

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