public abstract class View
extends java.lang.Object
implements de.ims.icarus.util.id.Identifiable
Modifier and Type | Class and Description |
---|---|
static interface |
View.ViewEvents |
Modifier and Type | Field and Description |
---|---|
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. |
Modifier | Constructor and Description |
---|---|
protected |
View() |
Modifier and Type | Method and Description |
---|---|
protected void |
addBroadcastListener(java.lang.String eventName,
de.ims.icarus.ui.events.EventListener listener) |
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 |
buildToolBar(ToolBarDelegate delegate)
Entry point for subclasses to add tool-bar elements to the
frame-wide tool-bar.
|
void |
close()
Tells this
View to release all its resources and
return ownership of the JComponent it was provided with
on the initial call to #init(JComponent) . |
protected boolean |
defaultLoadActions(java.lang.Class<?> clazz,
java.lang.String path) |
protected void |
fireBroadcastEvent(de.ims.icarus.ui.events.EventObject event) |
void |
focusView()
Requests this
View to get the focus. |
protected javax.swing.JComponent |
getContainer()
Returns the
JComponent that was provided by the
enclosing Perspective for this View to lay out
its user interface. |
protected de.ims.icarus.ui.actions.ActionManager |
getDefaultActionManager()
Returns the default
ActionManager that is available to this
View . |
org.java.plugin.registry.Extension |
getExtension() |
protected java.awt.Frame |
getFrame()
Returns the enclosing
Frame . |
de.ims.icarus.util.id.Identity |
getIdentity() |
protected InfoPanel |
getInfoPanel()
Returns the
InfoPanel available for this View . |
Perspective |
getPerspective()
Returns the enclosing
Perspective that manages this View
instance. |
protected de.ims.icarus.util.mpi.ResultMessage |
handleRequest(de.ims.icarus.util.mpi.Message message) |
abstract void |
init(javax.swing.JComponent container)
Tells the
view to layout its visible parts. |
boolean |
isClosable()
Checks whether this
View can be closed. |
protected void |
refreshInfoPanel(InfoPanel infoPanel)
Called when the
View gets the input focus. |
protected void |
reloadViewTab()
Forces the enclosing
Perspective to update the following
properties of the JTabbedPane 's tab that holds this
view's container by using the view's Identity : |
protected void |
removeBroadcastListener(de.ims.icarus.ui.events.EventListener listener) |
protected void |
removeBroadcastListener(de.ims.icarus.ui.events.EventListener listener,
java.lang.String eventName) |
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() |
protected void |
selectViewTab()
Tells the enclosing
Perspective to set the tab
that holds this View 's container object as the
selected component in the corresponding JTabbedPane . |
protected de.ims.icarus.util.mpi.ResultMessage |
sendRequest(java.lang.Object receiver,
de.ims.icarus.util.mpi.Message message)
Forwards the given
data to this View 's Perspective
to be dispatched. |
protected de.ims.icarus.util.mpi.ResultMessage |
sendRequest(java.lang.Object perspective,
java.lang.Object receiver,
de.ims.icarus.util.mpi.Message message) |
protected void |
showError(java.lang.Throwable t) |
protected void |
toggleContainer()
Toggles the state of this
View 's container which can
be either maximized or the default state. |
java.lang.String |
toString() |
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.public final org.java.plugin.registry.Extension getExtension()
public de.ims.icarus.util.id.Identity getIdentity()
getIdentity
in interface de.ims.icarus.util.id.Identifiable
Identifiable.getIdentity()
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 abstract void init(javax.swing.JComponent container)
view
to layout its visible parts. From the moment
of this call until #close()
is called this View
is allowed
to take complete ownership if the provided container
. Due to the
nature of Swing's component hierarchy it is possible for a View
object
to access components outside its root
container but this is not
recommended! The basic job to be done within this method is to add components
to the container
and to resize it if needed.
This method will always be called on the EventDispatchThread
!
container
- public void close()
View
to release all its resources and
return ownership of the JComponent
it was provided with
on the initial call to #init(JComponent)
. After this
method is called the View
object is considered unusable
and will no longer be accessible from its previous Perspective
context! If an implementation encounters an error that renders it
unable to release some of its resources (e.g. threads still running
in the background) then it should throw a CorruptedStateException
so the enclosing Perspective
can handle this by presenting
the user some kind of feedback that suggests him to exit the program
or that at least informs him about the unusual state and the possible
problems that may result from it. The default implementation only
clears the container component of all its child components to fasten
the release of ui-resources.de.ims.icarus.util.CorruptedStateException
- if the View
was unable to release
all of its managed resources and therefore suggests immediate exit of
the programpublic boolean isClosable()
View
can be closed. This method exists
so that implementations that have ongoing background operations
still running can ask the user to cancel those. Note that in some
situations the return value from this method being true
does
not
prevent the enclosing Perspective
to close this
View
by calling #close()
!
The default implementation returns true
.
true
if this View
is ready to be closedpublic void reset()
public java.lang.String toString()
toString
in class java.lang.Object
public final Perspective getPerspective()
Perspective
that manages this View
instance. Note that it is not recommended to call this method before
a View
got initialized by the init(JComponent)
method!Perspective
java.lang.IllegalStateException
- if this View
is currently not
a visible member of any Perspective
protected final java.awt.Frame getFrame()
Frame
.protected InfoPanel getInfoPanel()
InfoPanel
available for this View
.
This request is forwarded to the enclosing Perspective
which will check whether or not this View
is the currently
active view, i.e. has the input focus. If this View
is not
the active one null
is returned.protected void refreshInfoPanel(InfoPanel infoPanel)
View
gets the input focus.
Hook for subclasses to initialize displayed fields on the info panel.
The default implementation just calls InfoPanel.clear()
on
the supplied argument.protected void buildToolBar(ToolBarDelegate delegate)
protected de.ims.icarus.util.mpi.ResultMessage handleRequest(de.ims.icarus.util.mpi.Message message) throws java.lang.Exception
java.lang.Exception
protected final de.ims.icarus.util.mpi.ResultMessage sendRequest(java.lang.Object receiver, de.ims.icarus.util.mpi.Message message)
data
to this View
's Perspective
to be dispatched. The receiver
argument serves as a filter for the
Perspective
to find suitable targets. It may either be a String
defining the exact unique-id
of the desired View
, a Class
object describing a super-type for targets, a Capability
describing
required capabilities or null
if the data
should be dispatched as a broadcast.
Note: As long as data is being dispatched by Perspective#dispatchData(View, String, Object, Object, Options)
this method will always be called on the EventDispatchThread
receiver
- target filter, may be a ViewFilter
a String
, a Class
or null
message
- the request to be dispatchedprotected final de.ims.icarus.util.mpi.ResultMessage sendRequest(java.lang.Object perspective, java.lang.Object receiver, de.ims.icarus.util.mpi.Message message)
protected final void selectViewTab()
Perspective
to set the tab
that holds this View
's container
object as the
selected component in the corresponding JTabbedPane
.protected final void reloadViewTab()
Perspective
to update the following
properties of the JTabbedPane
's tab
that holds this
view's container
by using the view's Identity
:
Identity.getIcon()
if not null
Identity.getDescription()
Identity.getName()
View
to change its tab
's appearance
at any time.protected final void toggleContainer()
View
's container which can
be either maximized
or the default state. Usually this method
is only called by the enclosing Perspective
when the user clicks
the corresponding control buttons or components.protected final javax.swing.JComponent getContainer()
JComponent
that was provided by the
enclosing Perspective
for this View
to lay out
its user interface.protected final void addBroadcastListener(java.lang.String eventName, de.ims.icarus.ui.events.EventListener listener)
protected final void removeBroadcastListener(de.ims.icarus.ui.events.EventListener listener)
protected final void removeBroadcastListener(de.ims.icarus.ui.events.EventListener listener, java.lang.String eventName)
protected final void fireBroadcastEvent(de.ims.icarus.ui.events.EventObject event)
protected final de.ims.icarus.ui.actions.ActionManager getDefaultActionManager()
ActionManager
that is available to this
View
. Per convention all views within the same Perspective
share the manager of that enclosing Perspective
.protected boolean defaultLoadActions(java.lang.Class<?> clazz, java.lang.String path)
public void focusView()
View
to get the focus. The default
implementation delegates this call to JComponent.requestFocusInWindow()
on the component
obtained through getContainer()
.
Subclasses might override this method to forward focus to some
components within their personal root container.protected void showError(java.lang.Throwable t)