How to automatically expand empty packages in Eclipse with hierarchical presentation? - eclipse

I have been often working on projects with huge namespaces on Eclipse.
Since I think that hierarchical package presention seems more visually helpful, I have the issue of selecting every package until the core classes, for example:
-br
-br.com
-br.com.company
-br.com.company.server.core
-br.com.company.server.core.web.common
-br.com.company.server.core.web.common.Utils.java (yay!)
Is there a way to automatically and recursivelly expand empty packages when using hierarchical package presentation?
So, when I click
+br
It would expand to:
-br
-com
-company
-server
-core
-web
-common
+Utils.java

Use the "Project explorer" view and change the "Package Presentation" from "Flat" to "Hierarchical". You find this setting in the view's menu.

For me, the hierarchical representation flattens multiple empty directories (e.g.: com.company.project) into one expandable and collapsible entry. The one trick I found that causes this to NOT be true (on OSX anyway) is that .DS_Store files will cause Eclipse to see the directory as "not empty". It then won't compress them into one entry. Removing these files (and any other hidden but present files in the directory) resolves this issue.
I can thus have com.company.project expandable with one click and all the packages appear hierarchically under it. It's a nice combination of the two views!

Related

Remove properties from files in powershell

I need to remove all properties (title, author, camera,...) from files in one folder with PowerShell (in Windows 10). Is that even possible or any simple command to do that or would I need to remove each property one by one?
If you need a simple one-off solution or occasional solution Windows explorer has this function built-in.
Select all your files in the folder.
Right click one and select Properties then Details tab.
Bottom of Properties has "Remove Properties and Personal Information"
--Has options to create copies of files with properties removed
or remove from active files. Select properties individually or Select All.

How to avoid repeated matching items in Eclipse 'Open Resource'?

The project I'm working in uses Maven and its typical standar directory layout.
When I look for a resource with Eclipse 'Open Resource' I get these matches:
Where I get repeated matches.
There are only 2 XML files in filesystem.
The one under src/ and the one under target/.
For example, the path to the src/ file is:
maindev/common/utils/persistence/src/main/resources/com/ericsson/m2m/common/utils/persistence/impl/mybatis/custom/xml/
But 'Open Resource' indicates 3 matches for the same file with relative paths:
maindev/common/utils/persistence/src/...
common/utils/persistence/src/...
persistence/src/...
Is there a way in Eclipse to avoid those repeated matches?
Moreover, is there a way in Eclipse to indicate not to return resources for target/ directories?
NOTE: I tried Wojtek O. suggestion, but still getting matches:
You see multiple files because they logically are contained withing difference Eclipse projects. You could try to close some of those projects but that may as well result in compilation errors. If you wish to hide some files from the Open Resource... dialog you need to mark the folder containg those files as derived by right clicking on it in the Project Explorer and selecting Derived checkbox under Attributes section.
This is a really old thread, but in the newer Eclipse versions (Photon+) there's a filter option for resource search.
On the Open Resource dialog (Ctrl+Shift+R), click the drop-down on top "Enter resource name prefix..." and select "Filter Duplicated Resources".
If you're just looking for Java classes you can also use Open Type dialog (CTRL-Shift-T).

How to remove the lock in file association in eclipse

IN Eclipse i want to chnage the default editor of some .htm files.
If i try to go to FIle Association and assiciate the default editor then file gets opened in that new editor but i don't get the syntax highlighting.
The solution is that the file association is locked ny some plugin editor
Preferences -- Context type----text ----Your editor -- reomve the extension
But i get the .htm(locked) so i cant remove it.
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-content-type.htm
Note: Certain items will be marked as "locked". An item is locked if
it is one of the associations provided by the plug-in that declares
the content type. In other words, you can remove only user-contributed
associations.
Is there any way to remove those locks even thought it can be hackish way but i want to do it
You don't need to "unlock" an existing association to add a new association and make it the default.
Add a new association via the "Add" button
Select the new entry
Hit the "Default" button to make your new entry the default editor
Could it be, that you want to change the "File Association"? This can be done in General / Editors / File Associations. BUT Eclipse uses at least one default-editor and this is the reason for the "locked"-message in the "Content Types". You could set the "Text Editor" to all unwanted types. Looks like a workaround, but makes sense, because it is the same as the file associations of your operating system, that asks you for the program to display the file.
Another question is, why do you want to unlock or remove the "Content Type"? Does it change anything in the Eclipse logic?
Go see this answer from "Greg Desmarais" (assign the desired editor to "default")
https://stackoverflow.com/a/15642583/162094

Lines of Code count for Flex in Eclipse

How to get the SLOC count for the Flex code in Eclipse?
Is there a plug-in similar to "Metrics" for finding information about the Flex porject?
This is the easiest way to count lines of code of any particular language and does not require a plugin.
Steps:
Click on the root folder of your project
Right-click and select Search (or Cntl+H)
In the box "Containing Text" type \n and make sure to select the "Regular Expression" checkbox
In the "File name patterns" input, type the file extensions of the files you want to include in your count, or click on "Choose" if you are feeling lazy.
Click "Search"
BAM! Instant line count for your entire project!
These instructions may differ slightly depending on your version of Eclipse, but you should be able to figure it out.
Good luck!
From this question:
http://metrics.sourceforge.net can do lines. I'm not sure about words
however.

Can Eclipse reformat multiple files at once?

I've invested a fair amount of time creating a code style profile in Eclipse which matches our persnickety code standard. Is there a way to apply this style en masse to many files at once, so I don't have to manually load/format/save each in turn?
You right-click on a package in the Package Explorer, and use the "Source > Format" menu option to format them all at once. You can also set up the "Source > Clean Up..." action to format in addition to other cleanup actions.