Getting the IWorkbench
To get the IWorkbench from a plugin use IWorkbench wb = PlatformUI.getWorkbench();
Getting the IWorkspace
The workspace can be gotten using ResourcesPlugin.getWorkspace();
Getting the "root" IResource of the workspace
This can be gotten from IWorkspace.getRoot()
Getting the "active" editor from an Action/command
public ITextEditor getTextEditor()
{
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
IEditorPart editor = page.getActiveEditor();
return (ITextEditor) editor;
}