@Override public void dispose() { if (this.currentEntity != null) { this.currentEntity.close(top, this); this.currentEntity = null; } if (top != null && !top.isDisposed()) { top.dispose(); } super.dispose(); }
/** 关闭模型 */ @Override public void close(Composite top, EntityViewPart view) { if (!top.isDisposed()) { BindingHandler handler = null; String viewID = view.getSite().getId(); // 用户视图 if (viewID.equals(ProductDeployView.ID)) { handler = (ProductDeployViewerBindingHandler) viewerHandlers.get(viewID); } handler.detachListeners(); handler.destroy(); top.dispose(); } }
/** 初始化viewer */ @Override public void open(Composite top, EntityViewPart view) { String viewID = view.getSite().getId(); if (viewID.equals(ProductDeployView.ID)) { ProductDeployViewerCreator viewerCreator = new ProductDeployViewerCreator(); ProductDeployViewerBindingHandler handler = new ProductDeployViewerBindingHandler(); if (handler.initContents(viewerCreator, top) && handler.initControls()) { if (viewerCreator.getBindedControls() != null && viewerCreator.getBindedControls().size() > 0) { handler.attachListeners(); viewerHandlers.put(viewID, handler); viewer = viewerCreator.getViewer(); } } } }
/** 增删改操作 */ @Override public Object execute(ExecutionEvent event, EntityViewPart view, String operationID) { if (operationID.equals(OPSConstants.ADD_DEPLOY)) { ProductDeployDialog dialog = new ProductDeployDialog(operationID, this); dialog.setTitleText("新增部署信息"); dialog.open(); } else if (operationID.equals(OPSConstants.UPDATE_DEPLOY)) { if (!this.isOnlyOneSelected(view)) { return null; } TableRowModel model = (TableRowModel) this.getSelectedElements()[0]; String addUser = (String) model.getData().get("a.dp_user"); HttpSession session = RWT.getUISession().getHttpSession(); boolean is_admin = (Boolean) session.getAttribute(FrameworkConstants.IS_ADMIN); if (!is_admin) { String account = OPSUtil.getUserNameAndAccount(); if (account != null && !account.equals(addUser)) { MessageUtil.showMessageDialog( "抱歉,您不是该信息的部署人,不能修改或删除。", MessageUtil.MESSAGE_DIALOG_TYPE_INFO); return null; } } ProductDeployDialog dialog = new ProductDeployDialog(operationID, this); dialog.setTitleText("修改部署信息"); dialog.open(); } else if (operationID.equals(OPSConstants.READ_DEPLOY)) { if (!this.isOnlyOneSelected(view)) { return null; } ProductDeployDialog dialog = new ProductDeployDialog(operationID, this); dialog.setTitleText("查看部署信息"); dialog.open(); } else if (operationID.equals(OPSConstants.DELETE_DEPLOY)) { if (!this.isOnlyOneSelected(view)) { return null; } TableRowModel model = (TableRowModel) this.getSelectedElements()[0]; String addUser = (String) model.getData().get("a.dp_user"); HttpSession session = RWT.getUISession().getHttpSession(); boolean is_admin = (Boolean) session.getAttribute(FrameworkConstants.IS_ADMIN); if (!is_admin) { String account = OPSUtil.getUserNameAndAccount(); if (account != null && !account.equals(addUser)) { MessageUtil.showMessageDialog( "抱歉,您不是该信息的部署人,您不能修改或删除。", MessageUtil.MESSAGE_DIALOG_TYPE_INFO); return null; } } boolean result = MessageDialog.openConfirm( view.getSite().getShell(), "系统提示", "删除部署信息会影响监控的数据获取,确定删除部署信息?"); if (!result) { return null; } deleteProductDeploy(view); } return null; }