Eclipse Plug-In Architecture

For a tutorial about how to create various UI extensions such as wizards and menu entries see this page.

Resources

An Eclipse project consists of a hierarchy of files in a workspace.

In order to have an active running program we need to translate these files to resources in memory.

files

There are 2 types of URI:

  • Identify resources.
  • Identify java classes.

Eclipse Application Model

  • Perspectives
  • Parts (views + Editors)
  • Menus
  • Toolbars
  • Handlers
  • Commands
  • Key Bindings
  resource

URIs which identify resources (associated with a file) have the form:

"platform:/plugin/"+Bundle-SymbolicName+/path to file/filename.

Where Bundle-SymbolicName is from MANIFEST.MF file.

OSGi Bundle

Eclipse bundles together extension points into XML file(s) using an OSGi standard.

The files involved are:

META-INF/
        MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.euclideanspace.spad.builder;singleton:=true
Bundle-Version: 1.0.0.qualifier Bundle-Activator: com.euclideanspace.spad.builder.Activator Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.ui.ide;bundle-version="3.8.0", org.eclipse.core.resources;bundle-version="3.8.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy
OSGI-INF/l10n/
      bundle.properties

A '.properties' file contains key-value pairs. For instance the MANIFEST.MF file above references 'Bundle-Name' and 'Bundle-Vendor' from this file.

This is defined in:

java.util.ResourceBundle

#Properties file for com.euclideanspace.spad.builder
category.name = SPAD
wizard.name = SPAD project
Bundle-Vendor = EUCLIDEANSPACE
Bundle-Name = SPAD Builder
build.properties
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               OSGI-INF/l10n/bundle.properties
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
          <?eclipse version="3.4"?>
          <plugin>
  <extension
          point="org.eclipse.ui.newWizards">
  <category
          id="com.euclideanspace.spad.builder.category.wizards"
          name="%category.name">
  </category>
  <wizard
          category="com.euclideanspace.spad.builder.category.wizards"
          class="com.euclideanspace.spad.builder.BuilderNewWizard"
          id="builder.wizard.new.custom"
          name="%wizard.name">
  </wizard>
  </extension>
        </plugin>

Reading ResourceBundle

The ResourceBundle can be read programmatically like this:
ResourceBundle rb = ResourceBundle.getBundle("test.bundletest.mybundle");
		Enumeration  keys = rb.getKeys();
		while (keys.hasMoreElements()) {
			String key = keys.nextElement();
			String value = rb.getString(key);
			System.out.println(key + ": " + value);
		}

Workspace Resources

   
IResource General interface for all resources
IContainer Interface for resources that can contain other resources.
IFile Support for the creation, deletion and movement of a file.
IFolder  
IProject  
IWorkspaceRoot  

Associated types:

Nature Used to associate behavior and function with a project.
Builder Allows tool-specific logic to process and transform files when they change.
Marker Entity that can be associated with another resource

The diagram below is an attempt to represent how resources are structured in Eclipse. The (white) boxes on the left show how the file system is represented and the boxes on the right represent resources in working memory. These are linked by URIs.

resource

The registaries (yellow boxes) are typically populated by the extension points using:

Resource.Factory.Registry

Resource.Factory.Registry contains a Map of key/value pairs. The key is the file extension.

The following is what I saw when I wrote a program to look at Resource.Factory.Registry in my computer.

These all happen to have PluginClassDescriptor:org.eclipse.emf.ecore.plugin.RegistryReader.ResourceFactoryDescriptor entries

Key Value
xbase ResourceFactoryDescriptor
mwe2ResourceFactoryDescriptor
ecorediagResourceFactoryDescriptor
euclidResourceFactoryDescriptor
___xbaseResourceFactoryDescriptor
traceResourceFactoryDescriptor
*ResourceFactoryDescriptor
___singlecodetemplateResourceFactoryDescriptor
emofResourceFactoryDescriptor
e4xmiResourceFactoryDescriptor
xsd2ecoreResourceFactoryDescriptor
ecore2ecoreResourceFactoryDescriptor
umlResourceFactoryDescriptor
genmodelResourceFactoryDescriptor
ecore2xmlResourceFactoryDescriptor
dslResourceFactoryDescriptor
spadResourceFactoryDescriptor
xtext2ResourceFactoryDescriptor
xtextResourceFactoryDescriptor
xsdResourceFactoryDescriptor
_traceResourceFactoryDescriptor
codetemplatesResourceFactoryDescriptor
ecoreResourceFactoryDescriptor
xtendResourceFactoryDescriptor

EPackage.Registry:

