站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ToolTipSupport (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor.ext
Class ToolTipSupport

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by org.netbeans.editor.ext.ToolTipSupport
All Implemented Interfaces:
ActionListener, FocusListener, MouseListener, MouseMotionListener, PropertyChangeListener, EventListener, SettingsChangeListener

public class ToolTipSupport
extends MouseAdapter
implements MouseMotionListener, ActionListener, PropertyChangeListener, SettingsChangeListener, FocusListener

Support for editor tooltips. Once the user stops moving the mouse for the INITIAL_DELAY milliseconds the enterTimer fires and the updateToolTip() method is called which searches for the action named ExtKit.buildToolTipAction and if found it executes it. The tooltips can be displayed by either calling setToolTipText(java.lang.String) or setToolTip(javax.swing.JComponent).
However only one of the above ways should be used not a combination of both because in such case the text could be propagated in the previously set custom tooltip component.


Field Summary
static int DISMISS_DELAY
          Delay after which the tooltip will be hidden automatically in milliseconds.
static int INITIAL_DELAY
          Initial delay before the tooltip is shown in milliseconds.
static String PROP_DISMISS_DELAY
          Property for the dismiss delay change
static String PROP_ENABLED
          Property for the enabled flag change
static String PROP_INITIAL_DELAY
          Property for the initial delay change
static String PROP_STATUS
          Property for the visibility status change.
static String PROP_TOOL_TIP
          Property for the tooltip component change
static String PROP_TOOL_TIP_TEXT
          Property for the tooltip text change
static int STATUS_COMPONENT_VISIBLE
          Status indicating that the tooltip is visible because setToolTip(javax.swing.JComponent) was called.
static int STATUS_HIDDEN
          Status indicating that the tooltip is not showing on the screen.
static int STATUS_TEXT_VISIBLE
          Status indicating that the tooltip is visible because setToolTipText(java.lang.String) was called.
static int STATUS_VISIBILITY_ENABLED
          Status indicating that the tooltip is not showing on the screen but once either the setToolTipText(java.lang.String) or setToolTip(javax.swing.JComponent) gets called the tooltip will become visible.
 
Constructor Summary
ToolTipSupport(ExtEditorUI extEditorUI)
          Construct new support for tooltips.
 
Method Summary
 void actionPerformed(ActionEvent evt)
           
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add the listener for the property changes.
protected  void componentToolTipTextChanged(PropertyChangeEvent evt)
          Called automatically when the JComponent.TOOL_TIP_TEXT_KEY property of the corresponding editor component gets changed.
By default it calls setToolTipText(java.lang.String) with the new tooltip text of the component.
protected  JComponent createDefaultToolTip()
          Create the default tooltip component.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Fire the change of the given property.
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 int getDismissDelay()
           
 String getIdentifierUnderCursor()
          Helper method to get the identifier under the mouse cursor.
 int getInitialDelay()
           
 MouseEvent getLastMouseEvent()
           
 int getStatus()
           
 JComponent getToolTip()
           
 String getToolTipText()
           
 boolean isEnabled()
           
 boolean isToolTipVisible()
           
 void mouseClicked(MouseEvent evt)
           
 void mouseDragged(MouseEvent evt)
           
 void mouseEntered(MouseEvent evt)
           
 void mouseExited(MouseEvent evt)
           
 void mouseMoved(MouseEvent evt)
           
 void mousePressed(MouseEvent evt)
           
 void mouseReleased(MouseEvent evt)
           
 void propertyChange(PropertyChangeEvent evt)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void setDismissDelay(int delay)
          Set the delay between displaying of the tooltip and its automatic hiding in milliseconds.
 void setEnabled(boolean enabled)
          Set whether the tooltip support is enabled.
 void setInitialDelay(int delay)
          Set the delay between stopping mouse movement and displaying of the tooltip in milliseconds.
 void settingsChange(SettingsChangeEvent evt)
           
 void setToolTip(JComponent toolTip)
          Set the tooltip component.
 void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, PopupManager.Placement placement)
           
 void setToolTip(JComponent toolTip, PopupManager.HorizontalBounds horizontalBounds, PopupManager.Placement placement, int horizontalAdjustment, int verticalAdjustment)
           
 void setToolTipText(String text)
          Set the tooltip text to make the tooltip to be shown on the screen.
