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 [ComponentParametersPropertySection.java]

nameclass, %method, %block, %line, %
ComponentParametersPropertySection.java0%   (0/1)0%   (0/4)0%   (0/155)0%   (0/43)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComponentParametersPropertySection0%   (0/1)0%   (0/4)0%   (0/155)0%   (0/43)
ComponentParametersPropertySection (): void 0%   (0/1)0%   (0/3)0%   (0/1)
createControls (Composite, TabbedPropertySheetPage): void 0%   (0/1)0%   (0/65)0%   (0/18)
setColorOfTableItems (Table): void 0%   (0/1)0%   (0/33)0%   (0/10)
setInput (IWorkbenchPart, ISelection): void 0%   (0/1)0%   (0/54)0%   (0/14)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.pcmbench.tabs;
5 
6import org.eclipse.core.runtime.Assert;
7import org.eclipse.emf.ecore.EObject;
8import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
9import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
10import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
11import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
12import org.eclipse.gef.GraphicalEditPart;
13import org.eclipse.gmf.runtime.notation.View;
14import org.eclipse.jface.viewers.ISelection;
15import org.eclipse.jface.viewers.IStructuredSelection;
16import org.eclipse.swt.SWT;
17import org.eclipse.swt.graphics.Color;
18import org.eclipse.swt.widgets.Composite;
19import org.eclipse.swt.widgets.Display;
20import org.eclipse.swt.widgets.Table;
21import org.eclipse.swt.widgets.TableItem;
22import org.eclipse.ui.IWorkbenchPart;
23import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
24import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
25 
26import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext;
27import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory;
28import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory;
29import de.uka.ipd.sdq.pcmbench.tabs.parameters.ComponentParametersEditorSection;
30import de.uka.ipd.sdq.pcmbench.tabs.parameters.ParameterContentProvider;
31import de.uka.ipd.sdq.pcmbench.tabs.parameters.ParametersTabItemProviderAdapterFactory;
32import de.uka.ipd.sdq.pcmbench.tabs.parameters.VariableUsageWrapper;
33import de.uka.ipd.sdq.pcmbench.ui.provider.PalladioItemProviderAdapterFactory;
34 
35/**
36 * @author Roman Andrej
37 *
38 */
39public class ComponentParametersPropertySection extends AbstractPropertySection {
40        
41        /**
42         * The Property Sheet Page used to display the standard properties
43         */
44        private ComposedAdapterFactory adapterFactory;
45        private ComponentParametersEditorSection propertySection;
46        
47        /* (non-Javadoc)
48         * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
49         */
50        @Override
51        public void createControls(Composite parent,
52                        TabbedPropertySheetPage tabbedPropertySheetPage) {
53                super.createControls(parent, tabbedPropertySheetPage);
54                
55                Composite composite = getWidgetFactory()
56                        .createFlatFormComposite(parent);
57                
58                adapterFactory = new ComposedAdapterFactory();
59                adapterFactory
60                .addAdapterFactory(new RepositoryItemProviderAdapterFactory());
61                adapterFactory
62                .addAdapterFactory(new SeffItemProviderAdapterFactory());
63                adapterFactory
64                .addAdapterFactory(new ResourceItemProviderAdapterFactory());
65                adapterFactory
66                .addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
67                
68                propertySection = new ComponentParametersEditorSection(composite);
69//                propertySection.setViewerContentProvider(new AdapterFactoryContentProvider(
70//                                adapterFactory));
71                propertySection.setViewerContentProvider(new ParameterContentProvider());
72//                propertySection.setViewerLabelProvider(new ParameterLabelProvider());
73                propertySection.setViewerLabelProvider(new AdapterFactoryLabelProvider(
74                                new ParametersTabItemProviderAdapterFactory(
75                                                new PalladioItemProviderAdapterFactory(adapterFactory))));
76 
77 
78        
79        }
80 
81        /* (non-Javadoc)
82         * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
83         */
84        @Override
85        public void setInput(IWorkbenchPart part, ISelection selection) {
86                super.setInput(part, selection);
87                Assert.isTrue(selection instanceof IStructuredSelection);
88                Object input = ((IStructuredSelection) selection).getFirstElement();
89                
90                if (input instanceof GraphicalEditPart){
91                        GraphicalEditPart ep = (GraphicalEditPart)input;
92                        input = ep.getModel();
93                }
94                if (input instanceof View){
95                        input = ((View)input).getElement();
96                }
97                
98                Assert.isTrue(input instanceof EObject);
99                // set input for 'TableViewer'
100                propertySection.setViewerInput(input);
101                propertySection.getViewer().getTable();
102                // set in the diagram selected object to the TableViever cell modifier.
103                propertySection.getCellModifier().setContext((AssemblyContext) input);
104                
105                setColorOfTableItems(propertySection.getViewer().getTable());
106        }
107        
108        private void setColorOfTableItems(Table table) {
109 
110                // set color for items
111                Display display = table.getDisplay();
112                Color gray = display.getSystemColor(SWT.COLOR_GRAY);
113 
114                TableItem[] items = table.getItems();
115 
116                for (int i = 0; i < items.length; i++) {
117                        TableItem item = items[i];
118 
119                        VariableUsageWrapper wrapper = (VariableUsageWrapper) item
120                                        .getData();
121 
122                        if (!wrapper.isEdited()) {
123                                item.setForeground(gray);
124                        }
125 
126                }
127        }
128        
129}

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