Class FileMiniature

All Implemented Interfaces:
BrowserEventHandler, ErrorEventHandler, Animatable<FileMiniature>, CanDrop<FileMiniature>, Clickable<FileMiniature>, Draggable<FileMiniature>, HandleHotKey<FileMiniature>, HandleMouseEvents<FileMiniature>, Touchable<FileMiniature>

File miniature component

The component draws an icon (and the filename) in a box, that is representative of the file's format. The user can then download the file either by clicking on it's name, or it's icon

Supported events:

AnimationStart AnimationEnd, Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd HotKey

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • FileMiniature

      public FileMiniature(JBFile jbFile)
      Creates a file miniature component, based on the specified file
      Parameters:
      jbFile - The JBFile file, that will be the basis for the component.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
      NullPointerException - If the specified file is null
    • FileMiniature

      public FileMiniature(String id, JBFile jbFile)
      Creates a file miniature component, based on the specified file
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      jbFile - The JBFile file, that will be the basis for the component.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
      NullPointerException - If the specified file is null
    • FileMiniature

      public FileMiniature(JBFile jbFile, String language)
      Creates a file miniature component, based on the specified file
      Parameters:
      jbFile - The JBFile file, that will be the basis for the component.
      language - The code of the language, that will be used in the component
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
      NullPointerException - If the specified file is null
    • FileMiniature

      public FileMiniature(String id, JBFile jbFile, String language)
      Creates a file miniature component, based on the specified file
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      jbFile - The JBFile file, that will be the basis for the component.
      language - The code of the language, that will be used in the component
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
      NullPointerException - If the specified file is null
  • Method Details

    • getFileStoreName

      public final String getFileStoreName()
      Gets the name of the filestore, that is used to store the file that is used in this component
      Returns:
      The name of the filestore, that is used to store the file or null, if the file in the component has no file store name.
    • getFilename

      public String getFilename()
      Gets the name of the file that is used in this component
      Returns:
      The filename
    • getFileId

      public String getFileId()
      Gets the ID of the file that is used in the component
      Returns:
      The file ID or null, if the file is yet to be saved to a filestore
    • getExtension

      public String getExtension()
      Gets the extension of the file that is used in the component
      Returns:
      The file extension or null, if the file has no extension specified. The returned extension will be in all caps.
    • getIcon

      public final Icon getIcon()
      Gets the Icon that corresponds to the file's extension
      Returns:
      The Icon that corresponds to the file's extension
    • addComponent

      public FileMiniature addComponent(Component<?> component)
      Adds the specified component as a subcomponent, and redraws the component immediately
      Overrides:
      addComponent in class Component<FileMiniature>
      Parameters:
      component - The component to be added
      Returns:
      The component
    • removeComponent

      public FileMiniature removeComponent(Component component)
      Removes the specified subcomponent.
      Overrides:
      removeComponent in class Component<FileMiniature>
      Parameters:
      component - The component instance
      Returns:
      The component
    • addClickHandler

      public FileMiniature addClickHandler(ClickEventHandler handler)
      Adds a single click event handler to the component. This handler runs when the user clicks once on the component.
      Specified by:
      addClickHandler in interface Clickable<FileMiniature>
      Parameters:
      handler - The ClickEventHandler implementation
      Returns:
      The component
      See Also:
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<FileMiniature>
      Returns:
      If the componentwas drawn, true, otherwise false
    • downloadFile

      public FileMiniature downloadFile()
      Downloads the file to the client where the component is currently visible.
      Returns:
      The file miniature component
      Throws:
      IllegalStateException - If the method is called when the component isn't displayed on any interfaces.
    • addDownloadErrorHandler

      public final FileMiniature addDownloadErrorHandler(ErrorEventHandler handler)
      Adds a download event handler to the component. The specified event handler is called, when an error is encountered during the download process
      Parameters:
      handler - The ErrorEventHandler implementation
      Returns:
      The file miniature component
      See Also:
    • onError

      public void onError(ErrorEvent event)
      Description copied from interface: ErrorEventHandler

      Generic error event handler

      The event handler will be called, when an error is encountered in a process.

      Specified by:
      onError in interface ErrorEventHandler
      Parameters:
      event - The event object
      See Also:
    • addHotKey

      public FileMiniature addHotKey(int hotKey)
      Adds the specified hot key to the component. If the user presses the hot key, the component's Click event handler will be fired. If the hot key was assigned to an input field, the field will gain focus.
      Specified by:
      addHotKey in interface HandleHotKey<FileMiniature>
      Parameters:
      hotKey - The button combination, that will be assigned to the component. This button combination can be specified, by using the Key class' constants. If the hot key is a combination of two buttons, then the values must be added. For example, the CTRL+S combination is specified as KEY.CTRL + KEY.KEY_S
      Returns:
      The component
    • addHotKey

      public FileMiniature addHotKey(int hotKey, HotKeyEventHandler handler)
      Adds the specified hot key to the component. If the user presses the hot key, the specified event handler will be fired
      Specified by:
      addHotKey in interface HandleHotKey<FileMiniature>
      Parameters:
      hotKey - The button combination, that will be assigned to the component. This button combination can be specified, by using the Key class' constants. If the hot key is a combination of two buttons, then the values must be added. For example, the CTRL+S combination is specified as KEY.CTRL + KEY.KEY_S
      handler - The HotKeyEventHandler implementation
      Returns:
      The component
      See Also: