Developing an Eclipse Plugin and adding a submenu item to navigator - eclipse

This is my first attempt at an Eclipse plugin- the plugin architecture is vast and a little overwhelming, but I've found a number of tutorials and how-to's online which is helping, but trying to do the following is driving me nuts:
I want to add a submenu item that is available in the navigator context menu when you right click on an Eclipse project.
I can get a submenu to appear on a project file or folder, but absolutely no idea how to have it appear on a project.
Would someone be so kind as to provide me with step by step instructions, starting with creating a new plugin-project? This is probably a lot to ask, but I can't seem to find an online guide that has just the right amount of detail. I specifically want to use the plugin-project wizard rather than hand code a plugin.xml file as I am not very familiar with the Eclipse plugin architecture.

Ok- I got it- it was simple, but I got lost in the noise of the API-
Create a new Plug-in Project using the Plugin-Project Wizard and when the wizard has launched...
1.
On the Plug-in Project page, use anything as the project name and 3.5 as target platform eclipse version
2.
On the Content page, skip ahead and just press next
3.
On the Templates page, select "plug-in with a popup menu" and press next
4.
On the Sample Popup Menu page, you will see that eclipse has prefilled the field
"Target Object's Class" with a value of "org.eclipse.core.resources.IFile".
This means that when your popup menu will only appear when you right-click on a file in
a project. As we want the menu to appear when we right click on a Project when
we are using the Navigator view, simply use "org.eclipse.core.resources.IProject" instead
5.
Finish
You can validate that your pop-up will appear as expected by right-clicking the MF file
and "Run-as" > Eclipse Application
Now to refactor the resulting code to use menuContributions and commands rather than objectContributions and actions :)

I think you have a similar question (menu in the package explorer) here:
Renaming packages in Eclipse (thanks to Rich Seller)
This could be a good start, and is a complete plugin project.

You should look into the Eclipse Common Navigator Framework there are a few tutorials on this side that tell you what to do in detail The Project Explorer is an implementation of the CNF. You should also consider using the Platform Commands to add your commands (and popup menu item) to the popup menu associated with the project explorer. It's somewhat easier to use commands than actions. You should be able to do it with by adding a Command in your plugin extensions. Unfortunately off the top of my head I don't know the right incantation to have the command appear in the project explorer. But you will be able to find it in these resources.

Related

How to make eclipse (neon 2) work better with goovy/grails?

Some time ago I edited a node project in grails. Now every project, even if it has nothing to do with node, shows 5 node files when I do "new" to create a new file. (type script, node project file etc).
I now only have a grails 3 projects in Eclipse, with the usual groovy eclipse plugins installed.
When I want to create a new groovy file (e.g. a domain object, controller etc), I go to file->new, and I only see the 5 node entries, plus a few generic ones.
Is there any way to make it show "groovy class" in the new list, and not show the node related ones?
I thought facets might be for this, but my project has no facets configured (and eclipse still thinks its node), and there are no grails/groovy type facets).
Any suggestions? Not a show stopper obviously.
E.g. can I create my own facet without coding, or can I influence which file types appear on create new by project?
I could open up a DOS command box and do the grails command to create the classes, but his is more work, especially as it creates broken tests which have to be manually deleted after (until such point as we need tests)
Intellij ultimate is unfeasibly expensive, so that is not an option.
You should be able to customize what appears in the New drop-down using Window > Perspective > Customize Perspective.... In the dialog that comes up, click the Shortcuts tab and you can check or uncheck items that will show in the New drop-down.
You can also edit what options will show for the Show View and Open Perspective sub-menus from here.

How to link Eclipse editor window to Eclipse project

I'm running into an issue in Eclipse where the editor pane is not linked to the project in the Package Explorer window. For instance, if I click on a project in the package explorer and then open a Problems window that is set to Configure Contents > uncheck Show all items > set Scope to On any element in same project, it will show any applicable errors or warnings, but as soon as I open one of the class files with an error/warning in it, in the editor pane, the problems list goes blank as the editor pane does not appear to link the active tab to the active project. Simply clicking the Package Explorer window will then repopulate the problems tab until focus goes back to the editor window/tab.
This used to work with older versions of Eclipse, but ever since I updated Eclipse, it no longer does this and I don't recall which version it was that I had been using. I've also downloaded a completely clean copy of Eclipse Luna (latest version) and simply imported the old projects and still the same issue.
Is there any way to change it so the active tab in the editor points to its associated project? It's quite frustrating having to click the Package Explorer window every time I want to look at a list of problems or tasks for a specific project.
Edit: I've narrowed the issue down to minimized windows only and provided an example of the issue below.
Both windows are restricted to "Show issue on project" rather than showing all issues. Notice how the "Tasks" window works as intended while the "Problems" window does not.
Found the issue... sort of. Apparently, if you minimize the problems tab, then try to access it via the minimized icon for the tab, it loses the correct focusing to tell you what the problems are. My previous version was setup in exactly the same way and had no issues, so they must have changed something that broke this. Going to look at submitting this to the Eclipse team, as a bug.

Google Plugin for Eclipse gone

