# Contexts

###### Identifier:

org.eclipse.ui.contexts

###### Since:

3.0

###### Description:

The `org.eclipse.ui.contexts` extension point is used to declare contexts and associated elements.

###### Configuration Markup:

<!ELEMENT extension (context*)>

<!ATTLIST extension

id CDATA #IMPLIED

name CDATA #IMPLIED

point CDATA #REQUIRED>

- id - An optional identifier of the extension instance.
- name - An optional name of the extension instance.
- point - A fully qualified identifier of the target extension point.

<!ELEMENT context EMPTY>

<!ATTLIST context

description CDATA #IMPLIED

id CDATA #REQUIRED

name CDATA #REQUIRED

parentId IDREF #IMPLIED>

This element is used to define contexts. If more than one of these elements exist with the same `id` attribute, only the last declared element (in order of reading the registry) is considered valid.

- description - A translatable short description of this context for display in the UI.
- id - The unique identifier of this context.
- name - The translatable name of this context for display in the UI.
- parentId - The unique identifier of the parent of this context.

###### Examples:

The `plugin.xml` file in the `org.eclipse.ui` plugin makes use of the `org.eclipse.ui.contexts` extension point.

###### API Information:

In general, it is preferrably to declare all contexts statically (in `plugin.xml`). This is so that users can use them in key bindings. However, it is possible to declare contexts at run-time. To do this, retrieve the `org.eclipse.ui.commands.IContextService` from a workbench component, call `getContext(contextId)` and then call `Context#define(...)`. Contexts defined programmatically must be cleaned up by the plugin if it is unloaded.

Copyright (c) 2000, 2007 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html