How to create Eclipse EFS resources on the fly in a content provider? - eclipse

I like to write a plugin for Eclipse, which allows to work with archive files as with normal file directories. For instance, if there is a zip file inside a project, the user should be able to view the contents of the zip file just by opening the zip folder. The user should be able e.g., to read text files in that archive.
I already created an EFS wrapper arround a particular archive format. Also, I created a new content-type for this archive format. I have a navigatorContent which is triggered on the content-type. In the content provider, currently I provide objects of type IFileStore. AFAIK there isn't any nice label provider shipped with eclipse for this types so I have to implement it on my own (there is one which is declared as private). However, this seems to be rather huge code duplication effort. What I therefore like to do is not to return IFileStore but IFile or IFolder instead so that the normal project explorer content provider can do its job. Is it possible at all to do something like this? If so, how can this practical be achieved?

Call IFolder.createLink() to create a new resource referencing a folder on your custom filesystem.
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_efs_resources.htm
This will create a new folder in your project, containing all files from ZIP archive. The problem, however is, that you will need to put it into an existing container, polluting resource tree.

Implementing ILabelProvider is not a huge effort at all, especially when compared to IFile or IFolder. If you extend BaseLabelprobivider you only need to implement 2 methods: getText() and getImage().

Related

Can we overlay the file to our custom path

Can we overlay the file to our custom path or we have to overlay the file to exact folder structure location as in libs?
For example, I want to overlay the constants.js (/libs/cq/ui/widgets/source/constants.js) file, in this adobe recommended Copy this file to /apps/cq/ui/widgets/source/constants.js for overlaying, but in my project that folder structure is not there, so I have copied to the custom path in apps folder and tested the changes and overlaying is working fine.
The file needs to have the same path as the one in libs except for replacing 'libs' with 'apps'. It does not work with custom paths*. If the project does not already have the structure, you can always create it. Don't forget to update the META-INF/Vault/filter.xml file to register the new path with projects package definition.
*Technically you can change the configs to add new searchpaths. But do remember that you might have to share the AEM instance with different tenants and sticking to the usual conventions goes a long way in having a predictable setup. I honestly don't see a reason to do this, it is already an acceptable practice to overlay under '/apps'. The filters on package provide enough flexibility to get along with other tenants while modifying similar areas.
I think you want to create the overlay in your custom project under /apps. If my assumption is correct, then you can certainly do it.
Taking your example in consideration, /libs/cq/ui/widgets/source/constants.js can be overlayed to /apps/<your-project>/cq/ui/widgets/source/constants.js by adding an entry in the Apache Sling Resource Resolver Factory configuration.
See this answer for the detailed steps. I hope this helps.

Where should I place the java properties file under netbeans

In my netbeans IDE I am creating one project.That project(Web Application) needs properties file.Since my application is having several packages.And all packages need to read this properties file in their code.So where should I place this java properties file.If I place the file out side of the packages that is under sourcepackages seperately,I am getting FilenotFound Exception.So where should I place it.
And one more doubt is if I want to change any content in the file in future where should I change the contents since it is present in Projects folder and under Files->build->classes folder also.From where should I modify it.From where the changes will be effected.
Please help.
Thank you.
Put your file under /src/resources/, then use it like below:
ResourceBundle props = ResourceBundle.getBundle("resources.config");
You may put this in any package. The point ist to read with
MyClass.getResourceAsStream("my.properties");
Read further here.
You always change in the project src folder. The build folder is only for building your app.
If you want to change the properties file on a deployed system you may put the properties into the WEB-INF folder and then access with ServletContext#getRealPath().
I put the .properties file in the same folder as the src and it works :)
Alright, so I'm working on Windows and here's my solution...
It actually doesn't matter much where you put the .properties file--but assuming you created the file in NetBeans and let it save to its default location, you can simply call the data with the full directory attached.
Just for reference, here's what I did:
SimpleDataSource sds = new SimpleDataSource("src\\simpledatasource\\mystuff.properties");
Notice you'll need to escape the backslash, so use two of them.

