Eclipse org.eclipse.compare plug-in

时间:2023-01-15 12:59:24

Plug-in metedata tell eclipse runtime kernel how to create a expected object and set its perperties, 

and assign these objects to defined interfce object, make these interface objects 

communicate with each other.

Eclipse org.eclipse.compare plug-in

org.eclipse.compare/plugin.xml

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <?eclipse version="3.0"?>
  3 
  4 <plugin>
  5 <!-- Compare extension point definitions -->
  6    <extension-point id="streamMergers" name="%streamMergers" schema="schema/streamMergers.exsd"/>
  7    <extension-point id="structureCreators" name="%structureCreators" schema="schema/structureCreators.exsd"/>
  8    <extension-point id="structureMergeViewers" name="%structureMergeViewers" schema="schema/structureMergeViewers.exsd"/>
  9    <extension-point id="contentMergeViewers" name="%contentMergeViewers" schema="schema/contentMergeViewers.exsd"/>
 10    <extension-point id="contentViewers" name="%contentViewers" schema="schema/contentViewers.exsd"/>
 11 <!-- Extensions -->
 12    <extension
 13          point="org.eclipse.ui.themes">
 14       <themeElementCategory
 15             label="%textCompareAppearance.label"
 16             id="org.eclipse.compare.contentmergeviewer.TextMergeViewer">
 17       </themeElementCategory>
 18       <colorDefinition
 19             label="%compareIncomingColor.label"
 20             categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
 21             value="COLOR_BLUE"
 22             id="INCOMING_COLOR">
 23          <description>
 24             %compareIncomingColor.description
 25          </description>
 26       </colorDefinition>
 27       <colorDefinition
 28             label="%compareOutgoingColor.label"
 29             categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
 30             value="COLOR_BLACK"
 31             id="OUTGOING_COLOR">
 32          <description>
 33             %compareOutgoingColor.description
 34          </description>
 35       </colorDefinition>
 36       <colorDefinition
 37             label="%compareConflictColor.label"
 38             categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
 39             value="COLOR_RED"
 40             id="CONFLICTING_COLOR">
 41          <description>
 42             %compareConflictColor.description
 43          </description>
 44       </colorDefinition>
 45       <colorDefinition
 46             label="%compareResolvedColor.label"
 47             categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
 48             value="COLOR_GREEN"
 49             id="RESOLVED_COLOR">
 50          <description>
 51             %compareResolvedColor.description
 52          </description>
 53       </colorDefinition>
 54       <fontDefinition
 55             label="%compareFontDefiniton.label"
 56             defaultsTo="org.eclipse.jface.textfont"
 57             categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
 58             id="org.eclipse.compare.contentmergeviewer.TextMergeViewer">
 59           <description>
 60             %compareFontDefiniton.description
 61          </description>
 62       </fontDefinition>
 63    </extension>   
 64    <extension
 65          id="rejectedPatchMarker"
 66          name="%rejectedPatchMarker.name"
 67          point="org.eclipse.core.resources.markers">
 68       <super
 69             type="org.eclipse.core.resources.taskmarker">
 70       </super>
 71       <persistent
 72             value="true">
 73       </persistent>
 74    </extension>
 75    <extension
 76          point="org.eclipse.ui.editors">
 77       <editor
 78             name="%defaultCompareEditor.name"
 79             icon="$nl$/icons/full/eview16/compare_view.gif"
 80             contributorClass="org.eclipse.compare.internal.CompareEditorContributor"
 81             class="org.eclipse.compare.internal.CompareEditor"
 82             id="org.eclipse.compare.CompareEditor">
 83       </editor>
 84    </extension>   
 85    <extension
 86          point="org.eclipse.ui.preferencePages">
 87       <page
 88             name="%ComparePreferencePage.name"
 89             category="org.eclipse.ui.preferencePages.Workbench"
 90             class="org.eclipse.compare.internal.ComparePreferencePage"
 91             id="org.eclipse.compare.internal.ComparePreferencePage">
 92             <keywordReference id="org.eclipse.compare.general"/>
 93       </page>
 94    </extension>   
 95     <extension
 96         point="org.eclipse.ui.keywords">
 97         <keyword
 98             label="%preferenceKeywords.general"
 99             id="org.eclipse.compare.general"/>
