How to control a View on selecting particular File Type in Eclipse Editor - eclipse

I want to control a view , like if I select a .js type of file , a particular view should be visible else for all other type it shouldn't.
I dont want to use perspective as for just a single selection, it will be an overhead.
Please suggest me any way to achieve the same through Eclipse plug-in Development.

When you contribute the view, you either don't mention a perspective (in which case when the view is shown it defaults to the bottom right) or you use the org.eclipse.ui.perspectiveExtensions extension point to contribute it to a specific location. You can make it visible or invisible by default.
You make the view visible/invisible at runtime using the org.eclipse.ui.IWorkbenchCommandConstants.VIEWS_SHOW_VIEW command and the view ID parameter, or by using the showView()/hideView() API in org.eclipse.ui.IWorkbenchPage
See Plugging into the Workbench for more information.

Related

Build a Perspective from Fragment with Eclipse e4

Is it possible to define a perspective stack and perspective in the fragment.e4xmi?
The Eclipse 4 model editor doesn't seem to allow it. Why?
I add a new Model Fragment and for Feature Name I click Find ....
When I want to add a Perspective or a Perspective Stack, the dialog greys out the OK-Button.
Also, I have a lack of understanding what this Dialog is showing in general. It lists certain UI Elements and a lot of items below them, like
children
handlers
menus
and so on.
But those are listed multiple times. For example children is listed under CompositePart and under Dialog. But it doesn't make any difference which one I chose.
I know I can define the Perspective in the plugin.xml using the extension point and implementing IPerspectiveFactory. Is there no way to do it with the fragment.e4xmi?
Not sure about that dialog as I don't usually use it.
What you want to add is a Model Fragment with the 'Extended Element-ID' set to the id of the TrimmedWindow you want to put the perspective in. The 'Feature Name' would be children.
The model editor should then let you add a "Perspective Stack" as a child.
You can add the Perspective to the stack.
Note: Using the plugin.xml and IPerspectiveFactory is for Eclipse 3.x compatability mode, not pure e4. If you are using compatability mode I'm not sure how defining a perspective in the model editor fits.

Associate newWizard with nature of selected project

I am trying to add a contribution to the org.eclipse.ui.newWizards extension point so that the entry in the new-menu is only shown, when the selected project has a certain nature.
Is this possible only by declarative use of this extension point?
I already look for an attribute like <enabledwhen>of a menu's action but the wizard's extension point does not seem to offer this possibility.
Any ideas to achieve the said behaviour is welcome.
This is not supported. New wizards always appear everywhere.
The only thing that can be controlled is the 'shortcuts' which appear in the top level of the New menu which can be configured according to the perspective using the org.eclipse.ui.perspectiveExtensions extension point.

Eclipse add type hierarchy to under opened files

I have two laptops and on one of them in Eclipse I was able to add a type hierarchy that shows class members, etc. directly under the opened files (or whatever you call the tabs that are right about the red box in my image). I have no idea how to do this though, anyone have any suggestions?
Also, on a related note, when I do just open the type hierarchy it always requires that I open it given the context of the current opened .java file. On my other laptop it's sort of dynamic and allows me to explore the type hierarchy of whatever file I'm viewing. I want it all to work like how it is in Microsoft Visual Studio.
I think you mean the breadcrumb - Navigate > Show in Breadcrumb

Showing markers in the Eclipse "file compare" view

I've added some functionality to the standard Eclipse "compare view" via a handler which is activated on the Compare view's popup (context) menu. One of the things that this handler does is add a marker at the selection location. However, markers are not shown in the compare view. How can I enhance the compare view to show markers? Do I have to build my own view?
The compare editor is really different from the standard editors, every functionality has to be reimplemented for it. You have to code it yourself (as far as I know), but you can look at the implementation of the original editor for hints.
In case of Eclipse, AbstractDecoratedTextEditor implements the marker display functionality (that is a descendant of the TextEditor class). What makes this functionality hard to implement in case of Compare editors is the fact, that the compare editor opens two resources at once, so it is harder to put every marker into its correct place (I think that's why it is not implemented generically).

eclipse: Do not show references from binary types in call hierarchy

Is there any way to remove binary references from "call hierarchy" (Ctrl-Alt-H) ?
Our project setup is such that for many members we have duplicated references (one reference from source file and one from the jar file with class compiled from that source file). The navigation is inconvenient and I wondering if any ways to fix that is available.
Call hierarchy can be limited in scope to a working set. You just need to set one up to exclude all your libraries.
If you click on the white down arrow in the top right of the Call Hierarchy window a popup menu will appear. Choose Search Scope/Working set and then select or set up the working set you want. A working set can include a source folder or a jar. Once set up your working sets will appear at the bottom of the Search Scope menu so you can access them quickly in future.
I've discovered another way to accomplish this, and since this question is one of the top results in google, I thought it would be good to add it as an answer.
In the Call Hierarchy view, one can click the 'View Menu' (the downward facing arrow) and select "Search In...". In the window that pops up, the user can un-check the options they want to exclude. For example, I only have 'Sources' and 'Required projects' checked.