@OpenApi
public class DiagramListenerAdapter
extends java.lang.Object
Forwards diagram events to the given PropertyChangeListener
delegate.
Diagram content event listeners in DiagramPresentationElement
are notified about all changes in the diagram.
This class adds itself to those listeners and forwards all events to the
delegate.
It listens for diagram content change events from opened diagrams only.
It takes care of (de)attaching itself as listener to the diagram when diagram is closed or opened.
Diagram open/close events are forwarded to the delegate as well.
A DiagramListenerAdapter object has the ability to delegate all events to your own listener. This adapter is everything you need, when listening to the opened diagram change events. Adapter works in a project scope.
To listen to the diagram change events, you must create a DiagramListenerAdapter and install it for the project. To create the DiagramListenerAdapter, call:
new DiagramListenerAdapter(propertyChangeListener)
To create the adapter, you need to pass the property change listener as a delegator, which will receive all events. To start using the adapter, install it. Uninstall it when it is no longer necessary.
IMPORTANT! The uninstalled adapter cannot be reused anymore. To start receiving events, you must create a new instance of the DiagramListenerAdapter.
DiagramListenerAdapter adapter = new DiagramListenerAdapter(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (ExtendedPropertyNames.VIEW_ADDED.equals(propertyName) || ExtendedPropertyNames.VIEW_REMOVED.equals(propertyName)) { // added/removed symbol PresentationElement presentationElement = (PresentationElement) evt.getNewValue(); } } }); adapter.install(project); // When it is no longer needed, uninstall it. adapter.uninstall(project);
Constructor and Description |
---|
DiagramListenerAdapter(Project project,
java.beans.PropertyChangeListener delegate)
Deprecated.
|
DiagramListenerAdapter(java.beans.PropertyChangeListener delegate)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose(Project project)
Deprecated.
|
void |
install(Project project)
Install DiagramListenerAdapter to a project.
|
void |
uninstall(Project project)
Removes itself from the project.
|
@OpenApi @Deprecated public DiagramListenerAdapter(Project project, java.beans.PropertyChangeListener delegate)
DiagramListenerAdapter(java.beans.PropertyChangeListener)
uninstall(Project)
to stop receiving property change event in delegate.project
- project to install adapter to.delegate
- delegate listener.@OpenApi public DiagramListenerAdapter(java.beans.PropertyChangeListener delegate)
delegate
- delegate listener.@Deprecated @OpenApi public void dispose(Project project)
uninstall(com.nomagic.magicdraw.core.Project)
project
- uninstall from project.@OpenApi public void install(Project project)
project
- project to install adapter to.uninstall(com.nomagic.magicdraw.core.Project)
@OpenApi public void uninstall(Project project)
project
- uninstall from project.install(com.nomagic.magicdraw.core.Project)