public abstract class AbstractRegistryEventListener extends Object implements org.eclipse.core.runtime.IRegistryEventListener
IExtensionRegistry
. It provides base implementation to
added(IExtension[])
and removed(IExtension[])
. Users must implement
readElement(IConfigurationElement, Action)
according to their extension schema.
The helper method #readRegistry()
is browsing already registered extension to the extension
registry making it easy to read the registry after having added the listener to it.
#readRegistry()
is delegating to readElement(IConfigurationElement, Action)
.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractRegistryEventListener.Action
Enumeration that says if the
IConfigurationElement is to be added or removed from the
IExtensionRegistry . |
Constructor and Description |
---|
AbstractRegistryEventListener(String namespace,
String extensionPointID,
org.eclipse.core.runtime.ILog log)
Creates a new registry event listener.
|
Modifier and Type | Method and Description |
---|---|
void |
added(org.eclipse.core.runtime.IExtension[] extensions) |
void |
added(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints) |
protected abstract boolean |
addedValid(org.eclipse.core.runtime.IConfigurationElement element)
Process the given element as the addition of a valid element extension.
|
protected void |
log(org.eclipse.core.runtime.IConfigurationElement element,
String errorMessage,
Throwable cause)
Logs the given error with a human-readable error message.
|
protected void |
log(org.eclipse.core.runtime.IConfigurationElement element,
Throwable t)
Log the error to the current plugin logger.
|
protected void |
log(int severity,
org.eclipse.core.runtime.IConfigurationElement element,
String message)
Log the error to the current plugin logger.
|
protected void |
logMissingAttribute(org.eclipse.core.runtime.IConfigurationElement element,
String attributeName)
Delegates the logging of a missing attribute to
#log(IConfigurationElement, String) with a
proper message. |
protected boolean |
readElement(org.eclipse.core.runtime.IConfigurationElement element,
AbstractRegistryEventListener.Action action)
Reads the given
element . |
void |
readRegistry(org.eclipse.core.runtime.IExtensionRegistry extensionRegistry)
Reads the given registry and call
readElement(IConfigurationElement, Action) as the read
IConfigurationElement were just added to it. |
void |
removed(org.eclipse.core.runtime.IExtension[] extensions) |
void |
removed(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints) |
protected abstract boolean |
removedValid(org.eclipse.core.runtime.IConfigurationElement element)
Process the given element as the removal of a valid element extension.
|
protected abstract boolean |
validateExtensionElement(org.eclipse.core.runtime.IConfigurationElement element)
Validates if the given element is an element for the given extension and is well constructed.
|
public AbstractRegistryEventListener(String namespace, String extensionPointID, org.eclipse.core.runtime.ILog log)
namespace
- The namespace of the extension point to be monitored.extensionPointID
- The extension point ID to be monitoredlog
- The log object to be used to log error and/or warning.public void readRegistry(org.eclipse.core.runtime.IExtensionRegistry extensionRegistry)
readElement(IConfigurationElement, Action)
as the read
IConfigurationElement
were just added to it.extensionRegistry
- the registry to read.protected boolean readElement(org.eclipse.core.runtime.IConfigurationElement element, AbstractRegistryEventListener.Action action)
element
. This method can be call when the element is added or remove. The
action
reflect it. It returns true if the element is recognized as valid regarding the
monitored extension point. It will be call on sub elements recursively for all recognized ones.element
- the element to be read.action
- is the element added or removed.protected abstract boolean validateExtensionElement(org.eclipse.core.runtime.IConfigurationElement element)
element
- the element to validate.protected abstract boolean addedValid(org.eclipse.core.runtime.IConfigurationElement element)
element
- the element to be added.protected abstract boolean removedValid(org.eclipse.core.runtime.IConfigurationElement element)
element
- the element to be removed.protected void logMissingAttribute(org.eclipse.core.runtime.IConfigurationElement element, String attributeName)
#log(IConfigurationElement, String)
with a
proper message.element
- the element to which an attribute is missing.attributeName
- the name of the missing attribute.protected void log(int severity, org.eclipse.core.runtime.IConfigurationElement element, String message)
severity
- Severity of this message. One of IStatus.OK
, IStatus.ERROR
,
IStatus.INFO
, IStatus.WARNING
, or IStatus.CANCEL
element
- the element from which comes to the error.message
- the message to be logged.protected void log(org.eclipse.core.runtime.IConfigurationElement element, Throwable t)
element
- the element from which comes to the error.t
- the exception to be logged.protected void log(org.eclipse.core.runtime.IConfigurationElement element, String errorMessage, Throwable cause)
element
- The element from which originates the error.errorMessage
- Human-readable cause of this exception.cause
- Actual exception that is to be logged.public void added(org.eclipse.core.runtime.IExtension[] extensions)
added
in interface org.eclipse.core.runtime.IRegistryEventListener
IRegistryEventListener.added(org.eclipse.core.runtime.IExtension[])
public void removed(org.eclipse.core.runtime.IExtension[] extensions)
removed
in interface org.eclipse.core.runtime.IRegistryEventListener
IRegistryEventListener.removed(org.eclipse.core.runtime.IExtension[])
public void added(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)
added
in interface org.eclipse.core.runtime.IRegistryEventListener
IRegistryEventListener.added(org.eclipse.core.runtime.IExtensionPoint[])
public void removed(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints)
removed
in interface org.eclipse.core.runtime.IRegistryEventListener
IRegistryEventListener.removed(org.eclipse.core.runtime.IExtensionPoint[])
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.