Creating an Eclipse plug-in to display content assist regardless of cursor location - eclipse

I'm working on some reflection stuff using Java across XML files. The process would be made much faster and less prone to error if I could get content assist to behave like a tree in a small window off to the side, but more than by my current cursor location.
My question is can this really be done without reinventing the wheel too much? Essentially I want to display a list of classes, choose a class, then drill down a TreeView similar to the outline view Eclipse has for a current open file and at some point I click a button below and it generates the desired XML formatted text I would have typed manually, this is generated based on whatever in the tree I have highlighted.
I've designed and begun work on the front and back end, but the piece that keeps eluding me is harnessing Eclipse's content assist to gather a list of practically anything I could possibly call in a given project.
Can this be done? I've been combing Eclipse's documentation for a few days and fighting with the source download dying halfway repeatedly.

I am not 100% if that's it but I had an eclipse plugin with spider in it's name in mind, which does what you described.
Maybe it is this one: http://eclipse-plugins.2y.net/eclipse/plugin_details.jsp?id=202
Furthermore when writing Eclipse plugins, it is useful to press ctrl+shift+f1 (eclipse plugin spy) once having worked in the pde this should be possible.
It shows you info about all possible extensionpoints refering to your current view.

Related

how to remove google sign in button in eclipse

I'm facing a wierd problem. My eclipse, has a google signin button which is occupying some of the space which I do not want to happen. Initially it had "Sign-in to Google" text along with it. I've followed some blog post and set accordingly to show just the icon (I don't remember that blog post link).
But now, the icon is getting replicating .. it is being shown 12 times. It is actually creating childs :P
I've gone through all the options present in Customize Perspective menu, none of them had this button listed. Can someone help me in removing that google sign button from my perspective? One possible suspect is- my eclipse crashes when I suspend and wakeup my machine.
You can use the Window > Reset Perspective... menu command to reset the perspective to its default state, which might eliminate that toolbar and buttons. If that fails, I would create a new workspace and import the projects into it using File > Import > Existing Projects into Workspace.
If you want to try to salvage your existing workspace, it's possible to do so my manually editing Eclipse's internal file that stores your Workbench layout, but it's a bit tricky. Here are the steps I've followed to eliminate a similar repeated toolbar item:
Exit Eclipse.
Find the Workbench layout file, it's path is <workbench>\.metadata\.plugins\org.eclipse.e4.workbench\workbench.xmi. Make a backup of this file before you touch it - this is essential because it's easy to corrupt the file if you change the wrong things.
Open the file in your favorite XML-aware editor - most packages of Eclipse include the XML editor that works just fine1, but be aware that if you use Eclipse to edit the file you can't have Eclipse open on the workspace that contains the workbench.xmi you want to edit.
Find the section of <trimBars> nodes in the XML; from there you have to determine which <trimBars> node you need to edit. In your case it looks like a vertical one, probably with a side="Right" attribute.
Under the correct <trimBars> node you'll find multiple <chlidren> nodes, each with an elementId attribute that should help you identify it; you're looking for <children> nodes that are identified as something related to the Google plugin.
Delete the <children> nodes that seem related to the unwanted toolbar buttons. In your case, it appears that there is an entire toolbar that you might want to eliminate, so you might want to delete the entire containing <trimBars> node.
Save the file and start Eclipse on that workspace.
1Some packages of Eclipse include EMF tools that will open it in a special XMI editor that does not provide a view of the source, only a structural tree view. Depending on how you like to work with XML, this might be easier than editing raw XML.
This is not a perspective but a view. You can hover over that bar with the buttons and click Alt+Shift+F1 to check where this View comes from. Then you can either disable/uninstall the contributing feature (Help -> Installation Details) or check where the feature came from.
If it comes from the IDE, you can open a bug for it. If it is contributed from a third party plugin, contact the developers of that plugin.
There is an eclipse bug concerning duplicate view toolbar buttons in Luna that has recently closed as well. Maybe this solves your problem as well.
Edit: Taken from this bug:
root cause is that in Luna 4.4M5 WorkbenchWindowControlContribution.createControl is called twice, the
first time with a null value for
WorkbenchWindowControlContribution.getWorkbenchWindow() while it is
still being created. This is related to what has been reported here
https://bugs.eclipse.org/bugs/show_bug.cgi?id=427452
second cause is that my createControl(Composite parent) method was calling PlatformUI.getWorkbench().getActiveWorkbenchWindow() instead
of WorkbenchWindowControlContribution.getWorkbenchWindow(). This
resulted in an attempt to create a new Workbench Window, which
recursively calls createControl() again. This has already been
reported here https://bugs.eclipse.org/bugs/show_bug.cgi?id=366708

Eclipse IDE lost popup menu suggestions

I've seem to have lost the ability in my Eclipse to auto-correct errors in my source code lines.
For example, a line like this:
Date date = new Date();
has red jagged lines beneath the Date() part. Previously I could mouse hover over it see a popup menu of options to fix it. Now I all I ever get is a popup with the text "Cannot resolve to a type".
The only change I can think of that I've made and I don't know if it has anything to do with this problem, is that I started editing my .java files with an outside editor. Then focusing back into Eclipse I get a popup saying the source has changed and do I want to update so I say OK.
Sometimes I will edit inside Eclipse and sometimes i will edit the source outside of Eclipse. I'm not sure if this is a bad practice or not?
Its your wish to edit Java files outside or inside eclipse. But Java editor has many features which are very helpful to developers. I suggest to edit Java files inside eclipse only.If you find other editors are good or you used to it then no problem you can edit Java files out side eclipse also. The problem you mentioned in not related to it. But make sure that changes are applied before building project in eclipse.
Solution
This occurs whenever there are multiple classes are available with the same name in you build path then eclipse don't know which one to import by default. So keep the caret on the error line and press Ctrl+1. Then a eclipse gives options to user to import one among these. See the picture below. Choose the right one then error will disappear.

Smalltalk-style method browsing for eclipse Java?

I am using Eclipse (Indigo) for Java development. My personal, idiosyncratic style prefers to see Java methods one-at-a-time, instead and not as a region of a longer .java file.
I am looking for a preference, view, or plug-in that shows me a java method, and only that method, when I select the method name from a explorer or browser. For reference, here is a screen-shot of a typical Smalltalk browser (Cincom's VisualWorks). The "Method Code Area" shows on only one methods as opposed scrolling through all methods in the class.
The Java Browsing Perspective comes close to a Smalltalk browser. I customized it a little bit and found it very useful.
Enable 'Show Source of Selected Element Only' and you will see only the selected method.
On today's widescreens, you won't need the whole width for the method source, and projects and methods take some vertical space. So I decided to vary the original Smalltalk layout.
Make sure that Eclipse closes open files automatically, as you want to browse, not to open and close files.
One thing that is missing is the 'Protocol' view. Maybe the developers had something like that in mind while introducing the #category Javadoc tag, but the only thing you can do is to filter by category. I hope that some lucky day someone will develop a protocol view.

Eclipse (ctrl+space) content assist hook

I wrote a plugin that gets user input from Java editor, makes some computation, and writes the results to my view. The way I start the process of aforementioned computation is via context menu and I hate it. I would like it to start on ctrl+space, i.e. content assist. It is faster, more intuitive w.r.t. what the plugin does. Is there a way to do so?
Update:
For example, what should I do to get the current cursor position when user presses ctrl+space? I would use that position info and print it to my view. This is the most simplistic plugin that I basically need.
You could take part in the content assistent calculation of Ctrl-Space by extending javaCompletionProposalComputer. However, if you want to trigger some arbitrary modification operation on the Java file, you are better suited by providing a quick assist instead.
If you are confused by the terms: An example for quick assist is the suggestion "Invert if statement", which you can see when pressing Ctrl-1 with the cursor placed on an "if".

How to add views to Show In menu for particular file types

I use an older plugin called Veloeclipse for editing Velocity templates in Eclipse. There's been no development on this since 2009, which isn't a problem because it's mainly just for syntax highlighting and format validation. The really annoying thing about it, however, is that when I try to do Show In to view the current Velocity template within my Package Explorer or Project Explorer, the only available option is Properties. That's not really useful. I really need to be able to get to the file in one of the regular explorer views.
So I have sort of two questions:
Is there a way to configure this without having to monkey with any code? A configuration file or something? I've grepped through my Eclipse installation and haven't seen anything, but I'm hoping that there's something I'm missing.
So assuming that the answer to my first question is no, how do I go about modifying the plugin code so that it will show more than the Properties view in the Show In menu? Most of what I found on the plugin development wiki comes from the other direction: how to make your view or perspective appear in the Show In menu.
Any help with this would be hugely appreciated!
Try to check the plugin source code. it might do something different than other editors. What I mean is that the show in menu item that you have there is not the usual extension point but a hard coded context menu option.