public class CPanelPopup extends CDecorateableAction<CPanelPopup.PanelPopup>
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.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.closePopup() to explicitly close it. The
window closes automatically if it loses the focus, clients can call
setCloseOnFocusLost(boolean) to change that behavior.
| Modifier and Type | Class and Description |
|---|---|
static class |
CPanelPopup.ButtonBehavior
When the popup should show up if the action is displayed as button.
|
static class |
CPanelPopup.MenuBehavior
Tells how a
CPanelPopup behaves if it is a child
of a menu. |
class |
CPanelPopup.PanelPopup
A custom action shows some dialog or window when triggered
|
| Modifier and Type | Field and Description |
|---|---|
static ActionType<CPanelPopup.PanelPopup> |
PANEL_POPUP
the kind of action this class represents
|
| Constructor and Description |
|---|
CPanelPopup()
Creates a new action.
|
| Modifier and Type | Method and Description |
|---|---|
void |
closePopup()
Makes the current popup invisible.
|
protected DialogWindow |
createDialogWindow(Component owner)
Creates a new window which will be used as popup for this
CPanelPopup. |
protected MenuWindow |
createMenuWindow(JPopupMenu menu)
Creates a new window which will be used as popup for this
CPanelPopup. |
protected void |
executeOneDockableHasFocus(Dockable dockable,
Runnable run)
Calls
run once the owning Dockable of this action has the focus |
CPanelPopup.ButtonBehavior |
getButtonBehavior()
Tells how this action behaves if displayed as button.
|
JComponent |
getContent()
Gets the contents of this action.
|
CPanelPopup.MenuBehavior |
getMenuBehavior()
Tells how this action behaves if in a menu.
|
boolean |
isCloseOnFocusLost()
Tells whether the window is automatically closed if the focus is lost.
|
boolean |
isOpen()
Tells whether the content of this action is currently being showed.
|
protected void |
onMenuItemTrigger(Dockable dockable)
Called if the menu-item representing this action has been
hit.
|
protected void |
onMenuTrigger(JPopupMenu menu)
Called if a menu is opening a submenu in which
the content
is to be shown. |
protected void |
onMousePressed(Dockable dockable,
JComponent item,
DockTitle.Orientation orientation)
Called if the mouse is pressed on the button
item of
of a DockTitle which has orientation orientation. |
protected void |
onMouseReleased(Dockable dockable,
JComponent item,
DockTitle.Orientation orientation)
Called if the mouse is released of the button
item of
of a DockTitle which has orientation orientation. |
protected void |
onTrigger(Dockable dockable,
JComponent item,
DockTitle.Orientation orientation)
|
protected void |
openDialog(Dockable dockable,
JComponent item,
DockTitle.Orientation orientation)
Opens a new undecorated dialog below or aside of
item. |
void |
openPopup(PanelPopupWindow window)
Informs this
CPanelPopup that its content is shown and
allows this to handle the closing event. |
void |
setButtonBehavior(CPanelPopup.ButtonBehavior button)
Tells this action how to handle buttons.
|
void |
setCloseOnFocusLost(boolean closeOnFocusLost)
Whether the window should be closed if focus is lost.
|
void |
setContent(JComponent content)
Sets the component that is shown on a popup dialog/menu/window... by
this
CPanelPopup. |
void |
setMenuBehavior(CPanelPopup.MenuBehavior menu)
Tells this action how to behave if it is in a menu.
|
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, setTooltippublic static final ActionType<CPanelPopup.PanelPopup> PANEL_POPUP
public void setContent(JComponent content)
CPanelPopup.content - the content, may be nullpublic JComponent getContent()
public void setMenuBehavior(CPanelPopup.MenuBehavior menu)
menu - the behavior, not nullpublic CPanelPopup.MenuBehavior getMenuBehavior()
nullpublic void setButtonBehavior(CPanelPopup.ButtonBehavior button)
button - when to open a popuppublic CPanelPopup.ButtonBehavior getButtonBehavior()
nullpublic void setCloseOnFocusLost(boolean closeOnFocusLost)
closeOnFocusLost - true if it should close automaticallypublic boolean isCloseOnFocusLost()
public void openPopup(PanelPopupWindow window)
CPanelPopup that its content is shown and
allows this to handle the closing event.window - the windowIllegalArgumentException - if PanelPopupWindow.isOpen()
return falsepublic void closePopup()
public boolean isOpen()
true if the content is visibleprotected void onMousePressed(Dockable dockable, JComponent item, DockTitle.Orientation orientation)
item of
of a DockTitle which has orientation orientation.dockable - the element for which this panel is shownitem - the pressed componentorientation - the orientation of the titleprotected void onMouseReleased(Dockable dockable, JComponent item, DockTitle.Orientation orientation)
item of
of a DockTitle which has orientation orientation.dockable - the element for which this panel is shownitem - the released componentorientation - the orientation of the titleprotected void onTrigger(Dockable dockable, JComponent item, DockTitle.Orientation orientation)
dockable - the element for which this panel is shownitem - the triggered buttonorientation - the orientation of the titleprotected void openDialog(Dockable dockable, JComponent item, DockTitle.Orientation orientation)
item. This method
does nothing if isOpen() return true.dockable - the element for which this panel is shownitem - the owner of the new dialogorientation - the orientation of the title which shows itemprotected void onMenuItemTrigger(Dockable dockable)
dockable - the source of the eventprotected DialogWindow createDialogWindow(Component owner)
CPanelPopup.owner - the owner of the windownullprotected void onMenuTrigger(JPopupMenu menu)
the content
is to be shown.menu - the new parent of the contentprotected MenuWindow createMenuWindow(JPopupMenu menu)
CPanelPopup.menu - the owner of the windownullprotected void executeOneDockableHasFocus(Dockable dockable, Runnable run)
run once the owning Dockable of this action has the focusdockable - the element for which this panel is shownrun - some piece of code to run, usually it will open the popup-dialog created by createDialogWindow(Component).
Should be called by the EDT.Copyright © 2018. All rights reserved.