Create jdt look like custom tool tip for GEF canvas objects - eclipse

I have a graphical representation for my model, and I want to implement a tooltip that look like jdt tooltip in the following :
- the tooltip shows up when hover over the object in the canvas
- being able to click on the tooltip window to focus, and scroll bar is there if needed.
- Ability to resize the tooltip window after the user change focus to it
- being able to assign command with F2 keybind to pop up the tooltip window (I know how to create command, and how to associate keybind with it)
- Ability to have hyperlinks in the tooltip text ( optional )
I do not know from where to start.
Which eclipse interfaces/classes to implement, extensions to add, adaptors to support.
I tried to find a work through tutorial but I could not.
Thanks in advance

A lot of what you describe is specific to the Eclipse Text editor and JDT code so won't be available in a Canvas so you would have to write your own code.
You can create a tooltip based on org.eclipse.jface.window.ToolTip. If the tooltip contains StyledText you can create hyperlinks.
There is an example of a fairly elaborate custom tooltip Here
What Eclipse does when the tooltip is clicked is open a new normal window of exactly the same size and contents over the tooltip and close the tooltip.

Related

Is there a shortcut for color chooser in NetBeans?

Is there a shortcut for color chooser in NetBeans?
I found this same query on NetBeans website, it was said that this was possible but I can't find an actual answer how to do it.
I mean this: when I am in a CSS file and I am editing a property that involves a color, the color chooser pops up automatically. I would like to have the color chooser pop up on demand when I am editing any file (e.g. a PHP file). It would be very helpful.
I already looked in Options -> Keymap and there seems to be no shortcut containing the word "color".
Thanks.
In the editor, click the text representing the color (you don't even have to highlight the whole thing), then hit Ctrl+Spacebar.
While it's not ideal in Netbeans 8.0.2 you can do the following:
open any CSS file that contains a rule with a property that takes colour as value and place the cursor inside the declaration block of that rule,
in the top menu click on Window -> Web -> CSS Styles,
click on the dropdown with colour values and scroll right to the top,
click on Choose Color and a colour chooser will appear.
You can now close the CSS file (if you like) and open any type of file - the CSS Styles window will stay and you can repeat the above procedure starting from step 3.
P.S. Netbeans has a bug tracker that is not just for reporting bugs:
Issues = Bugs, Feature Requests, and Enhancements

How to add text hovers for generic eclipse editor- generic text hover for all text editors

I want to display a text hover functionality in Eclipse editors without contributing a new editor. That means my hover functionality shall work on CDT editor ,JDT editor (java editor) and all other text editors.Is their any generic extension point is present for this purpose ? I know, for java editor org.eclipse.jdt.ui.javaEdit or TextHovers is there and for CDT editor org.eclipse.cdt.ui.textHovers is there. But I want the hover shall work in all type of editors. is there any extension point present for this?
Thank you in advance.
I think what you are looking for is the org.eclipse.jface.text.ITextHover extension point and then write a class that implements ITextHover which allows you to specify an IRegion for areas where the hover should be displaye dand then another method for displaying hover text based in cursor position.

Flash Builder - Disable highlighting of all instances of a word in code editor?

In Flash Builder, for objects, properties, variables and such where your cursor is on it, the editor highlights all instances of that name in the code with a grey box. This can be very distracting and I was wondering if there was a way to turn it off or if there is a hot key to disable it.
Another things that is very distracting are the mouse hover popups, although apparently there's no way to disable those :
Flash Builder + Eclipse: disable mouse hover popup?
I have been annoyed by this as well, and finally found something that helps. You need to turn off "Mark Occurrences" by clicking the button in the IDE that looks like a highlighter.
Here is a link to where I found that answer:
http://jwopitz.wordpress.com/2008/02/22/flex-builder-3-annoyance-code-highlighting-how-do-you-turn-this-thing-off/

How to Display Current Function in Eclipse

I miss a certain functionality in Eclipse. I would like to know the name of the current function the cursor is currently inside. This is useful when browsing unknown code using the search function, for example.
Any idea how to show it? Maybe a plugin?
I'm using the "Toggle Breadcrumb" option from toolbar:
It shows a nice breadcrumb, ending with current function name.
It's quite handy for me, as Outline becomes cumbersome to use if you have zilions of functions.
It produces the following structure above your Java Editor (truncated at the picture below):
The "Outline" view shows the current function.
It may be necessary to enable the 'Link to Editor' option in the Outline View dropdown menu. This might be off by default for CDT.
I was looking for something similar (Xcode-like bar at the top showing the current function, where you can also go to another function by clicking on it to open a popup list of functions). Here is what I settled on with Eclipse 3.5.1 CDT:
I moved the Outline view to the top, resized it to make it a 1-line horizontal strip (don't make it too narrow), and selected "Link With Editor" in its menu, so that it always shows the current function. However, this doesn't open a popup list like Xcode. For that functionality, I assigned a shortcut to the "Show Outline" command which does open a popup list of all functions.
The Eclipse function 'show outline' will pop up a list of outline objects, and it will highlight the object your cursor is inside in grey. It's typically bound to 'ctrl-o' (the letter 'o', not zero), but you can re-bind it as you see fit. I'm running Eclipse with the CDT plugin and it works pretty well for me.
To enable the breadcrumb invoke Toggle Java Editor Breadcrumb in the toolbar or press Alt+Shift+B in the Java editor.
You can also display the Quick Outline (ctrl+o). This way you see the context quickly without having to have a permanent Outline Window linked to the Editor.
Use the "Link With Editor" option on the outline menu
Press Ctrl+o (cursor is currently inside a function at a particular line).
It highlights the current method, or name of the class if the cursor is outside the method body.
You can click on highlighted method.
It has got inline search feature ...start typing name of the method to navigate to the specified method or method with matching search pattern.
If you press again Ctrl+o to shows the inherited members/methods.
Using outline with "link with editor" option worked also for me, thanks!
Just an addition, you can move outline pane in to the same window group as search, progress etc. saves the space in your perspective instead of keeping it at another group.

JFace: Resizable tooltip with ColumnViewerToolTipSupport

Can anyone show me how to use org.eclipse.jface.viewers.ColumnViewerToolTipSupport to create a tooltip similar to the one shown in Eclipse IDE when you hover your mouse to any Java element? That is, I want the tooltip to be resizable, I also want to hook an F2 key to show the tooltip on demand in addition to mouse hover.
I have managed to add my own custom control to the tooltip (a TableViewer), but I can't see any methods/ways to set the tooltip to be resizable and only dissappear when user clicks on a key (e.g. esc key). Is this even possible with ColumnViewerToolTipSupport?
I have used as my reference an example at http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet037FancyCustomTooltips.java?view=markup
Thanks.
The window appearing in Eclipse when you hover mouse pointer over a Java element is not a tooltip, but InformationControl. See org.eclipse.jface.text.AbstractInformationControlManager.install(Control) for more information.
I don't think it will work right away with table cells, so you probably will have to combine some ColumnViewerToolTipSupport techniques with it.
Cheers,
Max