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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceHandles laying out an EntityApplicationPanel.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 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> Specifies whether the application should callSystem.exit(int)when exiting.static final PropertyValue<Boolean> Indicates whether the application should ask for confirmation when exiting Value type: Boolean Default value: falsestatic final PropertyValue<Boolean> Specifies whether a button for displaying system properties is included on the about panel.static 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 legacy preferences are used along with file based preferences Value type: Boolean Default value: truestatic final PropertyValue<Boolean> Specifies whether to include sql tracing related controls in the log menu.Fields 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, List<EntityPanel> entityPanels, Collection<EntityPanel.Builder> lookupPanelBuilders) Instantiates a newEntityApplicationPanelbased on the given application model, using the defaultTabbedApplicationLayout.EntityApplicationPanel(M applicationModel, List<EntityPanel> entityPanels, Collection<EntityPanel.Builder> lookupPanelBuilders, Function<EntityApplicationPanel<M>, EntityApplicationPanel.ApplicationLayout> applicationLayout) Instantiates a newEntityApplicationPanelbased on the given application model, using theEntityApplicationPanel.ApplicationLayoutprovided byapplicationLayout. -
Method Summary
Modifier and TypeMethodDescriptionfinal Statefinal Mprotected voidapplyPreferences(Preferences preferences) Called on application start, override to apply any custom preferences.protected voidOverride to add event bindings after initializationprotected final Controlprotected JPanelprotected final ToggleControlstatic TreeModelcreateDependencyTreeModel(Entities entities) protected final Controlprotected final Controlprotected final Controlsprotected final ControlsCreates the JMenuBar to use on the application Frameprotected final ControlAllows the user the select between the available Look and Feels.protected final Controlprotected final Controlprotected final Controlprotected final Controlfinal voidShows an about-dialogprotected final voiddisplayEntityPanelDialog(EntityPanel entityPanel) Displays a non-modal dialog containing the given entity panelprotected final voiddisplayEntityPanelDialog(EntityPanel entityPanel, boolean modal) Shows a dialog containing the given entity panelprotected final voiddisplayEntityPanelFrame(EntityPanel entityPanel) Displays a frame containing the given entity panelprotected final voiddisplayEntityPanelWindow(EntityPanel entityPanel) Displays the given panel in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE.protected final voiddisplayEntityPanelWindow(EntityPanel.Builder panelBuilder) Displays the panel provided by the given builder in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE.final voiddisplayException(Exception exception) Displays the exception in a dialogvoidDisplays the help.final voidDisplays a keyboard shortcut overview panel.final EntityPanelentityPanel(EntityType entityType) final List<EntityPanel> final voidexit()Exits this application.protected final Observer<?> exiting()To cancel the exit add a listener throwing aCancelException.final EntityApplicationPanel<M> Initializes this panel and marks is as initialized, subsequent calls have no effect.final Observer<EntityApplicationPanel<?>> voidRequests the initial application focus by callingEntityPanel.requestInitialFocus()on the main entity panel.final voidDisplays in a dialog a tree describing the application layoutfinal voidShows a dialog containing a dependency tree view of all defined entitiesprotected voidwritePreferences(Preferences preferences) Called during the exit() method, override to write custom user preferences on program exit.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
-
CALL_SYSTEM_EXIT
Specifies whether the application should callSystem.exit(int)when exiting.- Value type: Boolean
- Default value: false
- See Also:
-
DISPLAY_SYSTEM_PROPERTIES
Specifies whether a button for displaying system properties is included on the about panel.- Value type: Boolean
- Default value: true
- See Also:
-
SQL_TRACING
Specifies whether to include sql tracing related controls in the log menu.- Value type: Boolean
- Default value: false
-
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
-
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
- See Also:
-
LEGACY_PREFERENCES
Specifies whether legacy preferences are used along with file based preferences- Value type: Boolean
- Default value: true
-
-
Constructor Details
-
EntityApplicationPanel
public EntityApplicationPanel(M applicationModel, List<EntityPanel> entityPanels, Collection<EntityPanel.Builder> lookupPanelBuilders) Instantiates a newEntityApplicationPanelbased on the given application model, using the defaultTabbedApplicationLayout.- Parameters:
applicationModel- the application modelentityPanels- the entity panelslookupPanelBuilders- the support panel builders
-
EntityApplicationPanel
public EntityApplicationPanel(M applicationModel, List<EntityPanel> entityPanels, Collection<EntityPanel.Builder> lookupPanelBuilders, Function<EntityApplicationPanel<M>, EntityApplicationPanel.ApplicationLayout> applicationLayout) Instantiates a newEntityApplicationPanelbased on the given application model, using theEntityApplicationPanel.ApplicationLayoutprovided byapplicationLayout.- Parameters:
applicationModel- the application modelentityPanels- the entity panelslookupPanelBuilders- the support panel buildersapplicationLayout- provides the application layout
-
-
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
- Returns:
- the application layout
-
entityPanel
- 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 -
initialized
- Returns:
- an observer notified when this application panel is initialized
- See Also:
-
exit
public final void exit()Exits this application. CallsSystem.exit(int)in caseCALL_SYSTEM_EXITis true.- Throws:
CancelException- if the exit is cancelled- See Also:
-
displayHelp
Displays the help.- Throws:
Exception- in case of an exception, for example a malformed URL- See Also:
-
displayKeyboardShortcuts
public final void displayKeyboardShortcuts()Displays a keyboard shortcut overview panel. -
displayAbout
public final void displayAbout()Shows an about-dialog- See Also:
-
initialize
Initializes this panel and marks is as initialized, subsequent calls have no effect.- Returns:
- this application panel
-
requestInitialFocus
public void requestInitialFocus()Requests the initial application focus by calling
EntityPanel.requestInitialFocus()on the main entity panel.By default, the main entity panel is the first one returned by
entityPanels(). -
createDependencyTreeModel
- Parameters:
entities- the entities- Returns:
- a tree model showing the dependencies between entities via foreign keys
-
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
-
createLookupMenuControls
- Returns:
- the Controls on which to base the Lookup 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.- Returns:
- a Control for selecting the application look and feel
- See Also:
-
createSelectScalingControl
- Returns:
- a Control for selecting the scaling
-
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
-
createLogControls
- Returns:
- Controls for log handling
-
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 -
displayEntityPanelWindow
Displays the panel provided by the given builder in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE.- Parameters:
panelBuilder- the entity panel builder- See Also:
-
displayEntityPanelWindow
Displays the given panel in a frame or dialog, depending onEntityPanel.Config.WINDOW_TYPE.- Parameters:
entityPanel- the entity panel- See Also:
-
displayEntityPanelFrame
Displays a frame containing the given entity panel- Parameters:
entityPanel- the entity panel
-
displayEntityPanelDialog
Displays 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 panelmodal- if true the dialog should be modal
-
exiting
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:
-
writePreferences
Called during the exit() method, override to write custom user preferences on program exit.
Remember to call super.writePreferences(preferences) when overriding.
- Parameters:
preferences- the preferences instance to write to
-
applyPreferences
Called on application start, override to apply any custom preferences.
Remember to call super.savePreferences(preferences) when overriding.
- Parameters:
preferences- the preferences instance containing the preferences to apply
-