Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 52d94e975d496da7b555abf3fe24bd8ef57a5983 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>extensionpoints</title>
		<link type="text/css" rel="stylesheet" href="../assets/css/stylesheet.css"/>
	</head>
	<body>
		<h2 id="ExtensionPoints">Extension Points</h2>
		<h3 id="eeflifecyclemanagerprovider">IEEFLifecycleManagerProvider</h3>
		<p>This extension point can be used in order to replace the original appearance and behavior of any existing widget or to provide the appearance and behavior of a custom widget description.</p>
		<pre><code>&lt;extension
      point="org.eclipse.eef.ide.ui.eefLifecycleManagerProvider"&gt;
   &lt;descriptor
         class="org.eclipse.eef.sample.internal.extensions.SampleLifecycleManagerProvider"
         description="Provides EEF Lifecycle Managers"
         id="org.eclipse.eef.sample.eefLifecycleManagerProvider"
         label="EEF Sample Lifecycle Manager Provider"&gt;
   &lt;/descriptor&gt;
&lt;/extension&gt;
</code></pre>
		<p>Example of IEEFLifecycleManagerProvider contribution. In this example, we are providing a contribution to provider an IEEFLifecycleManager for a custom widget description. Once EEF has retrieved the description of the user interface to create, it will navigate in this description in order to build the necessary widgets and containers. For each description of containers or widgets found, it will ask the IEEFLifecycleManagerProviders registered if they can handle the description. The first lifecycle manager provider which can handle the given description will thus be used to create the lifecycle manager for this description using the whole available context. The lifecycle manager returned will have the following responsibilities:</p>
		<ul>
			<li>Creation of the SWT widgets for the description &#8211; IEEFLifecycleManager#createControls(...)</li>
			<li>Registration of the listeners between the widgets &#8211; IEEFLifecycleManager#aboutToBeShown(...)</li>
			<li>Refresh of the widgets &#8211; IEEFLifecycleManager#refresh(...)</li>
			<li>Unregistration of the listeners &#8211; IEEFLifecycleManager#aboutToBeDisposed(...)</li>
			<li>Removal of all additional resources &#8211; IEEFLifecycleManager#dispose(...)</li>
		</ul>
		<p>In order to perform those duties, the architecture of EEF encourages the creator of an IEEFLifecycleManager to separate the user interface-related behavior from the business behavior by using a controller to handle the business part. The controller should implement 
			<code>org.eclipse.eef.core.api.controllers.IEEFController</code> in order to perform basic task in a similar fashion as other controllers. There are several abstract classes available in order to build a new controller quite easily:
		</p>
		<ul>
			<li>
				<code>org.eclipse.eef.core.api.controllers.AbstractEEFController</code>
			</li>
			<li>
				<code>org.eclipse.eef.core.api.controllers.AbstractEEFWidgetController</code>
			</li>
			<li>
				<code>org.eclipse.eef.core.api.controllers.AbstractEEFCustomWidgetController</code>
			</li>
		</ul>
		<p>The AbstractEEFController provides support for the validation and the refresh. The AbstractEEFWidgetController, which extends the AbstractEEFController, adds support for the refresh of the label and the help of the widgets and finally the AbstractEEFCustomWidgetController, which extends the AbstractEEFWidgetController, adds on top of that utility methods for the execution of command expressions.</p>
		<pre><code>package org.eclipse.eef.sample.internal.extensions;

import org.eclipse.eef.EEFControlDescription;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManager;
import org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManagerProvider;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;

public class SampleLifecycleManagerProvider implements IEEFLifecycleManagerProvider {

    private static final String DESCRIPTION_IDENTIFIER = "org.eclipse.eef.sample.customwidget";

    @Override
    public boolean canHandle(EEFControlDescription controlDescription) {
        // Only handle the control with our description
        return DESCRIPTION_IDENTIFIER.equals(controlDescription.getIdentifier());
    }