entry:org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@d506aaf
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@1a8c0dfd
org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl@60ea6aa8 (name: menu) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application/ui/menu, nsPrefix: menu)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@3e006d4d
org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl@e07fa08 (name: ui) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application/ui, nsPrefix: ui)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@2db02a6a
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@8b0ac95
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@7126ea8
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@4b1edb38
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@56ca600f
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@68a54d
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@563c6270
org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl@1662d34b (name: basic) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application/ui/basic, nsPrefix: basic)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@321dec68
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@4a8bb98c
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@1b42bc90
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@3a699feb
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@6c821b42
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@51cbc1b5
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@181a7c07
org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl@72c4bbed (name: application) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application, nsPrefix: application)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@520dff78
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@14ff495e
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@429c517
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@524a6b23
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@13bff10a
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@1e69d1a7
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@35433a8a
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@50b85557
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@75eaec27
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@123630ec
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@23c5df4b
org.eclipse.emf.ecore.xml.type.impl.XMLTypePackageImpl@5ace65a0 (name: type) (nsURI: http://www.eclipse.org/emf/2003/XMLType, nsPrefix: ecore.xml.type)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@13c6c746
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@5f44cece
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@1e65673f
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@135d68b0
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@598404be
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@6a5383db
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@10f5d566
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@7b8d243c
org.eclipse.emf.ecore.impl.EcorePackageImpl@2897ac05 (name: ecore) (nsURI: http://www.eclipse.org/emf/2002/Ecore, nsPrefix: ecore)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@6f461e82
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@647d21e0
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@533b2caa
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@51f17796
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@43e242e1
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@3b94e498
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@2c2bd5b7
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@71dbf808
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@20790f9e
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@6bf05eb9
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@71dafb0b
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@5f97c992
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@6632c145
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@e2ecd6e
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@22b0f808
org.eclipse.e4.ui.model.application.ui.advanced.impl.AdvancedPackageImpl@106be703 (name: advanced) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced, nsPrefix: advanced)
org.eclipse.e4.ui.model.application.commands.impl.CommandsPackageImpl@1c0b7e61 (name: commands) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application/commands, nsPrefix: commands)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@369620a9
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@3a3a533e
org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicPackageImpl@4b2f294f (name: basic) (nsURI: http://www.eclipse.org/ui/2010/UIModel/application/descriptor/basic, nsPrefix: basic)
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@5412819
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@78af8400
org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor@4b0359e6

Extension Points

Plug-ins can be used to extend Eclipse itself or a RCP application. Plugins can also plugin to another plugin, giving a possible hierarchy of Extension Points.

Purpose Extension Point  
Window -> Show -> View org.eclipse.ui.views  
iconic decorators to object labels org.eclipse.ui.decorators  
contribute a new wizard to the standard export and import menu choices org.eclipse.ui.exportWizards
org.eclipse.ui.importWizards
 
contribute a new wizard to the standard File -> new menu choice org.eclipse.ui.newWizards  
contribute a preference page to the Window -> Preferences dialog org.eclipse.ui.preferencePages  
contribute pages to an objects properties dialog org.eclipse.ui.propertyPages  
define new editors on resources: this is shown as a choice on its Open With menu cascade. org.eclipse.ui.editors  
define new perspectives for the Window -> Open Perspective menu choice. Add new perspective shortcuts, view shortcuts and action sets to an existing perspective

org.eclipse.ui.perspectives
org.eclipse.ui.perspectiveExtensions

 
contribute actions to the Workbench window menu bar or toolbar

org.eclipse.ui.actionSets

depreciated

 
contribute actions to the Workbench window menu bar or toolbar if the specified view/editor is opened in the perspective org.eclipse.ui.actionSetPartAssociations  
contribute actions to the actions to an editors toolbar or menu choices org.eclipse.ui.editorActions  
contribute actions to an editor, view or objects contect menu org.eclipse.ui.popupMenus  
contribute actions to a views toolbar or pulldown menu org.eclipse.ui.viewActions  
define online help availible from the help -> Help Contents choice

org.eclipse.ui.help
org.eclipse.help.contentProducer

 
define additional filters for the Navigator views Filter menu choice org.eclipse.ui.ide.resourceFilters  
Define your own incremental build provessing (Project -> Rebuild Project) for existing sesource types or your own resources. Enhance project capabilities. org.eclipse.core.resources.builders
org.eclipse.core.resources.natures
 
Tag a resource with some user information. Markers can be displayed in views or editors, such as the Tasks view, vertical ruler of text editors and as label decorations in the Outline view. org.eclipse.core.resources.markers  
The builtin text editor JFace Text offers an extensible and reusable text editor to ensure the user a consistant editing experience. You can customise it to your editing needs for unique text annotations in rulers, additional information such as line numbers, syntax highlighting and content assist org.eclipse.core.resources.fileBuffers.documentSetup
org.eclipse.ui.editors.templates
 
help reduce the number of availible options presented to the user based on their activities. Externally this is referred to as capibilities org.eclipse.ui.activities  

 


metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

 

 

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2017 Martin John Baker - All rights reserved - privacy policy.