Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » add a tooltips for treeViewer
add a tooltips for treeViewer [message #523955] Tue, 30 March 2010 01:16 Go to next message
yizhang  is currently offline yizhang Friend
Messages: 2
Registered: March 2010
Junior Member
I need to add tooltips into each item of the treeViewer:

First I create myLabelProvider extends ColumnLabelProvider
public class MyLabelProvider extends ColumnLabelProvider  {

    @Override
  public Image getImage(Object element) {
      retrun null;
  }

  @Override
  public String getText(Object element) {
     return "some text";
  }
  
 

  /* (non-Javadoc)
   * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
   */
  @Override
  public void update(ViewerCell cell) {
    // TODO Auto-generated method stub
    cell.setText(cell.getElement().toString());
  }
  
  @Override
  public String getToolTipText(Object element) {
    return "Tooltip (" + "test "+ ")";
  }

  @Override
  public Point getToolTipShift(Object object) {
    return new Point(5, 5);
  }

  @Override
  public int getToolTipDisplayDelayTime(Object object) {
    return 0;
  }

  @Override
  public int getToolTipTimeDisplayed(Object object) {
    return 5000;
  }



}





And then :

in the Treeview,
TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

viewer.setContentProvider(new TreeNodeContentProvider());
ColumnViewerToolTipSupport.enableFor(viewer,ToolTip.NO_RECREATE);

viewer.setLabelProvider(new MyLabelProvider ());

viewer.setInput(someInput());



The tooltips cannot show when I put mouse over the treeNode.
Can any one help me? What wrong ? or give some tips how to put tooltips into treeview
Re: add a tooltips for treeViewer [message #524278 is a reply to message #523955] Wed, 31 March 2010 07:02 Go to previous message
Ralf Ebert is currently offline Ralf EbertFriend
Messages: 168
Registered: July 2009
Senior Member
Hi yizhang,

> The tooltips cannot show when I put mouse over the treeNode.
> Can any one help me? What wrong ? or give some tips how to put tooltips
> into treeview

have a look at:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet015CustomTooltipsForTree.java?view=markup

Greetings,

Ralf


--
http://www.ralfebert.de/blog/
http://twitter.com/ralfebert/
Previous Topic:Using Viewers with Hibernate
Next Topic:Treeviewer Scrollbar vanishing act
Goto Forum:
  


Current Time: Fri Nov 28 03:17:10 GMT 2014

Powered by FUDForum. Page generated in 0.05285 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software