This is the second time this has happened to me, and the first time I chalked it up to some "user error". It happened again so I will post in here for any ideas / thoughts.
Here is a picture of the installed software I have.
I have no option to create a web application project, I can't show the Development Mode View, doesn't recognize GAE or GWT library folders, JSNI methods don't have auto-complete, etc.
The only thing that appears to be working, is the "Google" properties inside the project, I can edit those.
Everything appears to be installed, is there something I am missing?, or any way that I can see why some stuff is missing?
I have found 2 good methods to handle Eclipse breaking.
Start from Scratch
a. Download or Locate an Eclipse Archive and place the contents in a new folder.
b. Launch the New install.
c. Perform Updates.
d. Re-install all necessary addons.
Rollback your install/updates to a working version.
a. Select the Help Menu
b. Select About Eclipse (Usually at the Bottom)
c. Click the "Installation Details" Button (Lower Left Hand Corner)
d. Select the 2nd Tab "Installation History"
e. Select one of the Available options
f. Follow the wizard instruction to "Revert"
Neither of these options have ever failed in getting me back to work. They are not the most expedient, but they work every time.

How to debug Eclipse source code

I am having tough time to figure out debugging UI parts of Eclipse. I couldn't find any information on google (or) Eclipse web site.
All I wanted to do is to find out the code that gets executed when we double-click a file in project explorer to open the file in Editor.
I tried to bring up Eclipse source code from Plug-ins view -> right click on the plugins -> import as Source Project. But, I am unsure what are all the components that constitutes to the UI part. I get some weird errors when I try to import everything that's found in plug-ins view.
Where can I find the information related to debugging Eclipse source code?
Instead of using Plug-ins->Import as Source Project, I would recommend opening the Plug-ins view, selecting all plug-ins, right click, and Add to Java Search.
Then you can use Open Type Ctrl-Shift-t to search for class names and the source will be attached so you can read it, set breakpoints, and debug.
In your case, I think you want to investigate IWorkbench, IWorkbenchWindow, and IWorkbenchPage. The openEditor(*) methods on IWorkbenchPage will be of particular interest.
You may also want to take a look at the org.eclipse.ui.editors and org.eclipse.core.contenttype.contentTypes extension points.

Slim down Eclipse context menus

I have several plugins (Apatana, SVN, Pydev, Zend Debugger, PHP) installed in my Eclipse 3.5.2 (Ubuntu 10.10) installation. The one problem that keeps bugging me since I first used Eclipse years ago is, that each plugin puts new entries into the context menus.
Unfortunately, it seems that the various perspectives are not able to determine, what menu entries are useless. So while programming PHP the menus are full of java and pydev stuff, I really have no use for!
The more plugins are installed the messier the menus get. It seems a bit odd, that such a rich IDE doesn't have support for context sensitive "context" menus ... :-(
My hope is, that somewhere out there on the internet, someone knows how to remove unused menu entries, or even has created a small plugin for that??
Any ideas?
Screenshot: http://i.stack.imgur.com/D9HjN.png
Eclipse provides "capabilities" as a functionality for the plugin developpers to provide a way to the users to disable the features and UI contributions of their plugins. I don't really know if that feature will help in your case (that is : if the plugins contributing the menu entries that bother you have defined the necessary capability to disable them).
If you go to Window > Preferences, then General > Capabilities, you can see a number of "capabilities" categories to enable or disable. I don't recommend disabling the categories themselves (for example "development") as you would disable all of Ant, Java, Python... menus and extension at once. Rather, use the "Advanced..." menu at the bottom of this page to see not only the categories, but also what they contain. There, under "Development", you should be able to disable "java development" (JDT) extensions and menus, "Ant Development" (remember that "Run Ant Tool" button that is visible on all perspectives beside the "Run" button? That would remove it)... You should be able to disable most of the clutter with this.
Note that if the provided capabilities are not sufficient, you can create your own very easily, allowing you to disable even the contributions from other plugins. For this the steps are simple :
Use the File > New > Other... menu item
Select Plug-in Project and name the new project as you desire, click Finish
In the editor that has opened, select the "Extensions" tab
Click Add, untick "Show only extensions points from the required plug-ins"
search for the extension point org.eclipse.ui.activities, select it, and hit Finish
Right click the item org.eclipse.ui.activities on the left and select New > Activity
enter the id of your new activity on the right of the page, for example my.disable.activity.id. Enter a human-readable name below it; for example "disable JDT".
Right click the item org.eclipse.ui.activities on the left and select New > activityPatternBinding.
re-enter your activity Id (my.disable.activity.id) in the "activityId" field, then enter the "pattern" of the contributions you wish to disable. This is a regex. In order to disable all "JDT" (java development) contributions, enter org\.eclipse\.jdt\..*
Right click the item org.eclipse.ui.activities on the left and select New > categoryActivityBinding
re-enter your activity Id (my.disable.activity.id) in the "activityId" field once again; then click Browse... at the right of the "categoryId" field. Double click the org.eclipse.categories.developmentCategory so that it appears in the preference menu for capability enablement.
Now, if you export this plugin (I won't detail the update site creation here, you should be able to adapt the explanation from Stephane Begaudeau's blog), all menus from the JDT will be disabled (I tested this, so I know it at least disables those I checked (the "source" and "refactor" menus from a right-click on a Java file). As you specified a category, you can re-enable these menu items from the capabilities preference page I hinted at in the beginning of this answer.
Not really a solution for your problem, but worth mentioning anyway: Eclipse does support the context sensitive menus, but in a way where the plug-in developer defines the contexts where the menu entries should be displayed.
Unfortunately many developers don't care and say "Make it visible everywhere". The solution then is to complain loudly to them.
Not a complete solution, but more of a workaround. You can install clearlooks compact theme for Ubuntu. It considerably reduces the size of components, even in Eclipse.