Prakash
Prakash

Reputation: 19

RCP Application : Could not open the eclipse default editor to open selected file on button click

I am creating RCP application and in that I have to browse file and selected file path is displayed in text box. One button is there to open that selected file. I want to open it in eclipse default editor and I have user listener on button click to open editor. I used below code for opening editor :

   IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
   File file = new File("file path from text box");
   try {
        IFileStore fileStore= EFS.getLocalFileSystem().fromLocalFile(file);
        page.openEditor(new FileStoreEditorInput(fileStore), EditorsUI.DEFAULT_TEXT_EDITOR_ID);                 
    } catch (CoreException ce) {
        ce.printStackTrace();
    }

But when when I select file and click on open file button then new editor opens but file contents are not shown with following error :

Could not open the editor: The editor class could not be instantiated. This usually indicates a missing no-arg constructor or that the editor's class name was mistyped in plugin.xml.

In Details section it is giving error(I have copied part of stack trace) :

java.lang.NoClassDefFoundError: org/eclipse/core/resources/IWorkspace
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
    at java.lang.Class.getConstructor0(Class.java:2803)
    at java.lang.Class.newInstance(Class.java:345)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)

Please help me with this issue to open file(on button click) in Eclipse default editor.

Many Thanks in advance!!

Upvotes: 0

Views: 93

Answers (1)

siddu
siddu

Reputation: 31

Please try adding default constructor for editor if its a multipage editor

Upvotes: 0

Related Questions