Class AbstractFileViewPanel<T>

Type Parameters:
T - Type tag.
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public abstract class AbstractFileViewPanel<T> extends JCommandButtonPanel
Panel that hosts file-related command buttons with progress indication and cancellation capabilities.
See Also:
  • Field Details

    • buttonMap

      protected Map<String,JCommandButton> buttonMap
      Maps from file name to the buttons.
    • progressListener

      protected ProgressListener progressListener
      Progress listener to report back on loaded images.
    • loadedSet

      protected Set<JCommandButton> loadedSet
      Contains the buttons with completely loaded images.
  • Constructor Details

    • AbstractFileViewPanel

      public AbstractFileViewPanel(int startingDimension, ProgressListener progressListener)
      Creates a new panel.
      Parameters:
      startingDimension - Initial dimension for icons.
      progressListener - Progress listener to report back on loaded icons.
    • AbstractFileViewPanel

      public AbstractFileViewPanel(CommandButtonDisplayState startingState, ProgressListener progressListener)
      Creates a new panel.
      Parameters:
      startingState - Initial state for icons.
      progressListener - Progress listener to report back on loaded icons.
  • Method Details

    • setFolder

      public void setFolder(List<StringValuePair<T>> leafs)
      Sets the current entries to show. The current contents of the panel are discarded. For each matching entry determined by the toShowFile(StringValuePair) call, a new JCommandButton hosting an the matching implementation of ResizableIcon is added to the panel.
      Parameters:
      leafs - Information on the entries to show in the panel.
    • getLoadedIconCount

      public int getLoadedIconCount()
      Returns the number of loaded icons.
      Returns:
      The number of loaded icons.
    • cancelMainWorker

      public void cancelMainWorker()
      Cancels the pending processing.
    • getButtonMap

      public Map<String,JCommandButton> getButtonMap()
      Returns the button map.
      Returns:
      Unmodifiable view on the button map.
    • toShowFile

      protected abstract boolean toShowFile(StringValuePair<T> pair)
      Returns indication whether the specified file should be shown on this panel.
      Parameters:
      pair - Information on the file.
      Returns:
      true if the specified file should be shown on this panel, false otherwise.
    • getResizableIcon

      protected abstract ResizableIcon getResizableIcon(AbstractFileViewPanel.Leaf leaf, InputStream stream, CommandButtonDisplayState state, Dimension dimension)
      Returns the icon for the specified parameters.
      Parameters:
      leaf - Information on the file.
      stream - Input stream with the file contents.
      state - Icon state.
      dimension - Icon dimension.
      Returns:
      File icon.
    • configureCommandButton

      protected abstract void configureCommandButton(AbstractFileViewPanel.Leaf leaf, JCommandButton button, ResizableIcon icon)
      Configures the specified command button. Can be used to wire additional behavior, such as tooltips or action listeners if the specific view panel implementation requires it.
      Parameters:
      leaf - Information on the file "behind" the button.
      button - Button to configure.
      icon - Button icon.
    • getLeafContent

      protected abstract InputStream getLeafContent(T leaf)
      Returns the input stream with the file contents.
      Parameters:
      leaf - Leaf (file behind a command button on this panel).
      Returns:
      Input stream with the file contents.