    @Override
    public IEEFLifecycleManager getLifecycleManager(EEFControlDescription controlDescription, IVariableManager variableManager, IInterpreter interpreter, EditingContextAdapter contextAdapter) {
        // Returns a lifecycle manager for the control supported
        return new SampleLifecycleManager(controlDescription, variableManager, interpreter, contextAdapter);
    }

}
</code></pre>
		<p>This example requires at least the following dependencies:</p>
		<ul>
			<li>org.eclipse.sirius.common.interpreter</li>
			<li>org.eclipse.eef</li>
			<li>org.eclipse.eef.core</li>
			<li>org.eclipse.eef.ide.ui</li>
		</ul>
		<h3 id="eeftabdescriptorprovider">IEEFTabDescriptorProvider</h3>
		<p>This extension point allows the contribution of an 
			<code>org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManagerProvider</code> which can be used to create an instance of 
			<code>org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManager</code> for the description of some controls. With this mechanism, you can not only provide the compulsory lifecycle manager of a custom widget but you can also replace the default lifecycle manager of any widget or container which gives you the ability to change the behavior and appearance of each part of the user interface (excluding groups and pages).
		</p>
		<pre><code>&lt;extension
      point="org.eclipse.eef.properties.ui.eefTabDescriptorProvider"&gt;
   &lt;descriptor
         class="org.eclipse.eef.sample.internal.extensions.SampleTabDescriptorProvider"
         description="Provides EEF Tab descriptors"
         id="org.eclipse.eef.sample.eefTabDescriptorProvider"
         label="EEF Sample Tab Descriptor Provider"&gt;
   &lt;/descriptor&gt;
&lt;/extension&gt;
</code></pre>
		<p>Example of IEEFTabDescriptorProvider contribution. In this example, we are providing a contribution used to add new tabs to the Properties view created by EEF. In order to link an editor with the EEF-based Properties view, you will first need to use the method org.eclipse.core.runtime.IAdaptable.getAdapter(Class) of your editor to return an EEF-based property sheet page.</p>
		<pre><code>@Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class type) {
    if (type == IPropertySheetPage.class) {
        // Must be unique for your editor, should be stored in a static constant
        String contributorId = "org.eclipse.eef.sample.contributorId";
        return new EEFTabbedPropertySheetPage(type, contributorId);
    }

    return super.getAdapter(type);
}
</code></pre>
		<p>Once the Eclipse platform has retrieved this EEF-based tabbed property sheet page, EEF will look for the list of tabs to display in this property view using all its IEEFTabDescriptorProvider. Here is an implementation of an example:</p>
		<pre><code>package org.eclipse.eef.sample.internal.extensions;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.eclipse.eef.EEFViewDescription;
import org.eclipse.eef.core.api.EEFExpressionUtils;
import org.eclipse.eef.core.api.EEFPage;
import org.eclipse.eef.core.api.EEFView;
import org.eclipse.eef.core.api.EEFViewFactory;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.ide.ui.properties.api.EEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorProvider;
import org.eclipse.eef.properties.ui.api.IEEFTabbedPropertySheetPageContributor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
import org.eclipse.sirius.common.interpreter.api.VariableManagerFactory;
import org.eclipse.ui.IWorkbenchPart;

public class SampleTabDescriptorProvider implements IEEFTabDescriptorProvider {

    @Override
    public Collection&lt;IEEFTabDescriptor&gt; get(IWorkbenchPart part, ISelection selection, IEEFTabbedPropertySheetPageContributor contributor) {
        if (selection instanceof IStructuredSelection) {
            IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            Object[] objects = structuredSelection.toArray();

            // We will first retrieve the description of the user interface
            EEFViewDescription viewDescription = this.getViewDescription(objects);
            EEFView eefView = this.createEEFView(viewDescription, objects);

            List&lt;IEEFTabDescriptor&gt; descriptors = new ArrayList&lt;IEEFTabDescriptor&gt;();
            List&lt;EEFPage&gt; eefPages = eefView.getPages();
            for (EEFPage eefPage : eefPages) {
                descriptors.add(new EEFTabDescriptor(eefPage));
            }
            return descriptors;
        }
        return new ArrayList&lt;IEEFTabDescriptor&gt;();
    }

    private EEFViewDescription getViewDescription(Object object) {
        // Programmatically create the description of the view or load it from an EMF model
        return null;
    }

