MultiPageEditorActionBarContributor是MultiPageEditor的actions,当切换Editor 和Page的时候要自己更新toolbar,menu,statusbar等action或状态的.
由于我在单独的Editor测试这些地方(toolbar,menu,statusbar等)都没有问题.当时将这些单独的Editor放到MultiPageEditor中这些地方就很不正常.
一方面我不想改变单独editor的各自的Contributor;另一方面切换这些Editor 和Page的时候要到当前Editor的toolbar,menu.
初始化和dispose.
public MultiEditorContributor() {
super();
designContributor=new DesignEditorContributor();
sourceContributor=new SourceEditorContributor();
otherContributor=new OtherEditorContributor ();
}
protected DesignEditorContributor designContributor=null;
protected SourceEditorContributor sourceContributor=null;
protected
OtherEditorContributor otherContributor=null;
protected MultiEditorPart multiPageEditor=null;
public void init(IActionBars bars) {
if(bars != null)
{
if(designContributor!=null)
designContributor.init(bars,getPage());
if(sourceContributor!=null)
sourceContributor.init(bars,getPage());
}
if(otherContributor!=null)
otherContributor.init(bars,getPage());
}
}
public void dispose(){
super.dispose();
if(designContributor!=null)
designContributor.dispose();
if(sourceContributor!=null)
sourceContributor.dispose();
}
if(otherContributor!=null)
otherContributor.dispose();
}
记录当前editor,如果相同返回/否则刷新
private IEditorPart currentEditorPart=null;
public void setActivePage(IEditorPart activeEditor) {
......
}