1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.pcmbench.tabs; |
5 | |
6 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
7 | import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; |
8 | import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; |
9 | import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; |
10 | import org.eclipse.jface.viewers.ISelection; |
11 | import org.eclipse.swt.layout.FormAttachment; |
12 | import org.eclipse.swt.layout.FormData; |
13 | import org.eclipse.swt.widgets.Composite; |
14 | import org.eclipse.ui.IWorkbenchPart; |
15 | import org.eclipse.ui.views.properties.PropertySheetPage; |
16 | import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; |
17 | import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; |
18 | |
19 | import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory; |
20 | import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory; |
21 | |
22 | /** |
23 | * @author Snowball |
24 | * "Advanced" Property Section showing the original generated EMF |
25 | * property sheet |
26 | */ |
27 | public class AdvancedPropertySection |
28 | extends AbstractPropertySection { |
29 | |
30 | /** |
31 | * The Property Sheet Page used to display the standard properties |
32 | */ |
33 | protected PropertySheetPage page; |
34 | private ComposedAdapterFactory adapterFactory; |
35 | |
36 | /** |
37 | * @see org.eclipse.ui.views.properties.tabbed.ISection#createControls(org.eclipse.swt.widgets.Composite, |
38 | * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) |
39 | */ |
40 | @Override |
41 | public void createControls(Composite parent, |
42 | TabbedPropertySheetPage tabbedPropertySheetPage) { |
43 | |
44 | super.createControls(parent, tabbedPropertySheetPage); |
45 | Composite composite = getWidgetFactory() |
46 | .createFlatFormComposite(parent); |
47 | page = new PropertySheetPage(); |
48 | |
49 | page.createControl(composite); |
50 | FormData data = new FormData(); |
51 | data.left = new FormAttachment(0, 0); |
52 | data.right = new FormAttachment(100, 0); |
53 | data.top = new FormAttachment(0, 0); |
54 | data.bottom = new FormAttachment(100, 0); |
55 | page.getControl().setLayoutData(data); |
56 | |
57 | adapterFactory = new ComposedAdapterFactory(); |
58 | adapterFactory |
59 | .addAdapterFactory(new RepositoryItemProviderAdapterFactory()); |
60 | adapterFactory |
61 | .addAdapterFactory(new SeffItemProviderAdapterFactory()); |
62 | adapterFactory |
63 | .addAdapterFactory(new ResourceItemProviderAdapterFactory()); |
64 | adapterFactory |
65 | .addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); |
66 | |
67 | page |
68 | .setPropertySourceProvider(new AdapterFactoryContentProvider( |
69 | adapterFactory)); |
70 | |
71 | } |
72 | |
73 | /** |
74 | * @see org.eclipse.ui.views.properties.tabbed.ISection#setInput(org.eclipse.ui.IWorkbenchPart, |
75 | * org.eclipse.jface.viewers.ISelection) |
76 | */ |
77 | @Override |
78 | public void setInput(IWorkbenchPart part, ISelection selection) { |
79 | super.setInput(part, selection); |
80 | page.selectionChanged(part, selection); |
81 | } |
82 | |
83 | /** |
84 | * @see org.eclipse.ui.views.properties.tabbed.ISection#dispose() |
85 | */ |
86 | @Override |
87 | public void dispose() { |
88 | super.dispose(); |
89 | |
90 | if (page != null) { |
91 | page.dispose(); |
92 | page = null; |
93 | } |
94 | |
95 | } |
96 | |
97 | /** |
98 | * @see org.eclipse.ui.views.properties.tabbed.ISection#refresh() |
99 | */ |
100 | @Override |
101 | public void refresh() { |
102 | page.refresh(); |
103 | } |
104 | |
105 | /** |
106 | * @see org.eclipse.ui.views.properties.tabbed.ISection#shouldUseExtraSpace() |
107 | */ |
108 | @Override |
109 | public boolean shouldUseExtraSpace() { |
110 | return true; |
111 | } |
112 | } |