get the active project [message #336237] |
Tue, 02 June 2009 14:08  |
Eclipse User |
|
|
|
Hello.
I use this code to get the active project.
but I have an error with the "activeProject" variable.
The error says - "Cannot refer to a non-final variable activeProject
inside an inner class defined in a different method"
but when I add "final" to the var, another error appear -
"The final local variable activeProject cannot be assigned, since it is
defined in an enclosing type".
Can you please help me with that.
IProject activeProject = null;
PlatformUI.getWorkbench().getDisplay().syncExec(
new Runnable() {
public void run() {
IWorkbenchWindow window = PlatformUI
.getWorkbench()
.getActiveWorkbenchWindow();
if ( window != null ) {
IWorkbenchPage page = window.getActivePage();
if ( page != null ) {
IEditorPart editor = page.getActiveEditor();
if ( editor != null ) {
IEditorInput input = editor.getEditorInput();
if ( input instanceof IFileEditorInput ) {
IFileEditorInput fileInput = (IFileEditorInput) input;
activeProject = fileInput.getFile().getProject();
}
}
}
}
}
} );
Elad
|
|
|
|
Powered by
FUDForum. Page generated in 0.02938 seconds