Is there a way to load plugin.xml as an object? - eclipse

I have a plug-in project opened in the workspace. Is there an API which could help to change the plugin.xml? I don't want to parse it as an xml file.

There is no "good" way to do this as the PDE guys did not open their APIs to modify manifest files (MANIFEST.MF, plugin.xml, etc). You can only access those information in read only with their APIs. That being said, if you are not afraid of using internal code, you can have a look at PDEModelUtility and ModelModification. These classes are used in the OrganizeManifestProcessor.

Related

how to find file (Open Type) by project in eclipse

In eclipse (neon) I have several projects with similar files
I want to able to pick project when open type maybe using Path or Project name
Is there any plugin or similar way to get it?
I think you are asking for open resource(Ctrl+Shift+R) not open type(Ctrl+Shift+T).
IMHO there is no way to filter out types by their paths, as because same type(ex Enum/Inner class) may exist in different Java classes.
Yes. You can filter out resources by project/folder path. Refer this answer https://stackoverflow.com/a/39568618/1391924
Open Resource and Open Type both let You use Working Sets.
So You can define a WS per project or whatever makes sense for You and use the one You need at the given moment.
You can choose the WS directly in the modal dialog.

Extend or configure Eclipse compare files functionality

Eclipse has built in functionality for comparing files, but how can I configure that functionality? Say I create a new file type and want an external program do perform the diff. How do I set that up?
Can I create an Eclipse plugin to add my own plugin for handling file comparisons? Or perhaps that is the answer to the first question...
You may want to look at the EMF Compare Project which helps build compare editors for EMF models. If you don't have an EMF model for your file type, you can either create one or look through the source code of EMF Compare to see how it works.
The developer guide explains how to use the code to write your custom viewers.
There is a plugin integrating Beyond Compare into Eclipse. As it is open source, you might get a clue by looking at its sources.

How can I get a IFile instance from a File object in a non Eclipse plugin

I'm developing a Maven plugin that will use the IClassFile but the only way that I found to create it is having an instance of IFile. How can I get a instance of IFile from a File object ?
Without the Eclipse core, in particular the org.eclipse.core.resources plugin, there's no resource tree, no workspace, and therefore no IFiles to be had. IClassFile is part of the JDT implementation, and it, too, is not meant to be used outside of Eclipse. I am fairly sure you're not going to be able to do this.
You will need to find the IFile in the resources stuff (you can navigate through the workspace to do this).
Have a look in this documentation to see what you will need to do.

How to make easily use of XSDs located in a library?

We decided to go for an plugin mechanism which brings some services / logic etc., we use XML as a model approach, so the plugin has to bring it's own XSD to be integrated into the XML of the main application. This is done like the Spring approach (e.g. util:, jee: and other namespaces).
We can't upload every plugins XSD to a server. The XSD is located in the JAR of our plugin. Is it possible without adding this JAR to an XML Catalog to directly access this XSD and be able to reference it? So Eclipse can find this XSD and perform the auto-completion, validation, etc.?
Short: We have an XSD in our library and want to make use of it, how can we achieve this?
Look at the org.eclipse.wst.standard.schemas for examples of how to add schemas to the catalog from an Eclipse plug-in.

How to programmatically get information in Eclipse

I'm developing an Eclipse Plug-in.
I need to programmatically get both filepath and filename of the selected/active file in the eclipse editor.
Also need to programmatically add an existing file (located outside the project) to the project and then open it on the editor.
I'm a totally beginner with Eclipse, so complete solution would be appreciated.
You question is quite general, but this should clear things up a bit:
Eclipse Plugin Development Tutorial
About adding a file to the project, you have to read the documentation and find where eclipse handles projects. I think that if you have a reference to the project it should be easy.
Hope it helps =)
Your editor is most likely inheriting from IEditorPart, so you should be able to call getEditorInput(), which then may or may not turn out to be a FileEditorInput, for example. From there, you can get at the underlying details of the file.
For your second problem, you can use IProject.create() and then e.g. do an IFile.createLink() and use a local filesystem path, or copy the file using IFile.appendContents().
Have you tried the solution proposed in http://www.eclipse.org/forums/index.php/mv/msg/97927/300308/#msg_300308?