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

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.

Related

Is there a way to programmatically change the color of an editor tab in my Eclipse Plugin?

I have a SharedHeaderFormEditor in my Eclipse RCP plugin.
One of my requirements is to draw attention to the editor's tab when something happens outside of the editor and it needs a refresh.
Some of the ideas discussed included
changing the color of the tab
adding an icon to the editor's text (instead of the standard * for a dirty editor)
Are either of those possible? I've been looking around and have not found anything that could address this issue.
Thanks!
ViewPart and EditorPart both allow changing the title label and icon (setPartName(…) and setTitleImage(…) respectively). The Eclipse Workbench also offers an IWorkbenchPartProgressService to each part, which allows a part to indicate that it's busy (via incrementBusy()/decrementBusy()) and that its content has changed (via warnOfContentChange()). You can see this used in the Search and Console views (org.eclipse.search2.internal.ui.SearchView and org.eclipse.ui.internal.console.ConsoleView).

How can I customize the "jumping" from the Eclipse problems view?

I am trying to customize the way double clicking works in the ProblemsView for my RCP application. Right now, the resource is set to a file and the location is set to a line number. That works great for a text-based editor, but I am creating a multipage form based editor.
How can I change the behavior of the ProblemsView so that I can get in the middle of the double clicking and the jumping and interpret the location (or some other marker attribute) so that my form editor will respond in the right way?
Implement an IGotoMarker adapter for your editor, and then handle it how you will.
http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/ide/IGotoMarker.html

How to easily see the name of the current method

When I used Visual Studio with C++ there was a nice combo box where you could always easily see the name of the method in which the cursor was. Is there something similar in eclipse for Java (except of Outline, of course)?
You can switch on a breadcrumb like bar in the top of Java editors. Right-click a Java editor an select Show in breadcrumb or ShiftAltB.
You can also select elements of every level, the dropdowns also allow to expand into deeper levels.
if you hover your cursor over the closing bracket of a method or class then it will show you the name of the method/class that the bracket belongs too

Create jdt look like custom tool tip for GEF canvas objects

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.

Eclipse GEF graphical editor without header

I am developing RCP plug-in with GEF framework.
I've created basic graphical editor (GraphicalEditor and IEditorInput)
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.openEditor(new TEditorInput("T"), TGraphicalEditor.ID,false);
When I run the application I get editor with a header that contains the tab with the name of the editor and control buttons to maximize and minimize the editor.
What I need is to display just the editor, without the header.
Can it be done?
To my knowledge, it is not possible to just hide an editor's tab.
However, you can try two workarounds:
Have your GEF editor be displayed in an Eclipse view instead of an editor and open such a view as a standalone view. An example of how to open a GEF diagram in a view can be found in GEF's Directed Graph Example. An example of how to open a view as standalone can be found in one the Eclipse RCP official tutorials.
Extend the presentation factories extension point to control how workbench parts are displayed (which includes control over the part stack tab).
I suggest you try the first approach, as to me it seems easier to implement.
The idea with editors is that you can instantiate them multiply for different editor inputs. I am not aware of any way to restrict the number of open editors to just one (well, it appears you can in Eclipse 4.2 if that helps you)
For views, what you want can be done by setting the perspective to fixed and set showTitle of the org.eclipse.ui.perspectiveExtensions extension to false on the view. Maybe you can use a view instead of an editor and control the editor input yourself?
(For example, using an editor, the default Open action would instantiate a new editor, while you probably want to replace the contents in your only editor, right?)