Module is.codion.swing.framework.ui
Package is.codion.swing.framework.ui
Class EntityApplicationPanel<M extends SwingEntityApplicationModel>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
is.codion.swing.framework.ui.EntityApplicationPanel<M>
- Type Parameters:
M
- the application model type
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
A central application panel class.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Handles laying out an EntityApplicationPanel.static interface
EntityApplicationPanel.Builder<M extends SwingEntityApplicationModel,
P extends EntityApplicationPanel<M>> Builds aEntityApplicationPanel
and starts the application.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PropertyValue<Boolean>
Specifies whether EntityPanels displayed viadisplayEntityPanelDialog(EntityPanel)
ordisplayEntityPanelFrame(EntityPanel)
should be cached, instead of being created each time the dialog/frame is shown.static final PropertyValue<Boolean>
Indicates whether the application should ask for confirmation when exiting Value type: Boolean Default value: falsestatic final PropertyValue<String>
Specifies the URL to the application help Value type: String Default value: https://codion.is/doc/{version}/help/client.htmlstatic final PropertyValue<Boolean>
Specifies whether a startup dialog should be shown Value type: Boolean Default value: truestatic final PropertyValue<Boolean>
Specifies whether the client should save and apply user preferences Value type: Boolean Default value: trueFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionEntityApplicationPanel
(M applicationModel) EntityApplicationPanel
(M applicationModel, Function<EntityApplicationPanel<M>, EntityApplicationPanel.ApplicationLayout> applicationLayout) -
Method Summary
Modifier and TypeMethodDescriptionfinal State
final <T extends EntityApplicationPanel.ApplicationLayout>
Tfinal M
protected void
Override to add event bindings after initializationstatic <M extends SwingEntityApplicationModel,
P extends EntityApplicationPanel<M>>
EntityApplicationPanel.Builder<M,P> protected final Control
protected JPanel
protected final ToggleControl
static TreeModel
createDependencyTreeModel
(Entities entities) protected abstract List<EntityPanel>
Creates theEntityPanel
s to include in this application panel.protected final Control
protected final Control
protected final Controls
Creates the JMenuBar to use on the application Frameprotected final Control
protected final Control
Allows the user the select between the available Look and Feels, saves the selection as a user preference.protected Collection<EntityPanel.Builder>
Returns a Collection ofEntityPanel.Builder
instances to use to populate the Support Table menu.protected final Control
protected final Control
protected final Control
final void
Shows an about dialogprotected final void
displayEntityPanel
(EntityPanel entityPanel) Displays the given panel in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE
.protected final void
displayEntityPanel
(EntityPanel.Builder panelBuilder) Displays the panel provided by the given builder in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE
.protected final void
displayEntityPanelDialog
(EntityPanel entityPanel) Shows a non-modal dialog containing the given entity panelprotected final void
displayEntityPanelDialog
(EntityPanel entityPanel, boolean modalDialog) Shows a dialog containing the given entity panelprotected final void
displayEntityPanelFrame
(EntityPanel entityPanel) Shows a frame containing the given entity panelfinal void
displayException
(Exception exception) Displays the exception in a dialogvoid
Displays the help.final void
Displays a keyboard shortcut overview panel.final <T extends EntityPanel>
TentityPanel
(EntityType entityType) final List<EntityPanel>
final void
exit()
Exits this applicationprotected final Observer<?>
To cancel the exit add a listener throwing aCancelException
.final void
Initializes this panel and marks is as initialized, subsequent calls have no effect.final Observer<EntityApplicationPanel<?>>
protected void
Called during the exit() method, override to save user preferences on program exit, remember to call super.savePreferences() when overridingfinal void
Displays in a dialog a tree describing the application layoutfinal void
Shows a dialog containing a dependency tree view of all defined entitiesMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods 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, update
Methods 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, validateTree
Methods 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
-
USE_CLIENT_PREFERENCES
Specifies whether the client should save and apply user preferences- Value type: Boolean
- Default value: true
- See Also:
-
HELP_URL
Specifies the URL to the application help- Value type: String
- Default value: https://codion.is/doc/{version}/help/client.html
-
CONFIRM_EXIT
Indicates whether the application should ask for confirmation when exiting- Value type: Boolean
- Default value: false
-
SHOW_STARTUP_DIALOG
Specifies whether a startup dialog should be shown- Value type: Boolean
- Default value: true
-
CACHE_ENTITY_PANELS
Specifies whether EntityPanels displayed viadisplayEntityPanelDialog(EntityPanel)
ordisplayEntityPanelFrame(EntityPanel)
should be cached, instead of being created each time the dialog/frame is shown.- Value type: Boolean
- Default value: false
-
-
Constructor Details
-
EntityApplicationPanel
-
EntityApplicationPanel
public EntityApplicationPanel(M applicationModel, Function<EntityApplicationPanel<M>, EntityApplicationPanel.ApplicationLayout> applicationLayout)
-
-
Method Details
-
displayException
Displays the exception in a dialog- Parameters:
exception
- the exception to display
-
applicationModel
- Returns:
- the application model this application panel is based on
-
applicationLayout
- Type Parameters:
T
- the layout type- Returns:
- the application layout
-
entityPanel
- Type Parameters:
T
- the entity panel type- Parameters:
entityType
- the entityType- Returns:
- the first entity panel found based on the given entity type
- Throws:
IllegalArgumentException
- in case this application panel does not contain a panel for the given entity type
-
entityPanels
- Returns:
- an unmodifiable view of the main application panels
-
parentWindow
- Returns:
- the parent window of this panel, if one exists, an empty Optional otherwise
-
alwaysOnTop
- Returns:
- a State controlling the alwaysOnTop state of this panels parent window
-
viewApplicationTree
public final void viewApplicationTree()Displays in a dialog a tree describing the application layout -
viewDependencyTree
public final void viewDependencyTree()Shows a dialog containing a dependency tree view of all defined entities -
initializedEvent
- Returns:
- an observer notified when this application panel is initialized
- See Also:
-
exit
public final void exit()Exits this application- Throws:
CancelException
- if the exit is cancelled- See Also:
-
displayHelp
Displays the help. -
displayKeyboardShortcuts
public final void displayKeyboardShortcuts()Displays a keyboard shortcut overview panel. -
displayAbout
public final void displayAbout()Shows an about dialog- See Also:
-
initialize
public final void initialize()Initializes this panel and marks is as initialized, subsequent calls have no effect. -
createDependencyTreeModel
- Parameters:
entities
- the entities- Returns:
- a tree model showing the dependencies between entities via foreign keys
-
builder
public static <M extends SwingEntityApplicationModel,P extends EntityApplicationPanel<M>> EntityApplicationPanel.Builder<M,P> builder(Class<M> applicationModelClass, Class<P> applicationPanelClass) - Type Parameters:
M
- the application model typeP
- the application panel type- Parameters:
applicationModelClass
- the application model classapplicationPanelClass
- the application panel class- Returns:
- a
EntityApplicationPanel.Builder
-
createMainMenuControls
- Returns:
- the controls on which to base the main menu or an empty Optional if the menu should be excluded
- See Also:
-
createFileMenuControls
- Returns:
- the Controls specifying the items in the 'File' menu or an empty Optional to skip the menu
-
createToolsMenuControls
- Returns:
- the Controls specifying the items in the 'Tools' menu or an empty Optional to skip the menu
-
createViewMenuControls
- Returns:
- the Controls specifying the items in the 'View' menu or an empty Optional to skip the menu
-
createHelpMenuControls
- Returns:
- the Controls specifying the items in the 'Help' menu or an empty Optional to skip the menu
-
createSupportTableMenuControls
- Returns:
- the Controls on which to base the Support Tables menu or an empty Optional to skip the menu
-
createExitControl
- Returns:
- a Control for exiting the application
-
createLogLevelControl
- Returns:
- Controls for setting the log level
-
createViewApplicationTreeControl
- Returns:
- a Control for viewing the application structure tree
-
createViewDependencyTree
- Returns:
- a Control for viewing the application dependency tree
-
createSelectLookAndFeelControl
Allows the user the select between the available Look and Feels, saves the selection as a user preference.- Returns:
- a Control for selecting the application look and feel
- See Also:
-
createSelectFontSizeControl
- Returns:
- a Control for selecting the font size
-
createAlwaysOnTopControl
- Returns:
- a Control controlling the always on top status
-
createAboutControl
- Returns:
- a Control for viewing information about the application
-
createHelpControl
- Returns:
- a Control for displaying the help
-
createViewKeyboardShortcutsControl
- Returns:
- a Control for displaying the keyboard shortcuts overview
-
createAboutPanel
- Returns:
- the panel shown when Help -> About is selected
-
bindEvents
protected void bindEvents()Override to add event bindings after initialization -
displayEntityPanel
Displays the panel provided by the given builder in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE
.- Parameters:
panelBuilder
- the entity panel builder
-
displayEntityPanel
Displays the given panel in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE
.- Parameters:
entityPanel
- the entity panel
-
displayEntityPanelFrame
Shows a frame containing the given entity panel- Parameters:
entityPanel
- the entity panel
-
displayEntityPanelDialog
Shows a non-modal dialog containing the given entity panel- Parameters:
entityPanel
- the entity panel
-
displayEntityPanelDialog
Shows a dialog containing the given entity panel- Parameters:
entityPanel
- the entity panelmodalDialog
- if true the dialog is made modal
-
createEntityPanels
Creates theEntityPanel
s to include in this application panel. Returns an empty list in case this panel contains no entity panels or has a custom UI.- Returns:
- a List containing the
EntityPanel
s to include in this application panel or an empty list in case of no entity panels.
-
createSupportEntityPanelBuilders
Returns a Collection ofEntityPanel.Builder
instances to use to populate the Support Table menu. Returns an empty Collection in case of no support table panels.- Returns:
- a Collection of
EntityPanel.Builder
instances to use to populate the Support Table menu.
-
exitObserver
To cancel the exit add a listener throwing aCancelException
.- Returns:
- an observer notified when the application is about to exit.
-
createMenuBar
Creates the JMenuBar to use on the application Frame- Returns:
- by default a JMenuBar based on the main menu controls or an empty Optional in case of no menu bar
- See Also:
-
savePreferences
protected void savePreferences()Called during the exit() method, override to save user preferences on program exit, remember to call super.savePreferences() when overriding- See Also:
-