Class BasicToolManager
java.lang.Object
com.levigo.jadice.web.client.tool.BasicToolManager
- All Implemented Interfaces:
ToolManager,com.levigo.jadice.web.client.util.internal.widget.HasEnsureDebugId
public class BasicToolManager
extends Object
implements ToolManager, com.levigo.jadice.web.client.util.internal.widget.HasEnsureDebugId
Implementation of the default
ToolManager.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidActivates the tool of the given class.com.google.gwt.event.shared.HandlerRegistrationAdds a property change listener.com.google.gwt.event.shared.HandlerRegistrationAdds a tool changed handler.protected voidchangeEnabledState(Tool t, boolean enabled) deregister(Class<? extends Tool> tc) Deregisters the tool of the given class if the tool instance of this class is currently registered as tool.voidensureDebugId(String baseID) voidFires aToolChangedEventto all listeners.<T> Collection<T> getCompatibleTools(Class<T> clazz) Returns all registered Tools which are derived from the given class or which implement the given interface.<T> Collection<T> getCompatibleTools(Class<T> clazz, boolean enabledOnly) Return all registered Tools which are derived from the given class or which implement the given interface.Returns theClassof the current exclusiveToolornullif noToolhas been set toToolManager.setExclusive(Class)(Class) exclusive}Collection<? extends MenuContributor> Return the current list of tools suitable as menu contributors.Collection<Class<? extends Tool>> Allows access to all registered tool classes.<T extends Tool>
TReturns the tool instance for the given tool class, ornullif no such tool is registered.voidhandleEditEvent(Class<?> context, EditEvent e) booleanReturns whether this tool manager currently manages a tool of the given class.protected booleanReturn whether the given tool is currently active.booleanReturn whether the tool of the given class is currently active.booleanChecks whether the givenToolis enabled.booleanReturn whether the exclusive tool mode is active, i.e. if the currently active tool is also the exclusive tool.<T extends Tool>
TRegisters the tool of the given class if the tool instance of this class is not currently registered as tool.voidrender(RenderParameters parameters) Render the Tool UIs using the givenRenderControls.voidsetActivationPolicy(ToolActivationPolicy activationPolicy) voidsetCursor(com.google.gwt.dom.client.Style.Cursor cursor) Sets the current shown CursorvoidSets the currently used cursor.voidsetEnabled(Class<? extends Tool> tc, boolean enabled) Change the enabled state of the tool of the given class.voidsetExclusive(Class<? extends Tool> tc) Set the tool of the given class to be the exclusive tool.voidsetNonExclusive(Class<? extends Tool> tc) Leave exclusive mode.voidsetStatusFeedback(String statusFeedback) voidsetViewComponent(ViewComponent viewComponent)
-
Constructor Details
-
BasicToolManager
public BasicToolManager()
-
-
Method Details
-
getViewComponent
- Specified by:
getViewComponentin interfaceToolManager
-
setViewComponent
- Specified by:
setViewComponentin interfaceToolManager
-
ensureDebugId
- Specified by:
ensureDebugIdin interfacecom.levigo.jadice.web.client.util.internal.widget.HasEnsureDebugId
-
register
Description copied from interface:ToolManagerRegisters the tool of the given class if the tool instance of this class is not currently registered as tool. If a tool of this class is already registered, this method simply returns the registered instance. Otherwise a tool instance will be created, registered and returned.- Specified by:
registerin interfaceToolManager- Type Parameters:
T- type extending Tool- Parameters:
tc- The tool classenabled- Specifies whether the tool will initially be enabled or not- Returns:
- the registered tool instance
-
deregister
Description copied from interface:ToolManagerDeregisters the tool of the given class if the tool instance of this class is currently registered as tool. The deregistered tool instance will be returned if a matching tool instance was found and deregistered. Otherwise
nullwill be returned.- Specified by:
deregisterin interfaceToolManager- Parameters:
tc- the tool class- Returns:
- the deregistered tool instance or
nullif available otherwisenull. Be aware this tool instance is already deregistered when returned and can not be used as tool anymore.
-
activate
Description copied from interface:ToolManagerActivates the tool of the given class.
- Specified by:
activatein interfaceToolManager- Parameters:
tc- the tool class
-
handleEditEvent
- Specified by:
handleEditEventin interfaceToolManager
-
hasTool
Description copied from interface:ToolManagerReturns whether this tool manager currently manages a tool of the given class.- Specified by:
hasToolin interfaceToolManager- Parameters:
cls- The class to check- Returns:
- True, if a tool of the given class is managed, false else
-
getTool
Description copied from interface:ToolManagerReturns the tool instance for the given tool class, ornullif no such tool is registered.- Specified by:
getToolin interfaceToolManager- Type Parameters:
T- A type extending Tool- Parameters:
cls- The class of the tool to return- Returns:
- The tool if existing, null else
-
isActive
Description copied from interface:ToolManagerReturn whether the tool of the given class is currently active.- Specified by:
isActivein interfaceToolManager- Parameters:
tc- the tool class- Returns:
trueif the tool is active
-
isActive
Return whether the given tool is currently active.- Parameters:
t- the tool- Returns:
trueif the tool is active
-
isExclusive
public boolean isExclusive()Description copied from interface:ToolManagerReturn whether the exclusive tool mode is active, i.e. if the currently active tool is also the exclusive tool. In exclusive mode no tools except the exclusive one get a chance to render or handle events.- Specified by:
isExclusivein interfaceToolManager- Returns:
trueif exclusive mode is active
-
render
Description copied from interface:ToolManagerRender the Tool UIs using the givenRenderControls.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.
- Specified by:
renderin interfaceToolManager- Parameters:
parameters- the render parameters to use
-
setEnabled
Description copied from interface:ToolManagerChange the enabled state of the tool of the given class.- Specified by:
setEnabledin interfaceToolManager- Parameters:
tc- the tool classenabled-trueto enabled the tool, otherwisefalse
-
changeEnabledState
-
isEnabled
Description copied from interface:ToolManagerChecks whether the givenToolis enabled. This method will not fail if theToolhas not yet been registered. Instead, for non registered tools this method will return false.- Specified by:
isEnabledin interfaceToolManager- Parameters:
tc- The class of the tool to check- Returns:
trueif theToolis enabled, orfalseif it is not or theToolhas not yet been registered.
-
setExclusive
Description copied from interface:ToolManagerSet the tool of the given class to be the exclusive tool.- Specified by:
setExclusivein interfaceToolManager- Parameters:
tc- The class of the tool to make exclusive
-
setNonExclusive
Description copied from interface:ToolManagerLeave exclusive mode. Whatever tool is currently exclusive will loose its exclusive status. If there is currently no exclusive mode tool, this call has no effect.- Specified by:
setNonExclusivein interfaceToolManager- Parameters:
tc- The class of the tool to make non-exclusive
-
getCompatibleTools
Description copied from interface:ToolManagerReturns all registered Tools which are derived from the given class or which implement the given interface. Only tools in the state 'enabled' are considered.- Specified by:
getCompatibleToolsin interfaceToolManager- Type Parameters:
T- type of class or interface in question- Parameters:
clazz- the class or interface in question- Returns:
- a (possibly empty) collection of tools
-
getCompatibleTools
Description copied from interface:ToolManagerReturn all registered Tools which are derived from the given class or which implement the given interface.- Specified by:
getCompatibleToolsin interfaceToolManager- Type Parameters:
T- type of class or interface in question- Parameters:
clazz- the class or interface in questionenabledOnly- whether only enabled tools (true) or all registered tools shall be considered- Returns:
- a (possibly empty) collection of tools
-
getRegisteredToolClasses
Description copied from interface:ToolManagerAllows access to all registered tool classes. This method will return active and inactiveTools. The returnedCollectionis read-only and does not follow any kind of sorting. (The order is random)- Specified by:
getRegisteredToolClassesin interfaceToolManager- Returns:
- a
Collectionof all registeredToolclasses
-
getMenuContributors
Return the current list of tools suitable as menu contributors.- Specified by:
getMenuContributorsin interfaceToolManager- Returns:
- a read-only list of tools.
-
setActivationPolicy
- Specified by:
setActivationPolicyin interfaceToolManager
-
getActivationPolicy
- Specified by:
getActivationPolicyin interfaceToolManager
-
setCursor
public void setCursor(com.google.gwt.dom.client.Style.Cursor cursor) Sets the current shown Cursor- Specified by:
setCursorin interfaceToolManager- Parameters:
cursor- Cursor or null for no Cursor
-
setCursor
Description copied from interface:ToolManagerSets the currently used cursor. Examples: setCursor("crosshair") or
setCursor(UIStyler.get().cursorStyle().ZOOM_IN_CURSOR())- Specified by:
setCursorin interfaceToolManager- Parameters:
cursor- the css value of the cursor to be set
-
setStatusFeedback
- Specified by:
setStatusFeedbackin interfaceToolManager
-
getStatusFeedback
- Specified by:
getStatusFeedbackin interfaceToolManager
-
getActiveTool
- Specified by:
getActiveToolin interfaceToolManager- Returns:
- the
Classof the currently activeToolornull
-
getExclusiveTool
Description copied from interface:ToolManagerReturns theClassof the current exclusiveToolornullif noToolhas been set toToolManager.setExclusive(Class)(Class) exclusive}- Specified by:
getExclusiveToolin interfaceToolManager- Returns:
- the
Classof the current exclusiveToolornull
-
addPropertyChangeListener
public com.google.gwt.event.shared.HandlerRegistration addPropertyChangeListener(PropertyChangeListener listener) Description copied from interface:ToolManagerAdds a property change listener.- Specified by:
addPropertyChangeListenerin interfaceToolManager- Parameters:
listener- The listener to add- Returns:
- Registration to remove the listener
- See Also:
-
addToolChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addToolChangedHandler(ToolChangedEvent.Handler handler) Description copied from interface:ToolManagerAdds a tool changed handler.- Specified by:
addToolChangedHandlerin interfaceToolManager- Parameters:
handler- the handler to add- Returns:
HandlerRegistrationto remove the handler
-
fireToolChangedEvent
Description copied from interface:ToolManagerFires aToolChangedEventto all listeners.- Specified by:
fireToolChangedEventin interfaceToolManager- Parameters:
event- the ToolChangedEvent which should be fired
-