Class ContextBar.AbstractButton

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractButton​(java.lang.String id, java.lang.String name, java.lang.String iconResource)
      Creates a new button the specified id, name, and with an icon loaded from the specified resource.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.swing.Icon getIcon()
      Returns the button's icon.
      java.lang.String getID()
      Returns a unique ID for this button, such as "BOLD".
      java.lang.String getName()
      Returns the button's name, or null.
      boolean isEnabledInCurrentContext​(ContextBar.Context context)
      Returns true if the button should be enabled in the current context.
      boolean isVisibleInCurrentContext​(ContextBar.Context context)
      Returns true if the button should be visible in the current context.
      void onAttach​(ContextBar.Context context)
      This method is called to notify the button when the tool bar is about to be attached to a new target component (the component that it floats over and that its commands normally apply to).
      void onDetach​(ContextBar.Context context)
      This method is called to notify the button when the tool bar is about to be detached from the current target component (the component that it floats over and that its commands normally apply to).
      java.lang.String toString()
      Returns a string representation of the button suitable for debugging.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.awt.event.ActionListener

        actionPerformed
    • Constructor Detail

      • AbstractButton

        public AbstractButton​(java.lang.String id,
                              java.lang.String name,
                              java.lang.String iconResource)
        Creates a new button the specified id, name, and with an icon loaded from the specified resource. The icon image is loaded using ResourceKit.getIcon(java.lang.String), except that if the icon resource does not contain a slash, the resource will be loaded from resources/icons/toolbar.
        Parameters:
        id - a unique button identifier
        name - the user-friendly name of the button
        iconResource - the resource to load the button's icon from
        Throws:
        java.lang.NullPointerException - if the name or icon resource is null
    • Method Detail

      • getID

        public java.lang.String getID()
        Description copied from interface: ContextBar.Button
        Returns a unique ID for this button, such as "BOLD". Only letters, digits, underscores, and currency symbols may appear in an ID.
        Specified by:
        getID in interface ContextBar.Button
        Returns:
        a short ID that will identify this button in the application preferences
      • getName

        public java.lang.String getName()
        Description copied from interface: ContextBar.Button
        Returns the button's name, or null.
        Specified by:
        getName in interface ContextBar.Button
        Returns:
        a localized description of the button's function
      • onAttach

        public void onAttach​(ContextBar.Context context)
        Description copied from interface: ContextBar.Button
        This method is called to notify the button when the tool bar is about to be attached to a new target component (the component that it floats over and that its commands normally apply to).
        Specified by:
        onAttach in interface ContextBar.Button
        Parameters:
        context - information about the current context
      • onDetach

        public void onDetach​(ContextBar.Context context)
        Description copied from interface: ContextBar.Button
        This method is called to notify the button when the tool bar is about to be detached from the current target component (the component that it floats over and that its commands normally apply to).
        Specified by:
        onDetach in interface ContextBar.Button
        Parameters:
        context - information about the current context
      • isEnabledInCurrentContext

        public boolean isEnabledInCurrentContext​(ContextBar.Context context)
        Description copied from interface: ContextBar.Button
        Returns true if the button should be enabled in the current context.
        Specified by:
        isEnabledInCurrentContext in interface ContextBar.Button
        Parameters:
        context - information about the current context
        Returns:
        true if the button should be enabled (ignored if not visible)
      • isVisibleInCurrentContext

        public boolean isVisibleInCurrentContext​(ContextBar.Context context)
        Description copied from interface: ContextBar.Button
        Returns true if the button should be visible in the current context. A button should be invisible if it can never be enabled in the current context, and disabled if it is not currently usable due to a temporary restriction. For example, any text field can be copied from if there is an active selection, so a copy button should always be visible but should be enabled only if there is a selection. On the other hand, a command that only works for script code should be visible only when editing a script.
        Specified by:
        isVisibleInCurrentContext in interface ContextBar.Button
        Parameters:
        context - information about the current context
        Returns:
        true if the button should be visible
      • toString

        public java.lang.String toString()
        Returns a string representation of the button suitable for debugging. The returned string is Button<id>, where id is the button's ID as returned by ContextBar.Button.getID().
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the button