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: 18
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");
return;
}
IWorkspaceRoot workspaceRoot = workspace.getRoot();
if (workspaceRoot == null ) {
JOptionPane.showMessageDialog(null,"null workspaceRoot");
return;
}
JOptionPane.showMessageDialog(null,"before getFileForLocation");
IFile file = workspaceRoot.getFile(p);
JOptionPane.showMessageDialog(null,locationString);
FileEditorInput input = new FileEditorInput(file);
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
if (null != activePage) {
try {
JOptionPane.showMessageDialog(null,"HERE");
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:

JOptionPane.showMessageDialog(null,locationString);
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: 138
Registered: April 2012
Senior Member
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:
https://help.eclipse.org/2019-09/topic/org.eclipse.jdt.doc.user/gettingStarted/qs-13.htm?cp=1_1_0_11
https://help.eclipse.org/2019-09/topic/org.eclipse.jdt.doc.user/tasks/task-running_and_debugging.htm?cp=1_3_6
https://www.vogella.com/tutorials/EclipseDebugging/article.html
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: 3757
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: Sun Jul 12 07:32:31 GMT 2020

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

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

Back to the top