how to format code in eclipse "git repository browsing prespective"? - eclipse

How to format code to specific coding style in Git Repository perspective in Eclipse ? like Ctrl+shift+f works in Java perspective. Can anybody help me to solve this ?
Here My problem is to format a android repo.

The "format" actions are tied to specific editors. Use ctrl+shift+L twice in a row to open the list of all available hotkeys. Filter that list on "format" and you should see a number of potential candidates... and their context. The Java ctrl+shift+F (Format) action is available in any Java editor ... even when in the Git perspective (at least, that's true with Eclipse 4.2 as I just tried it). That is, as long as you have a Java editor open and it has focus. The Ant "format" action should work the same way : as long as you have an "ant build file" editor opened and focused.
Whether the "ctrl+shift+F" you want is active or not depends on which action exactly you are trying to trigger : java format, ant format, xtext format... and how that specific action is contributed (and bound) by its contributing plugin. To check that, you can open an editor where you know the action is active, hit alt+shift+F2 then right-click your editor and locate the "format" action. When you click that action just after alt+shift+F2 has been pressed, it will not be triggered : rather, a dialog will pop-up to tell you which action that is, who contributes it, through which plugin.xml...

I found the answer, it was very easy,
Right Click on project in Git perspective -> import project -> check import as a general project ->select the working directory which you want to import -> finish
Now go to the java perspective and find the project :) thats all

Related

Eclipse : Run an external software in editor view

I am using Eclipse to edit almost any file that I code. But for some, I prefer to use gEdit (for instance CoffeeScript files).
I wondered if there was a way to somehow embed the UI of gEdit (or any other software) in the Editor view of Eclipse. I could use my favorite editor in an unified environment and this could also bring the richness of the Eclipse environment to those files (even if I'm well aware that most of it won't work).
But is it ever possible ? Better, is there already a plugin for that ?
Thanks for your help !
I wondered if there was a way to somehow embed the UI of gEdit (or any other software) in the Editor view of Eclipse.
No, there isn't.
However, you can execute an external editor from Eclipse.
From the main Eclipse menu, left click on Window -> Preferences.
On the Preferences dialog, left click General -> Editors -> File Associations.
For any file type, you can associate one or more editors. These editors can be external to Eclipse.
Once you've done this, you can bring up your external editor by double clicking on the module name in the Package Explorer.
After you're finished editing with an external editor, refresh the module so Eclipse knows you've made changes.
SWT allows to integrate apps using OLE. Unluckily this is obviously available only when running on Windows.
For more info, see this article by Lars Vogel.

How can do code alignment in Eclipse base Force.com IDE

How can do code alignment with Eclipse base Force.com IDE.
Alignment shortcut key 'CTRL+SHIFT+F' is not working for Apex code.
None of the suggestions so far work for me. Note that the Force IDE opens the Apex class in an Apex Editor. This editor does not appear in the list of contexts that you can associate with a key event. For example, this list contains such contexts as "editing in structured text", "editing in Java Source", etc.
The Apex Editor does not contribute a "Source" menu option to the right click menu. So there is no way to get to the formatting features.
I tried to open the apex class in the Java. Now the "Source" menu option appears the format option doesn't do anything. (Hence no key event will be able to do anything.)
The only thing I can get to work is this ...
Select file.... Open With... Other ... locate Java Editor.
Once file is open ... select all text .. right click and select Source ... Correct Indentation .
This does not reformat but it does fix the indentation problem.
Someday I hope SFDC will make the code for the Force IDE open source. Then we, as a community, could build more developer-friendly tools.
Apex classes and triggers use a different editor than Java. The auto formatter (or code alignment) does not work with Apex Code (or the Apex Code Editor). I couldn't get CTRL-SHIFT+F to work in the most recent version of Eclipse with the Force.com IDE, either. I believe this is because the auto formatter is designed to work with Java only.
However, if you switch to the Java perspective and open your Apex class with the Java Editor, CTRL+I does correct indentation properly.
Go to Preferences -> General -> Keys and type "format" into the search box, you will see what keys (if any) are bound to the format commands. Then you can bind what you like or use what's available.

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.

Developing an Eclipse Plugin and adding a submenu item to navigator

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.

How to activate revision info in line number view

I know of an Eclipse feature to show revision information (gradual coloring, more info like revisionnumber, date and author on mouseover) for the last changes in a line in the linenumbers-view.
Does anyone know how to activate this feature for a file, or even better, by default? I accidently hit some shortcut lately which made it show in one file, it does not show up in the others, though.
This is called "Show Annotation" and you can find it in the "Team" menu. Since this is a pretty expensive operation, you can't make it the default.
Regarding the shortcut: You have to enable the command group SVN.
Window -> Customize Perspective... -> Command Groups Availability -> check "SVN".
If you do this, some SVN actions show up in the toolbar which you can remove again (if you want) using the same Customize Perspective dialog (tab Tool Bar Visibility).
Remapping the shortcut did not work for me but enabling the command group did (with the default key mapping Ctrl+Alt+A).
(did not find a way to reply to Aaron's answer so I had to create a new one)
I found my way here while trying to find a way to get the option to show up with code from my git repository.
A lot of the logic in the other answers applies to git too, and I followed the equivalent steps for git but it didn't help me.
It turned out that my projects, although imported from a git repository, hadn't been connected to (or had become disconnected from) the eclipse git integration. I think this happened because I imported the projects before I installed the elcipse git plugin.
I needed to connect them thus:
Right-click your project (or multiple selected projects) in the Project Explorer
Select 'Team' > 'Share Project...'
The default settings were fine for me, but change them if needed
Click 'Finish'
I found this solution here.