File file = new File("/home/rohit/func.c");
IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(file.toURI());
FileStoreEditorInput editorInput = new FileStoreEditorInput(fileOnLocalDisk);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
try {
page.openEditor(editorInput, "org.eclipse.ui.DefaultTextEdtior");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
IWorkspaceRoot ws = ResourcesPlugin.getWorkspace().getRoot();
IPath location = new Path("/home/rohit/func.c");
IFile file = ws.getFileForLocation(location);
IProject project = ws.getProject("External Files");
if (!project.exists())
try {
project.create(null);
if (!project.isOpen())
project.open(null);
//IFile file = project.getFile(location.lastSegment());
//file.createLink(location, IResource.NONE, null);
FileEditorInput fileEditorInput = new FileEditorInput(file);
IWorkbench workbench = PlatformUI.getWorkbench();
IEditorDescriptor desc = workbench.getEditorRegistry().getDefaultEditor(file.getName());
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
page.openEditor(fileEditorInput, desc.getId());
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}