protected  void setToolTipVisible(boolean visible)
          Set the visibility of the tooltip.
protected  void updateToolTip()
          Update the tooltip by running corresponding action ExtKit.buildToolTipAction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_TOOL_TIP

public static final String PROP_TOOL_TIP
Property for the tooltip component change

See Also:
Constant Field Values

PROP_TOOL_TIP_TEXT

public static final String PROP_TOOL_TIP_TEXT
Property for the tooltip text change

See Also:
Constant Field Values

PROP_STATUS

public static final String PROP_STATUS
Property for the visibility status change.

See Also:
Constant Field Values

PROP_ENABLED

public static final String PROP_ENABLED
Property for the enabled flag change

See Also:
Constant Field Values

PROP_INITIAL_DELAY

public static final String PROP_INITIAL_DELAY
Property for the initial delay change

See Also:
Constant Field Values

PROP_DISMISS_DELAY

public static final String PROP_DISMISS_DELAY
Property for the dismiss delay change

See Also:
Constant Field Values

INITIAL_DELAY

public static final int INITIAL_DELAY
Initial delay before the tooltip is shown in milliseconds.

See Also:
Constant Field Values

DISMISS_DELAY

public static final int DISMISS_DELAY
Delay after which the tooltip will be hidden automatically in milliseconds.

See Also:
Constant Field Values

STATUS_HIDDEN

public static final int STATUS_HIDDEN
Status indicating that the tooltip is not showing on the screen.

See Also:
Constant Field Values

STATUS_VISIBILITY_ENABLED

public static final int STATUS_VISIBILITY_ENABLED
Status indicating that the tooltip is not showing on the screen but once either the setToolTipText(java.lang.String) or setToolTip(javax.swing.JComponent) gets called the tooltip will become visible.

See Also:
Constant Field Values

STATUS_TEXT_VISIBLE

public static final int STATUS_TEXT_VISIBLE
Status indicating that the tooltip is visible because setToolTipText(java.lang.String) was called.

See Also:
Constant Field Values

STATUS_COMPONENT_VISIBLE

public static final int STATUS_COMPONENT_VISIBLE
Status indicating that the tooltip is visible because setToolTip(javax.swing.JComponent) was called.

See Also:
Constant Field Values
Constructor Detail

ToolTipSupport

public ToolTipSupport(ExtEditorUI extEditorUI)
Construct new support for tooltips.

Method Detail

getToolTip

public final JComponent getToolTip()
Returns:
the component that either contains the tooltip or is responsible for displaying of text tooltips.

setToolTip

public void setToolTip(JComponent toolTip)
Set the tooltip component. It can be called either to set the custom component that will display the text tooltips or to display the generic component with the tooltip after the tooltip timer has fired.

Parameters:
toolTip - component that either contains the tooltip or that will display a text tooltip.

setToolTip

public void setToolTip(JComponent toolTip,
                       PopupManager.HorizontalBounds horizontalBounds,
                       PopupManager.Placement placement)

setToolTip

public void setToolTip(JComponent toolTip,
                       PopupManager.HorizontalBounds horizontalBounds,
                       PopupManager.Placement placement,
                       int horizontalAdjustment,
                       int verticalAdjustment)

createDefaultToolTip

protected JComponent createDefaultToolTip()
Create the default tooltip component.


settingsChange

public void settingsChange(SettingsChangeEvent evt)
Specified by:
settingsChange in interface SettingsChangeListener

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

updateToolTip

protected void updateToolTip()
Update the tooltip by running corresponding action ExtKit.buildToolTipAction. This method gets called once the enterTimer fires and it can be overriden by children.


