platform-ui-home/object-aware-contributions/objCont.htm
Parent Directory
|
Revision Log
Revision 1.3 - (view) (download) (as text)
| 1 : | tod | 1.1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 : | <html> | ||
| 3 : | <head> | ||
| 4 : | <title>Untitled Document</title> | ||
| 5 : | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
| 6 : | </head> | ||
| 7 : | |||
| 8 : | <body> | ||
| 9 : | <h1>Content Sensitive Object Contributions</h1> | ||
| 10 : | dwilson | 1.3 | <p><em>Last modified June 14, 2004</em></p> |
| 11 : | tod | 1.1 | <p>Context menus for some applications have previously only been able to exclude |
| 12 : | some menu options based on peripheral information known about the resources | ||
| 13 : | selected (the number of resources selected, the physical name of the file, the | ||
| 14 : | type of the resource, etc.). There are some cases where a restricted amount | ||
| 15 : | dwilson | 1.2 | of information known about the contents of the resource would significantly |
| 16 : | reduce unusable options from the menus. Consider XML files as a good example | ||
| 17 : | of where such information would be useful. There are numerous situations where | ||
| 18 : | an action is applicable for one type of XML file but not another. For example, | ||
| 19 : | some XML files contain Ant scripts. The action "Run Ant..." makes | ||
| 20 : | sense in its context menu. But this action is not applicable to an XML file | ||
| 21 : | used to define a plug-in.</p> | ||
| 22 : | <p>The notion of a content type has been added to Eclipse. A new extension point, | ||
| 23 : | org.eclipse.core.runtime.contentTypes allows plug-ins to contribute to the Platform | ||
| 24 : | content type catalog. Further, classes called Content Type Describers have been | ||
| 25 : | added.</p> | ||
| 26 : | dwilson | 1.3 | <p>For developers providing their own content types, two customizable, built-in |
| 27 : | content type describers are available: BinarySignatureDescriber (for binary | ||
| 28 : | content types) and XMLRootElementContentDescriber (for text, XML based content | ||
| 29 : | types). Plug-in providers may create their own content describers. The Platform | ||
| 30 : | Plug-in Developer Guide (Programmer's Guide -> Runtime overview -> Content | ||
| 31 : | types) describes this in more detail.</p> | ||
| 32 : | dwilson | 1.2 | <h3>XMLRootElementContentDescriber</h3> |
| 33 : | tod | 1.1 | <p>It will now be possible to define object contributions which are specific to |
| 34 : | dwilson | 1.2 | an XML file with a given top level tag or which specify a given DTD. To do this, |
| 35 : | define an extension to the org.eclipse.core.runtime.contentTypes extension point | ||
| 36 : | with a describer class of XMLRootElementContentDescriber and parameters indicating | ||
| 37 : | the top level tag name or the dtd name as follows:</p> | ||
| 38 : | <pre> <extension | ||
| 39 : | point="org.eclipse.core.runtime.contentTypes"> | ||
| 40 : | <content-type | ||
| 41 : | id=<id> | ||
| 42 : | name=<name> | ||
| 43 : | base-type="org.eclipse.core.runtime.xml"> | ||
| 44 : | <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber"> | ||
| 45 : | <parameter name="element" value=<em>tagValue</em> /> | ||
| 46 : | </describer> | ||
| 47 : | </content-type> | ||
| 48 : | </extension></pre> | ||
| 49 : | or | ||
| 50 : | <pre> <extension | ||
| 51 : | point="org.eclipse.core.runtime.contentTypes"> | ||
| 52 : | <content-type | ||
| 53 : | id=<id> | ||
| 54 : | name=<name> | ||
| 55 : | base-type="org.eclipse.core.runtime.xml"> | ||
| 56 : | <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber"> | ||
| 57 : | <parameter name="dtd" value=<em>dtdValue</em> /> | ||
| 58 : | </describer> | ||
| 59 : | </content-type> | ||
| 60 : | </extension></pre> | ||
| 61 : | |||
| 62 : | tod | 1.1 | <blockquote> |
| 63 : | <p><font size="3">where <em>tagValue</em> represents the name of the top level | ||
| 64 : | tag to match and</font></p> | ||
| 65 : | <p><font size="3"><em>dtdValue</em> represents the name of the DTD as seen in | ||
| 66 : | the XML file.</font></p> | ||
| 67 : | </blockquote> | ||
| 68 : | <p><font size="3">Consider the following object contribution in a plugin.xml file:</font></p> | ||
| 69 : | dwilson | 1.2 | <pre> <extension |
| 70 : | point="org.eclipse.core.runtime.contentTypes"> | ||
| 71 : | <content-type | ||
| 72 : | id="topElementContentType" | ||
| 73 : | name="Tests top-level element recognition" | ||
| 74 : | base-type="org.eclipse.core.runtime.xml" | ||
| 75 : | priority="high"> | ||
| 76 : | <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber"> | ||
| 77 : | <parameter name="element" value="myTag" /> | ||
| 78 : | </describer> | ||
| 79 : | </content-type> | ||
| 80 : | </extension> | ||
| 81 : | |||
| 82 : | <extension | ||
| 83 : | point="org.eclipse.core.runtime.contentTypes"> | ||
| 84 : | <content-type | ||
| 85 : | id="dtdContentType" | ||
| 86 : | name="Tests dtd element recognition" | ||
| 87 : | base-type="org.eclipse.core.runtime.xml" | ||
| 88 : | priority="high"> | ||
| 89 : | <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber"> | ||
| 90 : | <parameter name="dtd" value="myDTD.xml" /> | ||
| 91 : | </describer> | ||
| 92 : | </content-type> | ||
| 93 : | </extension> | ||
| 94 : | </pre> | ||
| 95 : | <pre> <extension point="org.eclipse.ui.popupMenus"> | ||
| 96 : | <objectContribution | ||
| 97 : | id="org.eclipse.ui.examples.objectContributions" | ||
| 98 : | objectClass="org.eclipse.core.resources.IFile" | ||
| 99 : | nameFilter="*.xml"> | ||
| 100 : | <visibility> | ||
| 101 : | <or> | ||
| 102 : | <objectState | ||
| 103 : | name="contentTypeId" | ||
| 104 : | value="org.eclipse.ui.examples.topElementContentType"/> | ||
| 105 : | <objectState | ||
| 106 : | name="contentTypeId" | ||
| 107 : | value="org.eclipse.ui.examples.dtdContentType"/> | ||
| 108 : | </or> | ||
| 109 : | </visibility> | ||
| 110 : | <action id="org.eclipse.ui.examples.objectContributions.action1" | ||
| 111 : | label="%PopupMenus.action" | ||
| 112 : | icon="icons/ctool16/openbrwsr.gif" | ||
| 113 : | menubarPath="additions" | ||
| 114 : | class="org.eclipse.ui.examples.objectContributions.PopupMenuActionDelegate" | ||
| 115 : | enablesFor="1"> | ||
| 116 : | </action> | ||
| 117 : | </objectContribution> | ||
| 118 : | </extension></pre> | ||
| 119 : | tod | 1.1 | <p>This will make action1 visible for any IFile with a name matching *.xml provided |
| 120 : | it contains myTag as the top level XML tag or it uses the DTD called myDTD.xml. | ||
| 121 : | So the following XML files will match:</p> | ||
| 122 : | dwilson | 1.2 | <blockquote> |
| 123 : | tod | 1.1 | <pre><?xml version="1.0" encoding="UTF-8"?> |
| 124 : | <myTag | ||
| 125 : | id="org.eclipse.ui.workbench" | ||
| 126 : | name="%pluginName" | ||
| 127 : | version="3.0.0" | ||
| 128 : | provider-name="%providerName" | ||
| 129 : | class="org.eclipse.ui.internal.WorkbenchPlugin"> | ||
| 130 : | </myTag></pre> | ||
| 131 : | <p>Or</p> | ||
| 132 : | <pre> | ||
| 133 : | <?xml version="1.0" encoding="UTF-8"?> | ||
| 134 : | <!DOCTYPE Book SYSTEM "myDTD.xml"> | ||
| 135 : | <fragment | ||
| 136 : | id="org.eclipse.ui.workbench" | ||
| 137 : | name="%pluginName" | ||
| 138 : | version="3.0.0" | ||
| 139 : | provider-name="%providerName" | ||
| 140 : | class="org.eclipse.ui.internal.WorkbenchPlugin"> | ||
| 141 : | <runtime> | ||
| 142 : | <library name="workbench.jar"> | ||
| 143 : | <export name="*"/> | ||
| 144 : | <packages prefixes="org.eclipse.ui, org.eclipse.jface"/> | ||
| 145 : | </library> | ||
| 146 : | </runtime> | ||
| 147 : | dwilson | 1.2 | </fragment> |
| 148 : | </pre> | ||
| 149 : | tod | 1.1 | </blockquote> |
| 150 : | dwilson | 1.2 | <h3>BinarySignatureDescriber</h3> |
| 151 : | The BinarySignatureDescriber is a content describer to detect a specified binary | ||
| 152 : | 'signature' at a given offset within a file. This describer is used in the same | ||
| 153 : | fashion as the XMLRootElementContentDescriber with the exception that it takes | ||
| 154 : | parameters "signature", "offset" and "required" | ||
| 155 : | instead of "element" or "dtd". The Javadoc for BinarySignatureDescriber | ||
| 156 : | gives complete details on this content describer's class usage. | ||
| 157 : | tod | 1.1 | </body> |
| 158 : | </html> |
| help@eclipse.org | ViewVC Help |
| Powered by ViewVC 1.0.3 |
