[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: Removing editor area after perspective creation
|
- From: Daniel Krügler <dsp@xxxxxxx>
- Date: Thu, 07 Oct 2004 11:45:35 +0200
- Newsgroups: eclipse.platform.rcp
- Organization: EclipseCorner
- User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.4) Gecko/20030619 Netscape/7.1 (ax)
Hello community,
after finding the function setEditorAreaVisible of window pages I
realized a solution of my problem via a IPartListener counter class,
which counts open and close events of IEditorParts and calls the
setEditorAreaVisible function if the last editor has closed. Does there
exist a simpler and more natural solution? (There exist some problems
concerning a safe usage of the class, e.g. how to ensure that an
instance of EditorAreaWatcher exists **before** the very first editor
was opened.)
Thanks,
Daniel
public class EditorAreaWatcher implements IPartListener {
private IWorkbenchPage page;
private long editorCounter;
public EditorAreaWatcher(IWorkbenchPage page) {
this.page = page;
this.page.addPartListener(this);
}
public void partClosed(IWorkbenchPart part) {
if (part instanceof IEditorPart) {
--editorCounter;
if (editorCounter == 0) {
part.getSite().getPage().setEditorAreaVisible(false);
}
}
}
public void partOpened(IWorkbenchPart part) {
if (part instanceof IEditorPart) {
++editorCounter;
}
}
... // other IPartListener functions doeing nothing at all
public void dispose() {
page.removePartListener(this);
}
}