100     </extension>   
101 <!-- commands and their bindings -->
102    <extension
103          point="org.eclipse.ui.contexts">
104       <context
105             name="%context.name"
106             description="%context.description"
107             parentId="org.eclipse.ui.contexts.window"
108             id="org.eclipse.compare.compareEditorScope">
109       </context>
110    </extension>   
111    <extension
112          point="org.eclipse.ui.commands">
113       <category
114             name="%compareCategory.name"
115             description="%compareCategory.description"
116             id="org.eclipse.compare.ui.category.compare">
117       </category>
118       <command
119             name="%Command.copyRightToLeft.name"
120             description="%Command.copyRightToLeft.description"
121             categoryId="org.eclipse.compare.ui.category.compare"
122             id="org.eclipse.compare.copyRightToLeft">
123       </command>
124       <command
125             name="%Command.copyLeftToRight.name"
126             description="%Command.copyLeftToRight.description"
127             categoryId="org.eclipse.compare.ui.category.compare"
128             id="org.eclipse.compare.copyLeftToRight">
129       </command>
130       <command
131             name="%Command.copyAllRightToLeft.name"
132             description="%Command.copyAllRightToLeft.description"
133             categoryId="org.eclipse.compare.ui.category.compare"
134             id="org.eclipse.compare.copyAllRightToLeft">
135       </command>
136       <command
137             name="%Command.copyAllLeftToRight.name"
138             description="%Command.copyAllLeftToRight.description"
139             categoryId="org.eclipse.compare.ui.category.compare"
140             id="org.eclipse.compare.copyAllLeftToRight">
141       </command>
142       <command
143             name="%Command.selectNextChange.name"
144             description="%Command.selectNextChange.description"
145             categoryId="org.eclipse.compare.ui.category.compare"
146             id="org.eclipse.compare.selectNextChange">
147       </command>
148       <command
149             name="%Command.selectPreviousChange.name"
150             description="%Command.selectPreviousChange.description"
151             categoryId="org.eclipse.compare.ui.category.compare"
152             id="org.eclipse.compare.selectPreviousChange">
153       </command>
154       <command
155             categoryId="org.eclipse.compare.ui.category.compare"
156             description="%Command.ignoreWhiteSpace.description"
157             id="org.eclipse.compare.ignoreWhiteSpace"
158             name="%Command.ignoreWhiteSpace.name">
159       </command>
160       <command
161             categoryId="org.eclipse.compare.ui.category.compare"
162             defaultHandler="org.eclipse.compare.internal.CompareWithOtherResourceHandler"
163             description="%Command.compareWithOther.description"
164             id="org.eclipse.compare.compareWithOther"
165             name="%Command.compareWithOther.name">
166       </command>
167    </extension>   
168    <extension
169          point="org.eclipse.ui.popupMenus">
170       <objectContribution
171             objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
172             adaptable="true"
173             id="org.eclipse.compare.MenuGroups">
174          <menu
175                label="%ReplaceWithMenu.label"
176                path="additions"
177                id="replaceWithMenu">
178             <separator
179                   name="replaceWithGroup">
180             </separator>
181          </menu>
182          <menu
183                label="%CompareWithMenu.label"
184                path="additions"
185                id="compareWithMenu">
186             <separator
187                   name="compareWithGroup">
188             </separator>
189          </menu>
190       </objectContribution>
191       <objectContribution
192             objectClass="org.eclipse.core.resources.IResource"
193             adaptable="true"
194             id="org.eclipse.compare.CompareAction">
195          <action
196                label="%CompareWithEachOtherAction.label"
197                tooltip="%CompareWithEachOtherAction.tooltip"
198                class="org.eclipse.compare.internal.CompareAction"
199                menubarPath="compareWithMenu/compareWithGroup"
200                enablesFor="2+"
201                id="compareWithEachOther">
202          </action>
203       </objectContribution>
204       <objectContribution
205             objectClass="org.eclipse.core.resources.IFile"
206             adaptable="true"
207             id="org.eclipse.compare.ReplaceWithEditionAction">
208          <menu
209                label="%ReplaceWithMenu.label"
210                path="additions"
211                id="replaceWithMenu">
212             <separator
213                   name="replaceWithGroup">
214             </separator>
215          </menu>
216          <action
217                class="org.eclipse.compare.internal.ReplaceWithEditionAction"
218                enablesFor="1"
219                helpContextId="org.eclipse.compare.replace_with_edition_action_context"
220                id="replaceFromHistory"
221                label="%ReplaceFromHistoryAction.label"
222                menubarPath="replaceWithMenu/replaceWithGroup"
223                tooltip="%ReplaceFromHistoryAction.tooltip">
224          </action>
225          <action
226                label="%ReplaceWithPreviousFromHistoryAction.label"
227                tooltip="%ReplaceWithPreviousFromHistoryAction.tooltip"
228                class="org.eclipse.compare.internal.ReplaceWithPreviousEditionAction"
229                menubarPath="replaceWithMenu/replaceWithGroup"
230                enablesFor="1"
231                id="replaceWithPreviousFromHistory">
232          </action>
233       </objectContribution>
234       <objectContribution
235             objectClass="org.eclipse.core.resources.IFile"
236             adaptable="true"
237             id="org.eclipse.compare.CompareWithEditionAction">
238          <menu
239                label="%CompareWithMenu.label"
240                path="additions"
241                id="compareWithMenu">
242             <separator
243                   name="compareWithGroup">
244             </separator>
245          </menu>
246          <action
247                label="%CompareWithHistoryAction.label"
248                tooltip="%CompareWithHistoryAction.tooltip"
249                class="org.eclipse.compare.internal.CompareWithEditionAction"
250                menubarPath="compareWithMenu/compareWithGroup"
251                enablesFor="1"
252                id="compareWithHistory">
253          </action>
254       </objectContribution>
255       <objectContribution
256             objectClass="org.eclipse.core.resources.IContainer"
257             adaptable="true"
258             id="org.eclipse.compare.AddFromHistoryAction">
259          <action
260                label="%addFromHistoryAction.label"
261                tooltip="%addFromHistoryAction.tooltip"
262                class="org.eclipse.compare.internal.AddFromHistoryAction"
263                menubarPath="replaceWithMenu"
264                enablesFor="1"
265                id="addFromHistoryAction">
266          </action>
267       </objectContribution>
268    </extension>   
269    <extension
270          point="org.eclipse.compare.streamMergers">
271       <streamMerger
272             extensions="txt"
273             class="org.eclipse.compare.internal.merge.TextStreamMerger"
274             id="org.eclipse.compare.internal.merge.TextStreamMerger">
275       </streamMerger>
276       <contentTypeBinding
277               contentTypeId="org.eclipse.core.runtime.text"
278               streamMergerId="org.eclipse.compare.internal.merge.TextStreamMerger">
279       </contentTypeBinding>
280    </extension>
281    
282    <extension
283          point="org.eclipse.compare.structureCreators">
284       <structureCreator
285             extensions="zip"
286             class="org.eclipse.compare.ZipFileStructureCreator"
287             id="org.eclipse.compare.ZipFileStructureCreator">
288       </structureCreator>
289    </extension>   
290    <extension
291          point="org.eclipse.compare.contentMergeViewers">
292       <viewer
293             class="org.eclipse.compare.internal.BinaryCompareViewerCreator"
294             extensions="class,exe,dll,binary,zip,jar"
295             id="org.eclipse.compare.BinaryCompareViewerCreator"
296             label="%BinaryCompare.label">
297       </viewer>
298       <viewer
299             class="org.eclipse.compare.internal.TextMergeViewerCreator"
300             extensions="txt"
301             id="org.eclipse.compare.TextMergeViewerCreator"
302             label="%TextCompare.label">
303       </viewer>
304       <viewer
305             class="org.eclipse.compare.internal.ImageMergeViewerCreator"
306             extensions="gif,jpg,jpeg,png,bmp,ico,tif,tiff"
307             id="org.eclipse.compare.ImageMergeViewerCreator"
308             label="%ImageCompare.label">
309       </viewer>
310       <contentTypeBinding
311             contentTypeId="org.eclipse.core.runtime.text"
312             contentMergeViewerId="org.eclipse.compare.TextMergeViewerCreator">
313       </contentTypeBinding>
314    </extension>   
315    <extension
316          point="org.eclipse.compare.contentViewers">
317       <viewer
318             extensions="txt"
319             class="org.eclipse.compare.internal.TextViewerCreator"
320             id="org.eclipse.compare.TextViewerCreator">
321       </viewer>
322       <contentTypeBinding
323             contentTypeId="org.eclipse.core.runtime.text"
324             contentViewerId="org.eclipse.compare.TextViewerCreator">
325       </contentTypeBinding>
326    </extension>
327    <extension
328          point="org.eclipse.core.runtime.preferences">
329       <initializer
330             class="org.eclipse.compare.internal.ComparePreferenceInitializer">
331       </initializer>
332    </extension>
333    <extension
334          point="org.eclipse.core.runtime.adapters">
335       <factory
336             adaptableType="org.eclipse.compare.CompareEditorInput"
337             class="org.eclipse.compare.internal.AdapterFactory">
338          <adapter
339                type="org.eclipse.ui.IContributorResourceAdapter">
340          </adapter>
341       </factory>
342    </extension>
343 </plugin>
  • The description of extension-point which is contributed to other plug-ins.
  • 1 <extension-point id="streamMergers" name="%streamMergers" schema="schema/streamMergers.exsd"/>

    <extension-point> define a extension which can be as a extension point for other plug-in. Provide the features for other plug-ins.Now you can find detailed information of the StreamMergers provided by org.eclipse.compare plug-in as follows:

  •  1 public interface IStreamMerger {
     2     public static final int OK= IStatus.OK;      
     3     public static final int CONFLICT= 1;
     4     public static final int INTERNAL_ERROR= 2;
     5     IStatus merge(OutputStream output, String outputEncoding,
     6                   InputStream ancestor, String ancestorEncoding,
     7                   InputStream target, String targetEncoding,
     8                   InputStream other, String otherEncoding,
     9                   IProgressMonitor monitor);
    10 }
  • Stream Merger
    Identifier: org.eclipse.compare.streamMergers
    Since: 3.0 
    Description: This extension point allows a plug-in to register a stream merger for specific content types. The stream merger is expected to perform a three-way merge on three input streams and writes the result to an output stream. The extension point must implement the interface org.eclipse.compare.IStreamMerger.
    Configuration Markup:
    <!ELEMENT extension (streamMerger* , contentTypeBinding*)>
    <!ATTLIST extension
    point CDATA #REQUIRED
    id    CDATA #IMPLIED
    name  CDATA #IMPLIED
    >
    point - a fully qualified identifier of the target extension point 
    id - an optional identifier of the extension instance 
    name - an optional name of the extension instance 
    
    <!ELEMENT streamMerger EMPTY>
    <!ATTLIST streamMerger
    id         CDATA #REQUIRED
    class      CDATA #REQUIRED
    extensions CDATA #IMPLIED
    >
    id - a unique identifier that can be used to reference the stream merger 
    class - a fully qualified name of a class that implements org.eclipse.compare.IStreamMerger 
    extensions - a comma separated list of file extensions e.g. "java, properties" 
    <!ELEMENT contentTypeBinding EMPTY>
    <!ATTLIST contentTypeBinding
    contentTypeId  IDREF #REQUIRED
    streamMergerId IDREF #REQUIRED
    >
    A contentTypeBinding binds a stream merger to a content type.
    contentTypeId - The id of a content type defined using the org.eclipse.core.contenttype.contentTypes extension point. 
    streamMergerId - The id of a stream merger defined using the streamMerger element of this extension point (i.e. org.eclipse.compare.streamMergers)
    
    Examples: The following is an example of a stream merger for property files (extension "properties"):
    <extension point = "org.eclipse.compare.streamMergers"> 
         <streamMerger 
             id="org.eclipse.compare.internal.merge.TextStreamMerger" 
             class="org.eclipse.compare.internal.merge.TextStreamMerger" 
             extensions="properties" 
        /> 
    </extension> 
    API Information: The contributed class must implement org.eclipse.compare.IStreamMerger
    Supplied Implementation: The Compare UI plugin defines a stream merger for line oriented text files. 
  • The definition of <extension point>

  • 1 <extension  point="org.eclipse.ui.themes">

    <extension point=""> indicates that this plug-in want to extend from that point, add additional features or want that point service for this plug-in.Now we have a look at extenion-point of org.eclipse.ui.themes.

  • Take a look at interface ITheme.when we need a Theme object, elipse kernel can load plug-ins which define all properties of Theme through plug-in.xml of this exclipse plug-in.
  •  1 package org.eclipse.ui.themes;
     2 import java.util.Set;
     3 import org.eclipse.jface.resource.ColorRegistry;
     4 import org.eclipse.jface.resource.FontRegistry;
     5 import org.eclipse.jface.util.IPropertyChangeListener;
     6 public interface ITheme {
     7     void addPropertyChangeListener(IPropertyChangeListener listener);
     8     void dispose();
     9     boolean getBoolean(String key);
    10     ColorRegistry getColorRegistry();
    11     FontRegistry getFontRegistry();
    12     String getId();
    13     public int getInt(String key);
    14     String getLabel();
    15     String getString(String key);
    16     Set keySet();
    17     void removePropertyChangeListener(IPropertyChangeListener listener);
    18 }

     

 

