Class ExtensionDetailsPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ExtensionDetailsPanel extends JPanel
Shows the details of a single AppExtension (by interrogating its AppExtensionInfo). Can also be used to enable or disable an extension. You shouldn't generally need to instantiate this panel yourself... much easier to go through ExtensionPanel or ExtensionDialog.
Since:
2023-11-11
Author:
scorbo2
See Also:
  • Field Details

  • Constructor Details

    • ExtensionDetailsPanel

      public ExtensionDetailsPanel(Window owner, ExtensionManager manager, AppExtension extension, boolean isEnabled)
      Creates a new ExtensionDetailsPanel for the given AppExtension, which can be null - if null, an empty disabled panel will be generated.
      Parameters:
      owner - The Window that owns this panel.
      manager - The ExtensionManager that's managing this extension.
      extension - Any AppExtension, or null to generate a disabled empty details panel.
      isEnabled - Whether the given extension is enabled (ignored if extension is null).
  • Method Details

    • isExtensionEnabled

      public boolean isExtensionEnabled()
      Returns the state of the "enabled" checkbox, which can be manipulated by the user.
      Returns:
      Whether this extension is marked as enabled or not.
    • setExtensionEnabled

      public void setExtensionEnabled(boolean enabled)
      Allows programmatic setting of the "enabled" checkbox. Note that this doesn't actually enable or disable the extension - it just sets the checkbox state in this details panel, which can later be read by isExtensionEnabled().
      Parameters:
      enabled - The new value for the enabled checkbox.
    • addExtensionDetailsPanelListener

      public void addExtensionDetailsPanelListener(ExtensionDetailsPanelListener listener)
      Registers a listener that will be informed when our enabled checkbox state is modified.
      Parameters:
      listener - An ExtensionDetailsPanelListener
    • removeExtensionDetailsPanelListener

      public void removeExtensionDetailsPanelListener(ExtensionDetailsPanelListener listener)
      Unregisters the given listener.
      Parameters:
      listener - An ExtensionDetailsPanelListener
    • initComponents

      protected void initComponents(boolean isEnabled)
    • fireEnableChangeEvent

      protected void fireEnableChangeEvent()
    • determineExtensionType

      protected String determineExtensionType()
      If an extension jar exists in a read-only directory, we consider it a "system" extension, and if it is in a readable directory, it is a "user" extension - there is a third class of extensions called "application built-in" which are those provided directly by an application without being externally loaded from a jar file. Applications can decide how to package and install extensions, and users can decide where to put their own extension jars. This classification, or "extension type" is displayed in the ExtensionDetailsPanel for informational purposes, but it doesn't change the way we interact with those extensions.
      Returns:
      A String describing the type of extension: System, User, or Application built-in.
    • getSourceJar

      protected File getSourceJar()
      Returns the source jar file from which this extension was loaded, or null if there isn't one (which will be the case for built-in extensions, which are not loaded from external jar files).
      Returns:
      A File representing the jar file from which this extension was loaded, or null.
    • trimString

      protected String trimString(String input)
    • trimString

      protected String trimString(String input, int LIMIT)
    • 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.