The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Eclipse Plug-in

<3<3 Registered User regular
edited October 2009 in Help / Advice Forum
I'm writing a plug-in and I'm trying to open up a file or create a new file if it doesn't exist.

This is what I gathered from searching and reading the FAQ about opening files.
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IPath path = new Path("somefile.txt");
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
page.openEditor(new FileEditorInput(file), desc.getId());

However, this is not working, and frankly, I have no idea why. Do we have an expert on eclipse plug-in here that can help?

<3 on

Posts

  • <3<3 Registered User regular
    edited October 2009
    shameless self bump

    <3 on
  • DrFrylockDrFrylock Registered User regular
    edited October 2009
    Are you sure the file exists? You're looking for it in the workspace root...usually files are in a project somewhere. Otherwise, it could be editor matching strategy shenanigans or something, but check the file first.

    DrFrylock on
Sign In or Register to comment.