Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » workspaceRoot.getFile() does not return
workspaceRoot.getFile() does not return [message #1818164] Mon, 09 December 2019 09:00 Go to next message
Ming Cheng is currently offline Ming ChengFriend
Messages: 7
Registered: December 2019
Junior Member
My Code:

public static void openClassFile(String locationString) {
IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {

IPath p = new Path(locationString);
IWorkspace workspace = ResourcesPlugin.getWorkspace();

if (workspace == null ) {
JOptionPane.showMessageDialog(null,"null workspace");
IWorkspaceRoot workspaceRoot = workspace.getRoot();
if (workspaceRoot == null ) {
JOptionPane.showMessageDialog(null,"null workspaceRoot");
JOptionPane.showMessageDialog(null,"before getFileForLocation");
IFile file = workspaceRoot.getFile(p);
FileEditorInput input = new FileEditorInput(file);
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
if (null != activePage) {
try {
activePage.openEditor(input, "bndtools.bndWorkspaceConfigEditor", true);
} catch (PartInitException ex) {
JOptionPane.showMessageDialog(null,"Unable to open editor");
//ErrorDialog.openError(getSection().getShell(), "Error", "Unable to open editor", ex.getStatus());
} else {
JOptionPane.showMessageDialog(null,"No activePage");

I can see popup of "before getFileForLocation"; but I can't see the next popup which is supposed to display the file name:

Re: workspaceRoot.getFile() does not return [message #1818170 is a reply to message #1818164] Mon, 09 December 2019 09:59 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 82
Registered: April 2012
Using the Java debugger you can probably find the answer to your question.

To learn about the Java debugger, look at the Eclipse documentation and tutorials, some examples:
Re: workspaceRoot.getFile() does not return [message #1818343 is a reply to message #1818170] Fri, 13 December 2019 03:03 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3596
Registered: July 2009
Senior Member

Odds are it is related to using Swing controls while SWT is also running in-process.

Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:why PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null
Next Topic:Need to "Close / Open project" - after EACH edit ( CDT ) !
Goto Forum:

Current Time: Wed Feb 26 20:38:38 GMT 2020

Powered by FUDForum. Page generated in 0.04901 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top