Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Closing all opened editors at the time of Eclipse launch(Closing all opened editors at the time of Eclipse launch)
Closing all opened editors at the time of Eclipse launch [message #708744] Wed, 03 August 2011 02:19 Go to next message
newbie  is currently offline newbie
Messages: 5
Registered: July 2011
Junior Member
Hi,

I have designed an eclipse plugin. I want to close all editors athat were opened in the previous session at the time of launch. Since mine is a plugin project but is not an RCP application, i am not sure how and where do i override org.eclipse.ui.application.WorkbenchAdvisor.postStartup() method. I added following piece of code in start method of activator.

PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow iWorkbenchWindow : windows) {
if (iWorkbenchWindow.getActivePage() != null) {
break;
}
iWorkbenchWindow.close();
}
but this is of no use. I added above code to one of the methods of class implementing AbstractUIPlugin. It is closing all the editors at the time of eclipse luanch but throwd a NullPoiner Exception as well. Please fond the stack trace below:


java.lang.NullPointerException
at org.eclipse.ui.internal.menus.WorkbenchMenuService.releaseContributions(WorkbenchMenuService.java:854)
at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:1682)
at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:723)
at org.eclipse.ui.internal.WorkbenchWindow.access$0(WorkbenchWindow.java:699)
at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:815)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:813)
at org.eclipse.ui.internal.Workbench$61.runWithException(Workbench.java:3402)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1384)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)


Please help.

thanks
Re: Closing all opened editors at the time of Eclipse launch [message #708804 is a reply to message #708744] Wed, 03 August 2011 03:32 Go to previous messageGo to next message
newbie  is currently offline newbie
Messages: 5
Registered: July 2011
Junior Member
No Message Body

[Updated on: Wed, 03 August 2011 05:02]

Report message to a moderator

Re: Closing all opened editors at the time of Eclipse launch [message #710673 is a reply to message #708804] Fri, 05 August 2011 05:27 Go to previous message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 03.08.2011 09:32, newbie wrote:
> I tried to achieve the similar thing through
> Preferences->Editor->Close Editors automatically as well.
> www.java-tips.org/other-api-tips/eclipse/how-to-close-editors-automatically-with-work-2.html
>
>
> But it is not closing opened editors on exit. It just closes the
> editor when a new editor is opened based on the number set in
> Preferences->Editor->Number of opened editors before closing.
> Is it a bug?
No, this is how it is supposed to work.

Dani
Previous Topic:Using custom perspectives (e.g. Java debug)
Next Topic:new version of plugins not installed after an update
Goto Forum:
  


Current Time: Wed Jul 23 01:48:11 EDT 2014

Powered by FUDForum. Page generated in 0.02901 seconds