启动时清理Eclipse RCP工作台

时间:2014-03-03 15:55:19

标签: eclipse-rcp

如何让Eclipse RCP应用程序在启动时始终拥有干净的工作台?

我只是想隐藏ViewParts,而不是未恢复,所以切换工作台数据不是我需要的。

我尝试隐藏postWindowCreateWorkbenchWindowsAdvisor的所有观点,它适用于所有观看但只有一个,就好像我无法在工作台创建的这个阶段隐藏它们

隐藏视图的代码(最新尝试):

IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
                .getWorkbenchWindows();
for (IWorkbenchWindow workbenchWindow : windows) {
    IWorkbenchPage[] pages = workbenchWindow.getPages();
    for (IWorkbenchPage iWorkbenchPage : pages) {
        IViewReference[] viewReferences = iWorkbenchPage
                .getViewReferences();
        for (IViewReference iViewReference : viewReferences) {
            IWorkbenchPart part = iViewReference.getPart(true);
            if (part instanceof ISaveablePart2) {
                iWorkbenchPage.hideView((IViewPart) part);
            }
        }
    }
}

更新 有问题的视图会调用createPartControl,即使我的其他任何视图都没有调用createPartControl。它在postWindowCreatepostWindowOpen之后调用,堆栈跟踪:

CreativeAssistantView.createPartControl(Composite) line: 106    
CompatibilityView(CompatibilityPart).createPartControl(IWorkbenchPart, Composite) line: 142 
CompatibilityView.createPartControl(IWorkbenchPart, Composite) line: 174    
CompatibilityView(CompatibilityPart).create() line: 323 
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57  
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43  
Method.invoke(Object, Object...) line: 606  
MethodRequestor.execute() line: 56  
InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 877 
InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 857 
InjectorImpl.inject(Object, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 119 
InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 333 
InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 254    
ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 162   
ReflectionContributionFactory.createFromBundle(Bundle, IEclipseContext, IEclipseContext, URI) line: 102 
ReflectionContributionFactory.doCreate(String, IEclipseContext, IEclipseContext) line: 71   
ReflectionContributionFactory.create(String, IEclipseContext) line: 53  
ContributedPartRenderer.createWidget(MUIElement, Object) line: 129  
PartRenderingEngine.createWidget(MUIElement, Object) line: 949  
PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 633    
PartRenderingEngine$6.run() line: 526   
SafeRunner.run(ISafeRunnable) line: 42  
PartRenderingEngine.createGui(MUIElement, Object, IEclipseContext) line: 511    
ElementReferenceRenderer.createWidget(MUIElement, Object) line: 61  
PartRenderingEngine.createWidget(MUIElement, Object) line: 949  
PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 633    
PartRenderingEngine.safeCreateGui(MUIElement) line: 735 
PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 706 
PartRenderingEngine$7.run() line: 700   
SafeRunner.run(ISafeRunnable) line: 42  
PartRenderingEngine.createGui(MUIElement) line: 685 
PartRenderingEngine$1.handleEvent(Event) line: 134  
UIEventHandler$1.run() line: 41 
UISynchronizer(Synchronizer).syncExec(Runnable) line: 180   
UISynchronizer.syncExec(Runnable) line: 150 
Display.syncExec(Runnable) line: 4688   
E4Application$1.syncExec(Runnable) line: 205    
UIEventHandler.handleEvent(Event) line: 38  
EventHandlerWrapper.handleEvent(Event, Permission) line: 197    
EventHandlerTracker.dispatchEvent(EventHandlerWrapper, Permission, int, Event) line: 197    
EventHandlerTracker.dispatchEvent(Object, Object, int, Object) line: 1  
EventManager.dispatchEvent(Set<Entry<K,V>>, EventDispatcher<K,V,E>, int, E) line: 230   
ListenerQueue<K,V,E>.dispatchEventSynchronous(int, E) line: 148 
EventAdminImpl.dispatchEvent(Event, boolean) line: 135  
EventAdminImpl.sendEvent(Event) line: 78    
EventComponent.sendEvent(Event) line: 39    
EventBroker.send(String, Object) line: 80   
UIEventPublisher.notifyChanged(Notification) line: 58   
PlaceholderImpl(BasicNotifierImpl).eNotify(Notification) line: 374  
PlaceholderImpl(UIElementImpl).setToBeRendered(boolean) line: 290   
ModelServiceImpl.showElementInWindow(MWindow, MUIElement) line: 574 
ModelServiceImpl.bringToTop(MUIElement) line: 543   
PartServiceImpl.switchPerspective(MPerspective) line: 504   
PerspectiveStackRenderer.showTab(MUIElement) line: 124  
PerspectiveStackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 97    
PerspectiveStackRenderer.postProcess(MUIElement) line: 77   
PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 649    
PartRenderingEngine.safeCreateGui(MUIElement) line: 735 
PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 706 
PartRenderingEngine$7.run() line: 700   
SafeRunner.run(ISafeRunnable) line: 42  
PartRenderingEngine.createGui(MUIElement) line: 685 
SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 61   
PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 645    
PartRenderingEngine.safeCreateGui(MUIElement) line: 735 
PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 706 
PartRenderingEngine$7.run() line: 700   
SafeRunner.run(ISafeRunnable) line: 42  
PartRenderingEngine.createGui(MUIElement) line: 685 
WBWRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 61    
WBWRenderer.processContents(MElementContainer<MUIElement>) line: 676    
PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 645    
PartRenderingEngine.safeCreateGui(MUIElement) line: 735 
PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 706 
PartRenderingEngine$7.run() line: 700   
SafeRunner.run(ISafeRunnable) line: 42  
PartRenderingEngine.createGui(MUIElement) line: 685 
PartRenderingEngine$9.run() line: 1042  
Realm.runWithDefault(Realm, Runnable) line: 332 
PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 997 
E4Workbench.createAndRunUI(MApplicationElement) line: 138   
Workbench$5.run() line: 610 
Realm.runWithDefault(Realm, Runnable) line: 332 
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 567    
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 150   
Application.start(IApplicationContext) line: 32 
EclipseAppHandle.run(Object) line: 196  
EclipseAppLauncher.runApplication(Object) line: 110 
EclipseAppLauncher.start(Object) line: 79   
EclipseStarter.run(Object) line: 354    
EclipseStarter.run(String[], Runnable) line: 181    
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57  
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43  
Method.invoke(Object, Object...) line: 606  
Main.invokeFramework(String[], URL[]) line: 636 
Main.basicRun(String[]) line: 591   
Main.run(String[]) line: 1450   
Main.main(String[]) line: 1426

0 个答案:

没有答案