Configuration Markup:

<!ELEMENT extension (theme* , colorDefinition* , fontDefinition* , themeElementCategory* , data* , categoryPresentationBinding*)>

<!ATTLIST extension point CDATA #REQUIRED id CDATA #IMPLIED name CDATA #IMPLIED >

  • point - a fully qualified identifier of the target extension point
  • id - an optional identifier of the extension instance
  • name - an optional name of the extension instance

<!ELEMENT theme (colorOverride* , fontOverride* , description? , data*)>

<!ATTLIST theme id CDATA #REQUIRED name CDATA #IMPLIED >

A collection of font, color and data overrides. Such a collection may be used to alter the appearance of the workbench. Many theme elements may exist with the same id. This allows component authors to contribute to existing themes.

  • id - a unique name that will be used to identify this theme
  • name - a translatable name of the theme to be presented to the user.

At least one theme definition with any given id should contain this attribute.

<!ELEMENT themeElementCategory (description?)>

<!ATTLIST themeElementCategory id CDATA #REQUIRED parentId IDREF #IMPLIED class CDATA #IMPLIED label CDATA #IMPLIED >

A logical grouping of theme element definitions. This category may include colors and fonts.

  • id - the id for this category
  • parentId - the id of the parent category, if any.
  • class - a class that implements org.eclipse.ui.themes.IThemePreview
  • label - a translatable name of the theme element category to be presented to the user

