Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » get the active project
get the active project [message #336237] Tue, 02 June 2009 18:08 Go to next message
Elad is currently offline EladFriend
Messages: 7
Registered: July 2009
Junior Member
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
Re: get the active project [message #336238 is a reply to message #336237] Tue, 02 June 2009 18:13 Go to previous message
Elad is currently offline EladFriend
Messages: 7
Registered: July 2009
Junior Member
I figured out the problem.
I took the "IProject activeProject = null;" and moved it inside the main
class declaration.

Thanks anyway :)
Previous Topic:Moving table items
Next Topic:Add New Wizards to the File>New shortcut
Goto Forum:
  


Current Time: Fri Apr 19 07:00:43 GMT 2024

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

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

Back to the top