Class AbstractRegistryEventListener
java.lang.Object
org.eclipse.emf.compare.rcp.extension.AbstractRegistryEventListener
- All Implemented Interfaces:
EventListener
,org.eclipse.core.runtime.IRegistryEventListener
- Direct Known Subclasses:
AccessorFactoryExtensionRegistryListener
,ConfigurationUIRegistryEventListener
,ContentMergeViewerCustomizationRegistryListener
,DescriptorRegistryEventListener
,DifferenceFilterExtensionRegistryListener
,DifferenceGroupExtenderRegistryListener
,DifferenceGroupProviderExtensionRegistryListener
,EqualityHelperExtensionProviderDescriptorRegistryListener
,LoadOnDemandPolicyRegistryListener
,LogicalModelViewHandlerRegistryListener
,MatchEngineFactoryRegistryListener
,MergeResolutionListenerRegistryListener
,MergerExtensionRegistryListener
,ModelDependencyProviderRegistryListener
,ModelMinimizerRegistryListener
,ModelResolverRegistryListener
,PostProcessorFactoryRegistryListener
,ResourceSetHookRegistryListener
,SubscriberProviderRegistryListener
,WeightProviderDescriptorRegistryListener
public abstract class AbstractRegistryEventListener
extends Object
implements org.eclipse.core.runtime.IRegistryEventListener
Abstract utility class to listen to the
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)
.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
Enumeration that says if theIConfigurationElement
is to be added or removed from theIExtensionRegistry
. -
Constructor Summary
ConstructorDescriptionAbstractRegistryEventListener
(String namespace, String extensionPointID, org.eclipse.core.runtime.ILog log) Creates a new registry event listener. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 the error to the current plugin logger.protected void
Logs the given error with a human-readable error message.protected void
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 givenelement
.void
readRegistry
(org.eclipse.core.runtime.IExtensionRegistry extensionRegistry) Reads the given registry and callreadElement(IConfigurationElement, Action)
as the readIConfigurationElement
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.
-
Constructor Details
-
AbstractRegistryEventListener
public AbstractRegistryEventListener(String namespace, String extensionPointID, org.eclipse.core.runtime.ILog log) Creates a new registry event listener.- Parameters:
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.
-
-
Method Details
-
readRegistry
public void readRegistry(org.eclipse.core.runtime.IExtensionRegistry extensionRegistry) Reads the given registry and callreadElement(IConfigurationElement, Action)
as the readIConfigurationElement
were just added to it.- Parameters:
extensionRegistry
- the registry to read.
-
readElement
protected boolean readElement(org.eclipse.core.runtime.IConfigurationElement element, AbstractRegistryEventListener.Action action) Reads the givenelement
. This method can be call when the element is added or remove. Theaction
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.- Parameters:
element
- the element to be read.action
- is the element added or removed.- Returns:
- true if the element is recognized as valid regarding the monitored extension point.
-
validateExtensionElement
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. Returns true if the element should be further parsed for addition or removal.- Parameters:
element
- the element to validate.- Returns:
- true if the element should be further parsed for addition or removal, else otherwise.
-
addedValid
protected abstract boolean addedValid(org.eclipse.core.runtime.IConfigurationElement element) Process the given element as the addition of a valid element extension.- Parameters:
element
- the element to be added.- Returns:
- true if the given element has been added and if its children should be processed, false otherwise.
-
removedValid
protected abstract boolean removedValid(org.eclipse.core.runtime.IConfigurationElement element) Process the given element as the removal of a valid element extension.- Parameters:
element
- the element to be removed.- Returns:
- true if the given element has been removed and if its children should be processed, false otherwise.
-
logMissingAttribute
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.- Parameters:
element
- the element to which an attribute is missing.attributeName
- the name of the missing attribute.
-
log
protected void log(int severity, org.eclipse.core.runtime.IConfigurationElement element, String message) Log the error to the current plugin logger.- Parameters:
severity
- Severity of this message. One ofIStatus.OK
,IStatus.ERROR
,IStatus.INFO
,IStatus.WARNING
, orIStatus.CANCEL
element
- the element from which comes to the error.message
- the message to be logged.
-
log
Log the error to the current plugin logger.- Parameters:
element
- the element from which comes to the error.t
- the exception to be logged.
-
log
protected void log(org.eclipse.core.runtime.IConfigurationElement element, String errorMessage, Throwable cause) Logs the given error with a human-readable error message.- Parameters:
element
- The element from which originates the error.errorMessage
- Human-readable cause of this exception.cause
- Actual exception that is to be logged.- Since:
- 2.2
-
added
public void added(org.eclipse.core.runtime.IExtension[] extensions) - Specified by:
added
in interfaceorg.eclipse.core.runtime.IRegistryEventListener
- See Also:
-
IRegistryEventListener.added(org.eclipse.core.runtime.IExtension[])
-
removed
public void removed(org.eclipse.core.runtime.IExtension[] extensions) - Specified by:
removed
in interfaceorg.eclipse.core.runtime.IRegistryEventListener
- See Also:
-
IRegistryEventListener.removed(org.eclipse.core.runtime.IExtension[])
-
added
public void added(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints) - Specified by:
added
in interfaceorg.eclipse.core.runtime.IRegistryEventListener
- See Also:
-
IRegistryEventListener.added(org.eclipse.core.runtime.IExtensionPoint[])
-
removed
public void removed(org.eclipse.core.runtime.IExtensionPoint[] extensionPoints) - Specified by:
removed
in interfaceorg.eclipse.core.runtime.IRegistryEventListener
- See Also:
-
IRegistryEventListener.removed(org.eclipse.core.runtime.IExtensionPoint[])
-