Class CPanelPopup
java.lang.Object
bibliothek.gui.dock.common.action.CAction
bibliothek.gui.dock.common.intern.action.CDecorateableAction<CPanelPopup.PanelPopup>
bibliothek.gui.dock.common.action.CPanelPopup
This action shows some kind of popup (for example a
Clients may override the various
As long as the user works on the popup-window it does not close automatically, clients can call
Note: this action does not support being child of a drop down menu
JDialog) filled
with any content the client likes. This action is intended to be shown
as button in a title, but can also be used as menu item in a menu.Clients may override the various
onXYZ-methods and create
and show their custom popup. In such a case they should call openPopup(PanelPopupWindow)
to ensure that only one window is open at a time.As long as the user works on the popup-window it does not close automatically, clients can call
closePopup() to explicitly close it. The
window closes automatically if it loses the focus, clients can call
setCloseOnFocusLost(boolean) to change that behavior.
Note: this action does not support being child of a drop down menu
- Author:
- Benjamin Sigg
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhen the popup should show up if the action is displayed as button.static enumTells how aCPanelPopupbehaves if it is a child of a menu.classA custom action shows some dialog or window when triggered -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ActionType<CPanelPopup.PanelPopup>the kind of action this class represents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMakes the current popup invisible.protected DialogWindowcreateDialogWindow(Component owner) Creates a new window which will be used as popup for thisCPanelPopup.protected MenuWindowcreateMenuWindow(JPopupMenu menu) Creates a new window which will be used as popup for thisCPanelPopup.protected voidexecuteOneDockableHasFocus(Dockable dockable, Runnable run) Callsrunonce the owningDockableof this action has the focusTells how this action behaves if displayed as button.Gets the contents of this action.Tells how this action behaves if in a menu.booleanTells whether the window is automatically closed if the focus is lost.booleanisOpen()Tells whether the content of this action is currently being showed.protected voidonMenuItemTrigger(Dockable dockable) Called if the menu-item representing this action has been hit.protected voidonMenuTrigger(JPopupMenu menu) Called if a menu is opening a submenu in whichthe contentis to be shown.protected voidonMousePressed(Dockable dockable, JComponent item, DockTitle.Orientation orientation) Called if the mouse is pressed on the buttonitemof of aDockTitlewhich has orientationorientation.protected voidonMouseReleased(Dockable dockable, JComponent item, DockTitle.Orientation orientation) Called if the mouse is released of the buttonitemof of aDockTitlewhich has orientationorientation.protected voidonTrigger(Dockable dockable, JComponent item, DockTitle.Orientation orientation) protected voidopenDialog(Dockable dockable, JComponent item, DockTitle.Orientation orientation) Opens a new undecorated dialog below or aside ofitem.voidopenPopup(PanelPopupWindow window) Informs thisCPanelPopupthat its content is shown and allows this to handle the closing event.voidTells this action how to handle buttons.voidsetCloseOnFocusLost(boolean closeOnFocusLost) Whether the window should be closed if focus is lost.voidsetContent(JComponent content) Sets the component that is shown on a popup dialog/menu/window...voidTells this action how to behave if it is in a menu.Methods inherited from class bibliothek.gui.dock.common.intern.action.CDecorateableAction
addDecorateableActionListener, getAccelerator, getDisabledHoverIcon, getDisabledIcon, getDisabledPressedIcon, getHoverIcon, getIcon, getPressedIcon, getText, getTooltip, init, intern, isAcceleratorGlobal, isEnabled, isShowTextOnButtons, removeDecorateableActionListener, setAccelerator, setAcceleratorIsGlobal, setDisabledHoverIcon, setDisabledIcon, setDisabledPressedIcon, setEnabled, setHoverIcon, setIcon, setPressedIcon, setShowTextOnButtons, setText, setTooltip
-
Field Details
-
PANEL_POPUP
the kind of action this class represents
-
-
Constructor Details
-
CPanelPopup
public CPanelPopup()Creates a new action.
-
-
Method Details
-
setContent
Sets the component that is shown on a popup dialog/menu/window... by thisCPanelPopup.- Parameters:
content- the content, may benull
-
getContent
Gets the contents of this action.- Returns:
- the contents
-
setMenuBehavior
Tells this action how to behave if it is in a menu. This may not have an effect if the action already is part of a menu.- Parameters:
menu- the behavior, notnull
-
getMenuBehavior
Tells how this action behaves if in a menu.- Returns:
- the behavior, not
null
-
setButtonBehavior
Tells this action how to handle buttons.- Parameters:
button- when to open a popup
-
getButtonBehavior
Tells how this action behaves if displayed as button.- Returns:
- the behavior, not
null
-
setCloseOnFocusLost
public void setCloseOnFocusLost(boolean closeOnFocusLost) Whether the window should be closed if focus is lost.- Parameters:
closeOnFocusLost-trueif it should close automatically
-
isCloseOnFocusLost
public boolean isCloseOnFocusLost()Tells whether the window is automatically closed if the focus is lost.- Returns:
- whether the popup is closed automatically
-
openPopup
Informs thisCPanelPopupthat its content is shown and allows this to handle the closing event.- Parameters:
window- the window- Throws:
IllegalArgumentException- ifPanelPopupWindow.isOpen()returnfalse
-
closePopup
public void closePopup()Makes the current popup invisible. -
isOpen
public boolean isOpen()Tells whether the content of this action is currently being showed.- Returns:
trueif the content is visible
-
onMousePressed
protected void onMousePressed(Dockable dockable, JComponent item, DockTitle.Orientation orientation) Called if the mouse is pressed on the buttonitemof of aDockTitlewhich has orientationorientation.- Parameters:
dockable- the element for which this panel is shownitem- the pressed componentorientation- the orientation of the title
-
onMouseReleased
protected void onMouseReleased(Dockable dockable, JComponent item, DockTitle.Orientation orientation) Called if the mouse is released of the buttonitemof of aDockTitlewhich has orientationorientation.- Parameters:
dockable- the element for which this panel is shownitem- the released componentorientation- the orientation of the title
-
onTrigger
- Parameters:
dockable- the element for which this panel is shownitem- the triggered buttonorientation- the orientation of the title
-
openDialog
Opens a new undecorated dialog below or aside ofitem. This method does nothing ifisOpen()returntrue.- Parameters:
dockable- the element for which this panel is shownitem- the owner of the new dialogorientation- the orientation of the title which showsitem
-
onMenuItemTrigger
Called if the menu-item representing this action has been hit.- Parameters:
dockable- the source of the event
-
createDialogWindow
Creates a new window which will be used as popup for thisCPanelPopup.- Parameters:
owner- the owner of the window- Returns:
- the new window, not
null
-
onMenuTrigger
Called if a menu is opening a submenu in whichthe contentis to be shown.- Parameters:
menu- the new parent of the content
-
createMenuWindow
Creates a new window which will be used as popup for thisCPanelPopup.- Parameters:
menu- the owner of the window- Returns:
- the new window, not
null
-
executeOneDockableHasFocus
Callsrunonce the owningDockableof this action has the focus- Parameters:
dockable- the element for which this panel is shownrun- some piece of code to run, usually it will open the popup-dialog created bycreateDialogWindow(Component). Should be called by theEDT.
-