Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Closing all previously opened editors at the time of Eclipse launch(Closing all opened editors at the time of Eclipse launch)
Closing all previously opened editors at the time of Eclipse launch [message #707993] Tue, 02 August 2011 10:13 Go to next message
newbie  is currently offline newbie Friend
Messages: 5
Registered: July 2011
Junior Member
Hi,

I have designed an eclipse plugin. Eclipse has a feature that if the workbench is closed with some open editors, then next time the eclipse is launched all the editors opened in the previous session. remains in the open state.
My requirement is to close all the open editors based on the previous session at the time eclipse is launched. In one of the classes of plugin designed, i added following piece of code

PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow iWorkbenchWindow : windows) {
if (iWorkbenchWindow.getActivePage() != null) {
break;
}
iWorkbenchWindow.close();
}

This code is closing the editors at the time of launching. but it also throws an exception .
"Unable to read workbench state. Workbench UI layout will be reset.
java.lang.NullPointerException".

Request you to let me know where am i wrong.

Thanks


Re: Closing all previously opened editors at the time of Eclipse launch [message #708170 is a reply to message #707993] Tue, 02 August 2011 14:31 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
On 8/2/11 6:13 AM, newbie wrote:
> Hi,
> I have designed an eclipse plugin. Eclipse has a feature that if the
> workbench is closed with some open editors, then next time the eclipse
> is launched all the editors opened in the previous session. remains in
> the open state. My requirement is to close all the open editors based on
> the previous session at the time eclipse is launched. In one of the
> classes of plugin designed, i added following piece of code
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> IWorkbenchWindow[] windows =
> PlatformUI.getWorkbench().getWorkbenchWindows();
> for (IWorkbenchWindow iWorkbenchWindow : windows) {
> if (iWorkbenchWindow.getActivePage() != null) {
> break;
> }
> iWorkbenchWindow.close();
> }
>
> This code is closing the editors at the time of launching. but it also
> throws an exception . "Unable to read workbench state. Workbench UI
> layout will be reset.
> java.lang.NullPointerException".
> Request you to let me know where am i wrong.


The stack trace of that exception and the debugger are your best
friends; use them. If you run into a brick wall with that, try posting
details in the Platform forum group; this isn't really a "newcomers" topic.

Eric
Previous Topic:(no subject)
Next Topic:Run Menu options is not showing in custom perspective
Goto Forum:
  


Current Time: Fri Apr 26 22:55:54 GMT 2024

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

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

Back to the top