Package ca.corbett.extensions.ui
Class ExtensionDetailsPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ca.corbett.extensions.ui.ExtensionDetailsPanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA generic action that can be hooked onto any hyperlinked LabelField to open the given url in the user's default browser.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LabelFieldprotected LabelFieldprotected final AppExtensionInfoprotected FormPanelprotected LabelFieldprotected LabelFieldprotected LabelFieldprotected final Windowprotected ImageListFieldFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionExtensionDetailsPanel(Window owner, AppExtensionInfo extInfo) Creates an ExtensionDetailsPanel for the given AppExtensionInfo instance (which may be null). -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds a LabelField to show the author name.protected voidAdds an initially-hidden LabelField which can show a hyperlink for showing a preview of any config properties specified by this extension.protected voidIf any custom fields are defined in the AppExtensionInfo instance, this will add one LabelField for each defined field.protected voidAdds initially-hidden fields for displaying information about locally-installed extensions.protected voidAdds a LongTextField with popout capabilities to display the extension's long description.protected voidAdds a LabelField for displaying the extension name in slightly larger font.protected voidIf the AppExtensionInfo specifies a project URL, adds a hyperlink label for viewing it.protected voidIf the AppExtensionInfo specifies release notes, adds a LongTextField with popout capabilities for viewing them.addScreenshot(BufferedImage screenshot, boolean isEditable) You can supply optional screenshots to accompany this extension's display.addScreenshot(BufferedImage thumbnail, ImageIcon screenshot, boolean isEditable) You can supply optional screenshots to accompany this extension's display.protected voidAdds an initially-hidden ImageListPanel for viewing extension screenshots.protected voidAdds a multi-line text field for showing the short description of this extension.protected voidAdds a LabelField for showing the extension version (if one is set).protected voidIf the extension has a targetAppName and a targetAppVersion (which it typically will), adds a LabelField to show this.getScreenshotAtIndex(int i) intprotected booleanhasVisibleProps(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.protected voidprotected static booleanReports whether the current JRE supports browsing (needed to open hyperlinks).static booleanDoes a very quick check on the given String to see if it looks like a URL.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.setIsLocallyInstalledExtension(File jarFile) Use this method to indicate that the extension in question is a locally-installed extension with the given source jar.setNameFieldVisible(boolean visible) The extension Name field can be optionally made hidden.setScreenshotsEditable(boolean editable) setScreenshotsThumbnailSize(int size) setScreenshotsVisible(boolean visible) protected voidshowConfigPreview(List<AbstractProperty> configProps) Shows a read-only preview of the given properties list, with default values populated.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
owner
-
extInfo
-
formPanel
-
nameField
-
extensionTypeField
-
jarLocationField
-
jarNameField
-
configPropsField
-
screenshotsField
-
-
Constructor Details
-
ExtensionDetailsPanel
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
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
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
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
-
setScreenshotsEditable
-
getScreenshotCount
public int getScreenshotCount() -
getScreenshotAtIndex
-
setScreenshotsThumbnailSize
-
setConfigProperties
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
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
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
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.
-