| java.lang.Object net.sourceforge.squirrel_sql.fw.completion.PopupManager
PopupManager | public class PopupManager (Code) | | Popup manager allows to display an arbitrary popup component
over the underlying text component.
author: Martin Roskanin, Miloslav Metelka since: 03/2002 |
Inner Class :final public static class Placement | |
Field Summary | |
final public static Placement | Above | final public static Placement | AbovePreferred Place popup above cursor. | final public static Placement | Below | final public static Placement | BelowPreferred Place popup below cursor. | final public static Placement | Largest Place popup to larger area. |
Method Summary | |
protected static Rectangle | computeBounds(JComponent popup, JComponent view, Rectangle cursorBounds, Placement placement) Variation of the method for computing the bounds
for the concrete view component. | protected static Rectangle | computeBounds(JComponent popup, int viewWidth, int viewHeight, Rectangle cursorBounds, Placement placement) Computes a best-fit bounds of popup panel
according to available space in the underlying view
(visible part of the pane).
The placement is first evaluated and put into the popup's client property
by popup.putClientProperty(Placement.class, actual-placement) .
The actual placement is | public JComponent | get() | public void | install(JComponent popup) Install popup component to textComponent root pane
based on caret coordinates with the Largest placement. | public void | install(JComponent popup, Rectangle cursorBounds, Placement placement) |
Above | final public static Placement Above(Code) | | Place popup always above cursor
|
AbovePreferred | final public static Placement AbovePreferred(Code) | | Place popup above cursor. If a place above cursor is insufficient,
then popup will be placed below cursor.
|
Below | final public static Placement Below(Code) | | Place popup always below cursor
|
BelowPreferred | final public static Placement BelowPreferred(Code) | | Place popup below cursor. If a place below cursor is insufficient,
then popup will be placed above cursor.
|
Largest | final public static Placement Largest(Code) | | Place popup to larger area. i.e. if place below cursor is
larger than place above, then popup will be placed below cursor.
|
PopupManager | public PopupManager(JTextComponent textComponent)(Code) | | Creates a new instance of PopupManager
|
computeBounds | protected static Rectangle computeBounds(JComponent popup, JComponent view, Rectangle cursorBounds, Placement placement)(Code) | | Variation of the method for computing the bounds
for the concrete view component. As the component can possibly
be placed in a scroll pane it's first necessary
to translate the cursor bounds and also translate
back the resulting popup bounds.
Parameters: popup - popup panel to be displayed Parameters: view - component over which the popup is displayed. Parameters: cursorBounds - the bounds of the caret or mouse cursorrelative to the upper-left corner of the visible view. Parameters: placement - where to place the popup panel according tothe cursor position. bounds of popup panel relative to the upper-left cornerof the underlying view component.null if there is no place to display popup. |
computeBounds | protected static Rectangle computeBounds(JComponent popup, int viewWidth, int viewHeight, Rectangle cursorBounds, Placement placement)(Code) | | Computes a best-fit bounds of popup panel
according to available space in the underlying view
(visible part of the pane).
The placement is first evaluated and put into the popup's client property
by popup.putClientProperty(Placement.class, actual-placement) .
The actual placement is
-
Above if the original placement was Above .
Or if the original placement was AbovePreferred
or Largest
and there is more space above the cursor than below it.
-
Below if the original placement was Below .
Or if the original placement was BelowPreferred
or Largest
and there is more space below the cursor than above it.
-
AbovePreferred if the original placement
was AbovePreferred
and there is less space above the cursor than below it.
-
BelowPreferred if the original placement
was BelowPreferred
and there is less space below the cursor than above it.
Once the placement client property is set
the popup.setSize() is called with the size of the area
above/below the cursor (indicated by the placement).
The popup responds by updating its size to the equal or smaller
size. If it cannot physically fit into the requested area
it can call
putClientProperty(Placement.class, null)
on itself to indicate that it cannot fit. The method scans
the content of the client property upon return from
popup.setSize() and if it finds null there it returns
null bounds in that case. The only exception is
if the placement was either AbovePreferred
or BelowPreferred . In that case the method
gives it one more try
by attempting to fit the popup into (bigger) complementary
Below and Above areas (respectively).
The popup either fits into these (bigger) areas or it again responds
by returning null in the client property in which case
the method finally gives up and returns null bounds.
Parameters: popup - popup panel to be displayed Parameters: viewWidth - width of the visible view area. Parameters: viewHeight - height of the visible view area. Parameters: cursorBounds - the bounds of the caret or mouse cursorrelative to the upper-left corner of the visible view Parameters: placement - where to place the popup panel according tothe cursor position bounds of popup panel relative to the upper-left cornerof the underlying view.null if there is no place to display popup. |
install | public void install(JComponent popup)(Code) | | Install popup component to textComponent root pane
based on caret coordinates with the Largest placement.
Parameters: popup - popup component to be installed intoroot pane of the text component. |
|
|