platform-core-home/documents/plan_adapters.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : johna 1.1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 :     <html>
3 :     <head>
4 :     <title>Eclipse 3.0 adapter issues</title>
5 :     <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
6 :     </head>
7 :     <body text="#000000" bgcolor="#FFFFFF">
8 :    
9 :     <h1>Eclipse 3.0 adapter issues</h1>
10 :     <font size="-1">Last modified: February 16, 2004</font>
11 :     <p>
12 :     This document outlines proposed changes in the 3.0 timeframe to the
13 :     <tt>IAdapterManager</tt> infrastructure. Related bug reports contain
14 :     much of the rationale and discussion:
15 :     </p>
16 :     <ul>
17 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=32498">bug 32498 - Support to contribute adapter factory via XML</a></li>
18 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=32436">bug 32436 - Using adapters to filter UI selections without loading plugins</a></li>
19 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=30577">bug 30577 - Actions should check for IAdaptable#getAdapter(IJavaElement.class)</a></li>
20 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=36968">bug 36968 - [Plan Item] Improve action contributions</a></li>
21 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=37937">bug 37937 - [plan item] Support Java references outside Java code</a></li>
22 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=29809">bug 29809 - Rename/Delete Action hooks [refactoring]</a></li>
23 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=29809">bug 29809 - Rename/Delete Action hooks [refactoring]</a></li>
24 :     <li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=29809">bug 29809 - Rename/Delete Action hooks [refactoring]</a></li>
25 :     </ul>
26 :     <h3>Current limitations</h3>
27 :     <ul>
28 :     <li>Nothing is known about an adapter factory until the plugin that provides the
29 :     adapter is loaded. This makes it difficult to calculate if an action contribution
30 :     or refactoring participant may potentially be applicable for a given selection until
31 :     it is executed.</li>
32 :     <li>The current API only supports returning a single adapter for a given adaptable
33 :     type. For example, only one factory is allowed to adapt IFile to IPropertySource.
34 :     In some contexts, it is appropriate to obtain all possible adapters on a type. Several
35 :     plug-ins may want to supply an IPropertySource or an IActionFilter for IFile.
36 :     </li>
37 :     </ul>
38 :     <h3>Proposed solution</h3>
39 :     <p>
40 :     Add the following three new methods to IAdapterManager:<br>
41 :     <pre>
42 :     public boolean hasAdapter(Object adaptable, String adapterTypeName);
43 :     public Object getAdapter(Object adaptable, String adapterTypeName);
44 :     public Object[] getAdapters(Object adaptable, String adapterTypeName);
45 :     </pre>
46 :     </p>
47 :     <p>
48 :     <tt>getAdapter</tt> returns the first non-null adapter found as it does today (transitive
49 :     search of superclasses and then super-interfaces). <tt>getAdapters</tt> returns all adapters
50 :     for all superclasses and interfaces of the supplied object. Only factories belonging
51 :     to loaded plug-ins will be consulted by the <tt>getAdapter*</tt> methods. <tt>hasAdapter</tt> consults
52 :     both loaded and unloaded factories.
53 :     </p>
54 :     <p>
55 : johna 1.2 A new "adapters" extension in the runtime plug-in will specify the name of the factory
56 :     class, removing the need for plug-ins to explicitly register their adapters on startup
57 :     (they would be lazily registered on the first lookup on that factory after the plug-in is loaded):
58 : johna 1.1 <pre>
59 :     &lt;extension point=&quot;org.eclipse.core.runtime.adapters&quot;&gt;
60 :     &lt;factory
61 :     class=&quot;org.eclipse.jdt.internal.ui.JavaElementAdapterFactory&quot;
62 :     adaptableType=&quot;org.eclipse.jdt.core.IJavaElement&quot;&gt;
63 :     &lt;adapter class=&quot;org.eclipse.core.resources.IFile&quot;&gt;
64 :     &lt;adapter class=&quot;org.eclipse.ui.views.IPropertySource&quot;&gt;
65 :     &lt;adapter class=&quot;org.eclipse.ui.model.IWorkbenchAdapter&quot;&gt;
66 :     ...
67 :     &lt;/factory&gt;
68 :     &lt;/extension&gt;
69 :     </pre>
70 :     </p>
71 :     <p>
72 : johna 1.2 This extension point specifies a factory that adapts IJavaElement to IFile, IPropertySource, etc.
73 : johna 1.1 Of course, for backwards compatibility we will continue to support adapters
74 :     registered manually that do no have associated markup.
75 :     </p>
76 :    
77 :    
78 :    
79 :    
80 :    
81 :    
82 :    
83 :     </body>
84 :     </html>