|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.jadice.swing.tool.ToolManager
public final class ToolManager
Constructor Summary | |
---|---|
ToolManager(ViewComponent viewComponent)
|
Method Summary | ||
---|---|---|
void |
activate(Class<? extends Tool> tc)
Activates the tool of the given class. |
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
|
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
|
|
protected void |
changeEnabledState(Tool t,
boolean enabled)
|
|
Tool |
deregister(Class<? extends Tool> tc)
Deregisters the tool of the given class if the tool instance of this class is currently registered as tool. |
|
ToolActivationPolicy |
getActivationPolicy()
|
|
Class<? extends Tool> |
getActiveTool()
Returns the Class of the currently active Tool or null if no
Tool has been activated |
|
|
getCompatibleTools(Class<T> clazz)
Return all registered Tools which are derived from the given class or which implement the given interface. |
|
|
getCompatibleTools(Class<T> clazz,
boolean enabledOnly)
Return all registered Tools which are derived from the given class or which implement the given interface. |
|
Collection<? extends MenuContributor> |
getMenuContributors()
Return the current list of tools suitable as menu contributors. |
|
Collection<Class<? extends Tool>> |
getRegisteredToolClasses()
Allows access to all registered tool classes. |
|
String |
getStatusFeedback()
|
|
|
getTool(Class<T> cls)
Return the tool instance for the given tool class, or null if no such tool is
registered. |
|
static String |
getToolPropertyPrefix(Class<? extends Tool> tc)
Constructs the property name prefix for Tool property change events. |
|
ViewComponent |
getViewComponent()
|
|
void |
handleEditEvent(Class<?> context,
EditEvent e)
|
|
boolean |
hasTool(Class<? extends Tool> cls)
Return whether this tool manager currently manages a tool of the given class. |
|
boolean |
isActive(Class<? extends Tool> tc)
Return whether the tool of the given class is currently active. |
|
protected boolean |
isActive(Tool t)
Return whether the given tool is currently active. |
|
boolean |
isEnabled(Class<? extends Tool> tc)
Checks whether the given Tool is enabled. |
|
boolean |
isExclusive()
Return whether the exclusive tool mode is active, i.e. |
|
|
register(Class<T> tc,
boolean enabled)
Registers the tool of the given class if the tool instance of this class is not currently registered as tool. |
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
|
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
|
|
void |
render(RenderParameters parameters)
Render the Tool UIs onto the given Graphics2D context using the given
RenderControls . |
|
void |
repaint(Page p)
Repaint the area pertaining to the given page. |
|
void |
repaint(Page p,
Rectangle2D boundsDU)
Repaint the area pertaining to the given page and bounds. |
|
void |
setActivationPolicy(ToolActivationPolicy activationPolicy)
|
|
protected void |
setCursor(Cursor cursor)
|
|
void |
setEnabled(Class<? extends Tool> tc,
boolean enabled)
Change the enabled state of the tool of the given class. |
|
void |
setExclusive(Class<? extends Tool> tc)
Set the tool of the given class to be the exclusive tool. |
|
void |
setNonExclusive(Class<? extends Tool> tc)
Leave exclusive mode. |
|
protected void |
setStatusFeedback(String statusFeedback)
|
|
void |
toolPropertyChanged(Tool tool,
String propertyName,
Object oldValue,
Object newValue)
Send a PropertyChangeEvent for the specified Tool property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@CallOnEDT public ToolManager(ViewComponent viewComponent)
Method Detail |
---|
@CallableOffEDT public static String getToolPropertyPrefix(Class<? extends Tool> tc)
Tool
property change events. Any Event sent
using toolPropertyChanged(Tool, String, Object, Object)
will use the value returned by
this class as a prefix.
tc
- the Tool
implementation class
@CallOnEDT public void repaint(Page p)
p
- @CallOnEDT public void repaint(Page p, Rectangle2D boundsDU)
p
- boundsDU
- @CallOnEDT public ViewComponent getViewComponent()
@CallOnEDT public <T extends Tool> T register(Class<T> tc, boolean enabled)
tc
- the tool classenabled
- whether the tool will initially be enabled
IllegalStateException
- if the calling thread is not the Event Dispatch
Thread
@CallOnEDT public Tool deregister(Class<? extends Tool> tc)
null
will be returned.
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the tool class
null
if available otherwise
null
. Be aware this tool instance is already deregistered when returned
and can not be used as tool anymore.
IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT public void activate(Class<? extends Tool> tc)
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the tool class
IllegalArgumentException
- if no tool of the given class is currently managed by this
ToolManager
.
IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT public void handleEditEvent(Class<?> context, EditEvent e)
@CallableOffEDT public boolean hasTool(Class<? extends Tool> cls)
@CallableOffEDT public <T extends Tool> T getTool(Class<T> cls)
null
if no such tool is
registered.
@CallOnEDT public boolean isActive(Class<? extends Tool> tc)
tc
- the tool class
true
if the tool is active@CallOnEDT protected boolean isActive(Tool t)
t
- the tool
true
if the tool is active@CallOnEDT public boolean isExclusive()
true
if exclusive mode is active@CallOnEDT public void render(RenderParameters parameters)
Graphics2D
context using the given
RenderControls
.
This render method is usually called within the context and during the rendering of a single page. It will dispatch the render calls to all active tools.
parameters
- the render parameters to use.@CallOnEDT public void setEnabled(Class<? extends Tool> tc, boolean enabled)
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the tool classenabled
- true
to enabled the tool, otherwise false
IllegalArgumentException
- if no tool of the given class is currently managed by this
ToolManager
.
IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT protected void changeEnabledState(Tool t, boolean enabled)
@CallOnEDT public boolean isEnabled(Class<? extends Tool> tc)
Tool
is enabled. This method will not fail if the Tool
has not yet been registered. Instead, for non registered tools this method will return false.
tc
-
true
if the Tool
is enabled, or false
if it is not or
the Tool
has not yet been registered.@CallOnEDT public void setExclusive(Class<? extends Tool> tc)
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the class of the tool to make exclusive
IllegalArgumentException
- if no tool of the given class is currently managed by this
ToolManager
.
IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT public void setNonExclusive(Class<? extends Tool> tc)
public void toolPropertyChanged(Tool tool, String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent
for the specified Tool
property. The
property name
will be qualified using the
following schema: "ToolPropertyPrefix
.propertyName
"
tool
- propertyName
- the property name, which will be prefixed with
a Tool specific prefix
oldValue
- newValue
- getToolPropertyPrefix(Class)
@CallableOffEDT public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- PropertyChangeSupport.addPropertyChangeListener(java.beans.PropertyChangeListener)
@CallableOffEDT public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- listener
- PropertyChangeSupport.addPropertyChangeListener(java.lang.String,
java.beans.PropertyChangeListener)
@CallableOffEDT public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- PropertyChangeSupport.removePropertyChangeListener(java.beans.PropertyChangeListener)
@CallableOffEDT public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- listener
- PropertyChangeSupport.removePropertyChangeListener(java.lang.String,
java.beans.PropertyChangeListener)
@CallOnEDT public <T> Collection<T> getCompatibleTools(Class<T> clazz)
T
- type of class or interface in questionclazz
- the class or interface in question
@CallOnEDT public <T> Collection<T> getCompatibleTools(Class<T> clazz, boolean enabledOnly)
T
- type of class or interface in questionclazz
- the class or interface in questionenabledOnly
- whether only enabled tools (true
) or all registered tools shall
be considered
@CallableOffEDT public Collection<Class<? extends Tool>> getRegisteredToolClasses()
Tool
s. The returned Collection
is read-only and does not follow any kind of
sorting. (The order is random)
Collection
of all registered Tool
classes.@CallOnEDT public Collection<? extends MenuContributor> getMenuContributors()
@CallOnEDT public void setActivationPolicy(ToolActivationPolicy activationPolicy)
@CallOnEDT public ToolActivationPolicy getActivationPolicy()
@CallOnEDT protected void setCursor(Cursor cursor)
@CallOnEDT protected void setStatusFeedback(String statusFeedback)
@CallOnEDT public String getStatusFeedback()
@CallOnEDT public Class<? extends Tool> getActiveTool()
Class
of the currently active Tool
or null
if no
Tool
has been activated
Class
of the currently active Tool
or null
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |