Eclipse RCP: How to access internal classes of plugins?

I want to use the default XML editor (org.eclipse.wst.xml.ui) Eclipse in an RCP application. I need to read the DOM of the current xml file. The plugin does not offer extension points, so I'm trying to access inner classes. I know that I should not have access to inner classes, but I have no other option.

My approach is to create a fragment and extension point for reading data from the plugin. I try not to recompile the plugin, so I thought a snippet is needed. I just want to load it and extract the data at runtime.

So my question is: is there any other way to access the plugin classes? if so, how? Any tutorial, document page, or useful link for any of the methods is welcome.

+6
eclipse eclipse-plugin eclipse-rcp
source share
2 answers

Since no one answered my question, and I found the answer after a long search, I will send an answer to other users if they encounter this problem.

To access the plugin at run time, you must create both an extension point and add it to the plugin that you are trying to access.

Adding classes to the plugin using a fragment is not recommended if you want to access these classes from outside the plugin.

So, the best solution for this is to get the plugin source from the CVS repository and make changes directly to the plugin source. Add extensions, extensions, and code for functionality.

Tutorials:

+4
source share

I ended up extending XMLMultiPageEditorPart as follows:

public class MultiPageEditor extends XMLMultiPageEditorPart implements IResourceChangeListener { @Override public void resourceChanged(IResourceChangeEvent event) { // TODO Auto-generated method stub setActivePage(3); } public Document getDOM() { int activePageIndex = getActivePage(); setActivePage(1); StructuredTextEditor fTextEditor = (StructuredTextEditor) getSelectedPage(); IDocument document = fTextEditor.getDocumentProvider().getDocument( fTextEditor.getEditorInput()); IStructuredModel model = StructuredModelManager.getModelManager() .getExistingModelForRead(document); Document modelDocument = null; try { if (model instanceof IDOMModel) { // cast the structured model to a DOM Model modelDocument = (Document) (((IDOMModel) model).getDocument()); } } finally { if (model != null) { model.releaseFromRead(); } } setActivePage(activePageIndex); return modelDocument; } } 

This is not a pure implementation, but it does its job.

+1
source share

All Articles