Update of /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/completion
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16815/fw/src/net/sourceforge/squirrel_sql/fw/completion
Modified Files:
PopupManager.java Completor.java
Log Message:
Object tree search (Feature request 2004240):
Index: Completor.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/completion/Completor.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Completor.java 4 Aug 2007 21:07:48 -0000 1.10
--- Completor.java 5 Oct 2008 15:10:01 -0000 1.11
***************
*** 31,34 ****
--- 31,37 ----
public class Completor
{
+ public static final Color DEFAULT_POP_UP_BACK_GROUND = new Color(255,255,204);
+
+
private Vector<CompletorListener> _listeners = new Vector<CompletorListener>();
private ICompletorModel _model;
***************
*** 65,76 ****
private Action[] _originalActions = null;
! public Completor(JTextComponent txtComp, ICompletorModel model)
{
! this(txtComp, model, new Color(255,255,204), false); // light yellow
}
public Completor(JTextComponent txtComp, ICompletorModel model, Color popUpBackGround, boolean useOwnFilterTextField)
{
! _txtComp = new TextComponentProvider(txtComp, useOwnFilterTextField);
_model = model;
--- 68,84 ----
private Action[] _originalActions = null;
! public Completor(JTextComponent txtComp, ICompletorModel model)
{
! this(txtComp, model, DEFAULT_POP_UP_BACK_GROUND, false, txtComp); // light yellow
}
public Completor(JTextComponent txtComp, ICompletorModel model, Color popUpBackGround, boolean useOwnFilterTextField)
{
! this(txtComp, model, popUpBackGround, useOwnFilterTextField, txtComp);
! }
!
! public Completor(JTextComponent txtComp, ICompletorModel model, Color popUpBackGround, boolean useOwnFilterTextField, JComponent popupParent)
! {
! _txtComp = new TextComponentProvider(txtComp, useOwnFilterTextField);
_model = model;
***************
*** 125,130 ****
_completionPanel.setVisible(false);
! _popupMan = new PopupManager(txtComp);
! }
private void onKeyPressedOnList(KeyEvent e)
--- 133,138 ----
_completionPanel.setVisible(false);
! _popupMan = new PopupManager(popupParent);
! }
private void onKeyPressedOnList(KeyEvent e)
Index: PopupManager.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/completion/PopupManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PopupManager.java 26 May 2005 00:09:24 -0000 1.1
--- PopupManager.java 5 Oct 2008 15:10:01 -0000 1.2
***************
*** 17,38 ****
import java.awt.Rectangle;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import javax.swing.Action;
- import javax.swing.ActionMap;
- import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JRootPane;
- import javax.swing.KeyStroke;
- import javax.swing.text.JTextComponent;
- import java.awt.event.ComponentAdapter;
- import java.awt.event.ComponentEvent;
import javax.swing.SwingUtilities;
import java.awt.Component;
import javax.swing.JViewport;
- import javax.swing.text.BadLocationException;
--- 17,28 ----
***************
*** 46,52 ****
public class PopupManager
{
- private JComponent popup = null;
- private JTextComponent textComponent;
/** Place popup always above cursor */
--- 36,41 ----
public class PopupManager
{
+ private JComponent _popupParent = null;
/** Place popup always above cursor */
***************
*** 68,111 ****
public static final Placement BelowPreferred = new Placement("BelowPreferred"); //NOI18N
! private KeyListener keyListener;
!
! private TextComponentListener componentListener;
!
! /** Creates a new instance of PopupManager */
! public PopupManager(JTextComponent textComponent)
! {
! this.textComponent = textComponent;
! keyListener = new PopupKeyListener();
! textComponent.addKeyListener(keyListener);
! componentListener = new TextComponentListener();
! textComponent.addComponentListener(componentListener);
! }
!
! /** Install popup component to textComponent root pane
! * based on caret coordinates with the <CODE>Largest</CODE> placement.
! * @param popup popup component to be installed into
! * root pane of the text component.
! */
! public void install(JComponent popup)
! {
! int caretPos = textComponent.getCaret().getDot();
! try
! {
! Rectangle caretBounds = textComponent.modelToView(caretPos);
! install(popup, caretBounds, Largest);
! }
! catch (BadLocationException e)
! {
! // do not install if the caret position is invalid
! }
! }
! public void install(
JComponent popup, Rectangle cursorBounds, Placement placement)
{
- this.popup = popup;
// Update the bounds of the popup
! Rectangle bounds = computeBounds(this.popup, textComponent,
cursorBounds, placement);
--- 57,71 ----
public static final Placement BelowPreferred = new Placement("BelowPreferred"); //NOI18N
! public PopupManager(JComponent popupParent)
! {
! _popupParent = popupParent;
! }
! public void install(
JComponent popup, Rectangle cursorBounds, Placement placement)
{
// Update the bounds of the popup
! Rectangle bounds = computeBounds(popup, _popupParent,
cursorBounds, placement);
***************
*** 113,124 ****
{
// Convert to layered pane's coordinates
! bounds = SwingUtilities.convertRectangle(textComponent, bounds,
! textComponent.getRootPane().getLayeredPane());
! this.popup.setBounds(bounds);
}
else
{ // can't fit -> hide
! this.popup.setVisible(false);
}
--- 73,84 ----
{
// Convert to layered pane's coordinates
! bounds = SwingUtilities.convertRectangle(_popupParent, bounds,
! _popupParent.getRootPane().getLayeredPane());
! popup.setBounds(bounds);
}
else
{ // can't fit -> hide
! popup.setVisible(false);
}
***************
*** 132,156 ****
* to cover the workspace switches etc.
*/
! if (this.popup != null)
{
! removeFromRootPane(this.popup);
}
! if (this.popup != null)
{
! installToRootPane(this.popup);
}
}
- /** Returns installed popup panel component */
- public JComponent get()
- {
- return popup;
- }
-
! /** Install popup panel to current textComponent root pane */
private void installToRootPane(JComponent c)
{
! JRootPane rp = textComponent.getRootPane();
if (rp != null)
{
--- 92,110 ----
* to cover the workspace switches etc.
*/
! if (popup != null)
{
! removeFromRootPane(popup);
}
! if (popup != null)
{
! installToRootPane(popup);
}
}
! /** Install popup panel to current textComponent root pane */
private void installToRootPane(JComponent c)
{
! JRootPane rp = _popupParent.getRootPane();
if (rp != null)
{
***************
*** 353,404 ****
! /** Popup's key filter */
! private class PopupKeyListener implements KeyListener
! {
! public void keyTyped(KeyEvent e)
! {
! }
!
! public void keyReleased(KeyEvent e)
! {
! }
!
! public void keyPressed(KeyEvent e)
! {
! if (e == null) return;
! if (popup != null && popup.isShowing())
! {
!
! // get popup's registered keyboard actions
! ActionMap am = popup.getActionMap();
! InputMap im = popup.getInputMap();
!
! // check whether popup registers keystroke
! Object obj = im.get(KeyStroke.getKeyStrokeForEvent(e));
! if (obj != null)
! {
! // if yes, gets the popup's action for this keystroke, perform it
! // and consume key event
! Action action = am.get(obj);
! if (action != null)
! {
! action.actionPerformed(null);
! e.consume();
! }
! }
! }
! }
!
! }
!
! private final class TextComponentListener extends ComponentAdapter
! {
! public void componentHidden(ComponentEvent evt)
! {
! install(null); // hide popup
! }
! }
!
! /** Placement of popup panel specification */
public static final class Placement
{
--- 307,311 ----
! /** Placement of popup panel specification */
public static final class Placement
{
|