Module is.codion.swing.framework.ui
Package is.codion.swing.framework.ui
Class EntityApplicationPanel<M extends is.codion.swing.framework.model.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
public abstract class EntityApplicationPanel<M extends is.codion.swing.framework.model.SwingEntityApplicationModel>
extends JPanel
A central application panel class.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceHandles laying out an EntityApplicationPanel.static interfaceEntityApplicationPanel.Builder<M extends is.codion.swing.framework.model.SwingEntityApplicationModel,P extends EntityApplicationPanel<M>> Builds aEntityApplicationPaneland starts the application.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 TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<Boolean>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: falsestatic final is.codion.common.property.PropertyValue<Boolean>Indicates whether the application should ask for confirmation when exiting
Value type: Boolean
Default value: falsestatic final is.codion.common.property.PropertyValue<String>Specifies the URL to the application help
Value type: String
Default value: https://codion.is/doc/{version}/help/client.htmlstatic final is.codion.common.property.PropertyValue<Boolean>Specifies whether a startup dialog should be shown
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_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
ConstructorsConstructorDescriptionEntityApplicationPanel(M applicationModel) EntityApplicationPanel(M applicationModel, EntityApplicationPanel.ApplicationLayout applicationLayout) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddInitializationListener(Consumer<EntityApplicationPanel<?>> listener) protected final voidaddOnExitListener(Runnable listener) Adds a listener notified when the application is about to exit.final is.codion.common.state.Statefinal <T extends EntityApplicationPanel.ApplicationLayout>
Tfinal Mprotected voidOverride to add event bindings after initializationstatic <M extends is.codion.swing.framework.model.SwingEntityApplicationModel,P extends EntityApplicationPanel<M>>
EntityApplicationPanel.Builder<M,P> protected final is.codion.swing.common.ui.control.Controlprotected JPanelprotected final is.codion.swing.common.ui.control.ToggleControlstatic TreeModelcreateDependencyTreeModel(is.codion.framework.domain.entity.Entities entities) protected abstract List<EntityPanel>Creates theEntityPanels to include in this application panel.protected final is.codion.swing.common.ui.control.Controlprotected is.codion.swing.common.ui.control.Controlsprotected final is.codion.swing.common.ui.control.Controlprotected is.codion.swing.common.ui.control.Controlsprotected final is.codion.swing.common.ui.control.Controlprotected is.codion.swing.common.ui.control.Controlsprotected JMenuBarCreates the JMenuBar to use on the application Frameprotected final is.codion.swing.common.ui.control.Controlprotected final is.codion.swing.common.ui.control.Controlprotected final is.codion.swing.common.ui.control.ControlAllows 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.Builderinstances to use to populate the Support Table menu.protected is.codion.swing.common.ui.control.Controlsprotected is.codion.swing.common.ui.control.Controlsprotected final is.codion.swing.common.ui.control.Controlprotected final is.codion.swing.common.ui.control.Controlprotected final is.codion.swing.common.ui.control.Controlprotected is.codion.swing.common.ui.control.Controlsprotected final Stringfinal voidShows an about dialogprotected final voiddisplayEntityPanel(EntityPanel entityPanel) Displays the given panel in a frame or dialog, depending onEntityPanel.USE_FRAME_PANEL_DISPLAY.protected final voiddisplayEntityPanel(EntityPanel.Builder panelBuilder) Displays the panel provided by the given builder in a frame or dialog, depending onEntityPanel.USE_FRAME_PANEL_DISPLAY.protected final voiddisplayEntityPanelDialog(EntityPanel entityPanel) Shows a non-modal dialog containing the given entity panelprotected final voiddisplayEntityPanelDialog(EntityPanel entityPanel, boolean modalDialog) Shows a dialog containing the given entity panelprotected final voiddisplayEntityPanelFrame(EntityPanel entityPanel) Shows a frame containing the given entity panelfinal voiddisplayException(Throwable exception) Displays the exception in a dialogvoidDisplays the help.final voidDisplays a keyboard shortcut overview panel.final <T extends EntityPanel>
TentityPanel(is.codion.framework.domain.entity.EntityType entityType) final List<EntityPanel>final voidexit()Exits this applicationfinal voidInitializes this panel and marks is as initialized, subsequent calls have no effect.protected voidCalled during the exit() method, override to save user preferences on program exit, remember to call super.savePreferences() when overridingfinal voidDisplays in a dialog a tree describing the application layoutfinal voidShows a dialog containing a dependency tree view of all defined entitiesMethods 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
-
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, 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
public final <T extends EntityPanel> T entityPanel(is.codion.framework.domain.entity.EntityType entityType) - 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
public final is.codion.common.state.State 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 -
addInitializationListener
- Parameters:
listener- notified when this application panel has been initialized- See Also:
-
exit
public final void exit()Exits this application- Throws:
is.codion.common.model.CancelException- if the exit is cancelled- See Also:
-
addOnExitListener(Runnable)CONFIRM_EXITEntityApplicationModel.warnAboutUnsavedData()
-
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
public static TreeModel createDependencyTreeModel(is.codion.framework.domain.entity.Entities entities) - Parameters:
entities- the entities- Returns:
- a tree model showing the dependencies between entities via foreign keys
-
builder
public static <M extends is.codion.swing.framework.model.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
protected is.codion.swing.common.ui.control.Controls createMainMenuControls()- Returns:
- the controls on which to base the main menu
- See Also:
-
createFileMenuControls
protected is.codion.swing.common.ui.control.Controls createFileMenuControls()- Returns:
- the Controls specifying the items in the 'File' menu
-
createToolsMenuControls
protected is.codion.swing.common.ui.control.Controls createToolsMenuControls()- Returns:
- the Controls specifying the items in the 'Tools' menu
-
createViewMenuControls
protected is.codion.swing.common.ui.control.Controls createViewMenuControls()- Returns:
- the Controls specifying the items in the 'View' menu
-
createHelpMenuControls
protected is.codion.swing.common.ui.control.Controls createHelpMenuControls()- Returns:
- the Controls specifying the items in the 'Help' menu
-
createSupportTableMenuControls
protected is.codion.swing.common.ui.control.Controls createSupportTableMenuControls()- Returns:
- the Controls on which to base the Support Tables menu
-
createExitControl
protected final is.codion.swing.common.ui.control.Control createExitControl()- Returns:
- a Control for exiting the application
-
createLogLevelControl
protected final is.codion.swing.common.ui.control.Control createLogLevelControl()- Returns:
- a Control for setting the log level
-
createRefreshAllControl
protected final is.codion.swing.common.ui.control.Control createRefreshAllControl()- Returns:
- a Control for refreshing the application model
-
createViewApplicationTreeControl
protected final is.codion.swing.common.ui.control.Control createViewApplicationTreeControl()- Returns:
- a Control for viewing the application structure tree
-
createViewDependencyTree
protected final is.codion.swing.common.ui.control.Control createViewDependencyTree()- Returns:
- a Control for viewing the application dependency tree
-
createSelectLookAndFeelControl
protected final is.codion.swing.common.ui.control.Control 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:
-
LookAndFeelProvider.addLookAndFeelProvider(LookAndFeelProvider)LookAndFeelProvider.findLookAndFeelProvider(String)Dialogs.lookAndFeelSelectionDialog()LookAndFeelComboBox.ENABLE_ON_SELECTION
-
createSelectFontSizeControl
protected final is.codion.swing.common.ui.control.Control createSelectFontSizeControl()- Returns:
- a Control for selecting the font size
-
createAlwaysOnTopControl
protected final is.codion.swing.common.ui.control.ToggleControl createAlwaysOnTopControl()- Returns:
- a Control controlling the always on top status
-
createAboutControl
protected final is.codion.swing.common.ui.control.Control createAboutControl()- Returns:
- a Control for viewing information about the application
-
createHelpControl
protected final is.codion.swing.common.ui.control.Control createHelpControl()- Returns:
- a Control for displaying the help
-
createViewKeyboardShortcutsControl
protected final is.codion.swing.common.ui.control.Control 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.USE_FRAME_PANEL_DISPLAY.- Parameters:
panelBuilder- the entity panel builder
-
displayEntityPanel
Displays the given panel in a frame or dialog, depending onEntityPanel.USE_FRAME_PANEL_DISPLAY.- 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 theEntityPanels 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
EntityPanels to include in this application panel or an empty list in case of no entity panels.
-
createSupportEntityPanelBuilders
Returns a Collection ofEntityPanel.Builderinstances to use to populate the Support Table menu. Returns an empty Collection in case of no support table panels.- Returns:
- a Collection of
EntityPanel.Builderinstances to use to populate the Support Table menu.
-
addOnExitListener
Adds a listener notified when the application is about to exit. To cancel the exit throw aCancelException.- Parameters:
listener- a listener 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
- See Also:
-
defaultUsername
- Returns:
- the default username, that is, the username of the last successful login from user preferences, or the operating system username, if no username is found in user preferences.
-
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:
-
EntityApplicationModel.savePreferences()
-