<!ELEMENT colorDefinition (colorFactory? , colorValue* , description?)>

<!ATTLIST colorDefinition id CDATA #REQUIRED label CDATA #REQUIRED defaultsTo CDATA #IMPLIED value CDATA #IMPLIED categoryId IDREF #IMPLIED colorFactory CDATA #IMPLIED isEditable (true | false) >

A symbolic color definition.

  • id - a unique id that can be used to identify this color definition.
  • label - a translatable name of the color to be presented to the user.
  • defaultsTo - the id of another color definition that is the default setting for the receiver. When there is no preference for this color the color registry will have the value of defaultsTo set for it in the registry. Only one of defaultsTo, value or colorFactory may be defined.
  • value - The default value of this color. The value may be specified in the following ways:
    • a String containing comma separated integers in the form red,green,blue
    • a String that maps to an SWT color constant (ie: COLOR_RED).
    • Only one of defaultsTo, value or colorFactory may be defined. If value is specified, additional value definitions may be specified on a per platform/windowing system basis via the colorValue element.
  • categoryId - the optional id of the themeElementCategory this color belongs to.
  • colorFactory - a class that implements org.eclipse.ui.themes.IColorFactory. This may be used instead of value to specify the default value of the color. Please be advised that this should be used with caution - usage of this attribute will cause plugin activation on workbench startup.
  • isEditable - whether the user should be allowed to edit this color in the preference page. If this is false then the contribution is not shown to the user.
  • <!ELEMENT fontDefinition (fontValue* , description?)> <!ATTLIST fontDefinition id CDATA #REQUIRED label CDATA #REQUIRED value CDATA #IMPLIED categoryId IDREF #IMPLIED defaultsTo CDATA #IMPLIED isEditable (true | false) > A symbolic font definition.
  • id - a unique name that can be used to identify this font definition. label - a translatable name of the font to be presented to the user.
  • value - the font value. This is in the form: fontname-style-height where fontname is the name of a font, style is a font style (one of "regular", "bold", "italic", or "bold italic") and height is an integer representing the font height.