Class ExtensionDetailsPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ExtensionDetailsPanel extends JPanel
Displays details about an extension using a supplied AppExtensionInfo instance. Optionally, callers can provide additional information about the extension to display extra information:
  • For locally installed and loaded extensions, you can supply a jar file to display information about where the extension is installed.
  • For downloadable extensions that are not yet installed, you can display information such as the list of screenshots provided (if any).
  • You can supply a null AppExtensionInfo instance for a "blank" display panel.
Since:
2023-11-11
Author:
scorbo2
See Also:
  • Field Details

  • Constructor Details

    • ExtensionDetailsPanel

      public ExtensionDetailsPanel(Window owner, AppExtensionInfo extInfo)
      Creates an ExtensionDetailsPanel for the given AppExtensionInfo instance (which may be null). The Window parameter is to set ownership and position of any popups launched from this panel.
  • Method Details

    • setNameFieldVisible

      public ExtensionDetailsPanel setNameFieldVisible(boolean visible)
      The extension Name field can be optionally made hidden. This is useful if you are selecting extensions out of a list, and the name of the extension is already obvious from context.
    • setIsLocallyInstalledExtension

      public ExtensionDetailsPanel setIsLocallyInstalledExtension(File jarFile)
      Use this method to indicate that the extension in question is a locally-installed extension with the given source jar. Doing so will display extra information inferred from the supplied jar file (which may be null).

      If the given jar file is null: the extension is considered a "built-in" (application-supplied) extension that does not have an install location.

      If the given jar file is not null:

      • The install location of the jar file is displayed.
      • The name of the jar file is displayed.
      • Extension type: "system" if the jar is in a read-only location, or "user" if the jar is in a writable directory.

      Note that this method does nothing if the AppExtensionInfo supplied to the constructor was null.

    • addScreenshot

      public ExtensionDetailsPanel addScreenshot(BufferedImage screenshot, boolean isEditable)
      You can supply optional screenshots to accompany this extension's display.
    • addScreenshot

      public ExtensionDetailsPanel addScreenshot(BufferedImage thumbnail, ImageIcon screenshot, boolean isEditable)
      You can supply optional screenshots to accompany this extension's display.
    • setScreenshotsVisible

      public ExtensionDetailsPanel setScreenshotsVisible(boolean visible)
    • setScreenshotsEditable

      public ExtensionDetailsPanel setScreenshotsEditable(boolean editable)
    • getScreenshotCount

      public int getScreenshotCount()
    • getScreenshotAtIndex

      public Object getScreenshotAtIndex(int i)
    • setScreenshotsThumbnailSize

      public ExtensionDetailsPanel setScreenshotsThumbnailSize(int size)
    • setConfigProperties

      public ExtensionDetailsPanel setConfigProperties(List<AbstractProperty> configProps)
      You can supply a list of configuration properties for the extension, in which case a hyperlink field will be shown to display a preview of those properties. Note that if the given list does not contain any exposed properties (isExposed() == true), then the field will not be shown.
    • initComponents

      protected void initComponents()
    • addNameField

      protected void addNameField()
      Adds a LabelField for displaying the extension name in slightly larger font. This can be hidden via setNameFieldVisible().
    • addExtensionJarFields

      protected void addExtensionJarFields()
      Adds initially-hidden fields for displaying information about locally-installed extensions. These fields can be made visible via setIsLocallyInstalledExtension().
    • addVersionField

      protected void addVersionField()
      Adds a LabelField for showing the extension version (if one is set).
    • addVersionRequiredField

      protected void addVersionRequiredField()
      If the extension has a targetAppName and a targetAppVersion (which it typically will), adds a LabelField to show this.
    • addAuthorField

      protected void addAuthorField()
      Adds a LabelField to show the author name. If an author URL is also set, adds a LabelField to show that as well.
    • addShortDescriptionField

      protected void addShortDescriptionField()
      Adds a multi-line text field for showing the short description of this extension.
    • addConfigPropsField

      protected void addConfigPropsField()
      Adds an initially-hidden LabelField which can show a hyperlink for showing a preview of any config properties specified by this extension. This field can be made visible via setConfigProperties().
    • addCustomFields

      protected void addCustomFields()
      If any custom fields are defined in the AppExtensionInfo instance, this will add one LabelField for each defined field.
    • addLongDescriptionField

      protected void addLongDescriptionField()
      Adds a LongTextField with popout capabilities to display the extension's long description.
    • addProjectUrlField

      protected void addProjectUrlField()
      If the AppExtensionInfo specifies a project URL, adds a hyperlink label for viewing it.
    • addReleaseNotesField

      protected void addReleaseNotesField()
      If the AppExtensionInfo specifies release notes, adds a LongTextField with popout capabilities for viewing them.
    • addScreenshotsField

      protected void addScreenshotsField()
      Adds an initially-hidden ImageListPanel for viewing extension screenshots. This field can be made visible via either of the addScreenshot() methods.
    • hasVisibleProps

      protected boolean hasVisibleProps(List<AbstractProperty> configProps)
      Returns true if the given list of properties is not null, not empty, and has at least one config property that is exposed to the user.
      Parameters:
      configProps - The list of props to check. Can be null.
      Returns:
      True if there's at least one user-exposed config property in the list.
    • showConfigPreview

      protected void showConfigPreview(List<AbstractProperty> configProps)
      Shows a read-only preview of the given properties list, with default values populated. Note that any form visibility logic will NOT be reflected here, as the code at this level has absolutely no idea what fields should be visible by default (that logic lives at the application level).

      All props will be shown here read-only, as there's nowhere to save any changes.

      Parameters:
      configProps - A list of AbstractProperty instances to show.
    • isBrowsingSupported

      protected static boolean isBrowsingSupported()
      Reports whether the current JRE supports browsing (needed to open hyperlinks).
    • isUrl

      public static boolean isUrl(String url)
      Does a very quick check on the given String to see if it looks like a URL. This doesn't guarantee that it will parse as one! This is just a very quick check.