How can I rename multiple files in eclipse and update their references as well ?
For ex. I got these classes in many packages in my project :
com.a.b.c.Fooclass1
com.a.b.c.Fooclass2
com.a.b.c.Fooclass3
com.a.b.c.BarFooclass1
com.a.b.c.Dontworryclass
I want to replace Foo with BAR.
How can I replace Foo with BAR in the class names of all those classes in my project, which have Foo in their name.
Edit : I really know how to use refactor in eclipse for a single file ! I wanted to know a solution for multiple files.
This might help some other people crashing in here. If you wanna replace multiple file names use powershell:
Get-ChildItem -Filter “*currentfilename*” -Recurse | Rename-Item -NewName {$_.name -replace ‘currentfilename’,’newfilename’ }
Right click on file name -> Refactor -> Rename -> Use the new name then press enter. Confirm any prompts. This will change any references. But I am afraid there is no way to do that for multiple files.
I can tell you in windows explorer, Select your first folder from the list, hit F2, paste or append to the file name, then hit tab, paste or append to the second file name, hit tab and repeat....
Related
Yesterday I had to export all AEM tags into Excel file. While surfing for the best solution to do this, I've found out that almost everyone advices writing custom code that takes all of tags and enters it into Excel file.
I consider that solution good, but since there are a lot of people that do things like this for the first time and it will probably take some time for them to figure out how to do this.
For them, let's share some workarounds for this problem.
To get a comma separated list of tags I would recommend using the command line, the build-in AEM query builder, curl and jq (https://stedolan.github.io/jq/).
The general approach:
Use query builder to build a JSON representation of /etc/tags
Use curl to "download" the JSON
Use jq to "parse" the JSON and create a CSV
Example:
Exporting all tags below /etc/tags with their path, title and description would look like this:
curl \
--user admin:admin \
--silent \
"http://localhost:4502/bin/querybuilder.json?p.hits=selective&p.limit=-1&p.properties=jcr%3atitle%20jcr%3apath%20jcr%3adescription&path=%2fetc%2ftags&type=cq%3aTag" \
| jq --raw-output '.hits[] | [."jcr:path", ."jcr:title", ."jcr:description"] | #csv' \
> tags.csv
This would send a GET request to your local AEM instance (http://localhost:4502), authenticate as user admin with password admin(default settings for AEM), use the query builder API (/bin/querybuilder.json) to get all resources with type cq:Tag below /etc/tags and of those resources it would "select" the properties jcr:path, jcr:title and jcr:description.
The resulting JSON looks like this:
{
"success": true,
"results": 2,
"total": 2,
"more": false,
"offset": 0,
"hits": [
{
"jcr:path": "/etc/tags/experience-fragments",
"jcr:description": "Tag structured used by the Experience Fragments feature",
"jcr:title": "Experience Fragments"
},
{
"jcr:path": "/etc/tags/experience-fragments/variation",
"jcr:description": "A tag used by the experience fragments variations",
"jcr:title": "Variation"
},
]
}
Next, the command above will pipe the resulting JSON from the query builder to jq, which will use the "query" .hits[] | [."jcr:path", ."jcr:title", ."jcr:description"] to read only the hits array and of every item in that array only jcr:path, jcr:title and jcr:description. The resulting arrays are then used as input for #csv "string formatter" of jq, which will create proper comma-separated output.
The JSON from above would be formatted to:
"/etc/tags/experience-fragments","Experience Fragments","Tag structured used by the Experience Fragments feature"
"/etc/tags/experience-fragments/variation","Variation","A tag used by the experience fragments variations"
The last part of the command > tags.csv will just redirect the output to a file called tags.csv instead of the command line.
AEM has a query builder debugger which you can use to create queries that you then can use in your command line command:
http://localhost:4502/libs/cq/search/content/querydebug.html
The query parameters I used above would look like this in the tool:
path=/etc/tags
type=cq:Tag
p.hits=selective
p.limit=-1
p.properties=jcr:title jcr:path jcr:description
You can add properties as you like, but for them to show up in the CSV you also have to update the query used by jq.
If you add translations to your tags they will be stored in a property called jcr:title.<language-code>. If you translate your tags to German for example, you would have two properties: jcr:title and jcr:title.de. If you want the translation you have to extend the p.properties and add jcr:title.de etc.
If you need to export tags, here is simple solution on how to easy export them and then there are several ways how to import it in the Excel, without need to write custom code for this.
To export AEM tags do the following 5 steps:
Open package manager
Create package (give it some meaningful name)
Edit created package
Select "filters" tab
Enter path to tags you wish to export (for example: http://localhost:4502/libs/cq/tagging/gui/content/tags.html/etc/tags/geometrixx-outdoors)
you can find it under Adobe Experience Manager -> Tools -> General -> Tags
Done, Save
Build package
Download Package
Then you have all tags inside {download_package_name}/jcr_root/etc/tags.
Now there are several ways of getting downloaded tags to Excel file. This is how to do this on Windows -
Source: Is there a way to export a folder structure into excel?
Find the folder in Windows Explorer, then Shift Right click on that
folder and select "Open Command Window Here". Type the following
prompt:
dir /a /s /b > filelist.txt
That gives you a text file saved in your top folder, which you can
open in notebook, then copy and paste into an Excel document.
There's a GUI in AEM to export content as excel [well almost]. To get a tsv file of tags in the system AEM's bulk editor can be used. Navigate to '/etc/importers/bulkeditor.html' on the server. Set path as '/etc/tags' or a subtree. In query field type 'type:Tag'. Select the properties that need to be exported and hit search. The results can then be exported to a tsv file via the export button.
References
https://helpx.adobe.com/in/experience-manager/6-4/sites/administering/using/bulk-editor.html
https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/commons/search/GQL.html
I don't have the privileges to comment on the accepted answer but thought it would be useful to add to the excellent accepted answer: If you're on >= 6.4 then you may need to change the path in your query to /content/cq:tags (1) or query both paths if your install has been upgraded over time and you have long lived tags. I was getting 0 hits even though I could see several hundred when viewing http://localhost:4502/tagging
(1) https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/tagging-issue-in-aem-6-4/qaq-p/320994
Hopefully, this non-answer isn't overly frowned upon.
In Eclipse I want (for example) that code like this
public Foo bar() {
}
gets formatted to this
public Foo bar()
{
}
via the clean up function.
But to do that I have to check "Format source code" in the clean up profile.
But that also formats code like this
alert.setHeaderText("blablablablablablablablablablablablablablablabla");
to this
alert.setHeaderText(
"blablablablablablablablablablablablablablablabla");
which I absolutely do not want. Is there any possible way to stop Eclipse from cutting lines like that?
Go to Window->Preferences->Java->Code Style->Formatter. Create new formatter. Click on edit and then pick tab Line Wrapping and set Line Wrapping policy to Do not wrap.
For more clarification refer the below Link :-
http://eclipsesource.com/blogs/2013/07/09/invisible-chaos-mastering-white-spaces-in-eclipse/
You can configure the style to which code is formatted. Under
Preferences: Java -> CodeStyle -> Formatter
Then look for "Line wrapping".
I am using Eclipse for about 5 years. Now I'm begging with IntelliJ Idea 13. I can not get used to code completion :-(
How can I create new public method?
In Eclipse i press:
pub CTRL+SPACE ENTER int CTRL+SPACE test ENTER
and get
public int test() {
}
how can I do it in Idea?
IF this scenario is important to you,
You can use IntelliJ's Live Templates
There are no built-in templates for that. You can create your own, like other answers advise. But in general, just typing the method with autopopup completion seems to require almost the same number of key presses:
pub < autopopup appears with "public" selected, hit ENTER > int test( < CTRL+SHIFT+ENTER >
You can add a 'Live Template' in IntelliJ. Go to Preferences -> Live Templates -> Select your language (if Java is not there, you can select Other), select the "+" symbol and add a new template. e.g. Abbreviation = test, and put your method in the Template text.
IntelliJ will display a message 'No applicaable contexts yet'. Define' just below the box. If you click on 'Define' you can select 'Java' in the list that shows up.
In your editor, type the template abbreviation and press the tab key.
I have been researching about how to create my own Eclipse's editor template or customize code template to fit my need but to no avail.
Here is my requirement:
I need to have to this kind of script.
${class} ${classname:newName(class)} = new ${class}();
${classname}.toString();
So when I try to use use this. I can automatically generate the code below just by typing "MyClass" to the ${class} part of the code
MyClass myClass = new MyClass();
myClass.toString();
But just by using that script. "myClass" cannot be automatically generated when I input the class name "MyClass"
So for example, I will have
MyClass classname = new MyClass();
classname.toString();
I have found these resources, but it didn't help me. Can anyone point me to the right direction as I can't seem to find a solution for this problem.
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Fcodestyle%2Fref-preferences-code-templates.htm
Can you define your own template variables in Eclipse
Is there a Eclipse template variable for short version of enclosing type name
OR, is there a way to create my own Eclipse's "Generate Getters and Setters..",
which can be achieved my right clicking on any eclipse source file -> Source -> "Generate Getters and Setters"
This is the best I've found so far: https://marketplace.eclipse.org/content/fast-code-eclipse-plugin
It does exactly what I want, but it lacks polish and documentation. I've also had it crash on me to the point where I needed to reinstall it.
But it's still the best I've found so far.
I'm developing an eclipse product and i need to associate a file extension to my editor.
I followed several examples (as like as this and
this) but it seems that the editor ever receives the SWT OpenDocument event.
As described in the fileAssociation example i created an eventListener class to process SWT.OpenDocument events and i added this in my Application class to the display before that the PlatformUI.createAndRunWorkbench() method gets called
public Object start(IApplicationContext context) throws Exception {
Object args = context.getArguments().get(IApplicationContext.APPLICATION_ARGS);
OpenDocumentEventProcessor eProc = new OpenDocumentEventProcessor();
Display display = PlatformUI.createDisplay();
display.addListener(SWT.OpenDocument, eProc);
try{
if(!handleWorkspace(display)){
System.exit(0);
return IApplication.EXIT_OK;
}
int returnCode = PlatformUI.createAndRunWorkbench(display, new XVRWorkbenchAdvisor(args, eProc));
In the product file i added the following program arguments:
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-name
XVR Studio Developer
If I use the same code in a new empty RCP project it works like a charm..
I can't figured out which could be the problem..
can you help me?
Thanks a lot!!
This approach is unknown for me, but since there is no explicit editor call in your pasted code I guess you still rely on eclipse to decide which editor has to be opened. So I guess you still have to define contentypes and file associations declaratively. To do that contribute to "org.eclipse.core.contenttype.contentTypes" extension, add a 'file-association' (file extension...). Get your editor declaration in your plugin xml and add the previously created 'contentTypeBinding' id.
As I have just made this work for an RCP app, I thought it would be helpful to document how I did it here, and provide refs.
I had no use for the 'context.getArguments()..', the 'OpenDocumentEventProcessor' handled everything.
I would suggest that the reason this did not work was that the -name value did not match the value of the 'appName' property in the 'org.eclipse.core.runtime.products' extension point. Just to be sure, I removed the spaces from the appName property and in the -name. Then it worked.
Very useful references are:
For the basic coding:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fproduct_open_file.htm
For an explanation of how this works:
http://aniefer.blogspot.co.uk/2010/05/opening-files-in-eclipse-from-command.html
One small point that eluded me for some time, was getting the path for the file in several chunks at the place where there was a space in the name. Eventually I realised (in a 'duh!' moment) that I needed to put quotes round the %1 parameter in the installer's (InstallAware) definition for the file association - i.e it became "%1"