public abstract class JBPopupFactory
extends java.lang.Object
Types of popups in IntelliJ platform:
Lightweight Swing components, located in the contained window's layered pane. Cannot extend beyond window bounds.
Balloon
interface (implemented in BalloonImpl
)
Platform's lowest-level lightweight popup component. Supports title bar, shadow, callout pointer at specified side, animated showing/hiding, fade-out after delay, two layers for positioning, hiding on condition (mouse move, mouse click, key press), custom mouse click handler, custom action buttons, notification about showing/hiding.
Usually created via createBalloonBuilder(javax.swing.JComponent)
.
IdeTooltip
and IdeTooltipManager
Subsystem which replaces (by default) Swing's ToolTipManager. Allows to define a custom mouse hover tooltip for any UI component. Tooltip can also be explicitly requested to show in the given location.
Uses balloons to show tooltips internally (but doesn't expose this logic).
Components using a separate (OS-recognized) window. Can have location and size not limited by the parent window.
JBPopup
interface (implemented in AbstractPopup
)
Platform's lowest-level heavyweight popup component. Supports title and footer (ad) bar, resizing using mouse, fitting size to screen bounds, notification about showing/hiding/resizing/moving, hiding on condition (mouse exit, mouse click, key press, window deactivation), speed search, saving and restoring previously used location and size, custom keyboard actions for the content, custom settings/pin actions.
Usually created via createComponentPopupBuilder(javax.swing.JComponent, javax.swing.JComponent)
.
Hint
interface (implemented in LightweightHint
)
By default, if content fits the layered pane, tries to use lightweight components to display it (either using
IdeTooltipManager
, or by directly adding content to the layered pane).
If the content doesn't fit, uses heavyweight approach (via JBPopup
).
Usually created directly (via constructor).
Mostly used for showing hints in editor (works via LightweightHint
), but also has a method to show a hint at arbitrary
location (works via JBPopup
). Supports hiding of hints on additional conditions (caret movement, scrolling in editor, document
change, showing of another hint), update of hint position on scrolling in editor, hiding hint after delay. The class also has
utility methods to calculate appropriate hint position for the given location in editor coordinates
(offset/LogicalPosition/VisualPosition), and to show simple text hints.
Modifier and Type | Class and Description |
---|---|
static class |
JBPopupFactory.ActionSelectionAid
Possible ways to select actions in a popup from keyboard.
|
Constructor and Description |
---|
JBPopupFactory() |
Modifier and Type | Method and Description |
---|---|
abstract ListPopup |
createActionGroupPopup(java.lang.String title,
ActionGroup actionGroup,
DataContext dataContext,
boolean showNumbers,
boolean showDisabledActions,
boolean honorActionMnemonics,
java.lang.Runnable disposeCallback,
int maxRowCount,
Condition<? super AnAction> preselectActionCondition) |
ListPopup |
createActionGroupPopup(java.lang.String title,
ActionGroup actionGroup,
DataContext dataContext,
boolean showDisabledActions,
java.lang.Runnable disposeCallback,
int maxRowCount) |
ListPopup |
createActionGroupPopup(java.lang.String title,
ActionGroup actionGroup,
DataContext dataContext,
JBPopupFactory.ActionSelectionAid selectionAidMethod,
boolean showDisabledActions)
Creates a popup allowing to choose one of the actions from the specified action group.
|
ListPopup |
createActionGroupPopup(java.lang.String title,
ActionGroup actionGroup,
DataContext dataContext,
JBPopupFactory.ActionSelectionAid selectionAidMethod,
boolean showDisabledActions,
java.lang.Runnable disposeCallback,
int maxRowCount)
Creates a popup allowing to choose one of the actions from the specified action group.
|
abstract ListPopup |
createActionGroupPopup(java.lang.String title,
ActionGroup actionGroup,
DataContext dataContext,
JBPopupFactory.ActionSelectionAid aid,
boolean showDisabledActions,
java.lang.Runnable disposeCallback,
int maxRowCount,
Condition<? super AnAction> preselectActionCondition,
java.lang.String actionPlace) |
ListPopup |
createActionGroupPopup(java.lang.String title,
ActionGroup actionGroup,
DataContext dataContext,
JBPopupFactory.ActionSelectionAid selectionAidMethod,
boolean showDisabledActions,
java.lang.String actionPlace)
Creates a popup allowing to choose one of the actions from the specified action group.
|
ListPopupStep |
createActionsStep(ActionGroup actionGroup,
DataContext dataContext,
boolean showNumbers,
boolean showDisabledActions,
java.lang.String title,
java.awt.Component component,
boolean honorActionMnemonics)
|
ListPopupStep |
createActionsStep(ActionGroup actionGroup,
DataContext dataContext,
boolean showNumbers,
boolean showDisabledActions,
java.lang.String title,
java.awt.Component component,
boolean honorActionMnemonics,
int defaultOptionIndex,
boolean autoSelectionEnabled)
|
abstract ListPopupStep |
createActionsStep(ActionGroup actionGroup,
DataContext dataContext,
java.lang.String actionPlace,
boolean showNumbers,
boolean showDisabledActions,
java.lang.String title,
java.awt.Component component,
boolean honorActionMnemonics,
int defaultOptionIndex,
boolean autoSelectionEnabled) |
abstract BalloonBuilder |
createBalloonBuilder(javax.swing.JComponent content) |
abstract ComponentPopupBuilder |
createComponentPopupBuilder(javax.swing.JComponent content,
javax.swing.JComponent preferableFocusComponent) |
abstract ListPopup |
createConfirmation(java.lang.String title,
java.lang.Runnable onYes,
int defaultOptionIndex)
Creates a popup with the specified title and two options, Yes and No.
|
abstract ListPopup |
createConfirmation(java.lang.String title,
java.lang.String yesText,
java.lang.String noText,
java.lang.Runnable onYes,
int defaultOptionIndex)
Creates a popup allowing to choose one of two specified options and execute code when one of them is selected.
|
abstract ListPopup |
createConfirmation(java.lang.String title,
java.lang.String yesText,
java.lang.String noText,
java.lang.Runnable onYes,
java.lang.Runnable onNo,
int defaultOptionIndex)
Creates a popup allowing to choose one of two specified options and execute code when either of them is selected.
|
abstract BalloonBuilder |
createDialogBalloonBuilder(javax.swing.JComponent content,
java.lang.String title) |
abstract BalloonBuilder |
createHtmlTextBalloonBuilder(java.lang.String htmlContent,
javax.swing.Icon icon,
java.awt.Color textColor,
java.awt.Color fillColor,
javax.swing.event.HyperlinkListener listener) |
BalloonBuilder |
createHtmlTextBalloonBuilder(java.lang.String htmlContent,
javax.swing.Icon icon,
java.awt.Color fillColor,
javax.swing.event.HyperlinkListener listener) |
abstract BalloonBuilder |
createHtmlTextBalloonBuilder(java.lang.String htmlContent,
MessageType messageType,
javax.swing.event.HyperlinkListener listener) |
abstract ListPopup |
createListPopup(ListPopupStep step)
Creates a custom list popup with the specified step.
|
abstract ListPopup |
createListPopup(ListPopupStep step,
int maxRowCount)
Creates a custom list popup with the specified step.
|
<T> PopupChooserBuilder<T> |
createListPopupBuilder(javax.swing.JList<T> list)
Deprecated.
Please use
createPopupChooserBuilder(List) instead |
abstract JBPopup |
createMessage(java.lang.String text) |
PopupChooserBuilder |
createPopupChooserBuilder(javax.swing.JTable table) |
abstract <T> IPopupChooserBuilder<T> |
createPopupChooserBuilder(java.util.List<? extends T> list) |
protected abstract <T> PopupChooserBuilder.PopupComponentAdapter<T> |
createPopupComponentAdapter(PopupChooserBuilder<T> builder,
javax.swing.JList<T> list) |
protected abstract <T> PopupChooserBuilder.PopupComponentAdapter<T> |
createPopupComponentAdapter(PopupChooserBuilder<T> builder,
javax.swing.JTable table) |
protected abstract <T> PopupChooserBuilder.PopupComponentAdapter<T> |
createPopupComponentAdapter(PopupChooserBuilder<T> builder,
javax.swing.JTree tree) |
abstract TreePopup |
createTree(JBPopup parent,
TreePopupStep step,
java.lang.Object parentValue) |
abstract TreePopup |
createTree(TreePopupStep step) |
abstract java.awt.Point |
getCenterOf(javax.swing.JComponent container,
javax.swing.JComponent content) |
JBPopup |
getChildFocusedPopup(java.awt.Component parent) |
abstract java.util.List<JBPopup> |
getChildPopups(java.awt.Component parent) |
static JBPopupFactory |
getInstance()
Returns the popup factory instance.
|
abstract Balloon |
getParentBalloonFor(java.awt.Component c) |
abstract RelativePoint |
guessBestPopupLocation(DataContext dataContext)
Returns the location where a popup with the specified data context is displayed.
|
abstract RelativePoint |
guessBestPopupLocation(Editor editor)
Returns the location where a popup invoked from the specified editor should be displayed.
|
abstract RelativePoint |
guessBestPopupLocation(javax.swing.JComponent component) |
abstract boolean |
isBestPopupLocationVisible(Editor editor) |
boolean |
isChildPopupFocused(java.awt.Component parent) |
abstract boolean |
isPopupActive() |
public static JBPopupFactory getInstance()
public abstract <T> IPopupChooserBuilder<T> createPopupChooserBuilder(java.util.List<? extends T> list)
public PopupChooserBuilder createPopupChooserBuilder(javax.swing.JTable table)
@Deprecated public <T> PopupChooserBuilder<T> createListPopupBuilder(javax.swing.JList<T> list)
createPopupChooserBuilder(List)
insteadpublic abstract ListPopup createConfirmation(java.lang.String title, java.lang.Runnable onYes, int defaultOptionIndex)
title
- the title of the popup.onYes
- the runnable which is executed when the Yes option is selected.defaultOptionIndex
- the index of the option which is selected by default.public abstract ListPopup createConfirmation(java.lang.String title, java.lang.String yesText, java.lang.String noText, java.lang.Runnable onYes, int defaultOptionIndex)
title
- the title of the popup.yesText
- the title for the Yes option.noText
- the title for the No option.onYes
- the runnable which is executed when the Yes option is selected.defaultOptionIndex
- the index of the option which is selected by default.public abstract ListPopup createConfirmation(java.lang.String title, java.lang.String yesText, java.lang.String noText, java.lang.Runnable onYes, java.lang.Runnable onNo, int defaultOptionIndex)
title
- the title of the popup.yesText
- the title for the Yes option.noText
- the title for the No option.onYes
- the runnable which is executed when the Yes option is selected.onNo
- the runnable which is executed when the No option is selected.defaultOptionIndex
- the index of the option which is selected by default.@Deprecated public ListPopupStep createActionsStep(ActionGroup actionGroup, DataContext dataContext, boolean showNumbers, boolean showDisabledActions, java.lang.String title, java.awt.Component component, boolean honorActionMnemonics)
@Deprecated public ListPopupStep createActionsStep(ActionGroup actionGroup, DataContext dataContext, boolean showNumbers, boolean showDisabledActions, java.lang.String title, java.awt.Component component, boolean honorActionMnemonics, int defaultOptionIndex, boolean autoSelectionEnabled)
public abstract ListPopupStep createActionsStep(ActionGroup actionGroup, DataContext dataContext, java.lang.String actionPlace, boolean showNumbers, boolean showDisabledActions, java.lang.String title, java.awt.Component component, boolean honorActionMnemonics, int defaultOptionIndex, boolean autoSelectionEnabled)
public abstract RelativePoint guessBestPopupLocation(javax.swing.JComponent component)
public boolean isChildPopupFocused(java.awt.Component parent)
public JBPopup getChildFocusedPopup(java.awt.Component parent)
public ListPopup createActionGroupPopup(java.lang.String title, ActionGroup actionGroup, DataContext dataContext, JBPopupFactory.ActionSelectionAid selectionAidMethod, boolean showDisabledActions)
title
- the title of the popup.actionGroup
- the action group from which the popup is built.dataContext
- the data context which provides the data for the selected actionselectionAidMethod
- keyboard selection mode for actions in the popup.showDisabledActions
- if true, disabled actions are shown as disabled; if false, disabled actions are not shownpublic ListPopup createActionGroupPopup(java.lang.String title, ActionGroup actionGroup, DataContext dataContext, JBPopupFactory.ActionSelectionAid selectionAidMethod, boolean showDisabledActions, java.lang.String actionPlace)
title
- the title of the popup.actionGroup
- the action group from which the popup is built.dataContext
- the data context which provides the data for the selected actionselectionAidMethod
- keyboard selection mode for actions in the popup.showDisabledActions
- if true, disabled actions are shown as disabled; if false, disabled actions are not shownactionPlace
- action place for ActionManager to use when creating the popuppublic ListPopup createActionGroupPopup(java.lang.String title, ActionGroup actionGroup, DataContext dataContext, JBPopupFactory.ActionSelectionAid selectionAidMethod, boolean showDisabledActions, java.lang.Runnable disposeCallback, int maxRowCount)
title
- the title of the popup.actionGroup
- the action group from which the popup is built.dataContext
- the data context which provides the data for the selected actionselectionAidMethod
- keyboard selection mode for actions in the popup.showDisabledActions
- if true, disabled actions are shown as disabled; if false, disabled actions are not showndisposeCallback
- method which is called when the popup is closed (either by selecting an action or by canceling)maxRowCount
- maximum number of popup rows visible at once (if there are more actions in the action group, a scrollbar
is displayed)public ListPopup createActionGroupPopup(java.lang.String title, ActionGroup actionGroup, DataContext dataContext, boolean showDisabledActions, java.lang.Runnable disposeCallback, int maxRowCount)
public abstract ListPopup createActionGroupPopup(java.lang.String title, ActionGroup actionGroup, DataContext dataContext, boolean showNumbers, boolean showDisabledActions, boolean honorActionMnemonics, java.lang.Runnable disposeCallback, int maxRowCount, Condition<? super AnAction> preselectActionCondition)
public abstract ListPopup createActionGroupPopup(java.lang.String title, ActionGroup actionGroup, DataContext dataContext, JBPopupFactory.ActionSelectionAid aid, boolean showDisabledActions, java.lang.Runnable disposeCallback, int maxRowCount, Condition<? super AnAction> preselectActionCondition, java.lang.String actionPlace)
public abstract ListPopup createListPopup(ListPopupStep step)
step
- the custom step for the list popup.public abstract ListPopup createListPopup(ListPopupStep step, int maxRowCount)
step
- the custom step for the list popup.maxRowCount
- the number of visible rows to show in the popup (if the popup has more items,
a scrollbar will be displayed).public abstract TreePopup createTree(JBPopup parent, TreePopupStep step, java.lang.Object parentValue)
public abstract TreePopup createTree(TreePopupStep step)
public abstract ComponentPopupBuilder createComponentPopupBuilder(javax.swing.JComponent content, javax.swing.JComponent preferableFocusComponent)
public abstract RelativePoint guessBestPopupLocation(DataContext dataContext)
dataContext
- the data context from which the location is determined.public abstract RelativePoint guessBestPopupLocation(Editor editor)
editor
- the editor over which the popup is shown.public abstract boolean isBestPopupLocationVisible(Editor editor)
editor
- the editor over which the popup is shown.public abstract java.awt.Point getCenterOf(javax.swing.JComponent container, javax.swing.JComponent content)
public abstract java.util.List<JBPopup> getChildPopups(java.awt.Component parent)
public abstract boolean isPopupActive()
public abstract BalloonBuilder createBalloonBuilder(javax.swing.JComponent content)
public abstract BalloonBuilder createDialogBalloonBuilder(javax.swing.JComponent content, java.lang.String title)
public BalloonBuilder createHtmlTextBalloonBuilder(java.lang.String htmlContent, javax.swing.Icon icon, java.awt.Color fillColor, javax.swing.event.HyperlinkListener listener)
public abstract BalloonBuilder createHtmlTextBalloonBuilder(java.lang.String htmlContent, javax.swing.Icon icon, java.awt.Color textColor, java.awt.Color fillColor, javax.swing.event.HyperlinkListener listener)
public abstract BalloonBuilder createHtmlTextBalloonBuilder(java.lang.String htmlContent, MessageType messageType, javax.swing.event.HyperlinkListener listener)
public abstract JBPopup createMessage(java.lang.String text)
public abstract Balloon getParentBalloonFor(java.awt.Component c)
protected abstract <T> PopupChooserBuilder.PopupComponentAdapter<T> createPopupComponentAdapter(PopupChooserBuilder<T> builder, javax.swing.JList<T> list)
protected abstract <T> PopupChooserBuilder.PopupComponentAdapter<T> createPopupComponentAdapter(PopupChooserBuilder<T> builder, javax.swing.JTree tree)
protected abstract <T> PopupChooserBuilder.PopupComponentAdapter<T> createPopupComponentAdapter(PopupChooserBuilder<T> builder, javax.swing.JTable table)