As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

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

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

    <3 on
  • Options
    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.