setToolTipVisible

protected void setToolTipVisible(boolean visible)
Set the visibility of the tooltip.

Parameters:
visible - whether tooltip should become visible or not. If true the status is changed to #STATUS_VISIBILITY_ENABLED} and @link #updateToolTip() is called.
It is still possible that the tooltip will not be showing on the screen in case the tooltip or tooltip text are left unchanged.

isToolTipVisible

public boolean isToolTipVisible()
Returns:
Whether the tooltip is showing on the screen. getStatus() gives the exact visibility state.

getStatus

public final int getStatus()
Returns:
status of the tooltip visibility. It can be STATUS_HIDDEN or STATUS_VISIBILITY_ENABLED or STATUS_TEXT_VISIBLE or STATUS_COMPONENT_VISIBLE.

getToolTipText

public String getToolTipText()
Returns:
the current tooltip text.

setToolTipText

public void setToolTipText(String text)
Set the tooltip text to make the tooltip to be shown on the screen.

Parameters:
text - tooltip text to be displayed.

getIdentifierUnderCursor

public String getIdentifierUnderCursor()
Helper method to get the identifier under the mouse cursor.

Returns:
string containing identifier under mouse cursor.

isEnabled

public boolean isEnabled()
Returns:
whether the tooltip support is enabled. If it's disabled the tooltip does not become visible.

setEnabled

public void setEnabled(boolean enabled)
Set whether the tooltip support is enabled. If it's disabled the tooltip does not become visible.

Parameters:
enabled - whether the tooltip will be enabled or not.

getInitialDelay

public int getInitialDelay()
Returns:
the delay between stopping mouse movement and displaying of the tooltip in milliseconds.

setInitialDelay

public void setInitialDelay(int delay)
Set the delay between stopping mouse movement and displaying of the tooltip in milliseconds.


getDismissDelay

public int getDismissDelay()
Returns:
the delay between displaying of the tooltip and its automatic hiding in milliseconds.

setDismissDelay

public void setDismissDelay(int delay)
Set the delay between displaying of the tooltip and its automatic hiding in milliseconds.


actionPerformed

public void actionPerformed(ActionEvent evt)
Specified by:
actionPerformed in interface ActionListener

mouseClicked

public void mouseClicked(MouseEvent evt)
Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class MouseAdapter

mousePressed

public void mousePressed(MouseEvent evt)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter

mouseReleased

public void mouseReleased(MouseEvent evt)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter

mouseEntered

public void mouseEntered(MouseEvent evt)
Specified by:
mouseEntered in interface MouseListener
Overrides:
mouseEntered in class MouseAdapter

mouseExited

public void mouseExited(MouseEvent evt)
Specified by:
mouseExited in interface MouseListener
Overrides:
mouseExited in class MouseAdapter

mouseDragged

public void mouseDragged(MouseEvent evt)
Specified by:
mouseDragged in interface MouseMotionListener

mouseMoved

public void mouseMoved(MouseEvent evt)
Specified by:
mouseMoved in interface MouseMotionListener

getLastMouseEvent

public final MouseEvent getLastMouseEvent()
Returns:
last mouse event captured by this support. This method can be used by the action that evaluates the tooltip.

componentToolTipTextChanged

protected void componentToolTipTextChanged(PropertyChangeEvent evt)
Called automatically when the JComponent.TOOL_TIP_TEXT_KEY property of the corresponding editor component gets changed.
By default it calls setToolTipText(java.lang.String) with the new tooltip text of the component.


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add the listener for the property changes. The names of the supported properties are defined as "PROP_" public static string constants.

Parameters:
listener - listener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Fire the change of the given property.

Parameters:
propertyName - name of the fired property
oldValue - old value of the property
newValue - new value of the property.

focusGained

public void focusGained(FocusEvent e)
Specified by:
focusGained in interface FocusListener

focusLost

public void focusLost(FocusEvent e)
Specified by:
focusLost in interface FocusListener

org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.