/**
* 背景:当别的页面跳转其他单据并且需要隐藏当局上所有的工具栏
* BillShowParameter parameter = new BillShowParameter();
* parameter.setFormId("xxxx");
* parameter.getOpenStyle().setShowType(ShowType.Modal);
* parameter.addCustPlugin("xx.xx.xx.xx.xx.VisibleToolBarFormPlugin");
* parameter.setPkId(xxxxxxxxx);
* parameter.setStatus(OperationStatus.VIEW);
* this.getView().showForm(parameter);
*/
public class VisibleToolBarFormPlugin extends AbstractFormPlugin {
private OperationStatus billStatus = null;
@Override
public void initialize() {
super.initialize();
if (this.billStatus == null){
FormView view = (FormView) this.getView();
this.billStatus = view.getStatus();
}
}
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
List<Control> controls = Collections.singletonList(this.getView().getRootControl());
loopAndHideToolBar(controls);
}
private void loopAndHideToolBar(List<Control> list){
if (CollectionUtils.isNotEmpty(list)){
for (Control control : list) {
String key = control.getKey();
if ("pagepanel".equals(key)){
this.getView().setVisible(false,"pagepanel");
}else if (control instanceof Toolbar){
if (OperationStatus.VIEW.equals(this.billStatus)){
this.getView().setVisible(false,key);
}
}else if (control instanceof Container){
this.loopAndHideToolBar(((Container) control).getItems());
}
}
}
}
}
代码.docx(63.71KB)
推荐阅读