




已阅读5页,还剩26页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
packagecom.dsrcom.ecq.client.carlvisitmanage.actionGroup; importjava.util.ArrayList; importjava.util.List; importorg.eclipse.jface.action.Action; importorg.eclipse.jface.action.IMenuManager; importorg.eclipse.jface.action.IToolBarManager; importorg.eclipse.jface.action.MenuManager; importorg.eclipse.jface.dialogs.IDialogConstants; importorg.eclipse.jface.dialogs.MessageDialog; importorg.eclipse.jface.resource.ImageDescriptor; importorg.eclipse.jface.viewers.ISelection; importorg.eclipse.jface.viewers.IStructuredSelection; importorg.eclipse.jface.viewers.TreePath; importorg.eclipse.jface.viewers.TreeSelection; importorg.eclipse.jface.viewers.TreeViewer; importorg.eclipse.swt.SWT; importorg.eclipse.swt.widgets.Menu; importorg.eclipse.swt.widgets.MessageBox; importorg.eclipse.swt.widgets.Shell; importorg.eclipse.swt.widgets.Tree; importorg.eclipse.swt.widgets.TreeItem; importorg.eclipse.ui.IActionBars; importorg.eclipse.ui.IWorkbenchPage; importcom.dsrcom.ecq.client.carlvisitmanage.data.DataFactory; importcom.dsrcom.ecq.client.carlvisitmanage.dialog.AddTreeDlg; importcom.dsrcom.ecq.client.carlvisitmanage.dialog.TreeDialog; importcom.dsrcom.ecq.client.carlvisitmanage.images.SmsImages; importcom.dsrcom.ecq.client.carlvisitmanage.views.SampleView1; importcom.dsrcom.ecq.client.carlvisitmanage.views.VisitViews; mons.SpringBeanFactory; importcom.dsrcom.ecq.client.main.Activator; importcom.dsrcom.ecq.client.util.eli.eba.EmployeeMap; .OrgDataFactory; importcom.dsrcom.ecq.main.domain.StrOrganization; importcom.dsrcom.ecq.main.service.StrOrgService; importcom.dsrcom.ecq.visitmanager.domain.VisitTree; /导航树中的菜单和工具栏实现代码 publicclassMyActionGroup privatestaticfinalintNO1=0; privatestaticfinalLongSUPERNODEVALUE=null; /将uplink为Null的情况设置为根节点的情况 privateTreeViewertv; publicActionaddAction=newAddAction(); publicActionmodifyAction=newModifyAction(); publicActionopenAction=newOpenAction(); publicActionmoveAction=newMoveAction(); publicActionupAction=newUpAction(); publicActiondownAction=newDownAction(); publicActionrefreshAction=newRefreshAction(); publicActiondeleteAction=newDeleteAction(); publicTreePathtreePath; publicMyActionGroup(TreeViewertreeViewer) this.tv=treeViewer; publicvoidfillContextMenu(IMenuManagermgr) MenuManagermenuManager=(MenuManager)mgr; menuManager.add(addAction); menuManager.add(modifyAction); menuManager.add(openAction); menuManager.add(moveAction); menuManager.add(upAction); menuManager.add(downAction); menuManager.add(refreshAction); menuManager.add(deleteAction); Treetree=tv.getTree(); Menumenu=menuManager.createContextMenu(tree); tree.setMenu(menu); publicvoidfillActionBars(IActionBarsactionBars) if(actionBars=null) return; IToolBarManagertoolBar=actionBars.getToolBarManager(); toolBar.add(addAction); toolBar.add(modifyAction); toolBar.add(refreshAction); privateclassOpenActionextendsAction publicOpenAction() setText(查看); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.VIEW); setImageDescriptor(imageDesc); setEnabled(true); publicvoidrun() AddTreeDlgdialog=newAddTreeDlg(tv.getControl().getShell(); /设置对话框的类型:是增加,修改还是查看 dialog.setWhat(Open); /获取树种所选结点的所属部门和所属员工的相关信息 /获取所选结点的belong_To和underDept字段值 LongbelongTo=getSelection().getBelongTo(); /StringbelongToCopy=belongTo.toString().trim(); LongunderDept=getSelection().getUnderDept(); StringnodeName=getSelection().getNodeName(); /设置对话框的显示 dialog.setText_TypeNameValue(nodeName); StringorgName=EmployeeMap.getOrgName(underDept); dialog.setText_DepartValue(orgName); if(belongTo=null) Stringstr=newString(); dialog.setText_EmpValue(str); else StringorgBelongTo=EmployeeMap.getEmpName(belongTo); dialog.setText_EmpValue(orgBelongTo); /if(underDept!=null) /if(checkDown(getStrOrganizationByOrgId(underDept)| /checkUp(getStrOrganizationByOrgId(underDept) /dialog.open(); / /elseif(belongTo!=null) /if(checkUp(belongTo)|getSessionEmpId()=belongTo) /dialog.open(); / /else dialog.open(); privateclassAddActionextendsAction publicAddAction() setText(增加); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.ADD); setImageDescriptor(imageDesc); publicvoidrun() AddTreeDlgdialog=newAddTreeDlg(tv.getControl().getShell(); /设置对话框的类型:是增加,修改还是查看 dialog.setWhat(Add); /获取对话框中的数据的变量 StringtextDepartValue=null; StringtextTypeNameValue=null; StringtextEmpValue=null; LongorgId=newLong(0); LongempId=newLong(0); /当关闭对话框时,获取对话框中的数据 if(dialog.open()=IDialogConstants.OK_ID) textDepartValue=dialog.getText_DepartValue(); textTypeNameValue=dialog.getText_TypeNameValue().trim(); textEmpValue=dialog.getText_EmpValue(); empId=dialog.getEmpId(); orgId=dialog.getOrgId(); visitTreeSave(textDepartValue,textTypeNameValue,textEmpValue, orgId,empId); privateclassModifyActionextendsAction publicModifyAction() setText(修改); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.EDIT); setImageDescriptor(imageDesc); publicvoidrun() AddTreeDlgdialog=newAddTreeDlg(tv.getControl().getShell(); dialog.setWhat(Modify);/设置对话框的类型:是增加,修改还是查看 StringtextDepartValue=null; StringtextTypeNameValue=null; StringtextEmpValue=null; LongorgId=null; LongempId=null; /显示所选择结点的相关信息 /ISelectionis=tv.getSelection(); /IStructuredSelectionISselection=(IStructuredSelection)is; /VisitTreeselection=(VisitTree)ISselection.getFirstElement(); VisitTreeselection=getSelection(); /获取所选结点的belong_To和underDept字段值 LongbelongTo=selection.getBelongTo(); LongunderDept=selection.getUnderDept(); StringnodeName=selection.getNodeName(); /设置对话框的显示 dialog.setText_TypeNameValue(nodeName); StringorgName=EmployeeMap.getOrgName(underDept); dialog.setText_DepartValue(orgName); if(belongTo=null) Stringstr=newString(); dialog.setText_EmpValue(str); else StringorgBelongTo=EmployeeMap.getEmpName(belongTo); dialog.setText_EmpValue(orgBelongTo); if(dialog.open()=IDialogConstants.OK_ID) textDepartValue=dialog.getText_DepartValue(); textTypeNameValue=dialog.getText_TypeNameValue().trim(); textEmpValue=dialog.getText_EmpValue(); orgId=dialog.getOrgId(); empId=dialog.getEmpId(); /保存修改後的值 visitTreeUpdate(textDepartValue,textTypeNameValue,textEmpValue, orgId,empId,selection); privateclassMoveActionextendsAction publicMoveAction() setText(迁移); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.MOVE); setImageDescriptor(imageDesc); publicvoidrun() TreeDialogdialog=newTreeDialog(null); /导航树中被选择的节点 ISelectionis=tv.getSelection(); IStructuredSelectionISselection=(IStructuredSelection)is; VisitTreeselection=(VisitTree)ISselection.getFirstElement(); dialog.setSelection(selection); if(dialog.open()=IDialogConstants.OK_ID) VisitTreevisitTree=dialog.getVisitTree(); if(visitTree=null) MessageDialog.openWarning(null,警告,请选择一个记录); else /获得对话框中所选择节点的相关信息 Longidx=visitTree.getIdx(); selection.setUplink(idx); selection.setRank(idx); DataFactory.saveEntry(selection); refreshAction.run(); privateclassUpActionextendsAction publicUpAction() setText(上移); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.UP); setImageDescriptor(imageDesc); SuppressWarnings(static-access) publicvoidrun() VisitTreeselTree=getSelTree(); VisitTreeupTree=getUpTree(selTree); /一个中间变量,目的是将上下结点的uplink值进行对调 Longrank=newLong(0); rank=upTree.getRank(); upTree.setRank(selTree.getRank(); selTree.setRank(rank); DataFactory.saveEntry(selTree); DataFactory.saveEntry(upTree); refreshAction.run(); tv.setAutoExpandLevel(tv.ALL_LEVELS); /if(treePath!=null) /tv.setExpandedTreePaths(treePath); tv.setExpandedState(getSelTree(),true); privateclassDownActionextendsAction publicDownAction() setText(下移); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.DOWN); setImageDescriptor(imageDesc); publicvoidrun() VisitTreeselTree=getSelTree(); VisitTreedownTree=getDownTree(selTree); /一个中间变量,目的是将上下结点的uplink值进行对调 Longrank=newLong(0); rank=downTree.getRank(); downTree.setRank(selTree.getRank(); selTree.setRank(rank); DataFactory.saveEntry(selTree); DataFactory.saveEntry(downTree); tv.refresh(selTree); /更新父结点 Longidx=selTree.getUplink(); VisitTreefatherNode=DataFactory.getVisitTreeByIdx(idx); refreshAction.run(); tv.refresh(fatherNode); privateclassRefreshActionextendsAction publicRefreshAction() setText(刷新); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.REFRESH); setImageDescriptor(imageDesc); SuppressWarnings(unchecked) publicvoidrun() tv.collapseAll(); refreshAction(); /获取树的根结点 java.util.Listinput=DataFactory.getVisitTreeTop(); IWorkbenchPagewbp=Activator.getDefault().getWorkbench(). getActiveWorkbenchWindow().getActivePage(); SampleView1sampleView=(SampleView1)wbp.findView(SampleView1.ID); VisitViewsvisitViews=(VisitViews)wbp.findView(VisitViews.ID); sampleView.visitTreeInput(sampleView.viewer,input); visitViews.setInput(null); modifyAction.setEnabled(false); addAction.setEnabled(false); tv.refresh(getSelTree(); privateclassDeleteActionextendsAction publicDeleteAction() setText(删除); ImageDescriptorimageDesc=SmsImages .getImageDescriptor(SmsImages.DELETE); setImageDescriptor(imageDesc); publicvoidrun() VisitTreeobj=getSelTree(); if(obj=null) return; if(isChild(obj) MessageDialog.openWarning(null,警告,所选结点有子节点或有访客记录不能删除); else MessageBoxmsgbox=newMessageBox(newShell(),SWT.ICON_QUESTION |SWT.OK|SWT.CANCEL); msgbox.setMessage(确定要删除吗?); intrc=msgbox.open(); if(rc=SWT.OK) tv.remove(obj); DataFactory.removeEntry(obj); /* *获取指定结点是否有数据 *paramvisitTree *return */privatebooleanisChild(VisitTreevisitTree) Longidx=visitTree.getIdx(); Listlist=DataFactory.getVisitTreeByUplink(idx); ListlistVisitInfor=DataFactory.getVisitInformationByVistTreeIdx(idx); if(list.isEmpty()&listVisitInfor.isEmpty() returnfalse; else returntrue; publicVisitTreegetSelTree() IStructuredSelectionselection=(IStructuredSelection)tv .getSelection(); VisitTreevt=(VisitTree)selection.getFirstElement(); returnvt; /得到vt结点的上一个结点 publicVisitTreegetUpTree(VisitTreevt) /得到VT结点的父结点 Listlist=DataFactory.getVisitTreeByUplink(vt.getUplink(); /保存上一个结点的结果 VisitTreeresult=newVisitTree(); for(inti=0;ilist.size();i+) VisitTreevt1=(VisitTree)list.get(i); if(vt1.getRank().equals(vt.getRank()/ if(i=0) result=(VisitTree)list.get(0); break; else result=(VisitTree)list.get(i-1); break; returnresult; /得到vt结点的下一个结点 publicVisitTreegetDownTree(VisitTreevt) /得到VT结点的父结点相同的结点List Listlist=DataFactory.getVisitTreeByUplink(vt.getUplink(); /保存vt结点的下一个结点的结果 VisitTreeresult=newVisitTree(); for(inti=0;ilist.size();i+) /父结点的子节点循环判断 VisitTreevt1=(VisitTree)list.get(i); if(vt1.getRank().equals(vt.getRank() if(i=list.size()-1)/ result=(VisitTree)list.get(list.size()-1); break; else result=(VisitTree)list.get(i+1); break; returnresult; /* *保存添加的数据 *paramtextDepartValue所属部门的值 *paramtextTypeNameValue种类名称的值 *paramtextEmpValue所属员工的值 *paramorgId部门ID *paramempId员工ID */privatevoidvisitTreeSave(StringtextDepartValue, Stri
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- Unit 9 Section A 3a-3c 说课稿2025-2026学年八年级英语下册同步教学(人教版)
- 第7课 设置动画效果教学设计-2025-2026学年小学综合实践活动长春版六年级上册-长春版
- 一年级道德与法治上册 第三单元 我爱我家 第10课《爱心伴我长大》说课稿 鄂教版
- 13 万里一线牵 (教案)部编版道德与法治三年级下册
- 《角》(教学设计)-2024-2025学年四年级数学上册人教版
- 第6课 奔向光明-亮度传感器的应用和条件控制教学设计-2025-2026学年初中信息技术粤教清华版九年级下册-粤教清华版
- 2025年幼儿发展与健康知识考试题库
- 金融市场概述教学设计-2025-2026学年中职专业课-财政与金融基础知识-财经类-财经商贸大类
- 1古诗三首《四时田园杂兴(其三十一)》教学设计-2024-2025学年统编版语文五年级下册
- Module 6 Unit 3 说课稿 2025-2026学年外研版英语八年级下册
- 加油、加气、充电综合站项目可行性研究报告
- 塔机拆卸合同范本
- 2024-2025学年广东省深圳市南山区四年级(下)期末数学试卷
- 《煤矿安全规程(2025版)》知识培训
- 2025秋数学(新)人教五年级(上)第1课时 小数乘整数
- 《数字技术应用基础模块》技工中职全套教学课件
- 房屋拆除专项施工方案(3篇)
- AutoCAD电气工程制图 课件 项目1 低压配电柜的绘制与识图
- 红河州公开遴选公务员试题及答案
- 2024年全国工会财务知识大赛备赛试题库500(含答案)
- 消防技术装备培训课件
评论
0/150
提交评论