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 Details

    • BasicToolManager

      public BasicToolManager()
  • Method Details

    • getViewComponent

      public ViewComponent getViewComponent()
      Specified by:
      getViewComponent in interface ToolManager
    • setViewComponent

      public void setViewComponent(ViewComponent viewComponent)
      Specified by:
      setViewComponent in interface ToolManager
    • ensureDebugId

      public void ensureDebugId(String baseID)
      Specified by:
      ensureDebugId in interface com.levigo.jadice.web.client.util.internal.widget.HasEnsureDebugId
    • register

      public <T extends Tool> T register(Class<T> tc, boolean enabled)
      Description copied from interface: ToolManager
      Registers 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:
      register in interface ToolManager
      Type Parameters:
      T - type extending Tool
      Parameters:
      tc - The tool class
      enabled - Specifies whether the tool will initially be enabled or not
      Returns:
      the registered tool instance
    • deregister

      public Tool deregister(Class<? extends Tool> tc)
      Description copied from interface: ToolManager

      Deregisters 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 null will be returned.

      Specified by:
      deregister in interface ToolManager
      Parameters:
      tc - the tool class
      Returns:
      the deregistered tool instance or null if available otherwise null. Be aware this tool instance is already deregistered when returned and can not be used as tool anymore.
    • activate

      public void activate(Class<? extends Tool> tc)
      Description copied from interface: ToolManager

      Activates the tool of the given class.

      Specified by:
      activate in interface ToolManager
      Parameters:
      tc - the tool class
    • handleEditEvent

      public void handleEditEvent(Class<?> context, EditEvent e)
      Specified by:
      handleEditEvent in interface ToolManager
    • hasTool

      public boolean hasTool(Class<? extends Tool> cls)
      Description copied from interface: ToolManager
      Returns whether this tool manager currently manages a tool of the given class.
      Specified by:
      hasTool in interface ToolManager
      Parameters:
      cls - The class to check
      Returns:
      True, if a tool of the given class is managed, false else
    • getTool

      public <T extends Tool> T getTool(Class<T> cls)
      Description copied from interface: ToolManager
      Returns the tool instance for the given tool class, or null if no such tool is registered.
      Specified by:
      getTool in interface ToolManager
      Type Parameters:
      T - A type extending Tool
      Parameters:
      cls - The class of the tool to return
      Returns:
      The tool if existing, null else
    • isActive

      public boolean isActive(Class<? extends Tool> tc)
      Description copied from interface: ToolManager
      Return whether the tool of the given class is currently active.
      Specified by:
      isActive in interface ToolManager
      Parameters:
      tc - the tool class
      Returns:
      true if the tool is active
    • isActive

      protected boolean isActive(Tool t)
      Return whether the given tool is currently active.
      Parameters:
      t - the tool
      Returns:
      true if the tool is active
    • isExclusive

      public boolean isExclusive()
      Description copied from interface: ToolManager
      Return 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:
      isExclusive in interface ToolManager
      Returns:
      true if exclusive mode is active
    • render

      public void render(RenderParameters parameters)
      Description copied from interface: ToolManager
      Render the Tool UIs 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.

      Specified by:
      render in interface ToolManager
      Parameters:
      parameters - the render parameters to use
    • setEnabled

      public void setEnabled(Class<? extends Tool> tc, boolean enabled)
      Description copied from interface: ToolManager
      Change the enabled state of the tool of the given class.
      Specified by:
      setEnabled in interface ToolManager
      Parameters:
      tc - the tool class
      enabled - true to enabled the tool, otherwise false
    • changeEnabledState

      protected void changeEnabledState(Tool t, boolean enabled)
    • isEnabled

      public boolean isEnabled(Class<? extends Tool> tc)
      Description copied from interface: ToolManager
      Checks whether the given 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.
      Specified by:
      isEnabled in interface ToolManager
      Parameters:
      tc - The class of the tool to check
      Returns:
      true if the Tool is enabled, or false if it is not or the Tool has not yet been registered.
    • setExclusive

      public void setExclusive(Class<? extends Tool> tc)
      Description copied from interface: ToolManager
      Set the tool of the given class to be the exclusive tool.
      Specified by:
      setExclusive in interface ToolManager
      Parameters:
      tc - The class of the tool to make exclusive
    • setNonExclusive

      public void setNonExclusive(Class<? extends Tool> tc)
      Description copied from interface: ToolManager
      Leave 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:
      setNonExclusive in interface ToolManager
      Parameters:
      tc - The class of the tool to make non-exclusive
    • getCompatibleTools

      public <T> Collection<T> getCompatibleTools(Class<T> clazz)
      Description copied from interface: ToolManager
      Returns 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:
      getCompatibleTools in interface ToolManager
      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

      public <T> Collection<T> getCompatibleTools(Class<T> clazz, boolean enabledOnly)
      Description copied from interface: ToolManager
      Return all registered Tools which are derived from the given class or which implement the given interface.
      Specified by:
      getCompatibleTools in interface ToolManager
      Type Parameters:
      T - type of class or interface in question
      Parameters:
      clazz - the class or interface in question
      enabledOnly - whether only enabled tools (true) or all registered tools shall be considered
      Returns:
      a (possibly empty) collection of tools
    • getRegisteredToolClasses

      public Collection<Class<? extends Tool>> getRegisteredToolClasses()
      Description copied from interface: ToolManager
      Allows access to all registered tool classes. This method will return active and inactive Tools. The returned Collection is read-only and does not follow any kind of sorting. (The order is random)
      Specified by:
      getRegisteredToolClasses in interface ToolManager
      Returns:
      a Collection of all registered Tool classes
    • getMenuContributors

      public Collection<? extends MenuContributor> getMenuContributors()
      Return the current list of tools suitable as menu contributors.
      Specified by:
      getMenuContributors in interface ToolManager
      Returns:
      a read-only list of tools.
    • setActivationPolicy

      public void setActivationPolicy(ToolActivationPolicy activationPolicy)
      Specified by:
      setActivationPolicy in interface ToolManager
    • getActivationPolicy

      public ToolActivationPolicy getActivationPolicy()
      Specified by:
      getActivationPolicy in interface ToolManager
    • setCursor

      public void setCursor(com.google.gwt.dom.client.Style.Cursor cursor)
      Sets the current shown Cursor
      Specified by:
      setCursor in interface ToolManager
      Parameters:
      cursor - Cursor or null for no Cursor
    • setCursor

      public void setCursor(String cursor)
      Description copied from interface: ToolManager
      Sets the currently used cursor. Examples: setCursor("crosshair") or
      setCursor(UIStyler.get().cursorStyle().ZOOM_IN_CURSOR())
      Specified by:
      setCursor in interface ToolManager
      Parameters:
      cursor - the css value of the cursor to be set
    • setStatusFeedback

      public void setStatusFeedback(String statusFeedback)
      Specified by:
      setStatusFeedback in interface ToolManager
    • getStatusFeedback

      public String getStatusFeedback()
      Specified by:
      getStatusFeedback in interface ToolManager
    • getActiveTool

      public Class<? extends Tool> getActiveTool()
      Returns the Class of the currently active Tool or null if no Tool has been activated
      Specified by:
      getActiveTool in interface ToolManager
      Returns:
      the Class of the currently active Tool or null
    • getExclusiveTool

      public Class<? extends Tool> getExclusiveTool()
      Description copied from interface: ToolManager
      Returns the Class of the current exclusive Tool or null if no Tool has been set to ToolManager.setExclusive(Class) (Class) exclusive}
      Specified by:
      getExclusiveTool in interface ToolManager
      Returns:
      the Class of the current exclusive Tool or null
    • addPropertyChangeListener

      public com.google.gwt.event.shared.HandlerRegistration addPropertyChangeListener(PropertyChangeListener listener)
      Description copied from interface: ToolManager
      Adds a property change listener.
      Specified by:
      addPropertyChangeListener in interface ToolManager
      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: ToolManager
      Adds a tool changed handler.
      Specified by:
      addToolChangedHandler in interface ToolManager
      Parameters:
      handler - the handler to add
      Returns:
      HandlerRegistration to remove the handler
    • fireToolChangedEvent

      public void fireToolChangedEvent(ToolChangedEvent event)
      Description copied from interface: ToolManager
      Fires a ToolChangedEvent to all listeners.
      Specified by:
      fireToolChangedEvent in interface ToolManager
      Parameters:
      event - the ToolChangedEvent which should be fired