public abstract class Perspective
extends java.lang.Object
implements de.ims.icarus.util.id.Identifiable
Modifier and Type | Class and Description |
---|---|
static interface |
Perspective.PerspectiveEvents |
protected class |
Perspective.ViewContainer |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<org.java.plugin.registry.Extension,View> |
activatedViews |
protected de.ims.icarus.ui.layout.AreaLayout |
areaLayout |
static java.lang.String |
CLIENT_PROPERTY_ALIGNMENT |
protected static java.util.Comparator<javax.swing.JComponent> |
COMPONENT_SORTER |
protected java.util.Set<org.java.plugin.registry.Extension> |
connectedViews |
protected java.util.Map<org.java.plugin.registry.Extension,Perspective.ViewContainer> |
containers |
protected de.ims.icarus.ui.events.EventSource |
eventSource
For security reasons we do not extend
EventSource but rather
store an internal instance and forward methods we want to expose. |
protected java.beans.PropertyChangeListener |
focusTracker |
protected de.ims.icarus.resources.Localizer |
tabLocalizer |
protected javax.swing.event.ChangeListener |
viewActivater |
protected java.util.Set<View> |
views |
Modifier | Constructor and Description |
---|---|
protected |
Perspective() |
Modifier and Type | Method and Description |
---|---|
protected void |
activateView(Perspective.ViewContainer container) |
void |
addListener(java.lang.String eventName,
de.ims.icarus.ui.events.EventListener listener)
Registers the given
listener for events of the
specified eventName or as a listener for all
events in the case the eventName parameter is null |
protected void |
buildMenuBar(MenuDelegate delegate) |
protected void |
buildToolBar(ToolBarDelegate delegate) |
void |
close() |
protected void |
closeView(View view,
boolean forceClose,
boolean removeContainer) |
protected void |
collectViewExtensions()
Collects all
Extension s that should be used for this perspective. |
protected void |
defaultDoLayout(javax.swing.JComponent root) |
static View |
findView(java.awt.Component comp)
Searches the component hierarchy of the given
JComponent for one that serves as container
for a View object and returns that view. |
protected void |
focusView(java.lang.Object view) |
de.ims.icarus.ui.actions.ActionManager |
getActionManager() |
View |
getActiveView() |
java.util.Collection<org.java.plugin.registry.Extension> |
getConnectedViewExtensions()
Returns all the
Extension s that represent View s
and are currently connected to this Perspective . |
protected javax.swing.JComponent |
getContainer() |
protected Perspective.ViewContainer |
getContainer(java.awt.Component comp)
Returns the ViewContainer for the given component.
|
org.java.plugin.registry.Extension |
getExtension() |
protected View |
getFocusedView() |
protected java.awt.Frame |
getFrame() |
protected FrameDelegate |
getFrameDelegate() |
de.ims.icarus.util.id.Identity |
getIdentity() |
protected InfoPanel |
getInfoPanel() |
InfoPanel |
getInfoPanel(View view) |
View |
getView(org.java.plugin.registry.Extension extension) |
View |
getView(java.lang.String id)
Returns the
View currently available within this
Perspective that uses the given id or null
if there is no matching View registered or it has not
yet been activated. |
protected de.ims.icarus.ui.Alignment |
getViewAlignment(org.java.plugin.registry.Extension extension) |
java.util.Collection<View> |
getViews()
Returns all the active
View instances within this
Perspective as an unmodifiable Collection |
java.util.Collection<View> |
getViews(java.lang.Class<?> clazz)
Searches the list of registered
View s within this
Perspective for instances of the given Class
and returns all such matches as a Collection . |
java.util.Collection<View> |
getViews(de.ims.icarus.util.Filter filter) |
protected de.ims.icarus.util.mpi.ResultMessage |
handleRequest(java.lang.Object sender,
java.lang.Object receiver,
de.ims.icarus.util.mpi.Message message) |
abstract void |
init(javax.swing.JComponent container)
Called from the framework when a
Perspective is made
visible for the first time after if was created. |
protected void |
initView(View view,
Perspective.ViewContainer container)
Called after a
View instance has been activated and before
notifying listeners to allow subclasses to perform implementation
specific configuration of views. |
boolean |
isActiveView(View view)
Checks whether the given
View is the currently active
view in this Perspective . |
boolean |
isClosable() |
void |
openPerspective(org.java.plugin.registry.Extension extension) |
protected void |
refreshInfoPanelForView(View view) |
void |
removeListener(de.ims.icarus.ui.events.EventListener listener)
Removes the given
EventListener from all events
it was previously registered for. |
void |
removeListener(de.ims.icarus.ui.events.EventListener listener,
java.lang.String eventName)
Removes from the list of registered listeners all pairs
matching the given combination of
EventListener
and eventName . |
void |
reset()
Resets all the
View objects currently associated
with this Perspective . |
protected de.ims.icarus.util.mpi.ResultMessage |
sendRequest(java.lang.Object sender,
java.lang.Object perspective,
java.lang.Object receiver,
de.ims.icarus.util.mpi.Message message) |
protected void |
setActiveView(View view) |
void |
toggleView(View view) |
java.lang.String |
toString() |
protected boolean |
usePrivateActionNamespace()
Hook for subclasses to disable private action-namespace.
|
public static final java.lang.String CLIENT_PROPERTY_ALIGNMENT
protected final java.util.Set<org.java.plugin.registry.Extension> connectedViews
protected final java.util.Map<org.java.plugin.registry.Extension,View> activatedViews
protected final java.util.Map<org.java.plugin.registry.Extension,Perspective.ViewContainer> containers
protected final java.util.Set<View> views
protected de.ims.icarus.ui.layout.AreaLayout areaLayout
protected final de.ims.icarus.ui.events.EventSource eventSource
EventSource
but rather
store an internal instance and forward methods we want to expose.
Since EventSource
does not offer access control to methods
like EventSource.setEventsEnabled(boolean)
this is necessary
to prevent external sources from disabling event handling for us.
Implementations might reconsider about that and expose more
functionality of the EventSource
via new forwarding methods.protected de.ims.icarus.resources.Localizer tabLocalizer
protected javax.swing.event.ChangeListener viewActivater
protected java.beans.PropertyChangeListener focusTracker
protected static final java.util.Comparator<javax.swing.JComponent> COMPONENT_SORTER
public de.ims.icarus.util.id.Identity getIdentity()
getIdentity
in interface de.ims.icarus.util.id.Identifiable
public final org.java.plugin.registry.Extension getExtension()
public java.lang.String toString()
toString
in class java.lang.Object
public final de.ims.icarus.ui.actions.ActionManager getActionManager()
protected boolean usePrivateActionNamespace()
false
then the ActionManager
provided by the present FrameDelegate
will be used as-is
otherwise a new manager will be instantiated by calling
ActionManager.derive()
on the one from the delegate. This way
all actions loaded by this Perspective
or any of its containing
View
s using the perspective's ActionManager
will be private.
The default implementation returns true
.public abstract void init(javax.swing.JComponent container)
Perspective
is made
visible for the first time after if was created. The provided
container
is the JComponent
that will serve as
root
for this Perspective
. It is up to the
implementation to add components or use the defaultDoLayout(JComponent)
method to layout all View
s registered to this perspective
so far.container
- the root
component of this Perspective
public boolean isClosable()
public void close()
public final View getView(java.lang.String id)
View
currently available within this
Perspective
that uses the given id
or null
if there is no matching View
registered or it has not
yet been activated.id
- the id to be matched against the ids of all active View
sView
within this Perspective
that
is assigned the given id
or null
if no such View
could be foundpublic final View getView(org.java.plugin.registry.Extension extension)
public final java.util.Collection<View> getViews(java.lang.Class<?> clazz)
View
s within this
Perspective
for instances of the given Class
and returns all such matches as a Collection
. The
check is performed by calling Class.isAssignableFrom(Class)
.clazz
- the superinterface or superclass of the desired View
instancesView
s within this Perspective
that either
implement or extend the class or interface defined by the clazz
parameterpublic final java.util.Collection<View> getViews()
View
instances within this
Perspective
as an unmodifiable Collection
View
instances within this
Perspective
as an unmodifiable Collection
public final java.util.Collection<View> getViews(de.ims.icarus.util.Filter filter)
public final java.util.Collection<org.java.plugin.registry.Extension> getConnectedViewExtensions()
Extension
s that represent View
s
and are currently connected to this Perspective
. The
returned Collection
is unmodifiable. Note that an
Extension
being connected does not
necessarily
mean that the corresponding View
is actually loaded or
active!public void reset()
View
objects currently associated
with this Perspective
. All catched exceptions are forwarded
to the default UI-logger save for CorruptedStateException
s
which will be re-thrown once the logging is done and all views had
their chance to properly reset.
If a subclass is overriding this method it is recommended that it
calls the super.reset()
after managing internal reset so that
forwarding of CorruptedStateException
s is ensured.
public void addListener(java.lang.String eventName, de.ims.icarus.ui.events.EventListener listener)
listener
for events of the
specified eventName
or as a listener for all
events in the case the eventName
parameter is null
eventName
- name of events to listen for or null
if
the listener is meant to receive all fired eventslistener
- the EventListener
to be registeredpublic void removeListener(de.ims.icarus.ui.events.EventListener listener)
EventListener
from all events
it was previously registered for.listener
- the EventListener
to be removedpublic void removeListener(de.ims.icarus.ui.events.EventListener listener, java.lang.String eventName)
EventListener
and eventName
. If eventName
is null
then all occurrences of the given listener
will be
removed.listener
- eventName
- public final void openPerspective(org.java.plugin.registry.Extension extension) throws java.lang.Exception
java.lang.Exception
protected java.awt.Frame getFrame()
protected void collectViewExtensions()
Extension
s that should be used for this perspective.
The default implementation simply adds all extensions defined for the
de.ims.icarus.core
plugin's 'View'
extension-point.
In addition all extensions for the 'View'
extension-point in the
declaring plugin will be added if present.protected void defaultDoLayout(javax.swing.JComponent root)
protected de.ims.icarus.ui.Alignment getViewAlignment(org.java.plugin.registry.Extension extension)
public void toggleView(View view)
protected void focusView(java.lang.Object view)
protected InfoPanel getInfoPanel()
protected View getFocusedView()
public boolean isActiveView(View view)
View
is the currently active
view in this Perspective
.protected void refreshInfoPanelForView(View view)
public final View getActiveView()
protected final void setActiveView(View view)
protected final Perspective.ViewContainer getContainer(java.awt.Component comp)
protected final void closeView(View view, boolean forceClose, boolean removeContainer) throws java.lang.Exception
java.lang.Exception
protected final javax.swing.JComponent getContainer()
protected final FrameDelegate getFrameDelegate()
protected void buildMenuBar(MenuDelegate delegate)
protected void buildToolBar(ToolBarDelegate delegate)
protected final void activateView(Perspective.ViewContainer container)
protected void initView(View view, Perspective.ViewContainer container)
View
instance has been activated and before
notifying listeners to allow subclasses to perform implementation
specific configuration of views. Note that it is mandatory to call
View.init(JComponent)
during this initialization process!
Subclasses should either make that call themselves or simply call
super.initView(View, ViewContainer)
since the default
implementation only calls the View.init(JComponent)
method
without additional configuration.protected final de.ims.icarus.util.mpi.ResultMessage sendRequest(java.lang.Object sender, java.lang.Object perspective, java.lang.Object receiver, de.ims.icarus.util.mpi.Message message)
protected de.ims.icarus.util.mpi.ResultMessage handleRequest(java.lang.Object sender, java.lang.Object receiver, de.ims.icarus.util.mpi.Message message) throws java.lang.Exception
java.lang.Exception
public static View findView(java.awt.Component comp)
JComponent
for one that serves as container
for a View
object and returns that view.