public class EntityPanel extends javax.swing.JPanel implements MasterDetailPanel
String entityId = ...; EntityConnectionProvider connectionProvider = ...; SwingEntityModel entityModel = new SwingEntityModel(entityId, connectionProvider); EntityPanel entityPanel = new EntityPanel(entityModel); entityPanel.initializePanel(); JFrame frame = new JFrame(); frame.add(entityPanel); frame.pack(); frame.setVisible(true);
Modifier and Type | Class and Description |
---|---|
static class |
EntityPanel.Direction
The novigation directions.
|
static class |
EntityPanel.PanelState
The possible states of a detail panel.
|
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static PropertyValue<java.lang.Boolean> |
CENTER_APPLICATION_DIALOGS
Indicates whether dialogs opened by child panels in the application should be centered
on their respective parent panel or the application frame/dialog.
|
static PropertyValue<java.lang.Boolean> |
COMPACT_ENTITY_PANEL_LAYOUT
Indicates whether entity panels containing detail panels should by default be laid out in a compact manner
Value type: Boolean Default value: true |
static PropertyValue<java.lang.Boolean> |
DISPOSE_EDIT_DIALOG_ON_ESCAPE
Indicates whether entity edit panel dialogs should be closed on escape
Value type: Boolean Default value: true |
static PropertyValue<java.lang.Boolean> |
SHOW_DETAIL_PANEL_CONTROLS
Specifies whether or not actions to hide detail panels or show them in a dialog are available to the user
Value type: Boolean Default value: true |
static PropertyValue<java.lang.Boolean> |
SHOW_TOGGLE_EDIT_PANEL_CONTROL
Specifies whether or not a control for toggling the edit panel is available to the user
Value type: Boolean Default value: true |
static PropertyValue<java.lang.Integer> |
SPLIT_PANE_DIVIDER_SIZE
Specifies the default size of the divider for detail panel split panes.
Value type: Integer Default value: 18 |
static PropertyValue<java.lang.Boolean> |
TOOLBAR_BUTTONS
Specifies whether the action buttons (Save, update, delete, clear, refresh) should be on a toolbar
Value type: Boolean Default value: false |
static PropertyValue<java.lang.Boolean> |
USE_FOCUS_ACTIVATION
Indicates whether entity panels should be activated when the panel receives focus
Value type: Boolean Default value: true |
static PropertyValue<java.lang.Boolean> |
USE_KEYBOARD_NAVIGATION
Indicates whether keyboard navigation will be enabled
Value type: Boolean Default value: true |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
EntityPanel(SwingEntityModel entityModel)
Initializes a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
EntityEditPanel editPanel)
Instantiates a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
EntityEditPanel editPanel,
EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
java.lang.String caption)
Initializes a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
java.lang.String caption,
EntityEditPanel editPanel)
Instantiates a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
java.lang.String caption,
EntityEditPanel editPanel,
EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance.
|
EntityPanel(SwingEntityModel entityModel,
java.lang.String caption,
EntityTablePanel tablePanel)
Instantiates a new EntityPanel instance.
|
Modifier and Type | Method and Description |
---|---|
void |
activatePanel()
Activates this panel, showing it and preparing it for input
|
EntityPanel |
addDetailPanel(EntityPanel detailPanel)
Adds the given detail panel, and adds the detail model to the underlying
model if it does not contain it already, and then sets
includeDetailPanelTabPane
to true |
EntityPanel |
addDetailPanels(EntityPanel... detailPanels) |
boolean |
containsDetailPanel(java.lang.String entityId)
Returns true if this panel contains a detail panel for the given
entityId |
boolean |
containsEditPanel() |
boolean |
containsTablePanel() |
protected javax.swing.JComponent |
createEditControlPanel()
Creates the control panel or component to place next to the edit panel, containing controls for managing
records, such as insert, update and delete.
|
void |
displayException(java.lang.Exception exception)
Displays the exception in a dialog
|
EntityPanel |
getActiveDetailPanel() |
java.lang.String |
getCaption() |
java.lang.String |
getControlPanelConstraints() |
EntityPanel |
getDetailPanel(java.lang.String entityId)
Returns the detail panel for the given
entityId , if one is available |
java.util.List<MasterDetailPanel> |
getDetailPanels() |
EntityPanel.PanelState |
getDetailPanelState() |
double |
getDetailSplitPaneResizeWeight() |
javax.swing.JPanel |
getEditControlPanel() |
SwingEntityEditModel |
getEditModel() |
EntityEditPanel |
getEditPanel() |
EntityPanel.PanelState |
getEditPanelState() |
java.util.Collection<EntityPanel> |
getLinkedDetailPanels() |
MasterDetailPanel |
getMasterPanel() |
SwingEntityModel |
getModel() |
MasterDetailPanel |
getNextPanel() |
MasterDetailPanel |
getPreviousPanel() |
SwingEntityTableModel |
getTableModel() |
EntityTablePanel |
getTablePanel() |
Control |
getToggleDetailPanelControl() |
Control |
getToggleEditPanelControl() |
protected void |
initialize()
Override to add code that should be called during the initialization routine after the panel has been initialized
|
protected void |
initializeAssociatedPanels()
Called during initialization, before controls have been initialized
|
protected void |
initializeControlPanels()
Called during initialization, after controls have been initialized,
use this method to initialize any application panels that rely on controls having been initialized
|
EntityPanel |
initializePanel()
Initializes this EntityPanels UI, in case of some specific initialization code you can override the
initialize() method and add your code there. |
protected void |
initializeUI()
Initializes this EntityPanels UI.
|
boolean |
isCompactDetailLayout() |
boolean |
isDisposeEditDialogOnEscape() |
boolean |
isIncludeControlPanel() |
boolean |
isIncludeDetailPanelTabPane() |
boolean |
isPanelInitialized() |
boolean |
isShowDetailPanelControls() |
boolean |
isShowToggleEditPanelControl() |
void |
prepareUI(boolean setInitialFocus,
boolean clearUI)
Prepares the UI, by clearing the input fields and setting the initial focus,
if both parameters are set to false then there is no effect
|
void |
resizePanel(EntityPanel.Direction direction,
int pixelAmount)
Resizes this panel in the given direction
|
void |
savePreferences()
Saves any user preferences for all entity panels and associated elements
|
void |
setActiveDetailPanel(MasterDetailPanel detailPanel)
Activates (and shows) the given detail panel
|
EntityPanel |
setCompactDetailLayout(boolean compactDetailLayout) |
EntityPanel |
setControlPanelConstraints(java.lang.String controlPanelConstraints)
Sets the layout constraints to use for the control panel
|
void |
setDetailPanelState(EntityPanel.PanelState state) |
EntityPanel |
setDetailSplitPanelResizeWeight(double detailSplitPanelResizeWeight) |
void |
setDisposeEditDialogOnEscape(boolean disposeEditDialogOnEscape) |
void |
setEditPanelState(EntityPanel.PanelState state) |
void |
setFilterPanelsVisible(boolean value)
Hides or shows the active filter panels for this panel and all its child panels
(detail panels and their detail panels etc.)
|
EntityPanel |
setIncludeControlPanel(boolean includeControlPanel) |
EntityPanel |
setIncludeDetailPanelTabPane(boolean includeDetailPanelTabPane) |
protected void |
setMasterPanel(EntityPanel masterPanel) |
EntityPanel |
setShowDetailPanelControls(boolean showDetailPanelControls) |
EntityPanel |
setShowToggleEditPanelControl(boolean showToggleEditPanelControl) |
void |
toggleDetailPanelState()
Toggles the detail panel state between DIALOG, HIDDEN and EMBEDDED
|
void |
toggleEditPanelState()
Toggles the edit panel state between DIALOG, HIDDEN and EMBEDDED
|
java.lang.String |
toString() |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final PropertyValue<java.lang.Boolean> USE_FOCUS_ACTIVATION
EntityEditPanel.ALL_PANELS_ACTIVE
public static final PropertyValue<java.lang.Boolean> USE_KEYBOARD_NAVIGATION
public static final PropertyValue<java.lang.Boolean> CENTER_APPLICATION_DIALOGS
public static final PropertyValue<java.lang.Boolean> DISPOSE_EDIT_DIALOG_ON_ESCAPE
public static final PropertyValue<java.lang.Boolean> SHOW_TOGGLE_EDIT_PANEL_CONTROL
public static final PropertyValue<java.lang.Boolean> SHOW_DETAIL_PANEL_CONTROLS
public static final PropertyValue<java.lang.Integer> SPLIT_PANE_DIVIDER_SIZE
public static final PropertyValue<java.lang.Boolean> COMPACT_ENTITY_PANEL_LAYOUT
public static final PropertyValue<java.lang.Boolean> TOOLBAR_BUTTONS
public EntityPanel(SwingEntityModel entityModel)
initializePanel()
is called.
The default caption of the underlying entity is used.entityModel
- the EntityModelpublic EntityPanel(SwingEntityModel entityModel, java.lang.String caption)
initializePanel()
is called.entityModel
- the EntityModelcaption
- the caption to use when presenting this entity panelpublic EntityPanel(SwingEntityModel entityModel, EntityEditPanel editPanel)
initializePanel()
is called.entityModel
- the EntityModeleditPanel
- the edit panelpublic EntityPanel(SwingEntityModel entityModel, EntityTablePanel tablePanel)
initializePanel()
is called.entityModel
- the EntityModeltablePanel
- the table panelpublic EntityPanel(SwingEntityModel entityModel, java.lang.String caption, EntityEditPanel editPanel)
initializePanel()
is called.entityModel
- the EntityModelcaption
- the caption to use when presenting this entity paneleditPanel
- the edit panelpublic EntityPanel(SwingEntityModel entityModel, java.lang.String caption, EntityTablePanel tablePanel)
initializePanel()
is called.entityModel
- the EntityModelcaption
- the caption to use when presenting this entity paneltablePanel
- the table panelpublic EntityPanel(SwingEntityModel entityModel, EntityEditPanel editPanel, EntityTablePanel tablePanel)
initializePanel()
is called.entityModel
- the EntityModeleditPanel
- the edit paneltablePanel
- the table panelpublic EntityPanel(SwingEntityModel entityModel, java.lang.String caption, EntityEditPanel editPanel, EntityTablePanel tablePanel)
initializePanel()
is called.entityModel
- the EntityModelcaption
- the caption to use when presenting this entity paneleditPanel
- the edit paneltablePanel
- the table panelpublic final SwingEntityModel getModel()
public final SwingEntityEditModel getEditModel()
public final SwingEntityTableModel getTableModel()
public final java.lang.String getControlPanelConstraints()
public final EntityPanel setControlPanelConstraints(java.lang.String controlPanelConstraints)
The default layout is as follows (BorderLayout.WEST): __________________________________ | edit panel |control| | (EntityEditPanel) | panel | } edit control panel |________________________|_______| With (BorderLayout.SOUTH): __________________________ | edit | | panel | |________________________| } edit control panel | control panel | |________________________| etc.
controlPanelConstraints
- the control panel layout constraints (BorderLayout constraints)java.lang.IllegalStateException
- if the panel has been initializedjava.lang.IllegalArgumentException
- in case the given constraint is not one of BorderLayout.SOUTH, NORTH, EAST or WESTpublic final boolean isCompactDetailLayout()
public final EntityPanel setCompactDetailLayout(boolean compactDetailLayout)
compactDetailLayout
- true if this panel and its detail panels should be laid out in a compact statepublic final EntityPanel addDetailPanels(EntityPanel... detailPanels)
detailPanels
- the detail panelspublic final EntityPanel addDetailPanel(EntityPanel detailPanel)
includeDetailPanelTabPane
to truedetailPanel
- the detail panel to addjava.lang.IllegalStateException
- if the panel has been initializedpublic final EntityPanel initializePanel()
initialize()
method and add your code there.
This method marks this panel as initialized which prevents it from running again, whether or not an exception occurs.initialize()
,
isPanelInitialized()
public final boolean isPanelInitialized()
initializePanel()
public final EntityEditPanel getEditPanel()
public final boolean containsEditPanel()
public final EntityTablePanel getTablePanel()
public final boolean containsTablePanel()
public final javax.swing.JPanel getEditControlPanel()
public final java.util.Collection<EntityPanel> getLinkedDetailPanels()
public final EntityPanel getDetailPanel(java.lang.String entityId)
entityId
, if one is availableentityId
- the entity ID of the detail panel to retrievejava.lang.IllegalArgumentException
- in case the panel was not foundpublic final boolean containsDetailPanel(java.lang.String entityId)
entityId
entityId
- the entityIdpublic final java.lang.String toString()
toString
in class java.awt.Component
public final java.lang.String getCaption()
public final void activatePanel()
activatePanel
in interface MasterDetailPanel
public final MasterDetailPanel getMasterPanel()
getMasterPanel
in interface MasterDetailPanel
public final EntityPanel getActiveDetailPanel()
getActiveDetailPanel
in interface MasterDetailPanel
public final void setActiveDetailPanel(MasterDetailPanel detailPanel)
setActiveDetailPanel
in interface MasterDetailPanel
detailPanel
- the detail panel to activate and showpublic final MasterDetailPanel getPreviousPanel()
getPreviousPanel
in interface MasterDetailPanel
public final MasterDetailPanel getNextPanel()
getNextPanel
in interface MasterDetailPanel
public final java.util.List<MasterDetailPanel> getDetailPanels()
getDetailPanels
in interface MasterDetailPanel
public final Control getToggleEditPanelControl()
public final Control getToggleDetailPanelControl()
public final void displayException(java.lang.Exception exception)
exception
- the exception to handleDefaultDialogExceptionHandler
public final double getDetailSplitPaneResizeWeight()
public final EntityPanel setDetailSplitPanelResizeWeight(double detailSplitPanelResizeWeight)
detailSplitPanelResizeWeight
- the detail panel split size weightjava.lang.IllegalStateException
- if the panel has been initializedpublic final boolean isIncludeDetailPanelTabPane()
public final EntityPanel setIncludeDetailPanelTabPane(boolean includeDetailPanelTabPane)
includeDetailPanelTabPane
- true if the detail panel tab pane should be includedjava.lang.IllegalStateException
- if the panel has been initializedpublic final boolean isShowToggleEditPanelControl()
SHOW_TOGGLE_EDIT_PANEL_CONTROL
public final EntityPanel setShowToggleEditPanelControl(boolean showToggleEditPanelControl)
showToggleEditPanelControl
- true if a control for toggling the edit panel should be shownjava.lang.IllegalStateException
- if the panel has been initializedpublic final boolean isShowDetailPanelControls()
SHOW_DETAIL_PANEL_CONTROLS
public final EntityPanel setShowDetailPanelControls(boolean showDetailPanelControls)
showDetailPanelControls
- true if detail panel controls should be shownjava.lang.IllegalStateException
- if the panel has been initializedpublic final boolean isIncludeControlPanel()
public final EntityPanel setIncludeControlPanel(boolean includeControlPanel)
includeControlPanel
- true if the control panel should be includedjava.lang.IllegalStateException
- if the panel has been initializedpublic final boolean isDisposeEditDialogOnEscape()
DISPOSE_EDIT_DIALOG_ON_ESCAPE
public final void setDisposeEditDialogOnEscape(boolean disposeEditDialogOnEscape)
disposeEditDialogOnEscape
- if true then the edit dialog is disposed of on ESCDISPOSE_EDIT_DIALOG_ON_ESCAPE
public final void toggleDetailPanelState()
public final void toggleEditPanelState()
public final EntityPanel.PanelState getDetailPanelState()
public final EntityPanel.PanelState getEditPanelState()
public final void setDetailPanelState(EntityPanel.PanelState state)
state
- the detail panel state (HIDDEN or EMBEDDED, DIALOG)public final void setEditPanelState(EntityPanel.PanelState state)
state
- the edit panel state, either HIDDEN, EMBEDDED or DIALOGpublic final void setFilterPanelsVisible(boolean value)
value
- true if the active panels should be shown, false if they should be hiddenpublic final void resizePanel(EntityPanel.Direction direction, int pixelAmount)
direction
- the resize directionpixelAmount
- the resize amountpublic final void prepareUI(boolean setInitialFocus, boolean clearUI)
setInitialFocus
- if true the component defined as the initialFocusComponent
gets the input focus, if none is defined the first child component of this EntityPanel is used,
if no edit panel is available the table receives the focusclearUI
- if true the the input components are clearedEntityEditPanel.setInitialFocusComponent(javax.swing.JComponent)
public void savePreferences()
protected void initializeUI()
The default layout is as follows: __________________________________ | edit panel |control| | (EntityEditPanel) | panel | } edit control panel |________________________|_______| | | | | table panel | detail | |(EntityTablePanel)| panel | | | | |__________________|_____________| or in case of compact layout: __________________________________ | edit |control| | | panel | panel | | |__________|_______| detail | | | panel | | table panel | | |(EntityTablePanel)| | | | | |__________________|_____________|
protected void initializeAssociatedPanels()
initializePanel()
protected void initializeControlPanels()
initializePanel()
protected void initialize()
initializePanel()
protected javax.swing.JComponent createEditControlPanel()
includeControlPanel
returns true.
By default the control panel provided by the edit panel is returned.EntityEditPanel.createControlPanel(boolean)
,
EntityEditPanel.createControlToolBar(int)
,
TOOLBAR_BUTTONS
protected final void setMasterPanel(EntityPanel masterPanel)
masterPanel
- the panel serving as master panel for this entity paneljava.lang.IllegalStateException
- in case a master panel has already been set