How can we make a nested directory in resource folder to put the xmls with same name?

How can we make a nested directory in resource folder to put the xmls with same name for different folders.And how we can read it using path in iphone app programatically?
Actually i want to make like resource>a>b>some.xml
again in resource like resource>f>g>some.xml
and so on...how ever both xml is containing different data in it.and also tell me the way how we can read it in iphone application.
You cannot use the same filename, even if they resides in different folders.
Instead, as a workaround, you can name the files like:
a_b_some.xml
f_g_some.xml
you can create a folder structure on your system and then directly add the folder to your XCode Project under resources by drag-drop.
this folder must display in BLUE color (physical grouping in folder on disk) rather than YELLOW (logical grouping in project only) just like native folders on mac. like this you can put same file in different folder hierarchy without any problems.
you need to create a absolute path to your file whenever you want its access your file [NSBundle pathForResource:] will not work in this case as it does not have access to your custom folder hierarchy.
best of luck.

sitecore package 6.2 quick look at content

I know that you can create an xml file detailing the contents when you create a package, but is there an easy way to determine what is in a package when it is just a zip file sitting on a file server or something?
This is in version 6.2.
Yes you can. Open the Package Designer on the server where the zip is. In the New menu click the dropdown and select "From Existing." From here pick the package and it will open in the designer.
Here's a blog post visually showing you the idea: Inspecting Sitecore Packages Before You Install Them
You can open a package with any archive editor (for instance, 7zip). The main ZIP contains another ZIP, called package.zip. The package.zip in its turn contains a number of folder. The most interesting to you are probably:
files
items
security
The contents of /files folder corresponds to the file system structure under the website root. For instance:
/App_Config/Include/my.config
/bin/my.dll
/xsl/my.xsl
The contents of the /items folder is a directory structure. The path to an XML representation of each item starts with the folder named like the database holding the item, then down the path of the item in the content tree (starting from /sitecore), then the ID of the item, next the language, and finally the version. For instance:
\items\core\sitecore\layout\Layouts\my layout{GUID-GOES-HERE}\en\1\xml
"xml" is the name of the XML file containing the item data.
The contents of /security folder is simpler:
\security\roles\sitecore\My Power Users
There are other folders inside the package.zip, but those primarily hold the metadata of the package, like readme, license, etc.
I suppose it's a superfluous warning, but still: don't try to edit anything there. It makes sense for a quick look only to make sure something is or is not in the package.
Hope this helps.

Netbeans creating a dist jar with all images etc included

I am trying to distribute a netbeans project however the jar it creates and the contents of the dist folder are dependant on some image files which i included into the project - however these images are not in the dist folder and I cannot workout how to make things work so I can export the project in a distributable format including all the things it needs.
Can somebody please tell me how I can export a project which runs within Netbeans without using the project's /dist folder which includes everything it needs?
Cheers
Andy
One way to achieve this is to add a folder (f.i."resources") in your project's src dir. Then copy the images to that dir. Now the images should get included when you build the project (if I remember correctly). Accessing the files can be accomplished with "getResourceAsStream"...
If whatever resources you are interested in are in the classpath, packaged in the jar, war, or the distribution, you can retrieve them by getting resources.
The convention is indeed to have a directory named 'src/resources' that serves as the root for this. Depending on the amount and scope of the resources you are using you may also want to add a sub-directory hierarchy to keep the organization and state of the resources manageable.
Also, not that a resource can be any file, an image, sound, text, xml, binary, etc. no limitation.
Finally, the call will look like this if you are using an object method:
getClass().getResourceAsStream("resources/myResource") - or - getClass().getResource("resources/myResource")
depends on if you want a stream or just the URI at that point in the code. Typically one would use the URI for delegating the processing of the resource elsewhere and the stream form when you are processing it in-line.
For a class method, you will need to do something more like:
new Object().getClass()...
The think to keep in mind here, is eventually this is resolving to the class loader and it is from that class path that the resource will be fetched.
You can add images the same way:
final Image image0 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("images/1.png"));