    private EEFView createEEFView(EEFViewDescription viewDescription, Object object) {
        IVariableManager variableManager = new VariableManagerFactory().createVariableManager();
        variableManager.put(EEFExpressionUtils.SELF, object);
        
        // See the documentation regarding the interpreter and the editing context adapter
        EEFView eefView = new EEFViewFactory().createEEFView(viewDescription, variableManager, new SampleInterpreter(), new SampleEditingContextAdapter(), object);
        return eefView;
    }
}
</code></pre>
		<p>This example requires at least the following dependencies:</p>
		<ul>
			<li>org.eclipse.sirius.common.interpreter</li>
			<li>org.eclipse.eef</li>
			<li>org.eclipse.eef.core</li>
			<li>org.eclipse.eef.ide.ui.properties</li>
			<li>org.eclipse.eef.properties.ui</li>
			<li>org.eclipse.ui.workbench</li>
			<li>org.eclipse.jface</li>
		</ul>
		<h3 id="eeftabdescriptorfilter">IEEFTabDescriptorFilter</h3>
		<p>This extension point allows to filter tabs contributed to the EEF tabbed property sheet page by implementing org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter.</p>
		<pre><code>&lt;extension
      point="org.eclipse.eef.properties.ui.eefTabDescriptorFilter"&gt;
   &lt;descriptor
         class="org.eclipse.eef.sample.internal.extensions.SampleTabDescriptorFilter"
         description="Provides EEF Tab filter"
         id="org.eclipse.eef.sample.eefTabDescriptorFilter"
         label="EEF Sample Tab Descriptor Filter"&gt;
   &lt;/descriptor&gt;
&lt;/extension&gt;
</code></pre>
		<p>Example of IEEFTabDescriptorFilter contribution. In this example, we are providing a contribution used to filter legacy tabs to the Properties view created by EEF.</p>
		<pre><code>import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter;

public class SampleTabDescriptorFilter implements IEEFTabDescriptorFilter {

    @Override
    public boolean filter(IEEFTabDescriptor tabDescriptor) {
     // Write here a useful condition
        return false;
    }

}
</code></pre>
		<p>This example requires at least the following dependencies:</p>
		<ul>
			<li>org.eclipse.eef.common</li>
			<li>org.eclipse.eef.properties.ui</li>
		</ul>
		<h3 id="eefextreferenceviewerfilterprovider">IEEFExtReferenceViewerFilterProvider</h3>
		<p>This extension point allows the contribution of an org.eclipse.eef.ide.ui.ext.widgets.reference.api.IEEFExtReferenceViewerFilterProvider which can be used to filter the content of the tree viewers used to display the objects that can be selected and where an object can be created using the reference widget.</p>
		<pre><code>&lt;extension
      point="org.eclipse.eef.ide.ui.ext.widgets.reference.eefExtReferenceViewerFilterProvider"&gt;
    &lt;descriptor
          class="org.eclipse.sirius.ui.properties.ext.widgets.reference.internal.EEFExtReferenceViewerFilterProvider"
          description="%viewerFilterProvider.Description"
          id="org.eclipse.sirius.ui.properties.ext.widgets.reference.viewerFilterProvider"
          label="%viewerFilterProvider.Label"&gt;
    &lt;/descriptor&gt;
&lt;/extension&gt;
</code></pre>
		<p>Example of the contribution of a viewer filter provider. This contribution will let a plugin filter the content displayed in the tree viewers used to show where a new value can be created and which value can be selected for a reference. Eclipse Sirius provides the following basic implementation which is used to filter everything not contained in a semantic resource:</p>
		<pre><code>import java.util.ArrayList;
import java.util.List;

import org.eclipse.eef.ide.ui.ext.widgets.reference.api.IEEFExtReferenceViewerFilterProvider;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;


public class EEFExtReferenceViewerFilterProvider implements IEEFExtReferenceViewerFilterProvider {

    @Override
    public List&lt;ViewerFilter&gt; getViewerFilters(ContextKind contextKind) {
        List&lt;ViewerFilter&gt; viewerFilters = new ArrayList&lt;&gt;();

        ViewerFilter viewFilter = new ViewerFilter() {
            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                // Used to filter aird, odesign, etc
                if (element instanceof Resource) {
                    Session session = SessionManager.INSTANCE.getSession((Resource) element);
                    return session != null;
                }
                return true;
            }
        };

        viewerFilters.add(viewFilter);
        return viewerFilters;
    }

}
</code></pre>
		<p>This example requires at least the following dependencies:</p>
		<ul>
			<li>org.eclipse.eef.ide.ui.ext.widgets.reference</li>
			<li>org.eclipse.emf.ecore</li>
			<li>org.eclipse.jface.viewers</li>
			<li>org.eclipse.sirius</li>
		</ul>
	</body>
</html>

Back to the top