commit 7c444e171556f6f89cfce76b4ed53557480e0268 Author: hongcj Date: Tue Jun 3 16:36:18 2025 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..ebf44c1 --- /dev/null +++ b/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..4ef6f61 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + cn.net.connor.process + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..0a2c23e --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +encoding//src/cn/net/connor/process/Processknowledgebase=GBK +encoding//src/cn/net/connor/process/commands/OpenPCBCommand3.java=UTF-8 +encoding//src/cn/net/connor/process/hourcalculation=GBK +encoding//src/cn/net/connor/process/meopviewfx/ui/TableLoader.java=UTF-8 +encoding//src/cn/net/connor/process/newprocess/NewProcessDialogController.java=UTF-8 +encoding//src/cn/net/connor/process/processview=GBK diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..716d0e8 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,59 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Process +Bundle-SymbolicName: cn.net.connor.process;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: cn.net.connor.process.Activator +Eclipse-RegisterBuddy: k.util +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp, + com.teamcenter.rac.common, + com.teamcenter.rac.external, + com.teamcenter.rac.kernel, + com.teamcenter.rac.tcapps, + com.teamcenter.rac.ui, + com.teamcenter.rac.ui.commands, + com.teamcenter.rac.util, + k.util;bundle-version="1.0.0", + com.teamcenter.rac.cme.mpp, + TcSoaCoreRac, + TcSoaCoreTypes, + com.teamcenter.rac.pse, + org.apache.poi.39;bundle-version="3.9.0", + org.apache.commons.io;bundle-version="1.4.0", + TcSoaWorkflowRac +Automatic-Module-Name: cn.net.connor.process +Bundle-ActivationPolicy: lazy +Export-Package: cn.net.connor.process, + cn.net.connor.process.choose, + cn.net.connor.process.commands, + cn.net.connor.process.gcjlk, + cn.net.connor.process.gzbomexport, + cn.net.connor.process.meopmodel, + cn.net.connor.process.meopviewfx, + cn.net.connor.process.meopviewfx.bean, + cn.net.connor.process.meopviewfx.dialog, + cn.net.connor.process.meopviewfx.ui, + cn.net.connor.process.modifymeopno, + cn.net.connor.process.newmeop, + cn.net.connor.process.newprocess, + cn.net.connor.process.openpcb, + cn.net.connor.process.processcard, + cn.net.connor.process.processcardmultiple, + cn.net.connor.process.processprocedure, + cn.net.connor.process.processview, + cn.net.connor.process.proctask, + cn.net.connor.process.revisemeprocess, + cn.net.connor.process.tsgcexport, + cn.net.connor.process.tsgcrefexport, + cn.net.connor.process.workflowname, + com.teamcenter.rac.kernel +Bundle-ClassPath: ., + lib/zip4j-1.3.2.jar, + lib/commons-compress-1.20.jar, + lib/xz-1.8.jar, + lib/ojdbc6.jar, + lib/groovy-all-2.4.7.jar +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: com.teamcenter.rac.kernel diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..f199af2 --- /dev/null +++ b/README.MD @@ -0,0 +1,797 @@ +# 首选项配置 + +> 中括号内表示可选配置,配置时不要把中括号也写进去 + +## 1. Connor_AVIC_[版本类型] + +配置创建工艺界面,对齐使用空格对齐(shift+space切换中英空格) + +```text +格式:“[*][#]标题名称=写入属性配置[=提取属性配置[+GY][=下拉内容1;下拉内容2;下拉内容3]]” +*:必填 +#:不可编辑 +属性配置格式:属性位置.属性名称(属性位置包含 item, rev, itemmaster, revmaster) +-------------------------------------------- +特殊写入属性配置: +object_type:必配,指定新建对象的类型,如有下拉值,配置“真实类型名称[-新对象版本(父)与用户选择版本(子)的关联关系名称[-用户选择版本(父)与新对象(子)的关联关系名称]]” +``` + +## 1.1 Connor_AVIC_ProcType_Symbol + +配置创建工艺功能中,工艺类型和类型简写的对应关系,选择类型后将创建工艺界面首选项中的配置的“[PROC_TYPE]”替换为对应简写 + +示例 + +```text +MEProcess=JJ +Item=ZP + +创建工艺界面中的配置示例: +工艺编码=item.object_desc=[PROC_TYPE]+item.item_id +``` + +## 2. Connor_AVIC_MEOP_[工艺版本类型] + +配置工艺版本类型对应的创建工序界面中,工序类型的列表 + +```text +格式:“工序类型真实名称[=工艺短描述的内容]” +``` + +## 3. Connor_AVIC_MEOP_Properties + +配置创建工序界面显示的属性 + +> 注意工艺短描述属性配置在jar包中的文件:`cn/net/connor/process/newmeop/newmeop.properties`,shortdesc.PROPNAME=[格式同下方首选项说明] +> +> 如果配置了版本表单属性ac5_Type,新对象版本号取填写的值+00 + +```text +格式:“[*][#][$]显示名称=属性位置.属性名称[=附加lov的名称[=从工艺提取属性的属性位置.属性名称[=属性是否显示配置]]]”(属性位置包含 item, rev, itemmaster, revmaster) +注意:此处增加[$]符号的配置,表示控件是文本域,可多行输入。[*][#]同上,分别表示必填和只读 + +属性是否显示配置格式:“属性位置.属性名称:配置文本”。当属性真实值等于配置文本时,这条配置为有效配置,控件可见;否则忽略该行配置。 +示例:“版本描述=rev.object_desc=BillCodes==rev.object_desc:1” + +20210112: 附加lov名称配置可以替换为用英文分号分隔的下拉值列表 +``` + +## 3.5 Connor_AVIC_MEOP_LOV_[属性名称] + +配置创建工序界面中,如果属性A存在LOV且配置了首选项“Connor_AVIC_MEOP_LOV_属性A”,当属性A选择值之后,将配置的指定值填写到其他属性 + +```text +格式:“选择的真实值:属性名称1=指定的值1;属性名称2=指定的值2;属性名称3=指定的值3” +``` + +## 4. Connor_AVIC_MEOPEXCEL_[属性真实名称] + +配置创建工序和工艺编辑视图界面中对应[属性真实名称]的选择按钮逻辑 + +```text +第一行:配置excel数据集的uid,可按照创建界面选择的类型区分。首先查找类型对应uid,未找到时查找默认uid。 +格式:“默认uid;真实类型名称1:类型1使用的uid;真实类型名称2:类型2使用的uid;...” +第二行开始:配置表格显示和属性映射信息 +格式:“[#]界面列名=excel列名[=属性位置.属性名称[=默认列宽]]” +#:表示添加该列的查询 +``` + +## 5. Connor_AVIC_ME_Properties_[对象真实类型] + +配置工艺视图中选择对应[对象真实类型]时,要在界面中显示的属性 + +```text +配置方法同首选项:Connor_AVIC_MEOP_Properties + +20201117 增加额外配置:某个下拉框(控制属性)选择指定的值时,隐藏指定的控件(隐藏属性) +格式:“HIDE_LISTENER:控制属性位置.控制属性名称=指定值:隐藏属性位置1.隐藏属性名称1;隐藏属性位置2.隐藏属性名称2” +示例:“HIDE_LISTENER:rev.object_desc=Civi:item.object_desc;item.object_name” +``` + +## 6. Connor_GZBomExport + +配置导出工装BOM明细表导出信息 + +```text +多值,格式:[#]属性名称 +配置‘#’表示属性名称在bomline上,否则从版本表单获取 +可选配内容: +1. 写入起始行:在其中一行配置数字,仅支持0-9 +2. 默认文件名后的日期后缀:##+日期格式。(##_yyyy_MM_dd) +``` + +示例 + +```text +object_name +object_desc +#bl_quantity +#bl_item_item_id +``` + +## 7. Connor_Signature_[版本类型] + +配置Word Excel签名 + +```text +多值,格式:word域名或excel文本框名称=版本表单属性名称或固定内容[=分隔符=取分隔后的第几个内容(从零开始)] +``` + +示例 + +```text +名称1=ac5_Assist1=;=0 +名称2=ac5_Assist1=;=1 +名称3=ac5_Assist1=;=2 +日期=ac5_riqi +文本1=写入首选项配置的内容 +``` + +## 8. 工序编制特殊文本树 + +> 首选项,单值,配置文件夹uid,文件夹内放置保存特殊文本的excel表格,加载后按sheet页的名称分标签显示 +> +> Connor_AVIC_GXBZ_Common_Folder: 配置通用文件夹或Excel的uid +> +> Connor_AVIC_GXBZ_Personal_Folder:配置个人文件夹或Excel的uid + +Excel 格式说明 + +> 从左上角开始写入内容,单元格排列保持树形即可,注意不要在内容之间插入空列 + +真实值说明:真实值有多种配置方式 + +> 1. 在真实值单元格内容前加“#RV#” +> +> 2. 在配置的uid后添加“#RealValue#列号”,配置后,对应文件夹内所有excel或指定uid的excel的对应列作为真实值列 + + +## 9. 工序编制表格 + +> 首选项,多值,格式见下方说明 +> +> Connor_AVIC_GXBZ_Bomline: 配置界面上方的表格 +> +> Connor_AVIC_GXBZ_[对象类型]: 配置界面下方的表格,对象类型是选择bom行对应item的真实类型名称 + +首选项格式说明: + +> 第一行配置:指定的对象类型 +> +> 指定对象类型后,该表格只加载指定类型的子行,如存在新建功能,则使用该类型新建对象 +> +> 如不需要指定类型,首行需配置"bomline",此表格仅支持读取和修改bom行属性 + +> 第二行开始配置属性映射 +> +> 格式:[列宽][$每行最大字符数量][属性位置.]属性真实名称[=属性值(按该值进行过滤)] +> +> 列宽:选配,直接在前面加数字 +> +> 每行最大字符数量:手动输入时,如果某行超过此数量则自动添加换行符 +> +> 属性位置:如不写即默认bomline属性(位置包含:bomline, item, rev, itemmaster, revmaster) +> +> 属性真实名称:定义的属性名称,如要支持换行,请务必配置“bl_sequence_no”属性 +> +> 属性值:配置后,只显示属性匹配的行(如配置指定的事例类型) +> +> revmaster.ac5_WorkstepNumber 属性进行特殊处理 + +20210119更新: 下方表格支持GDT编辑器,属性名称配置到GDT_properties首选项即可 + +示例 + +```text +bomline +bl_indented_title +bl_occ_type=MEAssemble +200bl_item_object_name +``` + +```text +Item +bomline.bl_sequence_no +bomline.bl_indented_title +150item.object_name +``` + +## 10. 工序编制表单属性 + +> 首选项:Connor_AVIC_GXBZ_[对象类型] +> +> 多值,格式:[\*]属性真实名称[=下拉值1;下拉值2;下拉值3] +> +> \*:表示属性在版本上,不添加\*表示属性在版本表单 +> +> 下拉值:配置后,若属性上未定义下拉值,则变更属性控件为下拉框,下拉内容为分号分隔后的配置内容;若定义下拉值,以bmide中定义的lov为准。 + +示例 + +```text +object_name +*object_name=名称1;名称2;名称3 +object_type +creation_date +``` + +## 11. 工序编制 TC兼容性 + +> 由于工序编制界面基于javafx开发,TC的文本检测未进行兼容,所以在文本框中进行复制粘贴和剪切时存在问题。 +> +> 需要修改 com.teamcenter.rac.common.xxxx.jar 中的 plugin.xml + +```xml + + + + + + + + + + +``` + +修改为 + +```xml + + + + + + + + + + + + + + + +``` + +## 12. 配置工道对象类型 + +> 配置首选项:Connor_AVIC_GDItem_Types,多值,配置工道对象的类型 + +## 13. 工艺卡片导出首选项(废除) + +> 配置首选项中的类型使用“[选中工序行所在工艺的制造目标的版本类型”,配置见下方[Word报表通用配置](#Word报表通用配置) + +```text +零部件列表:Connor_AVIC_GYKPSC_LBJLB_[类型] +工艺卡片:Connor_AVIC_GYKPSC_GYKP_[类型] +关键工序:Connor_AVIC_GYKPSC_GJGX_[类型] +工艺附图:Connor_AVIC_GYKPSC_GYFT_[类型] +工道附图:Connor_AVIC_GYKPSC_GDFT_[类型] +``` + +## 13.1 工艺卡片导出首选项(改) + +> 配置目录首选项:Connor_AVIC_GYKPSC_CATE_[选择的工序版本类型名称] +> +> 配置导出工艺卡片的结构,多值,配置首选项名称的前缀,导出时使用“前缀+制造目标的版本类型名称”找到配置首选项 +> +> 第一行配置零部件列表首选项名称的的前缀, +> +> 第二行开始配置其他页首选项名称的前缀,开头加“GD#”表示该行是工道下导出数据集的配置;开头加“KEY#”表示该行是关键工序页的配置,如果是关键工序,则导出此页。 + +示例 + +```text +Connor_AVIC_GYKPSC_LBJLB_ +Connor_AVIC_GYKPSC_GYKP_ +KEY#Connor_AVIC_GYKPSC_GJGX_ +Connor_AVIC_GYKPSC_GYFT_ +GD#Connor_AVIC_GYKPSC_GDFT_ +Connor_Other_Page1_ +Connor_Other_Page2_ +Connor_Other_Page3_ +Connor_Other_Page4_ +Connor_Other_Page5_ +Connor_Other_Page6_ +Connor_Other_Page7_ +Connor_Other_Page8_ +Connor_Other_Page9_ +Connor_Other_Page10_ +``` + +## 14. 工艺规程导出首选项(废除) + +> 配置首选项中的类型使用“[选中工艺的制造目标的版本类型”,配置见下方[Word报表通用配置](#Word报表通用配置) + +```text +工艺规程:Connor_AVIC_GYKPSC_GYGC_[类型] +工艺签署:Connor_AVIC_GYKPSC_GYQSKP_[类型] +辅料清单:Connor_AVIC_GYKPSC_FLQD_[类型] +工艺程序:Connor_AVIC_GYKPSC_GYCXKP_[类型] +``` + +## 14.1 工艺规程导出首选项(改) + +> 配置目录首选项:Connor_AVIC_GYGCSC_CATE_[选择的工艺版本类型名称] +> +> 配置导出工艺规程的结构,多值,配置首选项名称的前缀,导出时使用“前缀+制造目标的版本类型名称”找到配置首选项 +> +> 第一行配置分类辅料页首选项名称的前缀 +> +> 第二行配置工艺签署页首选项名称的前缀 +> +> 第三行开始配置其他页首选项名称的前缀 + +示例 + +```text +Connor_AVIC_GYKPSC_FLQD_ +Connor_AVIC_GYKPSC_GYQSKP_ +Connor_AVIC_GYKPSC_GYGC_ +Connor_AVIC_GYKPSC_GYCXKP_ +Connor_Other_Page11_ +Connor_Other_Page12_ +Connor_Other_Page13_ +Connor_Other_Page14_ +Connor_Other_Page15_ +Connor_Other_Page16_ +Connor_Other_Page17_ +Connor_Other_Page18_ +Connor_Other_Page19_ +Connor_Other_Page20_ +``` + +## Word报表通用配置 + +> 该首选项可以引用其他以"Connor_"开头首选项,直接在第一行配置其他首选项的名称,就不需要配置其他内容了 + +```text +首行配置模板word数据集的uid,工艺卡片界面中显示的名称从该数据集的名称获取 +从第二行开始配置其他内容:格式“标识=配置内容” + +标识说明 +1. 特殊标识: + STARTROW:配置表格数据开始行号,从1开始计数 + ENDROW: 配置表格数据结束行号,从1开始计数 + TABLEINDEX:配置填写模板中第几个表格,从1开始计数,默认1 + PICWIDTH:配置图片宽度,默认200 + PICHEIGHT:配置图片高度,默认200 + IMAGE: 配置图片(或excel)书签名称,配置后按附图模板处理,不输出子行数据 + CHECKIMAGE: + 配置图片为对应宽度和高度,则替换模板为另一个数据集,多个用英文分号分隔,取第一个匹配的数据集插入,格式“CHECKIMAGE=宽度|高度|模板数据集uid|插入word宽度|插入word高度” + 配置图片,如果数据集名称包含指定文本,则替换模板为另一个数据集,多个用英文分号分隔,取第一个匹配的数据集插入,格式“CHECKIMAGE=数据集名称中包含的值|模板数据集uid|插入word宽度|插入word高度” + 配置excel工作表名称对应模板,多个用英文分号分隔,格式“工作表名称包含文本|模板数据集uid” + LINEGAP:制定表格行数据之间的空行数量,默认0 +2. 文本域标识:配置文本域的名称 +3. 表格的标识:配置列号,从1开始计数 + +配置内容说明 +1. 格式:属性位置.属性名称[.默认值或NAME] +2. 如果需要拼接使用“+”连接,可连接固定文本(注意固定文本应避免出现属性定义的格式) +3. 属性位置包含: + bomline, item, rev, itemmaster, revmaster:分别对应bom行,对象,版本,对象表单,版本表单(如果是表格的行数据,主体对象是非工道子行;否则主体是当前行) + pbomline, pitem, prev, pitemmaster, prevmaster:分别对应bom行,对象,版本,对象表单,版本表单(主体对象是当前行的父行) + mitem, mrev, mitemmaster, mrevmaster:分别对应制造目标的对象,版本,对象表单,版本表单(主体对象是制造目标) + bomline2, item2, rev2, itemmaster2, revmaster2:分别对应bom行,对象,版本,对象表单,版本表单(仅用于表格中的行数据,主体对象是工道子行) +4. 配置“linenum”,对表格行从1开始计数 +5. 如果要取子行的子行中的数据,配置“#目标行对象的类型.目标行的bom行属性名称” +6. 配置默认值后,如果属性值为空,则取配置的默认值,默认值对提取父行、祖父行、子行属性时不生效 +7. 配置“属性位置.属性名称.NAME”时,读取属性显示名称 + +页码和页数:自动填写,表示合并前的页码和页数,在word中设置域名“页码”和“页数”即可 + +汇总页数:自动填写,表示合并后的页数,在word中设置域名“总页数”或“总页数减一” + +汇总页码:自动填写,表示合并后的页码,在word中设置域名“总页码”或“总页码减一” + +汇总实际页数:自动填写,表示合并后的word中的实际物理页数,在word中设置域名“总实际页数”或“总实际页数减一” + +图片:在需要插入图片的word模板中设置书签“图片” + +注:为了105项目配置方便,将【页码,总页码】【页数,总页数】功能进行对调 +``` + +示例 + +```text +wWX9SQz_5YkutB +startrow=6 +endrow=10 +image=图片 +checkimage=100|100|xxxxxxxuid +y4=bomline.object_string +y5=item.object_string +y6=制造目标=+mrev.object_string +y7=revmaster.object_string +1=linenum +2=item.item_id +3=item.object_name +6=工道属性示例:+bomline2.bl_indented_title +7=主要设备示例:+Ac5_MainDevice.bl_item_object_name +``` + +【备用配置,目前不需要,请忽略】LINEDATA标识的特别说明: +格式:“属性位置.关系名称1|关系名称1下查找的子对象类型1.关系名称2|关系名称2下查找的子对象类型2.关系名称3|关系名称3下查找的子对象类型3 +如果子对象类型存在多个,用英文分号分隔;如果取所有类型,子对象类型填“*”。 +bom装配关系,和bom行类型都用“bomline”标识。 + +## Word报表通用配置更改 + +20200814: + +```text +1. 增加特殊标识: + FILTERTYPE:按类型过滤子行,配置需要导出子行对象的类型名称,多个用英文逗号分隔,示例:“FILTERTYPE=MEOP;Item” + READGRANDCHILD:是否需要读取子行的子行中的数据。配置“READGRANDCHILD=true”后,数据会被加载,其属性位置用cbomline, citem, crev, citemmaster, crevmaster标识 + GRANDCHILDTYPE:按类型过滤子行的子行,配置子行的子行对象的类型名称,多个用英文逗号分隔,示例:“GRANDCHILDTYPE=MEOP;Item” + WRAPLINE:配置自动换行,格式“WRAPLINE=列号1=最大长度1;列号2=最大长度2”,示例:“WRAPLINE=4=15;9=10” +2. 关于“加载子行的子行”的特别说明 + 特殊配置:如果需要读取cbomline父行或祖父行的某个bom行属性,配置“parent.父行属性名称”或“grandparent.祖父行属性名称”。 + 数据加载后,在表格中,可提取的对象按表格行排列如下 + excel行1:子行1,子行1的子行1 + excel行2:子行1的子行2 (这一行的数据中已经没有子行,无法再通过bomline, item, rev等获取子行数据,可以配置“parent.父行属性名称”获取数据 + excel行3:子行1的子行3 + excel行4:如果配置隔行,这里没有数据可以取 + excel行5:子行2,子行2的子行1 + excel行6:子行2的子行2 + excel行7:子行2的子行3 +3. 提取bomline下数据集的页数:“列号=pagecount.数据集名称的前缀”。示例:“5=pagecount.工艺卡片_” +4. 如果要取子行的子行中的数据,配置“#目标行对象的类型.目标行的bom行属性名称”,示例:“#设备对象类型.bl_item_object_name” +5. 按子行类型重排的功能已弃用,不要配置属性位置( bomline2, item2, rev2, itemmaster2, revmaster2) + 类型过滤请通过FILTERTYPE配置 +6. 插入页保持原格式:在模板文件的开始和末尾插入“页面布局-分隔符-连续” +``` + +20200819 + +```text +1. 增加特殊标识: + MOVETOTOP:配置列数据向上移动至非空行,格式“MOVETOTOP=列号1;列号2”,示例:“MOVETOTOP=5;6;7;8;9” + 详细说明:对单独一列的数据进行重排,假设配置了列A,如果某行A列数据不为空,且此行上方的行A列数据为空,则移除此行中A列的数据,填写到上方A列为空的行中。 + 查找空行范围为从上一行开始,向上找到空数据行为止(目前空数据行只有配置的隔行) + 注意配置的列中不要配置自动换行WRAPLINE +``` + +20200922 + +```text +1. 增加特殊标识 + SPLITLINE:配置按字符分隔行,格式“SPLITLINE=列号1=分隔字符1$;列号2=分隔字符2”,多个配置之间用“$;”分隔,示例:“WRAPLINE=4=;$;9=10” + REWRITELINENUM:配置重写行号,格式“REWRITELINENUM=标识列;行号列”,标识列的数据以“#LN”开头时,在行号列填写新的行号 + READGRANDCHILDASTARGET:将通过READGRANDCHILD和GRANDCHILDTYPE配置得到的子行的子行作为表格中每行的主体,相同的对象不重复添加,作为主体后,属性位置不需要配置c开头 + 增加属性位置“sp”:配置READGRANDCHILDASTARGET后,用于读取与子行的子行所关联的父行的版本表单属性 +``` + +20201029 + +```text +1. 增加特殊标识 + 格式:ADDPAGECOUNTFROMMEOP=数据集名称前缀 + 功能:导出当前模板时,从子行中105工序类型版本的规范关系下,找到以配置的“数据集名称前缀”为前缀的最新word数据集,将其页数加到总页数 +``` + +20201030 + +```text +1. 在行数据的第一行增加顶层信息,在原来的属性位置前加“T”,如“TBOMLINE.bl_item_object_name” +2. 可以通过“pline.父行属性名称”读取属性位置bomline的父行的属性 +``` + +20201203 + +```text +1. 提取属性配置支持表格属性:格式“属性位置.表格属性名称-表格行属性名称[-连接符]”。连接符默认为“#ROW#”,用于连接多行的值 +2. 提取子行某个类型的属性:格式“#子行对象类型1|子行对象类型2|子行对象类型3#属性位置.属性名称”,示例:“#设备对象类型#revmaster.object_name” +``` + +20201228 + +```text +1. 新增首选项:Connor_AVIC_WORD_Protect,单值,配置word导出功能生成的word密码。 +``` + +20210112 + +```text +1. 所有模板中的文本域可以使用书签替换 +``` + +20210413 + +```text +工序附表首选项:Connor_AVIC_GYKPSC_CATE_A3_工序版本类型名称,Connor_AVIC_GYKPSC_CATE_A4_工序版本类型名称 + +新增配置:APPENDFILE=数据集名称[;表格页码行号;表格页码列号;表格页数行号;表格页数列号] +功能:导出当前模板时,从导出行版本的规范关系下,找到包含配置文本的word数据集,将其附加到导出文件末尾,并填充页码和页数,页数取该文件的实际页数 +页码页数替换规则: +1. 未配置表格位置时,按查找顺序替换word中的文本“第 页”“共 页”,中间为两个半角空格 +2. 配置表格位置时,按表格顺序替换word中每个表格对应位置的文本 + +更改配置:工序附表和工艺卡片使用相同代码运行,工序附表功能将目录首选项第一行更改为导出数据集名称配置 +数据集名称格式:用+拼接选择的对象版本的“属性位置.属性名称”或其他固定文本,末尾可用“:”连接导出文件日期后缀,如“ITEM.item_id+工序附表A3:_yyyy_MM_dd” + +附加图片时从3D快照提取Image文件 +``` + +20210527 + +```text +1. CHECKIMAGE: + 配置图片为对应宽度和高度,则替换模板为另一个数据集,多个用英文分号分隔,取第一个匹配的数据集插入,格式“CHECKIMAGE=宽度|高度|模板数据集uid|插入word宽度|插入word高度” + 配置图片,如果数据集名称包含指定文本,则替换模板为另一个数据集,多个用英文分号分隔,取第一个匹配的数据集插入,格式“CHECKIMAGE=数据集名称中包含的值|模板数据集uid|插入word宽度|插入word高度” + 配置excel工作表名称对应模板,多个用英文分号分隔,格式“工作表名称包含文本|模板数据集uid” + +2. 提取关系下某类型对象的属性 +格式:属性位置.关系属性名称.关系下的子对象类型.子对象属性名称[-连接符] +取所有类型:关系下的子对象类型配置“*” +连接符默认为英文分号 +示例:rev.IMAN_specification.*.object_name-; + +3. 替换属性值 +在属性提取配置后添加“:”,冒号后是替换配置,多个替换用英文分号分隔 +格式:属性位置.属性名称:被替换值1=替换值1;被替换值2=替换值2 +示例:rev.object_desc:每个=个 +``` + +20210602 + +```text +1. 在图片页写入图片数据集名称:配置域或书签名称为“图片的书签名_Name” + +``` + +20210604 + +```text +1. 换行分隔符更改,原“\n”建议改为“\r\n|\r|\n” +2. 计算bom行出现的数量,属性格式:“quantity.随便写”,在属性位置的地方写“quantity”,属性名称的位置不使用,仅作为格式的占位,示例:“3=quantity.xxx” +``` + +20210608 + +```text +1. MOVETOTOP配置增加格式“MOVETOTOP=移动到顶部的列1=[跟随列1移动的列a,跟随列1移动的列2];移动到顶部的列2” +示例:MOVETOTOP=4=5;2 +示例说明:将第四列和第二列按原逻辑移动到顶部,但是在移动第四列的时候,第五列的数据跟随第四列一起移动 +``` + +20211206 + +```text +1. 替换属性值扩展 +扩展配置:在属性提取配置后添加“:”,冒号后格式“EXCEL-excel数据集uid-列号1-列号2”,列号从零开始,功能是将列1的值替换为列2的值 +格式:属性位置.属性名称:EXCEL-excel数据集uid-列号1-列号2 +示例:rev.object_desc:EXCEL-xxxxxxx-0-2 +``` + +## 15 截图 + +> 配置首选项:Connor_ScreenShot_Command,单值,配置截图工具路径 + +示例: + +```text +D:\Siemens\Teamcenter12\portal\plugins\SogouSnapShot.exe +``` + +## 16 材料试件编辑 + +> 首选项名称为 “Connor_AVIC_CLSJBJ_版本类型名称” + +```text +格式:“[*][#]标题名称=写入属性配置[=提取属性配置[=下拉内容1;下拉内容2;下拉内容3]]” +*:必填 +#:不可编辑 +属性配置格式:属性位置.属性名称(属性位置包含 item, rev, itemmaster, revmaster) +对齐:在标题名称中加入适量空格进行对齐 +标题换行:第一行
第二行 + +特殊配置: +#TITLE=窗口标题 +#SIZE=窗口宽度,窗口高度 +#COLUME=属性列数量 +#INFO=修改完成的提示内容 +#DONT_CLOSE_DIALOG (添加此行则在修改完成后不关闭窗口) +``` + +示例 + +```text +#物料编码: =item.item_id +物料名称: =item.object_name +Assist1=revmaster.ac5_Assist1 +Assist2
第二行=revmaster.ac5_Assist2 +*keypro=revmaster.ac5_KeyProOrNot +数量=bomline.bl_quantity +#TITLE=材料定额 +#SIZE=800,300 +#COLUME=3 +#INFO=修改成功了 +#DONT_CLOSE_DIALOG +``` + +## 16.1 材料试件编辑特殊配置 + +> 首选项名称为 “Connor_AVIC_CLSJBJ_版本类型名称_plus” + +```text +1. 设置仅能输入数字,格式:“NUMBER=标题名称1;标题名称2;标题名称3” +2. 设置多个属性输入时,在其中一个属性填写值后,禁用其他非空属性控件,格式:“SELECT=标题名称1;标题名称2;标题名称3” +3. 设置通过一个控件的值控制其他控件是否可编辑,格式:“SWITCH=控制者标题名称=值1:被控制者标题名称1;!被控制者标题名称2|值2:被控制者标题名称” +用“|”分隔不同值的配置,用“;”分割对应值控制的控件标题名称 +被控制者标题名称前加“!”表示设置为不可编辑 +当控制者对应控件的值发生变化时,先将该行首选项所有涉及的被控制者设置为可编辑,再根据变化后的值,设置被控制者是否可编辑 +支持所有类型控件(文本框,下拉框),注意标题名称是否有符号 +``` + +示例: + +```text +NUMBER=Assist1 +NUMBER=Assist2 +SELECT=Assist1;Assist2;数量;keypro +``` + +## 17 在AD中打开文件 + +> 配置首选项:Connor_AVIC_OpenInAD,多值 + +```text +第一行:配置目标文件夹路径 +第二行开始配置其他内容 + +1. 数据集路径。格式:“对象1和选择工程版本的关系:对象1的类型:数据集和对象1版本的关系:数据集的后缀:工程版本表单中记录对象1版本号的属性名称” +2. 子文件夹名称。格式:“FOLDER=数据集和选择工程版本的关系:数据集的后缀”,子文件夹的名称取数据集的名称 +3. 打开文件。格式:“OPEN=打开的文件后缀1:打开的文件后缀2” +4. 注意以上的分隔符都是英文冒号 +``` + +示例 + +```text +C:\PCB_PROJECT +FOLDER=IMAN_specification:.PrjPCB +OPEN=PrjPCB:txt:docx +Ac5_EDADL_ref:原理图Item类型:IMAN_specification:数据集后缀:ac5_YLTRev +Ac5_Drawings_Irela:PCB对象类型:IMAN_specification:数据集后缀:ac5_PCBRev +``` + +配置右键菜单 + +> 打开jar包中的plugin.xml文件,将value="ItemRevision"中的ItemRevision修改为需要显示菜单的类型,多个类型可以用英文逗号分隔 + +```xml + + + + + + + + + + + + + + +``` + +## 18. 工艺分工 + +1. 首选项:Connor_AVIC_GYFGPZ_LXSX,多值,格式:"[产品/组部件/零件:]对象类型真实名称" +2. 首选项:Connor_AVIC_GYFGPZ_SXPZ,多值,格式:"表头名称=属性位置.属性名称",属性位置包含:item,rev,itemmaster,revmaster,bomline,工艺属性位置前加'M' +3. 首选项:Connor_AVIC_GYFGPZ_HANDLE,单值,配置handler名称“CONNOR-check-form-attribute”,handler名称配置在任务开始节点 +4. 首选项:Connor_AVIC_GYFGPZ_WORKFLOW,单值,配置正式分工的工作流程模板名称 + +## 19. 工序号表格 + +1. 首选项:Connor_AVIC_SQGXH_GXLX,多值,配置工序对象类型真实名称 +2. 首选项:Connor_AVIC_SQGXH_SXBJ,多值,格式:"表头名称=属性位置.属性名称",属性位置包含:item,rev,itemmaster,revmaster,bomline + +## 20. 流程名称提取 + +首选项 Connor_CopyWorkflowName,多值,格式:"选择的对象类型名称=提取属性拼接配置" + +提取属性拼接配置: + +```text +单属性配置:直接配置所选类型的属性名称 +引用或关系属性:配置"关系属性名称.引用对象属性名称",引用可以嵌套,如从版本获取对象所有者的id"items_tag.owning_user.user_id" +固定内容:直接配置内容(不能配置加号) +以上配置可以用加号连接"items_tag.item_id+/+item_revision_id" +``` + +特殊配置: + +```text +提取uid:配置属性名称为"uid",提取关系下对象的uid示例"items_tag.uid" +属性显示值:属性名称前加一个"#",如果是引用属性,则在最后一个属性名称前加"#" +``` + +示例: + +```text +Folder=object_name+_[+contents+] +ItemRevision=items_tag.item_id+/+item_revision_id+:+IMAN_master_form_rev.object_string +``` + +## 21. 通过产品查询特殊过程 + +首选项 CONNOR_AVIC_TSGC_Export,多值 + +格式: + +```text +第一行配置导出文件名称,可以包含日期格式(当配置日期格式时,文件名不能包含后缀或其他字母) +第二行开始配置属性映射,格式“表头名称=属性位置.属性名称” +属性位置包含: +item, rev, itemmaster, revmaster 对应特殊过程的对象、版本、对象表单、版本表单 +gitem, grev, gitemmaster, grevmaster 对应工艺的对象、版本、对象表单、版本表单 +pitem, prev, pitemmaster, prevmaster 对应工序的对象、版本、对象表单、版本表单 +mitem, mrev, mitemmaster, mrevmaster 对应制造目标的对象、版本、对象表单、版本表单 + +特殊映射:“表头名称=index”,填写序号 +``` + +## 22. 特殊过程被引用情况 + +首选项 CONNOR_AVIC_TSGC_Ref_Export,多值 + +格式: + +```text +同 CONNOR_AVIC_TSGC_Export +``` + +## 23. 生成过程记录卡 + +首选项1 CONNOR_AVIC_GCJLK_Query,多值,配置数据库连接和查询语句 + +格式: + +```text +第一行配置数据库连接 +第二行配置数据库登录用户 +第三行配置数据库登录密码 +第四行及之后的所有行为查询语句(即可以拆分成多行配置) +``` + +查询语句要求: + +```text +查询结果仅需要三列,分别对应界面中的订单编号、数量、是否首件鉴定 +查询条件为1个,对应对象ID,填写对应值的地方用“?”代替 +``` + +示例: + +```text +jdbc:oracle:thin:@127.0.0.1:1521:TC12 +infodba +infodba +select +a.DocNo as MODocNo, +a.ProductQty, +(case a.DescFlexField_PrivateDescSeg23 +when 10 then '是' +when 20 then '否' +end) as isFirstIdentify2 +from MO_MO a +inner join CBO_ItemMaster b on a.ItemMaster=b.ID +where b.Code=? and a.DocState='2' and a.Cancel_Canceled=0 and a.IsHoldRelease=0 +``` + +首选项2 CONNOR_AVIC_GCJLK_Export,多值 + +格式: + +```text +配置方式和工艺卡片导出方式相同,非列属性部分有工艺行和制造目标,列属性部分为工序 +需要的特殊配置: +订单编号、数量、是否首件鉴定,这三个界面中查询到的值以书签的形式插入到模板中,书签的名称和界面中列名相同 +导出时自动填写到书签的位置 +``` \ No newline at end of file diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..9e821c1 --- /dev/null +++ b/build.properties @@ -0,0 +1,14 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + lib/zip4j-1.3.2.jar,\ + lib/commons-compress-1.20.jar,\ + lib/xz-1.8.jar,\ + lib/ojdbc6.jar,\ + jars.compile.order = .,\ + lib/ojdbc6.jar,\ + lib/groovy-all-2.4.7.jar,\ + icons/ +source.lib/ojdbc6.jar = src/ diff --git a/icons/add_24px.png b/icons/add_24px.png new file mode 100644 index 0000000..34c2886 Binary files /dev/null and b/icons/add_24px.png differ diff --git a/icons/delete_24px.png b/icons/delete_24px.png new file mode 100644 index 0000000..5e33b13 Binary files /dev/null and b/icons/delete_24px.png differ diff --git a/icons/down_24px.png b/icons/down_24px.png new file mode 100644 index 0000000..5188b82 Binary files /dev/null and b/icons/down_24px.png differ diff --git a/icons/edit16.png b/icons/edit16.png new file mode 100644 index 0000000..a743326 Binary files /dev/null and b/icons/edit16.png differ diff --git a/icons/folder_24.png b/icons/folder_24.png new file mode 100644 index 0000000..8b04344 Binary files /dev/null and b/icons/folder_24.png differ diff --git a/icons/meoperation_16.png b/icons/meoperation_16.png new file mode 100644 index 0000000..d31bd13 Binary files /dev/null and b/icons/meoperation_16.png differ diff --git a/icons/meprocess_16.png b/icons/meprocess_16.png new file mode 100644 index 0000000..125f218 Binary files /dev/null and b/icons/meprocess_16.png differ diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/icons/search_24px.png b/icons/search_24px.png new file mode 100644 index 0000000..e1e45a7 Binary files /dev/null and b/icons/search_24px.png differ diff --git a/icons/text.png b/icons/text.png new file mode 100644 index 0000000..24a206b Binary files /dev/null and b/icons/text.png differ diff --git a/icons/up_24px.png b/icons/up_24px.png new file mode 100644 index 0000000..94e9cc8 Binary files /dev/null and b/icons/up_24px.png differ diff --git a/lib/commons-compress-1.20.jar b/lib/commons-compress-1.20.jar new file mode 100644 index 0000000..17c1c7b Binary files /dev/null and b/lib/commons-compress-1.20.jar differ diff --git a/lib/dom4j-1.6.1.jar b/lib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/lib/dom4j-1.6.1.jar differ diff --git a/lib/groovy-all-2.4.7.jar b/lib/groovy-all-2.4.7.jar new file mode 100644 index 0000000..1d92acc Binary files /dev/null and b/lib/groovy-all-2.4.7.jar differ diff --git a/lib/ojdbc6.jar b/lib/ojdbc6.jar new file mode 100644 index 0000000..aacbd97 Binary files /dev/null and b/lib/ojdbc6.jar differ diff --git a/lib/xz-1.8.jar b/lib/xz-1.8.jar new file mode 100644 index 0000000..9931efa Binary files /dev/null and b/lib/xz-1.8.jar differ diff --git a/lib/zip4j-1.3.2.jar b/lib/zip4j-1.3.2.jar new file mode 100644 index 0000000..dcdf85e Binary files /dev/null and b/lib/zip4j-1.3.2.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..9bb8b4c --- /dev/null +++ b/plugin.xml @@ -0,0 +1,589 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugin_backup_20211228.xml b/plugin_backup_20211228.xml new file mode 100644 index 0000000..682accb --- /dev/null +++ b/plugin_backup_20211228.xml @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/cn/net/connor/process/Activator.java b/src/cn/net/connor/process/Activator.java new file mode 100644 index 0000000..4f2e966 --- /dev/null +++ b/src/cn/net/connor/process/Activator.java @@ -0,0 +1,44 @@ +package cn.net.connor.process; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cn.net.connor.process"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/src/cn/net/connor/process/KLocalizer.java b/src/cn/net/connor/process/KLocalizer.java new file mode 100644 index 0000000..3015da6 --- /dev/null +++ b/src/cn/net/connor/process/KLocalizer.java @@ -0,0 +1,191 @@ +package cn.net.connor.process; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.util.Properties; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +@SuppressWarnings("serial") +public class KLocalizer extends JFrame{ + + private JTextField tf_key; + private JTextField tf_en; + private JTextField tf_cn; + private JButton b_add; + private JLabel l_info; + private JButton b_close; + + public static void main(String[] args) { + new KLocalizer().initUI(); + } + + public void initUI() { + this.setTitle("国际化"); + this.setMinimumSize(new Dimension(400,270)); + this.setPreferredSize(new Dimension(400,270)); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER,initCenterPanel()); + this.add(BorderLayout.SOUTH,initBtnPanel()); + addListeners(); + pack(); + this.setLocationRelativeTo(null); + this.setAlwaysOnTop(true); + setVisible(true); + } + + private void addListeners() { + b_add.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + addLocaleInfo(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + this.b_close.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + } + + protected void addLocaleInfo() throws Exception{ + this.l_info.setText(""); + String key = this.tf_key.getText(); + String en = this.tf_en.getText(); + String cn = this.tf_cn.getText(); + Package p = this.getClass().getPackage(); + String path = "src/"+p.getName().replace('.', '/'); + System.out.println("PATH: "+path); + int index = path.lastIndexOf('/'); + if(index<=0) { + this.l_info.setText("类路径不正确"); + return; + } + String title = path.substring(index+1); + String enFile = path+"/"+title+"_locale.properties"; + String cnFile = path+"/"+title+"_locale_zh_CN.properties"; + System.out.println("TITLE: "+title); + if(title.length()>0) { + String code = title.substring(0,1).toUpperCase()+title.substring(1)+"Locale.getString(\""+key+"\")"; + System.out.println("PASTE: "+code); + StringSelection selection = new StringSelection(code); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + } + File file = new File(enFile); + if(!file.exists()) { + file.createNewFile(); + } + file = new File(cnFile); + if(!file.exists()) { + file.createNewFile(); + } + //System.out.println("英文路径:"+enFile); + //System.out.println("中文路径:"+cnFile); + Properties enProps = new Properties(); + enProps.load(new FileReader(enFile)); + Properties cnProps = new Properties(); + cnProps.load(new FileReader(cnFile)); + if(enProps.containsKey(key)||cnProps.containsKey(key)) { + this.l_info.setText("关键字“"+key+"”已存在"); + System.out.println(title.substring(0,1).toUpperCase()+title.substring(1)+"Locale.getString(\""+key+"\")"); + return; + } + if(isEmpty(key)||isEmpty(en)||isEmpty(cn)) { + this.l_info.setText("请填写完整信息"); + return; + } + System.out.println("英文:"+key+"="+en); + System.out.println("中文:"+key+"="+cn); + enProps.setProperty(key, en); + cnProps.setProperty(key, cn); + FileOutputStream enos; + enProps.store(enos = new FileOutputStream(enFile), ""); + FileOutputStream cnos; + cnProps.store(cnos = new FileOutputStream(cnFile), ""); + enos.flush(); + enos.close(); + cnos.flush(); + cnos.close(); + this.l_info.setText("写入成功"); + tf_key.setText(""); + tf_en.setText(""); + tf_cn.setText(""); + } + + private JPanel initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER,15,5)); + panel.add(this.b_add = new JButton(" 添加 ")); + panel.add(this.b_close = new JButton(" 关闭 ")); + return panel; + } + + private JPanel initCenterPanel() { + JPanel panel = new JPanel(new GridBagLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(0,30,0,25)); + GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 0, 4, 5), 0, 0); + newRow(panel, new JLabel("关键字: "), s, 1); + addCol(panel, this.tf_key = new JTextField(), s, 1, 1); + newRow(panel, new JLabel("英文: "), s, 1); + addCol(panel, this.tf_en = new JTextField(), s, 1, 1); + newRow(panel, new JLabel("中文: "), s, 1); + addCol(panel, this.tf_cn = new JTextField(), s, 1, 1); + this.l_info = new JLabel(); + this.l_info.setForeground(Color.RED); + this.l_info.setPreferredSize(new Dimension(100,50)); + newRow(panel, l_info, s, 2); + return panel; + } + + public static boolean isEmpty(String str) { + return str==null||"".equals(str.trim()); + } + + @Override + protected void processWindowEvent(WindowEvent e) { + if(e.getID()==WindowEvent.WINDOW_CLOSING) { + dispose(); + } + super.processWindowEvent(e); + } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { + s.weightx = 0; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void addCol(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.gridx++; + s.gridwidth = width; + s.weightx = weightx; + panel.add(comp, s); + } +} diff --git a/src/cn/net/connor/process/ProcessLocale.java b/src/cn/net/connor/process/ProcessLocale.java new file mode 100644 index 0000000..316fea3 --- /dev/null +++ b/src/cn/net/connor/process/ProcessLocale.java @@ -0,0 +1,22 @@ +package cn.net.connor.process; + +import com.teamcenter.rac.util.Registry; + + +public class ProcessLocale { + + public static final Registry reg = Registry.getRegistry(ProcessLocale.class); + + public static String getString(String title) { + if (isEmpty(title)) { + return ""; + } else { + String res = reg.getString(title); + return isEmpty(res) ? title : res; + } + } + + private static boolean isEmpty(String title) { + return title == null || "".equals(title.trim()); + } +} diff --git a/src/cn/net/connor/process/ProcessUtil.java b/src/cn/net/connor/process/ProcessUtil.java new file mode 100644 index 0000000..a1994a8 --- /dev/null +++ b/src/cn/net/connor/process/ProcessUtil.java @@ -0,0 +1,25 @@ +package cn.net.connor.process; + +import k.util.KUtil; + +public class ProcessUtil { + + public static final String PREF_MEOP_ITEMTYPE = "Connor_AVIC_MEOP_Types"; + public static final String PREF_MEPROCESS_ITEMTYPE = "Connor_AVIC_MEProcess_Types"; + + public static boolean isMEOP(String itemTypeName) throws Exception{ + if(KUtil.isEmpty(itemTypeName)) { + return false; + } + String[] types = KUtil.getPrefVals(KUtil.session, PREF_MEOP_ITEMTYPE); + return KUtil.inArray(itemTypeName, types)>=0; + } + + public static boolean isMEProcess(String itemTypeName) throws Exception{ + if(KUtil.isEmpty(itemTypeName)) { + return false; + } + String[] types = KUtil.getPrefVals(KUtil.session, PREF_MEPROCESS_ITEMTYPE); + return KUtil.inArray(itemTypeName, types)>=0; + } +} diff --git a/src/cn/net/connor/process/Processknowledgebase/CustomLovBean.java b/src/cn/net/connor/process/Processknowledgebase/CustomLovBean.java new file mode 100644 index 0000000..cd10cfb --- /dev/null +++ b/src/cn/net/connor/process/Processknowledgebase/CustomLovBean.java @@ -0,0 +1,38 @@ +package cn.net.connor.process.Processknowledgebase; + +import java.util.ArrayList; +import java.util.List; + +public class CustomLovBean { + private java.util.List sub = new ArrayList(); + public String displayName = ""; + + public CustomLovBean(String displayName) { + super(); + this.displayName = displayName; + } + + public CustomLovBean(String displayName, String[] subArray) { + super(); + this.displayName = displayName; + translateArrayToSub(subArray); + } + + public void translateArrayToSub(String[] subArray) { + for (int i = 0; i < subArray.length; i++) { + sub.add(new CustomLovBean(subArray[i])); + } + } + + public java.util.List getSub() { + return sub; + } + + public boolean hasChild() { + return sub.size() != 0; + } + + public void addSub(CustomLovBean clb) { + sub.add(clb); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/process/Processknowledgebase/SJJHAction.java b/src/cn/net/connor/process/Processknowledgebase/SJJHAction.java new file mode 100644 index 0000000..ff56024 --- /dev/null +++ b/src/cn/net/connor/process/Processknowledgebase/SJJHAction.java @@ -0,0 +1,37 @@ +package cn.net.connor.process.Processknowledgebase; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.Instancer; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.process.hourcalculation.FitterCommand; +import cn.net.connor.process.hourcalculation.hourCCommand; + +public class SJJHAction extends AbstractAIFAction { + private InterfaceAIFComponent comp; + private TCSession session; + public SJJHAction(AbstractAIFApplication app, InterfaceAIFComponent comp,String s,TCSession session) { + super(app,s); + this.comp=comp; + this.session=session; + } + + @Override + public void run() { +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// session = (TCSession) app.getSession(); + //SJJHCommand Command=new SJJHCommand(); + //new hourCCommand(session); + //new FitterCommand(session); + try { + //Command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/cn/net/connor/process/Processknowledgebase/SJJHCommand.java b/src/cn/net/connor/process/Processknowledgebase/SJJHCommand.java new file mode 100644 index 0000000..8c99151 --- /dev/null +++ b/src/cn/net/connor/process/Processknowledgebase/SJJHCommand.java @@ -0,0 +1,142 @@ +package cn.net.connor.process.Processknowledgebase; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.imageio.ImageIO; +import javax.mail.Flags.Flag; +import javax.swing.JOptionPane; +import javax.xml.crypto.Data; + + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.tcservices.TcServicesService; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.process.meopviewfx.bean.KTableRow; +import cn.net.connor.process.meopviewfx.bean.PropConfig; +import javafx.scene.control.TableView; + + + +public class SJJHCommand extends AbstractAIFCommand { + + private TCComponentBOMLine comp; + private TCSession session; + private TableView table; + private List propConfigs; + public SJJHCommand(TCComponentBOMLine comp,TableView table,List propConfigs) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.propConfigs=propConfigs; + this.table=table; + try { + executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + CustomLovBean top=new CustomLovBean("չ"); +// CustomLovBean parent1=new CustomLovBean("1"); +// CustomLovBean parent11=new CustomLovBean("1111111111111111111111"); +// CustomLovBean parent12=new CustomLovBean("12"); +// CustomLovBean parent13=new CustomLovBean("13"); +// CustomLovBean parent2=new CustomLovBean("2"); +// CustomLovBean parent21=new CustomLovBean("21"); +// CustomLovBean parent22=new CustomLovBean("22"); +// CustomLovBean parent23=new CustomLovBean("23"); +// CustomLovBean parent3=new CustomLovBean("3"); +// CustomLovBean parent31=new CustomLovBean("31"); +// CustomLovBean parent32=new CustomLovBean("32"); +// CustomLovBean parent33=new CustomLovBean("33"); +// parent.addSub(parent1); +// parent1.addSub(parent11); +// parent1.addSub(parent12); +// parent1.addSub(parent13); +// +// parent.addSub(parent2); +// parent2.addSub(parent21); +// parent2.addSub(parent22); +// parent2.addSub(parent23); +// +// parent.addSub(parent3); +// parent3.addSub(parent31); +// parent3.addSub(parent32); +// parent3.addSub(parent33); + + + // Map parentMap=new HashMap();// + Map> PtoCMap=new HashMap>();// + // ȡݿ + SqlUtilT.getTCConnection(); + ResultSet rs = null; + String sql = String.format("select parent,child from TC_ProcessKnow_View"); + rs = SqlUtilT.read(sql); + while (rs.next()) { + String parent=rs.getString("parent"); + String child=rs.getString("child"); + CustomLovBean childLov=new CustomLovBean(child); + //System.out.println(parent+"===>"+child); + if(!PtoCMap.containsKey(parent)) { + CustomLovBean parentLov=new CustomLovBean(parent); + List list=new ArrayList(); + list.add(child); + parentLov.addSub(childLov); + PtoCMap.put(parent, list); + }else { + List list=PtoCMap.get(parent); + if(!list.contains(child)) { + list.add(child); + PtoCMap.put(parent, list); + } + } + + } + Set parents=PtoCMap.keySet(); + for (String parent : parents) { + CustomLovBean parentTree=new CustomLovBean(parent); + List childs=PtoCMap.get(parent); + for(String child:childs) { + parentTree.addSub(new CustomLovBean(child)); + } + top.addSub(parentTree); + } + + new SJJHDialog(comp,table,top,propConfigs); + } +} diff --git a/src/cn/net/connor/process/Processknowledgebase/SJJHDialog.java b/src/cn/net/connor/process/Processknowledgebase/SJJHDialog.java new file mode 100644 index 0000000..164863c --- /dev/null +++ b/src/cn/net/connor/process/Processknowledgebase/SJJHDialog.java @@ -0,0 +1,646 @@ +package cn.net.connor.process.Processknowledgebase; + +import java.awt.BorderLayout; +import javafx.scene.control.Control; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.JTextComponent; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import org.eclipse.swt.custom.StyledText; + +import com.sun.prism.impl.Disposer.Target; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.process.meopviewfx.bean.KTableRow; +import cn.net.connor.process.meopviewfx.bean.PropConfig; +import cn.net.connor.process.meopviewfx.ui.MEOPPanelController; +import cn.net.connor.process.meopviewfx.ui.TableLoader; +import javafx.application.Platform; +import javafx.beans.binding.StringExpression; +import javafx.beans.property.ObjectProperty; +import javafx.event.EventHandler; +import javafx.scene.control.Control; +import javafx.scene.control.TableView; +import k.ui.KFXEditableStringAreaTableCell; +import k.util.KUtil; + +public class SJJHDialog extends JFrame{ + + private TCSession session; + private TCComponentBOMLine comp; + private JPanel Right; + + private String[] header1 = new String[] { "", "ƺ", "ղ", "ղԴ", "ʵֵָ", "ע" }; + private JLabel Label1;// + private JTextField Field1; + private JLabel Label2;// ƺ + private JTextField Field2; + private JLabel Label3;// ղ + private JTextField Field3; + private JLabel Label4;// ղԴ + private JTextField Field4; + private JLabel Label5;// ʵֵָ + private JTextField Field5; + private JLabel Label6;// ע + private JTextField Field6; + + private Vector headVector = new Vector();// ͷ + private Vector tableVector = new Vector();// + + private JTable mainTable; + + private JButton searchButton;// ˳ + private JButton sureButton;// ȷ + private JButton cancelButton;// ˳ + private List propConfigs; + + private CustomLovBean top; + private String parent; + private String child; + private TableView table; + // private int currentCaret=0; + + private List> WeldDatas = new ArrayList>();// ͷ + + public SJJHDialog(TCComponentBOMLine comp, TableView table, CustomLovBean top, + List propConfigs) throws IOException { + super(); + // TODO Auto-generated constructor stub + this.table = table; + this.comp = comp; + this.top = top; + this.propConfigs = propConfigs; + init(); + } + + private void init() throws IOException { + this.setTitle("֪ʶ"); + this.setSize(new Dimension(1000, 600)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + //this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + +// Container container = this.getContentPane(); +// container.setLayout(new BorderLayout()); +// container.setSize(new Dimension(800, 600)); + + // + JTree tree = createTree(top); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setPreferredSize(new Dimension(160, 800)); + tree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // ϵ2,˫ + if (e.getClickCount() == 2) { + DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + if (note.isLeaf()) { + System.out + .println("ĸڵ㣺" + note.getParent().toString() + "====" + "ѡеӽڵ" + note.toString()); + parent = note.getParent().toString(); + child = note.toString(); + getTableValue(); + } + } else if (e.getClickCount() == 1) { + DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + if (note.isLeaf()) { + System.out + .println("ĸڵ㣺" + note.getParent().toString() + "====" + "ѡеӽڵ" + note.toString()); + parent = note.getParent().toString(); + child = note.toString(); + getTableValue(); + } + } + + } + }); + + // + Right = new JPanel(new FlowLayout()); + JPanel panel = new JPanel(new PropertyLayout()); + panel.setPreferredSize(new Dimension(800, 120)); + this.Label1 = new JLabel(""); + this.Label1.setPreferredSize(new Dimension(120, 30)); + this.Field1 = new JTextField(""); + this.Field1.setPreferredSize(new Dimension(180, 30)); + this.Label2 = new JLabel("ƺ"); + this.Label2.setPreferredSize(new Dimension(120, 30)); + this.Field2 = new JTextField(""); + this.Field2.setPreferredSize(new Dimension(180, 30)); + this.Label3 = new JLabel("ղ"); + this.Label3.setPreferredSize(new Dimension(120, 30)); + this.Field3 = new JTextField(""); + this.Field3.setPreferredSize(new Dimension(180, 30)); + this.Label4 = new JLabel("ղԴ"); + this.Label4.setPreferredSize(new Dimension(120, 30)); + this.Field4 = new JTextField(""); + this.Field4.setPreferredSize(new Dimension(180, 30)); + this.Label5 = new JLabel("ʵֵָ"); + this.Label5.setPreferredSize(new Dimension(120, 30)); + this.Field5 = new JTextField(""); + this.Field5.setPreferredSize(new Dimension(180, 30)); + this.Label6 = new JLabel("ע"); + this.Label6.setPreferredSize(new Dimension(120, 30)); + this.Field6 = new JTextField(""); + this.Field6.setPreferredSize(new Dimension(180, 30)); + + this.searchButton = new JButton(""); + this.searchButton.setPreferredSize(new Dimension(80, 30)); + this.searchButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + + searchData(Field1.getText(), Field2.getText(), Field3.getText(), Field4.getText(), Field5.getText(), + Field6.getText()); + + } + }); + + panel.add("1.1.left.top", Label1); + panel.add("1.2.left.top", Field1); + panel.add("1.3.left.top", Label2); + panel.add("1.4.left.top", Field2); + panel.add("2.1.left.top", Label3); + panel.add("2.2.left.top", Field3); + panel.add("2.3.left.top", Label4); + panel.add("2.4.left.top", Field4); + panel.add("2.5.left.top", this.searchButton); + panel.add("3.1.left.top", Label5); + panel.add("3.2.left.top", Field5); + panel.add("3.3.left.top", Label6); + panel.add("3.4.left.top", Field6); + Right.add("1.1.left.top", panel); + + // ñ + headVector.add("ID"); + headVector.add("汾"); + headVector.add(""); + headVector.add("ƺ"); + headVector.add("ղ"); + headVector.add("ղԴ"); + headVector.add("ʵֵָ"); + headVector.add("ע"); + + DefaultTableModel dtm = new DefaultTableModel(tableVector, headVector); + + mainTable = new JTable(dtm) {// JtableѡУ޷༭ + public boolean isCellEditable(int row, int column) { +// if(column==3) { +// return true; +// } + return false; + } + }; + mainTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer());//ñԶӦп + mainTable.setRowHeight(30); +// //+++++ +// int width=mainTable.getTableHeader().getColumnModel().getColumn(0).getWidth(); +// int w=width/2; +// mainTable.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(w); +// //mainTable.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0); +// //mainTable.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(w); +// mainTable.getTableHeader().getColumnModel().getColumn(1).setMaxWidth(w); +// mainTable.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(w); +// //+++++ + // رͷID + mainTable.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(0); + // mainTable.setEnabled(false);//ñ񲻿ɱ༭ + mainTable.addMouseListener(new MouseAdapter() { + /** + * + */ + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { +// dispose(); +// System.out.println("======>ȷ"); + // ȡѡееĹݣac5_ActivityContֵ + if (table != null) { +// int index = table.getSelectionModel().getSelectedIndex(); +// if(index>=0) { +// KTableRow item = table.getItems().get(index); +// for (int i = 0; i < propConfigs.size(); i++) { +// if(propConfigs.get(i).propName.equals("ac5_ActivityCont")) { +// PropConfig config = propConfigs.get(i); +// String ActivityCont = item.stringProps.get(config).getValue(); +// //item.stringProps.get(config).setValue(ActivityCont+(String) mainTable.getValueAt(mainTable.getSelectedRow(), 4)); + insertText((String) mainTable.getValueAt(mainTable.getSelectedRow(), 4)); +// break; +// } +// } +// } +// + // ȡѡжݿID + String ID = (String) mainTable.getValueAt(mainTable.getSelectedRow(), 0); + String REV = (String) mainTable.getValueAt(mainTable.getSelectedRow(), 1); + for (int i = 0; i < propConfigs.size(); i++) { + if (propConfigs.get(i).propName.equals("ac5_SloreID")) { + int index = table.getSelectionModel().getSelectedIndex(); + if (index >= 0) { + KTableRow item = table.getItems().get(index); + PropConfig config = propConfigs.get(i); + item.stringProps.get(config).setValue(ID); + } + } + if (propConfigs.get(i).propName.equals("ac5_SloreRev")) { + int index = table.getSelectionModel().getSelectedIndex(); + if (index >= 0) { + KTableRow item = table.getItems().get(index); + PropConfig config = propConfigs.get(i); + item.stringProps.get(config).setValue(REV); + } + } + } + } + + } + + } + }); + + JScrollPane J1 = new JScrollPane(); + J1.setPreferredSize(new Dimension(800, 380)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.setViewportView(mainTable); + Right.add("2.1.left.top", J1); + + // ðť + JPanel pane2 = new JPanel(new PropertyLayout()); + pane2.setPreferredSize(new Dimension(800, 50)); + + + this.sureButton = new JButton("ȷ"); + this.sureButton.setPreferredSize(new Dimension(80, 40)); + this.sureButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { +// dispose(); +// System.out.println("======>ȷ"); + // ȡѡееĹݣac5_ActivityContֵ + if (table != null) { +// int index = table.getSelectionModel().getSelectedIndex(); +// if(index>=0) { +// KTableRow item = table.getItems().get(index); +// for (int i = 0; i < propConfigs.size(); i++) { +// if(propConfigs.get(i).propName.equals("ac5_ActivityCont")) { +// PropConfig config = propConfigs.get(i); +// String ActivityCont = item.stringProps.get(config).getValue(); +// //item.stringProps.get(config).setValue(ActivityCont+(String) mainTable.getValueAt(mainTable.getSelectedRow(), 4)); + insertText((String) mainTable.getValueAt(mainTable.getSelectedRow(), 4)); +// break; +// } +// } +// } +// + // ȡѡжݿID + String ID = (String) mainTable.getValueAt(mainTable.getSelectedRow(), 0); + String REV = (String) mainTable.getValueAt(mainTable.getSelectedRow(), 1); + for (int i = 0; i < propConfigs.size(); i++) { + if (propConfigs.get(i).propName.equals("ac5_SloreID")) { + int index = table.getSelectionModel().getSelectedIndex(); + if (index >= 0) { + KTableRow item = table.getItems().get(index); + PropConfig config = propConfigs.get(i); + item.stringProps.get(config).setValue(ID); + } + } + if (propConfigs.get(i).propName.equals("ac5_SloreRev")) { + int index = table.getSelectionModel().getSelectedIndex(); + if (index >= 0) { + KTableRow item = table.getItems().get(index); + PropConfig config = propConfigs.get(i); + item.stringProps.get(config).setValue(REV); + } + } + } + } + + } + }); + + this.cancelButton = new JButton("ȡ"); + this.cancelButton.setPreferredSize(new Dimension(80, 40)); + this.cancelButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + dispose(); +// System.out.println(mainTable.getValueAt(0, 3)); +// System.out.println("======>ȡ"); + } + }); + + JLabel Labelnull1 = new JLabel(""); + Labelnull1.setPreferredSize(new Dimension(250, 30)); + JLabel Labelnull2 = new JLabel(""); + Labelnull2.setPreferredSize(new Dimension(80, 30)); + pane2.add("1.1.center.top", Labelnull1); + pane2.add("1.2.center.top", sureButton); + pane2.add("1.3.center.top", Labelnull2); + pane2.add("1.4.center.top", cancelButton); + //pane2.add("1.3.left.top", searchButton); + Right.add("3.1.left.top", pane2); + + this.add(treePanel, BorderLayout.WEST); + this.add(Right, BorderLayout.CENTER); + this.setVisible(true); + } + + public void insertText(String text) { + if (KUtil.isEmpty(text)) { + return; + } + int currentCaret = TableLoader.currentCaretSearch; + Control currentControl = TableLoader.currentControlSearch; + System.out.println("currentCaret=====>" + currentCaret); + if (currentControl == null) { + return; + } + if (currentControl instanceof KFXEditableStringAreaTableCell) { + KFXEditableStringAreaTableCell cell = (KFXEditableStringAreaTableCell) currentControl; + String oldValue = cell.getItem(); + String newValue; + System.out.println(currentCaret + ":" + oldValue); + int temp = currentCaret; + if (oldValue == null) { + newValue = text; + } else if (currentCaret >= 0 && currentCaret <= oldValue.length()) { + newValue = oldValue.substring(0, currentCaret) + text + oldValue.substring(currentCaret); + currentCaret += text.length(); + temp = currentCaret; + } else { + newValue = oldValue + text; + } + System.out.println("-> " + newValue); + cell.commitEdit(newValue); + table.edit(cell.getTableRow().getIndex(), cell.getTableColumn()); + final int temp2 = temp; + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + Platform.runLater(() -> { + cell.startEdit(temp2); + }); + } + }).start(); + } + table.refresh(); + //+++ + TableLoader.currentCaretSearch=-1; + TableLoader.currentControlSearch=null; + //+++ + } + + /** + * ѡСʱ± + */ + private void getTableValue() { + if (parent == null || child == null) { + return; + } + tableVector.clear(); + + SqlUtilT.getTCConnection(); + ResultSet rs = null; + String sql = String.format("select * from TC_ProcessKnow_View where parent=\'%s\' and child=\'%s\'", parent, + child); + try { + rs = SqlUtilT.read(sql); + System.out.println("====>" + sql); + while (rs.next()) { + Vector rowVector = new Vector(); + rowVector.add(rs.getString("ITEM_ID")); + rowVector.add(rs.getString("REV")); + rowVector.add(rs.getString("ITEM_NAME")); + rowVector.add(rs.getString("BRAND")); + rowVector.add(rs.getString("PROCESSPARA")); + rowVector.add(rs.getString("BASIS")); + rowVector.add(rs.getString("TECHNICALIND")); + rowVector.add(rs.getString("REMARKS")); + tableVector.add(rowVector); + } + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + DefaultTableModel dtm = (DefaultTableModel) mainTable.getModel();// ȡģ + dtm.setDataVector(tableVector, headVector);// + //mainTable.setRowHeight(100); + System.out.println("иߣ"+mainTable.getTableHeader().getColumnModel().getColumn(0).getPreferredWidth()); + + //mainTable.setRowHeight(0, this.getMinimumSize().height); + mainTable.updateUI();// ʾ + mainTable.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(0); + } + + /** + * + * + * @param name + * @param brand + * @param processpara + * @param basis + * @param technicalind + * @param remarks + */ + private void searchData(String name, String brand, String processpara, String basis, String technicalind, + String remarks) { + + StringBuilder sql = new StringBuilder("select * from TC_ProcessKnow_View where 1=1"); + if (name != null && !name.equals("")) { + sql.append(" and item_name like'%" + name + "%'"); + } + if (brand != null && !brand.equals("")) { + sql.append(" and brand like'%" + brand + "%'"); + } + if (processpara != null && !processpara.equals("")) { + sql.append(" and processpara like'%" + processpara + "%'"); + } + if (basis != null && !basis.equals("")) { + sql.append(" and basis like'%" + basis + "%'"); + } + if (technicalind != null && !technicalind.equals("")) { + sql.append(" and technicalind like'%" + technicalind + "%'"); + } + if (remarks != null && !remarks.equals("")) { + sql.append(" and remarks like'%" + remarks + "%'"); + } + // Ϊ + if (sql.toString().equals("select * from TC_ProcessKnow_View where 1=1")) { + System.out.println("δд"); + tableVector.clear(); + DefaultTableModel dtm = (DefaultTableModel) mainTable.getModel();// ȡģ + dtm.setDataVector(tableVector, headVector);// + mainTable.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(0); + mainTable.updateUI();// ʾ + return; + } else { + sql.append(" and parent='" + parent + "' and child='" + child+"'"); + System.out.println(sql); + tableVector.clear(); + } + SqlUtilT.getTCConnection(); + ResultSet rs = null; + try { + rs = SqlUtilT.read(sql.toString()); + while (rs.next()) { + Vector rowVector = new Vector(); + rowVector.add(rs.getString("ITEM_ID")); + rowVector.add(rs.getString("REV")); + rowVector.add(rs.getString("ITEM_NAME")); + rowVector.add(rs.getString("BRAND")); + rowVector.add(rs.getString("PROCESSPARA")); + rowVector.add(rs.getString("BASIS")); + rowVector.add(rs.getString("TECHNICALIND")); + rowVector.add(rs.getString("REMARKS")); + tableVector.add(rowVector); + } + DefaultTableModel dtm = (DefaultTableModel) mainTable.getModel();// ȡģ + dtm.setDataVector(tableVector, headVector);// + mainTable.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMaxWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setMinWidth(0); + mainTable.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(0); + mainTable.updateUI();// ʾ + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.setShowsRootHandles(false); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tree.putClientProperty("JTree.lineStyle", "Angled"); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + // cellRenderer.setOpenIcon(new ImageIcon("Swing/1.jpg")); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + } + +} + +class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + public TableCellTextAreaRenderer() { + setLineWrap(true); + setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + if (isSelected) { + setBackground(new Color(176,224,230)); + setForeground(Color.black); + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } +} diff --git a/src/cn/net/connor/process/Processknowledgebase/SJJHHandler.java b/src/cn/net/connor/process/Processknowledgebase/SJJHHandler.java new file mode 100644 index 0000000..2f0c66f --- /dev/null +++ b/src/cn/net/connor/process/Processknowledgebase/SJJHHandler.java @@ -0,0 +1,39 @@ +package cn.net.connor.process.Processknowledgebase; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + +public class SJJHHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp; + try { + comp=app.getTargetComponent(); + if(comp!=null) { + System.out.println(((TCComponentItem)comp).getStringProperty("object_name")); + //((TCComponentItem)comp).setProperty("object_name", "ceshi"); + new Thread(new SJJHAction(app,comp,"",session)).start(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + +} diff --git a/src/cn/net/connor/process/Processknowledgebase/SqlUtilT.java b/src/cn/net/connor/process/Processknowledgebase/SqlUtilT.java new file mode 100644 index 0000000..c0c99ae --- /dev/null +++ b/src/cn/net/connor/process/Processknowledgebase/SqlUtilT.java @@ -0,0 +1,709 @@ +package cn.net.connor.process.Processknowledgebase; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * ֹ̳final,ֹ󽨶˽й췽,ΪʹС PreparedStatementResultSetС + * + * @author hub 2015-02-06 + */ +public final class SqlUtilT { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + // private static Registry reg = Registry.getRegistry(SqlUtilT.class); + /** + * ˽йnew󣬷ֹö + */ + private SqlUtilT() { + + } + + static { + String driver = "oracle.jdbc.driver.OracleDriver"; // Util.getProperties("DRIVER"); + + if (driver == null) { + driver = "oracle.jdbc.driver.OracleDriver"; + } + + System.out.println("driver " + driver); + try { + Class.forName(driver); + } catch (ClassNotFoundException e) { + System.out.println("ORACEL DRIVER IS EXCEPTION"); + e.printStackTrace(); + } + } + + /** + * ݿ + */ + public static Connection getConnectionTC12() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "Connor_Oracle_ProKnowledge"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("ݿѡǷȷ", "ʾ", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"ʾ",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * ݿ + */ + public static Connection getConnectionTC() { + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC_Oracel_test"); + String driver_temp = null; + String url = null; + String dbName = null; + String dbPassword = null; + if (array != null) + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("ORACEL_DRIVER=")) { + driver_temp = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("ORACEL_URL=")) { + url = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("ORACEL_NAME=")) { + dbName = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("ORACEL_PASSWORD=")) { + dbPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (driver_temp == null || url == null || dbName == null + || dbPassword == null) { + + MessageBox.post("ݿѡǷȷ", "ʾ", MessageBox.ERROR); + + } + // else{ + // MessageBox.post(driver_temp+" | "+url+" | "+dbName+" | "+dbPassword,"ʾ",MessageBox.ERROR); + // + // } + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * ݿ + */ + public static Connection getConnection() { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + String url = "jdbc:oracle:thin:@192.168.1.248:1521:TOPPROD";// getProperties("URL"); + String dbName = "jfgroup";// Util.getProperties("dbName"); + String dbPassword = "jfgroup";// Util.getProperties("dbPassword"); + + /* + * if(driver_temp == null ||url==null|| dbName == null ||dbPassword + * == null ){ + * + * MessageBox.post("ݿѡǷȷ","ʾ",MessageBox.ERROR); + * + * } + */ + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + return null; + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + } + return connection; + } + + /** + * ݿ + */ + public static Connection getConnection(String url, String dbName, + String dbPassword) { + try { + String driver_temp = "oracle.jdbc.driver.OracleDriver"; + + System.out.println(url + dbName + dbPassword); + connection = DriverManager.getConnection(url, dbName, dbPassword); + connection.setAutoCommit(false); + } catch (SQLException e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * TCݿ + */ + public static Connection getTCConnection() { + try { + if(connection == null || connection.isClosed()) + { + SqlUtilT.getConnectionTC12(); +// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + } + } catch (Exception e) { + // MessageBox.post("MSG ==>"+url + dbName + dbPassword,"",1); + System.out.println("ORACEL CONNECT EXCEPTION"); + e.printStackTrace(); + MessageBox.post(" MSG = >" + e.getMessage(), "222", 1); + // MessageBox.post("ORACEL CONNECT EXCEPTION \n"+e.getMessage(),"ERROR",MessageBox.ERROR); + return null; + } + return connection; + } + + /** + * ƴSELECT + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, + String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * ƴSELECT + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * ƴӸ + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, + String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // ƴӸ + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("CREATED_DATE") + || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append( + "=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * ƴSQLinsert + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("LAST_UPDATE_DATE") + || args[i].toUpperCase().equals("CREATED_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * õݿ + * + * @param tableName + * @param args + * + * @param args2 + * + * @return ƴӺĴݿ + */ + public final static String GetCreateTableSQL(String tableName, + String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) + throws SQLException { + return getPs(sql, argments); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) + throws SQLException { + SqlUtilT.ps = SqlUtilT.connection.prepareStatement(sql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); + SqlUtilT.ps.setFetchSize(1000); + SqlUtilT.ps.setFetchDirection(ResultSet.FETCH_REVERSE); + + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtilT.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtilT.ps; + } + + /** + * + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * + */ + public final static int write2(Object[] argments, String sql) { + return write2(sql, argments); + } + + /** + * + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * + */ + public final static int write2(String sql, Object[] argments) { + + return update2(sql, argments); + } + + /** + * ɾ + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * ɾ + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * ɾ + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * ɾ + */ + public final static int delete2(String sql) { + int i = -1; + try { + i = SqlUtilT.getPs(null,sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + return i; + } + + /** + * ޸ + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * ޸ + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * ޸(ɾնҪô˷˴쳣رճConnectionĶ),ύ + */ + public final static int update2(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statementΪ"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * ޸(ɾնҪô˷˴쳣رճConnectionΪĶ) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + PreparedStatement statement=null; + while(statement==null) { + statement=SqlUtilT.getPs(argments, sql); + if(statement==null) { + getTCConnection(); + System.out.println("+++++++++++++++++statementΪ"); + } + } + i = statement.executeUpdate(); + //i = SqlUtilT.getPs(argments, sql).executeUpdate(); + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + return i; + } + + /** + * ѯ + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * ѯ + */ + public final static ResultSet read(Object[] argments, String sql) + throws SQLException { + return read(sql, argments); + } + + /** + * ѯ(вѯնҪô˷治쳣׳ɵߴfinallyͷԴ) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) + throws SQLException { + return SqlUtilT.rs = SqlUtilT.getPs(argments, sql).executeQuery(); + } + + /** + * + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * ɾ + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * ޸ı + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * ˷ִDDL(,޸ı,ɾ) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtilT.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtilT.rs, SqlUtilT.ps); + } + if (flag) { + try { + SqlUtilT.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * ͷԴ + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * ͷԴ + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * ͷԴ + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * ͷԴ + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * ͷԴ + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * ͷԴ(Ĭϲ) + */ + public final static void free() { + free(SqlUtilT.rs, SqlUtilT.ps); + } + + /** + * ͷԴ(ȫͷ) + */ + public final static void freeAll() { + free(SqlUtilT.rs, SqlUtilT.ps, SqlUtilT.connection); + } + + /** + * ͷԴ(ҲҪȫͷ) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/cn/net/connor/process/choose/ChooseDialog.java b/src/cn/net/connor/process/choose/ChooseDialog.java new file mode 100644 index 0000000..42af27e --- /dev/null +++ b/src/cn/net/connor/process/choose/ChooseDialog.java @@ -0,0 +1,129 @@ +package cn.net.connor.process.choose; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.process.ProcessLocale; +import k.KDialog; +import k.KDialogController; +import k.util.KUtil; + +@SuppressWarnings("serial") +public class ChooseDialog extends KDialog { + + private ChooseDialogController controller; + private JButton b_ok; + private JButton b_cel; + private JButton b_search; + + public ChooseDialog(AbstractAIFDialog newMeopDialog, KDialogController controller) { + super(newMeopDialog,true,controller); + this.controller = (ChooseDialogController) controller; + } + + @Override + protected void addListeners() { + this.b_cel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + this.b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + controller.doSelect(); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(ChooseDialog.this,e1); + } + } + }); + this.b_search.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + controller.doSearch(); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(ChooseDialog.this,e1); + } + } + }); + } + + @Override + protected void initUI() { + this.setTitle(ProcessLocale.getString("select.TITLE")); + this.setPreferredSize(new Dimension(900, 500)); + this.setMinimumSize(new Dimension(550, 400)); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER, initTablePanel()); + this.add(BorderLayout.EAST, initSearchPanel()); + } + + private Component initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0)); + panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + this.b_search = new JButton(ProcessLocale.getString("search")); + this.b_ok = new JButton(ProcessLocale.getString("ok")); + this.b_cel = new JButton(ProcessLocale.getString("cancel")); + if (controller.searchCols.size() > 0) { + panel.add(b_search); + } + panel.add(b_ok); + panel.add(b_cel); + return panel; + } + + private Component initSearchPanel() { + JPanel panel = new JPanel(new BorderLayout()); + if (controller.searchCols.size() == 0) { + this.add(BorderLayout.SOUTH, initBtnPanel()); + return panel; + } + JPanel searchPanel = new JPanel(new GridBagLayout()); + searchPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(5, 5, 5, 5)); + for (String title : controller.searchCols) { + KUtil.newRow(searchPanel, new JLabel(title), s, 1); + JTextField textField = new JTextField(12); + controller.searchComps.put(title, textField); + KUtil.addCol(searchPanel, textField, s, 1, 1); + } + s.weighty = 1; + KUtil.newRow(searchPanel, new JLabel(""), s, 1); + JScrollPane scroll = new JScrollPane(searchPanel); + scroll.setBorder(null); + panel.add(BorderLayout.CENTER, scroll); + panel.add(BorderLayout.SOUTH, initBtnPanel()); + return panel; + } + + private Component initTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 0)); + JScrollPane scroll = new JScrollPane(controller.tableBean.getTable()); + panel.add(BorderLayout.CENTER, scroll); + return panel; + } + +} diff --git a/src/cn/net/connor/process/choose/ChooseDialogController.java b/src/cn/net/connor/process/choose/ChooseDialogController.java new file mode 100644 index 0000000..dc82ca5 --- /dev/null +++ b/src/cn/net/connor/process/choose/ChooseDialogController.java @@ -0,0 +1,161 @@ +package cn.net.connor.process.choose; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCComponentDataset; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.newmeop.PrefComponent; +import k.KDialogController; +import k.swing.KExcelTable; +import k.swing.KExcelTable.Config; +import k.util.KUtil; + +public class ChooseDialogController extends KDialogController{ + + private String typeName; + private String[] config; + private List prefComponents; + //private Map otherComps; + private ChooseDialog dialog; + protected File excelFile; + protected List configs = new ArrayList(); + protected List searchCols = new ArrayList(); + protected Map searchComps = new HashMap(); + protected KExcelTable tableBean; + + public ChooseDialogController(AbstractAIFApplication app, String type, PrefComponent bean, List prefComponents) { + super(app); + this.typeName = type; + this.config = bean.getExcelConfig(); + this.prefComponents = prefComponents; + } + + @Override + public boolean init() throws Exception { + this.dialog = (ChooseDialog) aifDialog; + int len = KUtil.getLen(config); + if(len==0) { + System.out.println("No Choose Config"); + KUtil.error(dialog, ProcessLocale.getString("novalidchooseconfig.ERROR")); + return false; + } + String uid = config[0]; + System.out.println(">> Uid: "+uid); + if(!KUtil.isEmpty(typeName)) { + int ind=uid.indexOf(""+typeName+":"); + if(ind>0) { + uid = uid.substring(ind+typeName.length()+1); + } + } + int ind = uid.indexOf(';'); + if(ind>0) { + uid = uid.substring(0,ind); + } + System.out.println(">> Uid for type ["+typeName+"] is: "+uid); + if(KUtil.isEmpty(uid)) { + KUtil.error(dialog, ProcessLocale.getString("novalidchooseconfig.ERROR")); + return false; + } + TCComponentDataset excelDataset = null; + try { + excelDataset = (TCComponentDataset) session.stringToComponent(uid); + } catch (Exception e) { + e.printStackTrace(); + } + if(excelDataset==null||!"MSExcelX".equals(excelDataset.getType())) { + KUtil.error(dialog, ProcessLocale.getString("novalidchooseconfig.ERROR")); + return false; + } + //Read Config + for(int i=1;i0) { + tableCol = split[0]; + } + if(splitCnt>1) { + excelCol = split[1]; + } + if(splitCnt>2) { + propConfig = split[2]; + } + if(splitCnt>3) { + try { + prefW = Integer.parseInt(split[3]); + } catch (Exception e) { + e.printStackTrace(); + } + } + if(!KUtil.isEmpty(tableCol)&&!KUtil.isEmpty(excelCol)) { + if(tableCol.startsWith("#")) { + tableCol = tableCol.substring(1); + System.out.println(">> Add Search: "+tableCol); + if(!this.searchCols.contains(tableCol)) { + this.searchCols.add(tableCol); + } + } + this.configs.add(new Config(tableCol, excelCol, propConfig, prefW)); + }else { + System.out.println("ERROR Config: "+pref); + } + } + this.excelFile = KUtil.getDatasetFile(excelDataset); + if(this.excelFile==null||!this.excelFile.exists()) { + KUtil.error(dialog, ProcessLocale.getString("novalidchooseconfig.ERROR")); + return false; + } + this.tableBean = new KExcelTable(configs, excelFile.getAbsolutePath()); + return true; + } + + public void doSearch() throws Exception{ + Map searchInfo = new HashMap(); + System.out.println("Perform Search.."); + for (String colName : this.searchComps.keySet()) { + String value = this.searchComps.get(colName).getText(); + if(!KUtil.isEmpty(value)) { + System.out.println(">> "+colName+" = "+value); + searchInfo.put(colName,value); + } + } + this.tableBean.performSearch(searchInfo); + } + + public void doSelect() throws Exception{ + LinkedHashMap data = this.tableBean.getSelectedData(); + if(data==null||data.size()<=0) { + System.out.println("No Select Info"); + dialog.disposeDialog(); + return; + } + System.out.println("Selected Row: "+Arrays.toString(data.values().toArray())); + for (Config colConfig : data.keySet()) { + String val = data.get(colConfig); + String addition = colConfig.getAdditionalInfo(); + if(KUtil.isEmpty(addition)) { + continue; + } + System.out.println(">> Set "+addition+" = "+val); + for (PrefComponent comp : this.prefComponents) { + if(addition.equals(comp.getPropConfig())) { + comp.setValue(val); + } + } + } + dialog.disposeDialog(); + } + +} diff --git a/src/cn/net/connor/process/commands/EditItemCommand.java b/src/cn/net/connor/process/commands/EditItemCommand.java new file mode 100644 index 0000000..fb56117 --- /dev/null +++ b/src/cn/net/connor/process/commands/EditItemCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import k.KCommand; +import k.edititem.EditItemDialog; +import k.edititem.EditItemDialogController; + +public class EditItemCommand extends KCommand{ + + public EditItemCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new EditItemDialog(new EditItemDialogController(app, "Connor_AVIC_CLSJBJ_"))); + } + +} diff --git a/src/cn/net/connor/process/commands/GCJLKCommand.java b/src/cn/net/connor/process/commands/GCJLKCommand.java new file mode 100644 index 0000000..613466d --- /dev/null +++ b/src/cn/net/connor/process/commands/GCJLKCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.gcjlk.GCJLKDialog; +import cn.net.connor.process.gcjlk.GCJLKDialogController; +import k.KCommand; + +public class GCJLKCommand extends KCommand{ + + public GCJLKCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new GCJLKDialog(new GCJLKDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/GZBomExportCommand.java b/src/cn/net/connor/process/commands/GZBomExportCommand.java new file mode 100644 index 0000000..2a68f3b --- /dev/null +++ b/src/cn/net/connor/process/commands/GZBomExportCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.gzbomexport.GZBomExportOperation; +import k.KCommand; + +public class GZBomExportCommand extends KCommand{ + + public GZBomExportCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new GZBomExportOperation(app, ProcessLocale.getString("gzbomfunc.TITLE"))); + } + +} diff --git a/src/cn/net/connor/process/commands/MeopModelCommand.java b/src/cn/net/connor/process/commands/MeopModelCommand.java new file mode 100644 index 0000000..1234d9e --- /dev/null +++ b/src/cn/net/connor/process/commands/MeopModelCommand.java @@ -0,0 +1,54 @@ +package cn.net.connor.process.commands; + +import javax.swing.JOptionPane; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.util.Registry; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.ProcessUtil; +import cn.net.connor.process.meopmodel.DesignModelOperation; +import cn.net.connor.process.meopmodel.MeopModelDialog; +import cn.net.connor.process.meopmodel.MeopModelDialogController; +import k.KCommand; +import k.util.KUtil; + +public class MeopModelCommand extends KCommand { + + private static final Registry REG = Registry.getRegistry(MeopModelDialog.class); + + public MeopModelCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + } + + @Override + protected void executeCommand() throws Exception { + InterfaceAIFComponent target = app.getTargetComponent(); + System.out.println("Select: " + target); + String typeName = ""; + if (target instanceof TCComponentBOPLine) { + typeName = ((TCComponentBOPLine) target).getItem().getType(); + } + if (!ProcessUtil.isMEOP(typeName)) { + KUtil.info(null, ProcessLocale.getString("selectmeopline.INFO")); + return; + } + TCComponentBOPLine meopLine = (TCComponentBOPLine) target; + MeopModelDialog dialog = new MeopModelDialog(new MeopModelDialogController(app, meopLine)); + int option = JOptionPane.showOptionDialog(dialog, REG.getString("meopmodeloption.MESSAGE"), "", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, + new String[] { REG.getString("meopmodel"), REG.getString("designmodel") }, null); + if (option == JOptionPane.YES_OPTION) { + System.out.println("select meop model"); + this.setRunnable(dialog); + } else if (option == JOptionPane.NO_OPTION) { + System.out.println("select design model"); + this.setRunnable(new DesignModelOperation(app, REG.getString("designmodel.STATUS"), meopLine)); + } else { + System.out.println("cancel"); + } + super.executeCommand(); + } + +} diff --git a/src/cn/net/connor/process/commands/ModifyMeopNoCommand.java b/src/cn/net/connor/process/commands/ModifyMeopNoCommand.java new file mode 100644 index 0000000..a546163 --- /dev/null +++ b/src/cn/net/connor/process/commands/ModifyMeopNoCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.modifymeopno.ModifyMeopNoDialog; +import cn.net.connor.process.modifymeopno.ModifyMeopNoDialogController; +import k.KCommand; + +public class ModifyMeopNoCommand extends KCommand{ + + public ModifyMeopNoCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ModifyMeopNoDialog(new ModifyMeopNoDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/NewMeopCommand.java b/src/cn/net/connor/process/commands/NewMeopCommand.java new file mode 100644 index 0000000..9fc6e56 --- /dev/null +++ b/src/cn/net/connor/process/commands/NewMeopCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.newmeop.NewMeopDialog; +import cn.net.connor.process.newmeop.NewMeopDialogController; +import k.KCommand; + +public class NewMeopCommand extends KCommand { + + public NewMeopCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new NewMeopDialog(new NewMeopDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/NewProcessCommand.java b/src/cn/net/connor/process/commands/NewProcessCommand.java new file mode 100644 index 0000000..5f256c2 --- /dev/null +++ b/src/cn/net/connor/process/commands/NewProcessCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.newprocess.NewProcessDialog; +import cn.net.connor.process.newprocess.NewProcessDialogController; +import k.KCommand; + +public class NewProcessCommand extends KCommand{ + + public NewProcessCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new NewProcessDialog(new NewProcessDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/OpenPCBCommand.java b/src/cn/net/connor/process/commands/OpenPCBCommand.java new file mode 100644 index 0000000..34c05ae --- /dev/null +++ b/src/cn/net/connor/process/commands/OpenPCBCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.openpcb.OpenPCBOperation; +import k.KCommand; + +public class OpenPCBCommand extends KCommand{ + + public OpenPCBCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new OpenPCBOperation(app, ProcessLocale.getString("openpcb.STATUS"))); + } + +} diff --git a/src/cn/net/connor/process/commands/OpenPCBCommand2.java b/src/cn/net/connor/process/commands/OpenPCBCommand2.java new file mode 100644 index 0000000..a30cb13 --- /dev/null +++ b/src/cn/net/connor/process/commands/OpenPCBCommand2.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.openpcb.OpenPCBOperation2; +import k.KCommand; + +public class OpenPCBCommand2 extends KCommand{ + + public OpenPCBCommand2(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new OpenPCBOperation2(app, ProcessLocale.getString("openpcb.STATUS"))); + } + +} diff --git a/src/cn/net/connor/process/commands/OpenPCBCommand3.java b/src/cn/net/connor/process/commands/OpenPCBCommand3.java new file mode 100644 index 0000000..fcb36fd --- /dev/null +++ b/src/cn/net/connor/process/commands/OpenPCBCommand3.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.openpcb.OpenPCBOperation3; +import k.KCommand; + +public class OpenPCBCommand3 extends KCommand{ + + public OpenPCBCommand3(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new OpenPCBOperation3(app, ProcessLocale.getString("openpcb.STATUS"))); + } + +} diff --git a/src/cn/net/connor/process/commands/OpenViewCommand.java b/src/cn/net/connor/process/commands/OpenViewCommand.java new file mode 100644 index 0000000..533673c --- /dev/null +++ b/src/cn/net/connor/process/commands/OpenViewCommand.java @@ -0,0 +1,44 @@ +package cn.net.connor.process.commands; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.util.PlatformHelper; + +import k.KCommand; +import k.util.KUtil; + +public class OpenViewCommand extends KCommand{ + + public OpenViewCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + } + + @Override + protected void executeCommand() throws Exception { + System.out.println("Open View: "+actionInfo); + if(KUtil.isEmpty(actionInfo)) { + return; + } + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + try { + IWorkbenchWindow var1 = AIFUtility.getActiveDesktop().getDesktopWindow(); + IWorkbenchPage var2 = var1.getActivePage(); + IViewPart sv = var2.findView(actionInfo); + if (sv == null) { + sv = var2.showView(actionInfo); + } + PlatformHelper.getCurrentPage().activate(sv); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/src/cn/net/connor/process/commands/ProcTaskCommand.java b/src/cn/net/connor/process/commands/ProcTaskCommand.java new file mode 100644 index 0000000..bda93c8 --- /dev/null +++ b/src/cn/net/connor/process/commands/ProcTaskCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.proctask.ProcTaskDialog; +import cn.net.connor.process.proctask.ProcTaskDialogController; +import k.KCommand; + +public class ProcTaskCommand extends KCommand{ + + public ProcTaskCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ProcTaskDialog(new ProcTaskDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/ProcessCardCommand.java b/src/cn/net/connor/process/commands/ProcessCardCommand.java new file mode 100644 index 0000000..f1b45fc --- /dev/null +++ b/src/cn/net/connor/process/commands/ProcessCardCommand.java @@ -0,0 +1,17 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.processcardmultiple.MultiProcessCardDialog; +import cn.net.connor.process.processcardmultiple.MultiProcessCardDialogController; +import k.KCommand; + +public class ProcessCardCommand extends KCommand{ + + public ProcessCardCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + // this.setRunnable(new ProcessCardDialog(new ProcessCardDialogController(app, actionInfo))); + this.setRunnable(new MultiProcessCardDialog(new MultiProcessCardDialogController(app, actionInfo))); + } + +} diff --git a/src/cn/net/connor/process/commands/ProcessProcedureCommand.java b/src/cn/net/connor/process/commands/ProcessProcedureCommand.java new file mode 100644 index 0000000..f74b800 --- /dev/null +++ b/src/cn/net/connor/process/commands/ProcessProcedureCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.processprocedure.ProcessProcDialog; +import cn.net.connor.process.processprocedure.ProcessProcDialogController; +import k.KCommand; + +public class ProcessProcedureCommand extends KCommand{ + + public ProcessProcedureCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ProcessProcDialog(new ProcessProcDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/ReviseMEProcessCommand.java b/src/cn/net/connor/process/commands/ReviseMEProcessCommand.java new file mode 100644 index 0000000..e2d1b83 --- /dev/null +++ b/src/cn/net/connor/process/commands/ReviseMEProcessCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.revisemeprocess.ReviseMEProcessOperation; +import k.KCommand; + +public class ReviseMEProcessCommand extends KCommand{ + + public ReviseMEProcessCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ReviseMEProcessOperation(app, ProcessLocale.getString("revisemeprocess.OP"))); + } + +} diff --git a/src/cn/net/connor/process/commands/ScreenShotCommand.java b/src/cn/net/connor/process/commands/ScreenShotCommand.java new file mode 100644 index 0000000..61311f3 --- /dev/null +++ b/src/cn/net/connor/process/commands/ScreenShotCommand.java @@ -0,0 +1,46 @@ +package cn.net.connor.process.commands; + +import org.eclipse.swt.widgets.Display; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.process.ProcessLocale; +import k.KCommand; +import k.util.KUtil; + +public class ScreenShotCommand extends KCommand { + + private boolean hideTC; + private static final String PREF_SCREENSHOT = "Connor_ScreenShot_Command"; + + public ScreenShotCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.hideTC = "true".equals(actionInfo); + } + + @Override + public void executeModal() throws Exception { + String cmd = KUtil.getPrefVal((TCSession) app.getSession(), PREF_SCREENSHOT); + System.out.println("ScreenShot: "+cmd); + if(KUtil.isEmpty(cmd)) { + KUtil.info(null, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_SCREENSHOT)); + return; + } + if(hideTC) { + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + // System.out.println(AIFDesktop.getActiveDesktop().getShell()); + AIFDesktop.getActiveDesktop().getShell().setMinimized(true); + } + }); + Thread.sleep(600); + } + Runtime.getRuntime().exec(cmd); + } + + + +} diff --git a/src/cn/net/connor/process/commands/TSGCExportCommand.java b/src/cn/net/connor/process/commands/TSGCExportCommand.java new file mode 100644 index 0000000..e4cda3b --- /dev/null +++ b/src/cn/net/connor/process/commands/TSGCExportCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.tsgcexport.TSGCExportOperation; +import k.KCommand; + +public class TSGCExportCommand extends KCommand{ + + public TSGCExportCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new TSGCExportOperation(app, ProcessLocale.getString("tsgcexport.STATUS"))); + } + +} diff --git a/src/cn/net/connor/process/commands/TSGCRefExportCommand.java b/src/cn/net/connor/process/commands/TSGCRefExportCommand.java new file mode 100644 index 0000000..a144ffd --- /dev/null +++ b/src/cn/net/connor/process/commands/TSGCRefExportCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.tsgcrefexport.TSGCRefExportDialog; +import cn.net.connor.process.tsgcrefexport.TSGCRefExportDialogController; +import k.KCommand; + +public class TSGCRefExportCommand extends KCommand{ + + public TSGCRefExportCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new TSGCRefExportDialog(new TSGCRefExportDialogController(app))); + } + +} diff --git a/src/cn/net/connor/process/commands/TestCommand.java b/src/cn/net/connor/process/commands/TestCommand.java new file mode 100644 index 0000000..b702501 --- /dev/null +++ b/src/cn/net/connor/process/commands/TestCommand.java @@ -0,0 +1,38 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.gzbomexport.GZBomExportOperation; +import cn.net.connor.process.meopviewfx.dialog.TestDialog; +import cn.net.connor.process.meopviewfx.dialog.TestDialogController; +import cn.net.connor.process.modifymeopno.ModifyMeopNoDialog; +import cn.net.connor.process.modifymeopno.ModifyMeopNoDialogController; +import cn.net.connor.process.newmeop.NewMeopDialog; +import cn.net.connor.process.newmeop.NewMeopDialogController; +import cn.net.connor.process.newprocess.NewProcessDialog; +import cn.net.connor.process.newprocess.NewProcessDialogController; +import cn.net.connor.process.processcard.ProcessCardDialog; +import cn.net.connor.process.processcard.ProcessCardDialogController; +import cn.net.connor.process.processprocedure.ProcessProcDialog; +import cn.net.connor.process.processprocedure.ProcessProcDialogController; +import cn.net.connor.process.proctask.ProcTaskDialog; +import cn.net.connor.process.proctask.ProcTaskDialogController; +import k.KCommand; + +public class TestCommand extends KCommand{ + + public TestCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new NewProcessDialog(new NewProcessDialogController(app))); + this.setRunnable(new GZBomExportOperation(app, ProcessLocale.getString("gzbomfunc.TITLE"))); + this.setRunnable(new TestDialog(new TestDialogController(app))); + this.setRunnable(new NewMeopDialog(new NewMeopDialogController(app))); + this.setRunnable(new ModifyMeopNoDialog(new ModifyMeopNoDialogController(app))); + this.setRunnable(new ProcessProcDialog(new ProcessProcDialogController(app))); + this.setRunnable(new ProcessCardDialog(new ProcessCardDialogController(app, "A3_"))); + this.setRunnable(new ProcTaskDialog(new ProcTaskDialogController(app))); + this.setRunnable(new ProcessCardDialog(new ProcessCardDialogController(app, ""))); + } + +} diff --git a/src/cn/net/connor/process/commands/WorkflowNameCommand.java b/src/cn/net/connor/process/commands/WorkflowNameCommand.java new file mode 100644 index 0000000..bcd15cc --- /dev/null +++ b/src/cn/net/connor/process/commands/WorkflowNameCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.process.commands; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.process.ProcessLocale; +import cn.net.connor.process.workflowname.WorkflowNameOperation; +import k.KCommand; + +public class WorkflowNameCommand extends KCommand{ + + public WorkflowNameCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new WorkflowNameOperation(app, ProcessLocale.getString("workflowname.CMD"))); + } + +} diff --git a/src/cn/net/connor/process/gcjlk/GCJLKDialog.java b/src/cn/net/connor/process/gcjlk/GCJLKDialog.java new file mode 100644 index 0000000..ec7c611 --- /dev/null +++ b/src/cn/net/connor/process/gcjlk/GCJLKDialog.java @@ -0,0 +1,144 @@ +package cn.net.connor.process.gcjlk; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +import k.KDialog; +import k.KDialogController; +import k.util.KUtil; + +@SuppressWarnings("serial") +public class GCJLKDialog extends KDialog{ + + private static final Registry REG= Registry.getRegistry(GCJLKDialog.class); + private GCJLKDialogController controller; + private JButton b_export; + private JButton b_cancel; + protected DefaultTableModel tableModel; + protected JTable table; + protected String[] header = new String[] { + REG.getString("index.COL"), + REG.getString("orderno.COL"), + REG.getString("quantity.COL"), + REG.getString("isfirst.COL") + }; + private int [] headerWidth = new int[] {50, 180, 100, 120}; + protected JTextField tf_ItemID; + protected JTextField tf_RevID; + private JButton b_query; + + public GCJLKDialog(KDialogController controller) { + super(controller); + this.controller = (GCJLKDialogController)controller; + } + + @Override + protected void addListeners() { + b_cancel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + b_query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + controller.doQuery(); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(GCJLKDialog.this, e1); + } + } + }); + b_export.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + try { + controller.doExport(); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(GCJLKDialog.this, e1); + } + } + }); + } + + @Override + protected void initUI() { + this.setLayout(new BorderLayout()); + this.add(BorderLayout.NORTH, initQueryPanel()); + this.add(BorderLayout.CENTER, initTablePanel()); + this.add(BorderLayout.SOUTH, initBtnPanel()); + } + + private Component initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5)); + panel.add(this.b_export = new JButton(REG.getString("export.BTN"))); + panel.add(this.b_cancel = new JButton(REG.getString("cancel.BTN"))); + this.b_cancel.setPreferredSize(this.b_export.getPreferredSize()); + return panel; + } + + private Component initTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + this.tableModel = new DefaultTableModel(); + this.table = new JTable(tableModel) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + this.table.getTableHeader().setReorderingAllowed(false); + this.table.setRowHeight(23); + this.tableModel.setDataVector(null, header); + TableColumnModel colModel = this.table.getColumnModel(); + for(int i=0; i " + Arrays.toString(proc)); + int procCnt = KUtil.getLen(proc); + for (int i = 0; i < procCnt; i++) { + InterfaceAIFComponent comp = proc[i].getComponent(); + if (comp instanceof TCComponentItemRevision) { + if (ProcessUtil.isMEProcess(((TCComponentItemRevision) comp).getItem().getType())) { + this.procRev = (TCComponentItemRevision) comp; + } + } + } + System.out.println("find process: " + this.procRev); + if (this.procRev == null) { + throw new TCException(REG.getString("noprocess.ERROR")); + } + this.targetItemID = this.targetRev.getStringProperty("item_id"); + this.targetRevID = this.targetRev.getStringProperty("item_revision_id"); + String[] prefValues = KUtil.getPrefVals(session, PREF_QUERY_GCJLK); + int len = KUtil.getLen(prefValues); + if (len < 4) { + throw new TCException(String.format(REG.getString("pref.ERROR1"), PREF_QUERY_GCJLK)); + } + this.dbUrl = prefValues[0]; + this.dbUser = prefValues[1]; + this.dbPwd = prefValues[2]; + this.sql = ""; + for (int i = 3; i < len; i++) { + sql += prefValues[i]; + if (i != len - 1) { + sql += "\n"; + } + } + System.out.println("SQL: " + sql); + this.kWord = new KWord(session, PREF_EXPORT_GCJLK); + return true; + } + + public void doQuery() throws Exception { + String itemID = dialog.tf_ItemID.getText(); + // String revID = dialog.tf_RevID.getText(); + System.out.println(String.format("Query - [%s]", itemID)); + if (KUtil.isEmpty(itemID)) { + throw new TCException(REG.getString("queryinput.ERROR")); + } + Connection conn = KSqlUtil.getSqlServerConnection(dbUrl, dbUser, dbPwd); + try { + dialog.tableModel.getDataVector().clear(); + List data = KSqlUtil.queryStringArray(conn, sql, new String[] { itemID }, 3); + int rowCnt = data == null ? 0 : data.size(); + System.out.println("query result count: " + rowCnt); + for (int i = 0; i < rowCnt; i++) { + String[] rowData = data.get(i); + dialog.tableModel.addRow(new Object[] { i + 1, rowData[0], rowData[1], rowData[2] }); + } + } finally { + KSqlUtil.free(conn); + } + } + + public void doExport() throws Exception { + int rowNum = dialog.table.getSelectedRow(); + System.out.println("select row: " + rowNum); + if (rowNum < 0) { + throw new TCException(REG.getString("selectrow.ERROR")); + } + String fileName = procRev.getStringProperty("item_id")+REG.getString("filename")+KUtil.getDateStr(new Date(), "_yyyyMMdd")+".docx"; + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + String defaultFile = deskPath+File.separator+fileName; + File exportFile = KUtil.chooseSaveFile(dialog, defaultFile, "docx"); + if(exportFile==null) { + System.out.println("cancel export"); + return; + } + String orderNumber = (String) dialog.table.getValueAt(rowNum, 1); + String quantity = (String) dialog.table.getValueAt(rowNum, 2); + String isFirst = (String) dialog.table.getValueAt(rowNum, 3); + Map overwriteTexts = new HashMap(); + overwriteTexts.put(dialog.header[1], orderNumber); + overwriteTexts.put(dialog.header[2], quantity); + overwriteTexts.put(dialog.header[3], isFirst); + System.out.println("Overwrite texts: " + overwriteTexts); + dialog.disposeDialog(); + new KOperation2(AIFUtility.getCurrentApplication(), REG.getString("export.STATUS")) { + + private TCComponentBOMLine procLine; + private TCComponentBOPWindow bopWindow; + + @Override + public boolean init() throws Exception { + TCComponentBOPWindowType bopWindowType = (TCComponentBOPWindowType) session.getTypeComponent("BOPWindow"); + bopWindow = bopWindowType.createBOPWindow(null); + procLine = bopWindow.setWindowTopLine(procRev.getItem(), procRev, null, null); + return true; + } + + @Override + public void execute() throws Exception { + try { + List kWords = new ArrayList(); + kWords.add(kWord); + List targetLines = new ArrayList(); + List meTargetRevs = new ArrayList(); + targetLines.add(procLine); + meTargetRevs.add(targetRev); + KWordUtil.startWord(); + try { + KWord.export(session, kWords, REG.getString("filename"), null, targetLines, meTargetRevs, true, overwriteTexts, exportFile); + KUtil.info(dialog, REG.getString("export.SUCCESS")); + } finally { + KWordUtil.closeWord(); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(dialog, e); + } + } + + @Override + public void clearCache() throws Exception { + if (bopWindow != null) { + bopWindow.refresh(); + bopWindow.setClearCacheOnClose(true); + bopWindow.closeBOPWindow(); + } + } + }.executeModeless(); + + } + +} diff --git a/src/cn/net/connor/process/gcjlk/gcjlk.properties b/src/cn/net/connor/process/gcjlk/gcjlk.properties new file mode 100644 index 0000000..af8834e --- /dev/null +++ b/src/cn/net/connor/process/gcjlk/gcjlk.properties @@ -0,0 +1,17 @@ +selectrev.WARN=\u8BF7\u9009\u62E9\u5BF9\u8C61\u7248\u672C\u8FDB\u884C\u64CD\u4F5C +noprocess.ERROR=\u672A\u627E\u5230\u5173\u8054\u7684\u5DE5\u827A +export.BTN=\u751F\u6210\u62A5\u8868 +cancel.BTN=\u53D6\u6D88 +index.COL=\u5E8F\u53F7 +orderno.COL=\u8BA2\u5355\u7F16\u53F7 +quantity.COL=\u6570\u91CF +isfirst.COL=\u662F\u5426\u9996\u4EF6\u9274\u5B9A +itemid.LABEL=\u7269\u6599\u7F16\u7801 +revid.LABEL=\u7248\u672C +query.BTN=\u8BA2\u5355\u67E5\u8BE2 +queryinput.ERROR=\u8BF7\u8F93\u5165\u67E5\u8BE2\u6761\u4EF6 +pref.ERROR1=\u9996\u9009\u9879\u201C%s\u201D\u914D\u7F6E\u9519\u8BEF +selectrow.ERROR=\u8BF7\u9009\u62E9\u8981\u6253\u5370\u7684\u8BA2\u5355 +export.STATUS=\u751F\u6210\u62A5\u8868 +filename=\u8FC7\u7A0B\u8BB0\u5F55\u5361 +export.SUCCESS=\u751F\u6210\u62A5\u8868\u5B8C\u6210 \ No newline at end of file diff --git a/src/cn/net/connor/process/gzbomexport/GZBomExportOperation.java b/src/cn/net/connor/process/gzbomexport/GZBomExportOperation.java new file mode 100644 index 0000000..1af3d7a --- /dev/null +++ b/src/cn/net/connor/process/gzbomexport/GZBomExportOperation.java @@ -0,0 +1,149 @@ +package cn.net.connor.process.gzbomexport; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.pse.services.PSEApplicationService; + +import cn.net.connor.process.ProcessLocale; +import k.KOperation; +import k.util.KUtil; +import k.util.POIUtil; + +public class GZBomExportOperation extends KOperation{ + + private static final String FILENAME = ProcessLocale.getString("gzbomfilename"); + private static final String PREF_GZBOMEXPORT = "Connor_GZBomExport"; + private TCComponentBOMLine topLine; + private List configs = new ArrayList(); + private int rowNum = 2; + private XSSFSheet sheet; + private XSSFCellStyle cellStyle; + private static final int STARTCOL = 0; + private String dateformat = "_yyyy_MM_dd"; + + public GZBomExportOperation(AbstractAIFApplication app, String opName) { + super(app, opName); + } + + public class Config{ + String propName; + boolean isBomProp; + public Config(String propName, boolean isBomProp) { + this.propName = propName; + this.isBomProp = isBomProp; + } + } + + @Override + public boolean init() throws Exception { + if(!(app instanceof PSEApplicationService)) { + KUtil.error(null, ProcessLocale.getString("notinpse.ERROR")); + return false; + } + String[] prefs = KUtil.getPrefVals(session, PREF_GZBOMEXPORT); + int len = KUtil.getLen(prefs); + for(int i=0;i=0) { + System.out.println("RESET Start Row: "+num); + this.rowNum = num; + } + continue; + } + if(pref.startsWith("##")) { + this.dateformat = pref.substring(2); + System.out.println("RESET DATE FORMAT: "+this.dateformat); + continue; + } + String propName; + boolean isBomProp = pref.startsWith("#"); + if(isBomProp) { + propName = pref.substring(1); + }else { + propName = pref; + } + this.configs.add(new Config(propName, isBomProp)); + } + if(this.configs.size()==0) { + KUtil.info(null, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_GZBOMEXPORT)); + return false; + } + PSEApplicationService pse = (PSEApplicationService) app; + this.topLine = pse.getTopBOMLine(); + if(topLine==null) { + KUtil.info(null, ProcessLocale.getString("notopline.ERROR")); + return false; + } + System.out.println("Export: "+topLine); + return true; + } + + private void exportLine(TCComponentBOMLine parentLine) throws Exception{ + XSSFRow row = POIUtil.getRow(sheet, rowNum++); + TCComponentItemRevision rev = parentLine.getItemRevision(); + TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev"); + int colCnt = this.configs.size(); + for(int i=0;i table; + private List propConfigs; + private TCComponentBOMLine target; + public JTextField Field1=new JTextField();//ʱ + public JTextField Field2=new JTextField();//׼Ṥʱ + public JTextField Field3=new JTextField();// + public JTextField Field4=new JTextField();//ע + + public FitterCommand(TCSession session,TCComponentBOMLine target,JTextField Field1,JTextField Field2,JTextField Field3,JTextField Field4) { + this.session=session; + this.target=target; + this.Field1=Field1; + this.Field2=Field2; + this.Field3=Field3; + this.Field4=Field4; + // TODO Auto-generated constructor stub + try { + executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + CustomLovBean top = new CustomLovBean("չ"); + TCPreferenceService service = session.getPreferenceService(); + String puid = service.getStringValue("Connor_avic_JJGSJS_xml"); + if(puid==null||puid.equals("")) { + MessageBox.post("δҵѡConnor_avic_JJGSJS_xmlxmlļá", "", MessageBox.ERROR); + return; + } + + + if (MethodUtil.getDatByUid(puid,session)==null) { + MessageBox.post("δҵݼѡConnor_avic_JJGSJS_xmlļá", "", MessageBox.ERROR); + return; + } + + + //put("/С"([uidIValue,""],[uidXValue,""],[attributes,"1&&2&&..."],[GS,"㹫ʽ"])) + Map> PtoCMap = new HashMap>();// + + //¼ṹ + Map> treeMap=new HashMap>(); + + + // + SAXReader sax = new SAXReader(); + + Document doc = sax.read(MethodUtil.getDatByUid(puid,session)); + + // ȡԪ + Element root = doc.getRootElement(); + + // ȡԪµԪ: + List parents = root.elements(); + + // + List parentList=new ArrayList(); + + + // ȡ + for (Element parent : parents) {// һ㼶 + // System.out.println("ࣺ"+parent.attribute("name").getValue()); + List childList=new ArrayList(); + // + String parentName = parent.attribute("name").getValue(); + + // type + String parentType = parent.attribute("type").getValue(); + if(treeMap.containsKey(parentName)) { + childList=treeMap.get(parentName); + }else { + parentList.add(parentName); + } + if(parentType.equals("S")) {//"S"ֱ + continue; + } + + //System.out.println("Ϊ"+parentName+"====>Ϊ"+parentType); + // С + List childs = parent.elements(); + for (Element child : childs) { + Map map=new HashMap(); + String childName = child.attribute("name").getValue(); + String childType = child.attribute("type").getValue(); + //System.out.println("СΪ"+childName+"====>Ϊ"+childType); + childList.add(childName); + String attributes=""; + // С + List datas = child.elements(); + for (Element data : datas) { + if (data.getName().equals("prop")) { + if (data.attribute("uidX") != null) { + //System.out.println("СuidΪExcel=====>Ϊ" + data.attribute("uidX").getValue()); + map.put("uidXValue", data.attribute("uidX").getValue()); + } else if (data.attribute("uidI") != null) { + //System.out.println("СuidΪImage=====>Ϊ" + data.attribute("uidI").getValue()); + map.put("uidIValue", data.attribute("uidI").getValue()); + } + } else if (data.getName().equals("class")) { + //System.out.println("Ϊ" + data.getData()); +// if(data.getData().toString().indexOf("")>=0||data.getData().toString().indexOf("С")>=0|| +// data.getData().toString().indexOf("ʱ")>=0||data.getData().toString().indexOf("׼Ṥʱ")>=0|| +// data.getData().toString().indexOf("")>=0||data.getData().toString().indexOf("ע")>=0) { +// //⼸Թ̶չʾclassԹ˵ +// continue; +// } + if(attributes.equals("")) { + attributes=data.getData().toString(); + }else { + attributes=attributes+"&&"+data.getData().toString(); + } + } else if (data.getName().equals("GS")) { + map.put("GS", data.getData().toString()); + //System.out.println("㹫ʽΪ" + data.getData()); + } + + } + map.put("attributes", attributes); + PtoCMap.put(parentName+"/"+childName, map); + } + //System.out.println("--------------------------------"); + treeMap.put(parentName, childList); + } + + + + + //Set parentNames=treeMap.keySet(); + for (String parent : parentList) { + CustomLovBean parentTree=new CustomLovBean(parent); + List children=treeMap.get(parent); + for(String child:children) { + parentTree.addSub(new CustomLovBean(child)); + } + top.addSub(parentTree); + } + + + + new FitterDialog(target,session,top,PtoCMap,Field1,Field2,Field3,Field4); + //new hourCDialog(comp,session,top,PtoCMap); + } + + +} diff --git a/src/cn/net/connor/process/hourcalculation/FitterDialog.java b/src/cn/net/connor/process/hourcalculation/FitterDialog.java new file mode 100644 index 0000000..452005e --- /dev/null +++ b/src/cn/net/connor/process/hourcalculation/FitterDialog.java @@ -0,0 +1,1169 @@ +package cn.net.connor.process.hourcalculation; + +import java.awt.BorderLayout; +import org.apache.poi.ss.usermodel.Sheet; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.sun.prism.impl.Disposer.Target; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.process.Processknowledgebase.CustomLovBean; +import cn.net.connor.process.Processknowledgebase.SqlUtilT; +import cn.net.connor.process.meopviewfx.bean.KTableRow; +import cn.net.connor.process.meopviewfx.bean.PropConfig; +import javafx.scene.control.TableView; +import oracle.sql.ARRAY; +import groovy.lang.Binding; +import groovy.lang.GroovyShell; + +public class FitterDialog extends JFrame{ + + private TCSession session; + private TCComponentBOMLine comp; + private Box boxV1 = Box.createVerticalBox(); + private Box boxV2 = Box.createVerticalBox(); + private Box boxV21 = Box.createVerticalBox(); + private Box boxV22 = Box.createVerticalBox(); + private Box boxH23 = Box.createHorizontalBox(); + public JTextField Field01=new JTextField();//ʱ + public JTextField Field02=new JTextField();//׼Ṥʱ + public JTextField Field03=new JTextField();//ʱ + public JTextField Field04=new JTextField();//׼Ṥʱ + + + private String[] header1 = new String[]{"","ƺ","ղ","ղԴ","ʵֵָ","ע"}; + private JLabel Label0;//д +// private JLabel Label1;// +// private JTextField Field1; +// private JLabel Label2;//С +// private JTextField Field2; +// private JLabel Label3;//ʱ +// private JTextField Field3; +// private JLabel Label4;//׼Ṥʱ +// private JTextField Field4; +// private JLabel Label5;// +// private JTextField Field5; +// private JLabel Label6;//ע +// private JTextField Field6; +// private JLabel Label7; +// private JTextField Field7; +// private JLabel Label8; +// private JTextField Field8; +// private JLabel Label9; +// private JTextField Field9; + + private Vector headVector = new Vector();//ͷ + private Vector tableVector = new Vector();// + private HashMap labelNameToNum=new HashMap();//չʾԶӦıеֵ + private HashMap jlabelTojtext=new HashMap();//չʾдӦ + private HashMap labelToitem=new HashMap();//չʾдưֵдӦ + private ArrayList mustWrite=new ArrayList();//չʾдưֵдӦ + + + private JTable mainTable; +// private JTable mainTable2; +// private Vector headVector = new Vector();//ͷ +// private Vector tableVector2 = new Vector();// + + private JButton calculationButton;// + private JButton cancelButton;// ˳ + private JButton OpenPicButton;// ͼƬ + + private String uidIValue=null;//ͼƬUID + private String uidXValue=null;//EXCELuid + private String attributes=null;//չʾ + private String GS=null; + + + private CustomLovBean top; + private String parent; + private String child; + private TableView table; + private JPanel Right; + private JPanel Center; + private JPanel Left; + private Map> PtoCMap; + + private List> WeldDatas=new ArrayList>();//ͷ + public FitterDialog(TCComponentBOMLine comp,TCSession session,CustomLovBean top,Map> PtoCMap + ,JTextField Field01,JTextField Field02,JTextField Field03,JTextField Field04) throws IOException { + super(); + // TODO Auto-generated constructor stub + this.session=session; + this.comp = comp; + this.top=top; + this.PtoCMap=PtoCMap; + this.Field01=Field01; + this.Field02=Field02; + this.Field03=Field03; + this.Field04=Field04; + init(); + setInitialData(); + } + +// public FitterDialog() { +// super(); +// try { +// init(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + + + private void init() throws IOException { + this.setTitle("ʱ"); + this.setSize(new Dimension(1300, 700)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + //this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + +// Container container = this.getContentPane(); +// container.setLayout(new BorderLayout()); +// container.setSize(new Dimension(800, 600)); + + // + JTree tree = createTree(top); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setPreferredSize(new Dimension(150, 700)); + tree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // ϵ2,˫ + if (e.getClickCount() == 1||e.getClickCount() == 2) { + DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + if (note.isLeaf()) { + System.out + .println("ĸڵ㣺" + note.getParent().toString() + "====" + "ѡеӽڵ" + note.toString()); + parent = note.getParent().toString(); + child = note.toString(); + Map map=PtoCMap.get(parent+"/"+child); + uidIValue=null; + uidXValue=null; + attributes=null; + GS=null; + if(map.get("uidIValue")!=null) { + System.out.println("uidΪImage"); + System.out.println("uidֵΪ"+map.get("uidIValue")); + uidIValue=map.get("uidIValue"); + } + if(map.get("uidXValue")!=null) { + System.out.println("uidΪEXCEL"); + System.out.println("uidֵΪ"+map.get("uidXValue")); + uidXValue=map.get("uidXValue"); + } + if(map.get("attributes")!=null) { + System.out.println("ֵΪ"+map.get("attributes")); + attributes=map.get("attributes"); + } + if(map.get("GS")!=null) { + System.out.println("ʽΪ"+map.get("GS")); + GS=map.get("GS"); + } + getTableValue(); + getShowValue(); + + revalidate(); + repaint(); + //ˢ¿ؼ + validate(); + } + } + + } + }); + + boxV1.add(treePanel); + + // + Right = new JPanel(new FlowLayout()); + JPanel panel = new JPanel(new PropertyLayout()); + panel.setPreferredSize(new Dimension(700, 250)); + this.Label0 = new JLabel("д"); + this.Label0.setPreferredSize(new Dimension(100, 30)); +// this.Label1 = new JLabel(""); +// this.Label1.setPreferredSize(new Dimension(80, 30)); +// this.Field1 = new JTextField(""); +// this.Field1.setPreferredSize(new Dimension(150, 30)); +// this.Label2 = new JLabel("С"); +// this.Label2.setPreferredSize(new Dimension(80, 30)); +// this.Field2 = new JTextField(""); +// this.Field2.setPreferredSize(new Dimension(150, 30)); +// this.Label3 = new JLabel("ʱ"); +// this.Label3.setPreferredSize(new Dimension(80, 30)); +// this.Field3 = new JTextField(""); +// this.Field3.setPreferredSize(new Dimension(150, 30)); +// this.Label4 = new JLabel("׼Ṥʱ"); +// this.Label4.setPreferredSize(new Dimension(80, 30)); +// this.Field4 = new JTextField(""); +// this.Field4.setPreferredSize(new Dimension(150, 30)); +// this.Label5 = new JLabel(""); +// this.Label5.setPreferredSize(new Dimension(80, 30)); +// this.Field5 = new JTextField(""); +// this.Field5.setPreferredSize(new Dimension(150, 30)); +// this.Label6 = new JLabel("ע"); +// this.Label6.setPreferredSize(new Dimension(80, 30)); +// this.Field6 = new JTextField(""); +// this.Field6.setPreferredSize(new Dimension(150, 30)); + + + + + + DefaultTableModel dtm = new DefaultTableModel(tableVector, headVector); + mainTable = new JTable(dtm) {// JtableѡУ޷༭ + public boolean isCellEditable(int row, int column) { + + return false; + } + }; + mainTable.setRowHeight(30); + mainTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderers()); + mainTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);//ñֻѡ + mainTable.setPreferredSize(new Dimension(900,900)); + + // mainTable.setEnabled(false);//ñ񲻿ɱ༭ + mainTable.addMouseListener(new MouseAdapter() { + /** + * + */ + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + SetValueTableToShow(); + } + } + }); + + this.OpenPicButton = new JButton("鿴ͼƬ"); + //this.OpenPicButton.setSize(new Dimension(100, 600)); + this.OpenPicButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + if(uidIValue!=null) { + InitPic(getFile(uidIValue).getAbsolutePath()); + }else { + MessageBox.post("δѡδͼƬ", "ʾ", MessageBox.WARNING); + } + + //dispose(); +// System.out.println(mainTable.getValueAt(0, 3)); +// System.out.println("======>ȡ"); + } + }); + + Box boxV11 = Box.createHorizontalBox(); + JScrollPane J1 = new JScrollPane(); + J1.setPreferredSize(new Dimension(600, 380)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.getVerticalScrollBar().setUnitIncrement(10); + J1.setViewportView(mainTable); + boxV11.add(J1); + boxV11.add(OpenPicButton); + boxV21.add(boxV11); + + + // ðť + this.calculationButton = new JButton(""); + this.calculationButton.setPreferredSize(new Dimension(300, 40)); + this.calculationButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + calculation(); +// Field9.setPreferredSize(new Dimension(500, 90)); +// panel.revalidate(); +// panel.repaint(); + +// searchData(Field1.getText(), Field2.getText(), Field3.getText(), Field4.getText(), Field5.getText(), +// Field6.getText()); + + } + }); + //жûǷдȨ + try { + if(!session.getTCAccessControlService().checkPrivilege(comp.getItemRevision(), "WRITE")) { + calculationButton.setEnabled(false); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.cancelButton = new JButton("ȷ"); + this.cancelButton.setPreferredSize(new Dimension(300, 40)); + this.cancelButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + if(!FillInAll().equals("")) { + MessageBox.post(""+FillInAll()+"δд", "ʾ", MessageBox.WARNING); + }else { + setValueToItem(); + dispose(); + } +// System.out.println(mainTable.getValueAt(0, 3)); +// System.out.println("======>ȡ"); + } + }); + + boxH23.add(cancelButton); + boxH23.add(Box.createHorizontalStrut(100)); + boxH23.add(calculationButton); + + + JScrollPane JBox = new JScrollPane(boxV22); + boxV2.add(boxV21); + boxV2.add(JBox); + boxV2.add(Box.createVerticalStrut(10)); + boxV2.add(boxH23); + this.add(boxV1, BorderLayout.WEST); + this.add(boxV2, BorderLayout.CENTER); + this.setVisible(true); + } + + /** + * ȡĴСԣسʼ + */ + public void setInitialData() { + TCComponent form=null; + try { + form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + if(form!=null) { + String ParentValue=form.getStringProperty("ac5_Jclass01");//ȡֵ + String ChildValue=form.getStringProperty("ac5_Jclass02");//ȡСֵ + System.out.println("ʼʱֵΪ"+ParentValue); + System.out.println("ʼʱСֵΪ"+ChildValue); + if(ParentValue==null||ParentValue.equals("")||ChildValue==null||ChildValue.equals("")) { + System.out.println("ļδҵСԵֵ޷ʼݣ"); + }else { + String ParentAndChildValue=ParentValue+"/"+ChildValue; + System.out.println("СΪ"+ParentAndChildValue); + if(PtoCMap.containsKey(ParentAndChildValue)) { + Map map=PtoCMap.get(ParentAndChildValue); + parent=ParentValue; + child=ChildValue; + uidIValue=null; + uidXValue=null; + attributes=null; + GS=null; + if(map.get("uidIValue")!=null) { + System.out.println("uidΪImage"); + System.out.println("uidֵΪ"+map.get("uidIValue")); + uidIValue=map.get("uidIValue"); + } + if(map.get("uidXValue")!=null) { + System.out.println("uidΪEXCEL"); + System.out.println("uidֵΪ"+map.get("uidXValue")); + uidXValue=map.get("uidXValue"); + } + if(map.get("attributes")!=null) { + System.out.println("ֵΪ"+map.get("attributes")); + attributes=map.get("attributes"); + } + if(map.get("GS")!=null) { + System.out.println("ʽΪ"+map.get("GS")); + GS=map.get("GS"); + } + getTableValue(); + getShowValue(); + + revalidate(); + repaint(); + //ˢ¿ؼ + validate(); + } + } + + }else { + System.out.println("δҵµİ汾"); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + + + + /** + * ˫ѡmainTableУӦдչʾ + */ + public void SetValueTableToShow() { + for (Entry entry : jlabelTojtext.entrySet()) { + //System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue()); + if(labelNameToNum.containsKey(entry.getKey())) { + entry.getValue().setText(mainTable.getValueAt(mainTable.getSelectedRow(), labelNameToNum.get(entry.getKey())-1).toString()); + } + } + } + + + /** + * ͨʽ + */ + public void calculation() { + if(GS==null||GS.equals("")) { + MessageBox.post("ʽδ", "ʾ", MessageBox.WARNING); + return; + } + //ʱJtext + if(!jlabelTojtext.containsKey("ʱ")) { + MessageBox.post("չʾδáʱԣ޷¼", "ʾ", MessageBox.WARNING); + return; + } + //Jtext + if(jlabelTojtext.containsKey("")) { + JTextField FieldQT=jlabelTojtext.get(""); + //ûдʱĬΪ0 + if(FieldQT.getText()==null||FieldQT.getText().equals("")||FieldQT.getText().equals(" ")) { + FieldQT.setText("0"); + } + } + + JTextField FieldDJGS=jlabelTojtext.get("ʱ"); + + System.out.println("ʽΪ"+GS); + Binding binding = new Binding(); + for (Entry entry : jlabelTojtext.entrySet()) { + //System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue()); + if(GS.indexOf(entry.getKey())>=0) { + if(IsDouble(entry.getValue().getText())) { + double value=0; + if(entry.getValue().getText().indexOf("/")>=0) {// + value=(Double.parseDouble(entry.getValue().getText().split("/")[0]))/(Double.parseDouble(entry.getValue().getText().split("/")[1])); + }else { + value= Double.parseDouble(entry.getValue().getText()); + } + + binding.setVariable(entry.getKey(),value ); + }else { + MessageBox.post("չʾб"+entry.getKey()+",ֵ޷빫ʽ㣬ѡ", "ʾ", MessageBox.WARNING); + return; + } + } + } + GroovyShell shell = new GroovyShell(binding); + String str =GS; + str = str.replace("[", "(").replace("]", ")"); + try { + //Object f1 = shell.evaluate("result="+str+";return result"); + String result =String.valueOf( shell.evaluate(str)); + Double resultText=Double.parseDouble(result); +// if(IsDouble(FieldQT.getText())) { +// double value=0; +// if(FieldQT.getText().indexOf("/")>=0) {// +// value=(Double.parseDouble(FieldQT.getText().split("/")[0]))/(Double.parseDouble(FieldQT.getText().split("/")[1])); +// }else { +// value= Double.parseDouble(FieldQT.getText()); +// } +// +// resultText=Double.parseDouble(result)+value; +// }else { +// MessageBox.post("ֵ޷", "ʾ", MessageBox.WARNING); +// return; +// } + BigDecimal b =new BigDecimal(resultText); + resultText = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + FieldDJGS.setText(String.valueOf(resultText)); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post("ʽдδֵı", "ʾ", MessageBox.WARNING); + return; + } + } + + /** + * չʾеıд + */ + public void setValueToItem() { + //Ƚʱ׼Ṥʱעֵдع༭ + if(jlabelTojtext.containsKey("ʱ")&&Field01!=null) { +// double value=Double.parseDouble(jlabelTojtext.get("ʱ").getText()); +// BigDecimal b =new BigDecimal(value); +// value = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + Field01.setText(jlabelTojtext.get("ʱ").getText()); + } + if(jlabelTojtext.containsKey("׼Ṥʱ")&&Field02!=null) { + double value=Double.parseDouble(jlabelTojtext.get("׼Ṥʱ").getText()); + BigDecimal b =new BigDecimal(value); + value = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + Field02.setText(String.valueOf(value)); + } + if(jlabelTojtext.containsKey("")&&Field03!=null) { + Field03.setText(jlabelTojtext.get("").getText()); + } + if(jlabelTojtext.containsKey("")&&Field03!=null) { + Field03.setText(jlabelTojtext.get("").getText()); + } + if(jlabelTojtext.containsKey("ע")&&Field04!=null) { + Field04.setText(jlabelTojtext.get("ע").getText()); + } + + //ѡĴС嵽ac5_Jclass01࣬ac5_Jclass02С࣬汾 + try { + TCComponent form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + form.setProperty("ac5_Jclass01", parent); + form.setProperty("ac5_Jclass02", child); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + //еҪдԵı + for (Entry entry : labelToitem.entrySet()) { + //鿴labelǷ + if(jlabelTojtext.containsKey(entry.getKey())) { + //ȡԿеֵ + String value=jlabelTojtext.get(entry.getKey()).getText(); + //ֵд + if(entry.getValue().equals("")||value==null) { + continue; + } + else if(entry.getValue().indexOf("bomline.")>=0) {//bomline + try { + comp.setProperty(entry.getValue().split("\\.")[1], value); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else if(entry.getValue().indexOf("revmaster.")>=0){//뵽汾 + try { + TCComponent form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + form.setProperty(entry.getValue().split("\\.")[1], value); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(entry.getValue().indexOf(".")>=0){//뵽汾 + try { + comp.getItemRevision().setProperty(entry.getValue().split("\\.")[1], value); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + } + + + /** + * *Ƿд + * @return + */ + public String FillInAll() { + for (Entry entry : jlabelTojtext.entrySet()) { + if(mustWrite.contains(entry.getKey())) { + if(entry.getValue().getText().equals("")) { + return entry.getKey(); + } + } + } + return ""; + } + + + /** + * ǷתΪDouble + * @return + */ + public boolean IsDouble(String str) { + if(str==null||str.equals("")) { + return false; + } + if(str.matches("^(-)?[0-9]+[\\.]?[0-9]*")||str.matches("^(-)?[0-9]+[\\/]?[0-9]*")) { + return true; + } + return false; + } + + + /** + * ѡСʱ± + */ + private void getTableValue() { + if (parent==null||child==null) { + return; + } + tableVector.clear(); + headVector.clear(); + + Workbook wb = null; + Sheet sheet = null; + Row row = null; + if(uidXValue==null||getFile(uidXValue)==null) { + System.out.println("δҵexcel"); + }else { + wb =readExcel(getFile(uidXValue).getAbsolutePath()); + //ȡһsheet + sheet = (Sheet) wb.getSheetAt(0); + //ȡ + int rowNum = ((org.apache.poi.ss.usermodel.Sheet) sheet).getPhysicalNumberOfRows(); + //ȡ + int columnNum=((org.apache.poi.ss.usermodel.Sheet) sheet).getRow(0).getPhysicalNumberOfCells(); + for(int i=0;i=0) { + labelValue=values[0].split("#")[1]; + if(labelValue.indexOf("*")>=0) { + labelValue=labelValue.split("\\*")[1]; + mustWrite.add(labelValue); + } + isWrite=false; + }else { + labelValue=values[0]; + if(labelValue.indexOf("*")>=0) { + labelValue=labelValue.split("\\*")[1]; + mustWrite.add(labelValue); + } + } + + Label = new JLabel(labelValue); + Label.setToolTipText(labelValue); + Label.setPreferredSize(new Dimension(150, 30)); + + if(values.length>3) {//labelToitem + //labelӦдض + labelToitem.put(labelValue, values[1]); + + //textҪȡֵ + System.out.println(values[2]); + if(values[2].equals("")) { + + } + else if(values[2].indexOf("revmaster")>=0) {//ȡ汾 + try { + TCComponent form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + textValue=form.getStringProperty(values[2].split("\\.")[1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(values[2].indexOf("bomline")>=0){//ȡbomline + try { + String[] ssString=values[2].split("\\."); + System.out.println(Arrays.toString(ssString)); + textValue=comp.getStringProperty(ssString[1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else {//ȡ汾 + try { + textValue=comp.getItemRevision().getStringProperty(values[2].split("\\.")[1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //ȡǩӦ + if(!values[3].equals("")) { + labelNameToNum.put(labelValue, Integer.parseInt(values[3])); + } + + }else{ + System.out.println("ó"); + } + + Field = new JTextField(textValue); + Field.setPreferredSize(new Dimension(150, 30)); + + + + if(!isWrite) { + Field.setEnabled(false); + } + + jlabelTojtext.put(Label.getText(),Field); + boxh.add(Label); + boxh.add(Field); + if(i==attribute.length) { + boxV22.add(boxh); + } + }else { + JLabel Label; + JTextField Field; + //class洢 + String attr=attribute[i-1]; + //ָ + //ȡLabelƣ + String labelValue=""; + String textValue=""; + boolean isWrite=true;//Ƿ޸ + //ָ=һlabelǩƣڶдضƣڶǻȡֵƣĸѡexcelʱñǩӦ + String[] values=attr.split("=",-1); + if(values[0].indexOf("#")>=0) { + labelValue=values[0].split("#")[1]; + if(labelValue.indexOf("*")>=0) { + labelValue=labelValue.split("\\*")[1]; + mustWrite.add(labelValue); + } + isWrite=false; + }else { + labelValue=values[0]; + if(labelValue.indexOf("*")>=0) { + labelValue=labelValue.split("\\*")[1]; + mustWrite.add(labelValue); + } + } + + Label = new JLabel(labelValue); + Label.setToolTipText(labelValue); + Label.setPreferredSize(new Dimension(150, 30)); + + if(values.length>3) {//labelToitem + //labelӦдض + labelToitem.put(labelValue, values[1]); + + //textҪȡֵ + if(values[2].equals("")) { + + } + else if(values[2].indexOf("revmaster")>=0) {//ȡ汾 + try { + TCComponent form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + textValue=form.getStringProperty(values[2].split("\\.")[1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(values[2].indexOf("bomline")>=0){//ȡbomline + try { + textValue=comp.getStringProperty(values[2].split("\\.")[1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else {//ȡ汾 + try { + textValue=comp.getItemRevision().getStringProperty(values[2].split("\\.")[1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //ȡǩӦ + if(!values[3].equals("")) { + labelNameToNum.put(labelValue, Integer.parseInt(values[3])); + } + + }else{ + System.out.println("ó"); + } + + Field = new JTextField(textValue); + Field.setPreferredSize(new Dimension(150, 30)); + + if(!isWrite) { + Field.setEnabled(false); + } + + jlabelTojtext.put(Label.getText(),Field); + boxh.add(Label); + boxh.add(Field); + boxV22.add(boxh); + } + } +// Box boxhShow4 = Box.createHorizontalBox(); +// boxhShow4.add(Label5); +// boxhShow4.add(Field5); +// Box boxhShow5 = Box.createHorizontalBox(); +// boxhShow5.add(Label6); +// boxhShow5.add(Field6); +// jlabelTojtext.put(Label5.getText(),Field5); +// jlabelTojtext.put(Label6.getText(),Field6); +// boxV22.add(boxhShow4); +// boxV22.add(boxhShow5); + } + + + /** + * ȡexcel + * @param sheet + * @param row + * @param column + * @return + */ + public String getSheetValue(Sheet sheet,int row,int column) { +// sheet.getRow(row).getCell(column).setCellType(Cell.CELL_TYPE_STRING);//õԪΪString,ܻȡstringֵ +// return sheet.getRow(row).getCell(column).getStringCellValue(); + String cellValue=""; + Cell cell = sheet.getRow(row).getCell(column); + if (null != cell) { + // жݵ + switch (cell.getCellType()) { + case Cell.CELL_TYPE_NUMERIC: // +// String value=String.valueOf(cell.getNumericCellValue()); +// if(value.contains(".")) { +// +// } +// DecimalFormat df = new DecimalFormat("0"); +// cellValue = df.format(cell.getNumericCellValue()); + if(cell.getNumericCellValue()==0.0) { + cellValue="0"; + }else { + cellValue=String.valueOf(cell.getNumericCellValue()); + } + + break; + case Cell.CELL_TYPE_STRING: // ַ + cellValue = cell.getStringCellValue(); + break; + case Cell.CELL_TYPE_BOOLEAN: // Boolean + cellValue = cell.getBooleanCellValue() + ""; + break; + case Cell.CELL_TYPE_FORMULA: // ʽ + cellValue = cell.getCellFormula() + ""; + break; + case Cell.CELL_TYPE_BLANK: // ֵ + cellValue = ""; + break; + case Cell.CELL_TYPE_ERROR: // + cellValue = "Ƿַ"; + break; + default: + cellValue = "δ֪"; + break; + } + } + return cellValue; + } + + + + + /** + * 鿴ͼƬ + * + */ + public void InitPic(String picPath) { + //ϵͳĬϵIJ鿴 + File f = new File(picPath); + Desktop dt = Desktop.getDesktop(); + try { + dt.open(f); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("open picture over ."); +// String fileName = picPath; +// +// String [] commands = { +// +// "cmd.exe" , "/c", "start" , "\"DummyTitle\"", "\"" + fileName + "\"" +// +// }; +// +// Process p; +// try { +// p = Runtime.getRuntime().exec(commands); +// p.waitFor(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + + + System.out.println("Done."); +// JFrame jf=new JFrame("ͼƬչʾ"); +// jf.setPreferredSize(new Dimension(600,300)); +// //1.ͼƬӵǩѱǩĴСΪͼƬСͬѱǩڷֲײ㣻 +// ImageIcon bg=new ImageIcon(picPath); +// if(bg==null) { +// MessageBox.post("δѡδͼƬ", "ʾ", MessageBox.WARNING); +// return; +// } +// JLabel label=new JLabel(bg); +// //label.setSize(bg.getIconWidth(),bg.getIconHeight()); +// //jf.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE)); +// //2.ѴΪ岢Ϊ͸֡ +//// JPanel pan=(JPanel)jf.getContentPane(); +//// pan.setOpaque(false); +//// pan.setLayout(new FlowLayout()); +// JLabel jl=new JLabel(bg); +// //jl.setIcon(bg); +// jf.setAlwaysOnTop(true); +// jf.setSize(bg.getIconWidth(),bg.getIconHeight()); +// jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); +//// Box box=Box.createHorizontalBox(); +//// box.add(jl); +// jf.add(jl,BorderLayout.CENTER); +// jf.setVisible(true); + } + + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.setShowsRootHandles(false); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tree.putClientProperty("JTree.lineStyle","Angled"); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + // cellRenderer.setOpenIcon(new ImageIcon("Swing/1.jpg")); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + + } + + /** + * + * @param uid:ݼuid + * @return + */ + public File getFile(String uid) { + TCComponentDataset dat; + try { + dat = (TCComponentDataset)session + .stringToComponent(uid); + if(dat==null) { + return null; + } + TCComponentTcFile[] tcFile = dat.getTcFiles(); + // if(tcFile != null && tcFile.length == 0) + if(tcFile == null || tcFile.length == 0) + { + System.out.println("ͨuid:"+uid+",δҵݼ"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + + +// + public Workbook readExcel(String filePath) { + Workbook wb = null; + if (filePath == null) { + return null; + } + String extString = filePath.substring(filePath.indexOf('.')); + InputStream is = null; + try { + is = new FileInputStream(filePath); + if (".xls".equals(extString)) { + return wb = new HSSFWorkbook(is); + } else if (".xlsx".equals(extString)) { + return wb = new XSSFWorkbook(is); + } else { + return wb = null; + } + + } catch (FileNotFoundException e) { + System.out.println(e.toString()); + } catch (IOException e) { + System.out.println(e.toString()); + } catch (NoClassDefFoundError e) { + System.out.println(e.toString()); + } + return wb; + } + +} + + +class TableCellTextAreaRenderers extends JTextArea implements TableCellRenderer { + public TableCellTextAreaRenderers() { + setLineWrap(true); + setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + if (isSelected) { + setBackground(new Color(176,224,230)); + setForeground(Color.black); + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } +} + + + diff --git a/src/cn/net/connor/process/hourcalculation/MethodUtil.java b/src/cn/net/connor/process/hourcalculation/MethodUtil.java new file mode 100644 index 0000000..3ac644a --- /dev/null +++ b/src/cn/net/connor/process/hourcalculation/MethodUtil.java @@ -0,0 +1,77 @@ +package cn.net.connor.process.hourcalculation; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class MethodUtil { + /** + * ͨUIDݼ + * @param puid + * @param session + * @return + */ + public static File getDatByUid(String puid,TCSession session) { + File fmsFile=null; + TCComponentDataset dataset; + try { + dataset = (TCComponentDataset) session + .stringToComponent(puid); + if (dataset == null) { + return null; + } + TCComponentTcFile[] file = dataset.getTcFiles(); + fmsFile = file[0].getFmsFile(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return fmsFile; + } + + /** + * ͨļ·workbookfile.getAbsolutePath() + * @param filePath + * @return + */ + public static Workbook readExcel(String filePath) { + Workbook wb = null; + if (filePath == null) { + return null; + } + String extString = filePath.substring(filePath.indexOf('.')); + InputStream is = null; + try { + is = new FileInputStream(filePath); + if (".xls".equals(extString)) { + return wb = new HSSFWorkbook(is); + } else if (".xlsx".equals(extString)) { + return wb = new XSSFWorkbook(is); + } else { + return wb = null; + } + + } catch (FileNotFoundException e) { + System.out.println(e.toString()); + } catch (IOException e) { + System.out.println(e.toString()); + } catch (NoClassDefFoundError e) { + System.out.println(e.toString()); + } + return wb; + } + + +} diff --git a/src/cn/net/connor/process/hourcalculation/calculation.java b/src/cn/net/connor/process/hourcalculation/calculation.java new file mode 100644 index 0000000..d731048 --- /dev/null +++ b/src/cn/net/connor/process/hourcalculation/calculation.java @@ -0,0 +1,29 @@ +package cn.net.connor.process.hourcalculation; + +import groovy.lang.Binding; +import groovy.lang.GroovyShell; + +public class calculation { + public static void main(String[] args) { + Binding binding = new Binding(); + binding.setVariable("", 1.0); + binding.setVariable("е", 2.0); + binding.setVariable("", 3.0); + binding.setVariable("ÿԭϿɳ", 4.0); + binding.setVariable("ͷ", 5.0); + + binding.setVariable("language", "Groovy"); + + GroovyShell shell = new GroovyShell(binding); + String str = "[(+е+)*ÿԭϿɳ+ͷ]/2"; + str = str.replace("[", "(").replace("]", ")"); + try { + String f1 =String.valueOf(shell.evaluate(str)); + System.out.println(f1); + } catch (Exception e) { + // TODO: handle exception + System.out.println("ʽдδֵı"); + } + + } +} diff --git a/src/cn/net/connor/process/hourcalculation/hourCCommand.java b/src/cn/net/connor/process/hourcalculation/hourCCommand.java new file mode 100644 index 0000000..3a60a56 --- /dev/null +++ b/src/cn/net/connor/process/hourcalculation/hourCCommand.java @@ -0,0 +1,115 @@ +package cn.net.connor.process.hourcalculation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.swing.JTextField; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import cn.net.connor.process.Processknowledgebase.CustomLovBean; + +public class hourCCommand extends AbstractAIFCommand { + + private TCSession session; + private TCComponentBOMLine target; + public JTextField Field1=new JTextField(); + public JTextField Field2=new JTextField(); + public JTextField Field3=new JTextField(); + public JTextField Field4=new JTextField(); + public JTextField Field5=new JTextField(); +// public hourCCommand(TCComponentBOMLine comp, TableView table, List propConfigs) { +// // TODO Auto-generated constructor stub +// this.comp = comp; +// this.propConfigs = propConfigs; +// try { +// executeModal(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + public hourCCommand(TCSession session,TCComponentBOMLine target,JTextField Field1,JTextField Field2, + JTextField Field3,JTextField Field4,JTextField Field5) { + // TODO Auto-generated constructor stub + try { + + this.session=session; + this.target=target; + this.Field1=Field1; + this.Field2=Field2; + this.Field3=Field3; + this.Field4=Field4; + this.Field5=Field5; + + executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + CustomLovBean top = new CustomLovBean("չ"); + //ȡѡķ + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("AVIC_Assemblyhours_Classification"); //QrlNBWsgJ19vPC + + + // Map parentMap=new HashMap();// + Map> PtoCMap = new HashMap>();// + + // + List parentList=new ArrayList(); + + for(String str:strs) { + if(str.indexOf("=")>=0) { + String[] value=str.split("="); + if(value.length==3) { + if(!parentList.contains(value[0])) { + parentList.add(value[0]); + } + if(!PtoCMap.containsKey(value[0])) { + Map map=new HashMap(); + map.put(value[1],value[2]); + PtoCMap.put(value[0], map); + }else { + Map map=PtoCMap.get(value[0]); + map.put(value[1],value[2]); + PtoCMap.put(value[0], map); + } + } + } + + } + //Set parents=PtoCMap.keySet(); + for (String parent : parentList) { + CustomLovBean parentTree=new CustomLovBean(parent); + Map children=PtoCMap.get(parent); + Set childs=children.keySet(); + for(String child:childs) { + parentTree.addSub(new CustomLovBean(child)); + } + top.addSub(parentTree); + } + + //ж϶ǷдȨ + TCComponentItemRevision rev = this.target.getItemRevision(); + boolean isWrite = session.getTCAccessControlService().checkPrivilege(rev, "WRITE"); + + + new hourCDialog(target,session,top,PtoCMap,isWrite,Field1,Field2,Field3,Field4,Field5); + } + + +} + + + diff --git a/src/cn/net/connor/process/hourcalculation/hourCDialog.java b/src/cn/net/connor/process/hourcalculation/hourCDialog.java new file mode 100644 index 0000000..8df05a6 --- /dev/null +++ b/src/cn/net/connor/process/hourcalculation/hourCDialog.java @@ -0,0 +1,1289 @@ +package cn.net.connor.process.hourcalculation; + +import java.awt.BorderLayout; +import org.apache.poi.ss.usermodel.Sheet; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.process.Processknowledgebase.CustomLovBean; + +public class hourCDialog extends JFrame { + + /** + * + */ + private static final long serialVersionUID = 1L; + private TCSession session; + private TCComponentBOMLine comp; +// private TCComponentBOMLine topBomline; + private int materialNum=0; + private MyCheckBoxRenderer check; + + private JLabel Label1;// + private JTextField Field1; + private JLabel Label2;// ƺ + private JTextField Field2; + private String Field2Value=""; + private JLabel Label3;// ղ + private JTextArea Field3; + private JLabel Label4;// ղԴ +// private JTextField Field4; + private JLabel Label5;// ʵֵָ +// private JTextField Field5; + private JLabel Label6;// ע +// private JTextField Field6; + private JButton Label7;// + private JTextField Field7; + private JButton Label8;// + private JTextField Field8; + + private Vector headVector1 = new Vector<>();// ͷ + private Vector> tableVector1 = new Vector<>();// + + private JTable mainTable1; + private JTable mainTable2; + private Vector headVector2 = new Vector<>();// ͷ + private Vector> tableVector2 = new Vector<>();// + + private JButton searchButton;// + private JButton sureButton;// ȷ + private JButton cancelButton;// ˳ + private JButton moveRight;// + private JButton moveLeft;// + + private CustomLovBean top; + private String parent; + private String child; +// private TableView table; + private JPanel Right; +// private JPanel Center; +// private JPanel Left; + private Map> PtoCMap; + private boolean isWrite = true; + public JTextField Field01=new JTextField(); + public JTextField Field02=new JTextField(); + public JTextField Field03=new JTextField(); + public JTextField Field04=new JTextField(); + public JTextField Field05=new JTextField(); + +// private List> WeldDatas = new ArrayList>();// ͷ + + public hourCDialog(TCComponentBOMLine comp, TCSession session, CustomLovBean top, + Map> PtoCMap, boolean isWrite,JTextField Field01,JTextField Field02, + JTextField Field03,JTextField Field04,JTextField Field05) throws IOException { + super(); + // Auto-generated constructor stub + this.session = session; + this.comp = comp; + this.top = top; + this.PtoCMap = PtoCMap; + this.isWrite = isWrite; + this.Field01=Field01; + this.Field02=Field02; + this.Field03=Field03; + this.Field04=Field04; + this.Field05=Field05; + init(); + } + + private void init() throws IOException { + this.setTitle("ʱ"); + this.setSize(new Dimension(1640, 700)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + //this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + getBomLineData(); +// Container container = this.getContentPane(); +// container.setLayout(new BorderLayout()); +// container.setSize(new Dimension(800, 600)); + + // + JTree tree=createTree(top); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setPreferredSize(new Dimension(300, 600)); + tree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + // ϵ2,˫ + if (e.getClickCount() == 1||e.getClickCount() == 2) { + DefaultMutableTreeNode note = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + if(note.isLeaf()){ + System.out.println("ĸڵ㣺"+note.getParent().toString()+"===="+"ѡеӽڵ"+note.toString()); + parent=note.getParent().toString(); + child=note.toString(); + check.setSelected(false); + getTableValue(); + } + } + } + }); + + //ñ1 + headVector1.add("select"); + headVector1.add(""); + headVector1.add(""); + headVector1.add("׼ʱ"); + headVector1.add("ʱ"); + headVector1.add("ע"); + DefaultTableModel dtm1 = new DefaultTableModel(tableVector1,headVector1); + + mainTable1=new JTable(dtm1){// JtableѡУ޷༭ + /** + * + */ + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + if(column==0) { + return true; + } + return false; + } +// public Class getColumnClass(int c){ +// +// Object value = getValueAt(0, c); +// +// if(value!=null) +// +// return value.getClass(); +// +// else return super.getClass(); +// +// } + }; + check = new MyCheckBoxRenderer(); + check.setText("ȫѡ"); + mainTable1.getColumn("select").setHeaderRenderer(check); + mainTable1.getTableHeader().addMouseListener(new MouseAdapter() { + @Override + + public void mouseClicked(MouseEvent e){ + + if(mainTable1.getColumnModel().getColumnIndexAtX(e.getX())==0){//ǵ0Уcheckboxһ + + //޸ȫѡť + boolean b = !check.isSelected(); + check.setSelected(b); + + //ѡеʱΪfalse޸һȫѡťtrueеѡ + if(check.isSelected()) { + for(int i=0;i"+mainTable1.getTableHeader().getColumnModel().getColumn(0).getPreferredWidth()); + mainTable1.getTableHeader().getColumnModel().getColumn(0).setPreferredWidth(mainTable1.getTableHeader().getColumnModel().getColumn(0).getPreferredWidth()/2); + mainTable1.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(mainTable1.getTableHeader().getColumnModel().getColumn(2).getPreferredWidth()/2); + // System.out.println("===="+mainTable1.getTableHeader().getColumnModel().getColumn(0).getPreferredWidth()); + JScrollPane J1= new JScrollPane(); + J1.setPreferredSize(new Dimension(520, 600)); + J1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + J1.setViewportView(mainTable1); +// Center.add("1,1,left,top",J1); + + + JPanel panel3=new JPanel(new PropertyLayout()); + panel3.setPreferredSize(new Dimension(80, 600)); + + this.moveRight=new JButton(">>"); + this.moveRight.setPreferredSize(new Dimension(80, 30)); + this.moveRight.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + + moveTableData(); + System.out.println(">>"); + } + }); + + + + + this.moveLeft=new JButton("<<"); + this.moveLeft.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + DefaultTableModel model = (DefaultTableModel)mainTable2.getModel();//ȡģ; + if(mainTable2.getSelectedRow()>=0) { + System.out.println("ѡ"+Arrays.toString(mainTable2.getSelectedRows())); + //ֱmainTable2.getSelectedRows().lengthѭΪÿɾһоͻᵼmainTable2.getSelectedRows().lengthб仯 + int selectRows=mainTable2.getSelectedRows().length; + for(int i=selectRows-1;i>=0;i--) {//ӺǰʼɾӰǰк + System.out.println("ѡ===>"+mainTable2.getSelectedRows()[i]); + model.removeRow(mainTable2.getSelectedRows()[i]); + } + reSetTableNo(2); + } + System.out.println("<<"); + } + }); + this.moveLeft.setPreferredSize(new Dimension(80, 30)); + JLabel labelnull1=new JLabel(""); + labelnull1.setPreferredSize(new Dimension(80, 200)); + panel3.add("1.1.left.center",labelnull1); + panel3.add("2.1.left.center",moveRight); + panel3.add("3.1.left.center",moveLeft); + + JPanel panel4=new JPanel(new BorderLayout()); + panel4.add(panel3, BorderLayout.EAST); + panel4.add(J1, BorderLayout.CENTER); + + + + //ñ1 + headVector2.add(""); + headVector2.add(""); + headVector2.add("С"); + headVector2.add(""); + headVector2.add("׼ʱ"); + headVector2.add("ʱ"); + headVector2.add("ע"); + headVector2.add(""); + //汾е//// + if(comp!=null) { + TCComponent form; + try { + form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + if(form!=null) { + TCProperty p = form.getTCProperty("ac5_DataItem"); + String[] tableValues; + if(p == null) { + tableValues = new String[] { }; + }else { + tableValues = p.getStringArrayValue(); + } + System.out.println("ac5_DataItem===>"+Arrays.toString(tableValues)); + if(tableValues!=null&&tableValues.length>0){ + + for(int i=0;i"+tableValue); + if(tableValue!=null&&tableValue.split("&").length>=8) { + Vector rowVector = new Vector<>(); + rowVector.add(tableValue.split("&")[0]); + rowVector.add(tableValue.split("&")[1]); + rowVector.add(tableValue.split("&")[2]); + rowVector.add(tableValue.split("&")[3]); + rowVector.add(tableValue.split("&")[4]); + rowVector.add(tableValue.split("&")[5]); + rowVector.add(tableValue.split("&")[6]); + rowVector.add(tableValue.split("&")[7]); + tableVector2.add(rowVector); + } + + } + } + } + } catch (TCException e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + + DefaultTableModel dtm2 = new DefaultTableModel(tableVector2,headVector2){ + /** + * + */ + private static final long serialVersionUID = 1L; + + public void setValueAt(Object aValue, int rowIndex, int columnIndex) + + { + if (columnIndex == 7) { + try { + if(aValue.equals("")||aValue==null) { + return; + } + //ʽжǷ + if(((String) aValue).matches("[0-9]*[\\.]?[0-9]*")) { + super.setValueAt(aValue,rowIndex,columnIndex); + }else { + MessageBox.post("ֻд֣޷", "", MessageBox.ERROR); + } + } catch (Exception ex) { + //javax.swing.JOptionPane.showMessageDialog(null, "ֻ!"); + MessageBox.post("ֻд֣޷", "", MessageBox.ERROR); + //System.out.println("ֻ"); + return; + + } + } + + } + }; + mainTable2=new JTable(dtm2){// JtableѡУ޷༭ + /** + * + */ + private static final long serialVersionUID = 1L; + + public boolean isCellEditable(int row, int column) { + if(column==7) { + return true; + } + return false; + } + }; + mainTable2.setPreferredSize(new Dimension(900,900)); + mainTable2.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); + mainTable2.setRowHeight(30); + + JScrollPane J2= new JScrollPane(mainTable2); + J2.setPreferredSize(new Dimension(550, 600)); + J2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + //J2.getVerticalScrollBar().setUnitIncrement(10); + //J2.setViewportView(mainTable2); +// JPanel Center=new JPanel(new FlowLayout()); +// Center.add("1.2.left.center", sp); +// Center.add("1,3,left,top",J2); + + + + // + Right=new JPanel(new FlowLayout()); + Right.setPreferredSize(new Dimension(700, 500)); + JPanel panel = new JPanel(new PropertyLayout()); + panel.setPreferredSize(new Dimension(150, 600)); + this.Label1 = new JLabel(""); + this.Label1.setPreferredSize(new Dimension(100, 30)); + System.out.println("Ϊ"+materialNum); + if(materialNum>0) { + this.Field1 = new JTextField(String.valueOf(materialNum)); + }else { + this.Field1 = new JTextField(""); + } + this.Field1.setEnabled(false); + this.Field1.setPreferredSize(new Dimension(150, 30)); + + this.Label2 = new JLabel(""); + this.Label2.setPreferredSize(new Dimension(100, 30)); + this.Field2 = new JTextField("0"); + Field2.addFocusListener(new FocusListener() { + + @Override + //ʧȥ + public void focusLost(FocusEvent e) { + if((Field2.getText()).matches("^(-)?[0-9]*[\\.]?[0-9]*")||Field2.getText().equals("")) { + + }else { + Field2.setText(Field2Value); + //MessageBox.post("ֻд֣޷", "", MessageBox.ERROR); +// new Thread() { +// @Override +// public void run() { +// MessageBox.post("ֻд֣޷", "", MessageBox.ERROR); +// } +// }.start(); + } + } + + @Override + //ý + public void focusGained(FocusEvent arg0) { + // Auto-generated method stub + Field2Value=Field2.getText(); + } + + }); + this.Field2.setPreferredSize(new Dimension(150, 30)); + + + this.Label3 = new JLabel("ע"); + this.Label3.setPreferredSize(new Dimension(100, 30)); + this.Field3 = new JTextArea(""); + + JScrollPane JF = new JScrollPane(Field3); + JF.setPreferredSize(new Dimension(150, 200)); + + panel.add("1.1.left.top",Label1); + panel.add("2.1.left.top",Field1); + panel.add("3.1.left.top",Label2); + panel.add("4.1.left.top",Field2); + panel.add("5.1.left.top",Label3); + panel.add("6.1.left.top",JF); + +// JScrollPane J3= new JScrollPane(panel); +// //J3.setPreferredSize(new Dimension(600, 50)); +// J3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// Center.add("1.3.left.top",panel); + + + //ðť +// JPanel pane2 = new JPanel(new PropertyLayout()); + this.searchButton=new JButton(""); + if(!isWrite) { + this.searchButton.setEnabled(false); + } + this.searchButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + //ʱʧȥ񽹵 + if (mainTable2.getSelectedRow() >= 0 && mainTable2.getSelectedColumn() >= 0) { + (mainTable2.getCellEditor(mainTable2.getSelectedRow(), mainTable2.getSelectedColumn())).stopCellEditing(); + } + + + NumIsNull();//жϱ2Ƿпֵ + System.out.println(""); + if(NumIsNull()) { + MessageBox.post("пֵȷд", "", MessageBox.ERROR); + } + getCalculationData("ʱ"); + getCalculationData("׼Ṥʱ"); + } + }); + this.searchButton.setPreferredSize(new Dimension(80, 30)); + + Label4 = new JLabel(" "); + Label4.setPreferredSize(new Dimension(200, 30)); + Label5 = new JLabel(" "); + Label5.setPreferredSize(new Dimension(70, 30)); + Label6 = new JLabel(" "); + Label6.setPreferredSize(new Dimension(70, 30)); + JLabel Label9 = new JLabel(" "); + Label9.setPreferredSize(new Dimension(70, 30)); + JLabel Label0 = new JLabel(" "); + Label0.setPreferredSize(new Dimension(70, 30)); + + this.Label7 = new JButton("׼Ṥʱ"); + this.Label7.setPreferredSize(new Dimension(120, 30)); + this.Field7 = new JTextField(""); + this.Field7.setPreferredSize(new Dimension(150, 30)); + this.Field7.setEnabled(false); + this.Label8 = new JButton("ʱ"); + this.Label8.setPreferredSize(new Dimension(120, 30)); + this.Field8 = new JTextField(""); + this.Field8.setPreferredSize(new Dimension(150, 30)); + this.Field8.setEnabled(false); + + //汾е + if(comp!=null) { + TCComponent form; + try { + form = comp.getItemRevision().getRelatedComponent("IMAN_master_form_rev"); + if(form!=null) { + //ֵ + if(form.getStringProperty("ac5_Other")!=null) { + if(form.getStringProperty("ac5_Other").equals("")) { + Field2.setText("0"); + }else { + Field2.setText(form.getStringProperty("ac5_Other")); + } + }else { + Field2.setText("0"); + } + //ñעֵ + if(form.getStringProperty("ac5_Remark")!=null) { + Field3.setText(form.getStringProperty("ac5_Remark")); + } + //׼Ṥʱֵ + if(form.getStringProperty("ac5_AccurateHours")!=null) { + Field7.setText(form.getStringProperty("ac5_AccurateHours")); + } + //õʱֵ + if(form.getStringProperty("ac5_SingleWorkingHours")!=null) { + Field8.setText(form.getStringProperty("ac5_SingleWorkingHours")); + } + + } + } catch (TCException e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + + } + + + this.sureButton=new JButton("ȷ"); + this.sureButton.setPreferredSize(new Dimension(80, 30)); + if(!isWrite) { + this.sureButton.setEnabled(false); + } + this.sureButton.addActionListener(new ActionListener() { + // ťʱͻᴥ ActionEvent¼ + // actionPerformed ͻᱻִ + public void actionPerformed(ActionEvent e) { + System.out.println("ȷ:"); + // List> lists=new ArrayList>(); + String list=""; + if(mainTable2==null) { + System.out.println("mainTable2Ϊ"); + } + + for(int i=0;iȡ"); + } + }); + this.cancelButton.setPreferredSize(new Dimension(80, 30)); + + FlowLayout flow = new FlowLayout(); + flow.setAlignment(FlowLayout.CENTER); + JPanel pane2 = new JPanel(new FlowLayout(FlowLayout.CENTER)); + pane2.setPreferredSize(new Dimension(200, 50)); +// pane2.add(Label4); + pane2.add(sureButton); +// pane2.add(Label5); + pane2.add(cancelButton); +// pane2.add(Label6); + pane2.add(searchButton); + +// pane2.add("1.7.center.top",Label9); +// pane2.add("1.8.center.top",Label7); +// pane2.add("1.9.center.top",Field7); +// pane2.add("1.10.center.top",Label0); +// pane2.add("1.11.center.top",Label8); +// pane2.add("1.12.center.top",Field8); + panel.add("7.1.left.top",Label7); + panel.add("8.1.left.top",Field7); + panel.add("9.1.left.top",Label8); + panel.add("10.1.left.top",Field8); + + JPanel panel5=new JPanel(new BorderLayout()); + panel5.add(J2, BorderLayout.CENTER); + + JSplitPane center = new JSplitPane();//TODO JSplitPane + center.setLeftComponent(panel4); + center.setRightComponent(panel5); + +// // ť JSplitPane ڵһ +// JSplitPane center = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel4, J2); // +// center.setDividerLocation(600); // +// center.add(pane2, BorderLayout.SOUTH); // + + this.add(treePanel, BorderLayout.WEST); +// this.add(mainTable1, BorderLayout.CENTER); + this.add(center, BorderLayout.CENTER); + this.add(panel, BorderLayout.EAST); + this.add(pane2, BorderLayout.SOUTH); // ťӵ JFrame SOUTH +// this.add(pane2, BorderLayout.SOUTH); +// this.pack(); +// this.show(); + this.setVisible(true); + } + + /** + * ȡֵ + */ + public void getCalculationData(String flag) { + if(flag.equals("ʱ")) { + double nums=0; + for(int i=0;i rowVector = new Vector<>(); + rowVector.add(model2.getRowCount() + 1); + rowVector.add(parent); + rowVector.add(child); + rowVector.add(model1.getValueAt(i, 2)); + rowVector.add(model1.getValueAt(i, 3)); + rowVector.add(model1.getValueAt(i, 4)); + rowVector.add(model1.getValueAt(i, 5)); + rowVector.add(null); + model2.addRow(rowVector); + } + } + // model1.removeRow(mainTable1.getSelectedRow()); + } + + /** + * ȡϲ㹤IMAN_METargetϵ£bomṹе + */ + public void getBomLineData() { + TCComponentBOMLine processBomLine=comp.getCachedParent(); + String ID=""; + try { + ID=comp.getItemRevision().getStringProperty("item_id"); + } catch (TCException e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + if(processBomLine!=null) { + try {//ұ:bl_sequence_no + int No=Integer.parseInt(comp.getStringProperty("bl_sequence_no")); + System.out.println("ѡж"+ID+"ıΪ:"+No); + boolean isMin=true; + AIFComponentContext[] childBomline=processBomLine.getChildren(); + for(AIFComponentContext bomline:childBomline) { + if(Integer.parseInt(((TCComponentBOMLine)bomline.getComponent()).getStringProperty("bl_sequence_no")) listID=new ArrayList(); + for(AIFComponentContext bomline:METargetchilds) { + if(!listID.contains(((TCComponentBOMLine)(bomline.getComponent())).getItemRevision().getStringProperty("item_id"))) { + listID.add(((TCComponentBOMLine)(bomline.getComponent())).getItemRevision().getStringProperty("item_id")); + } + } + System.out.println("µȫӶ"+listID.toString()); + System.out.println("listIDΪ"+listID.size()); + materialNum=listID.size(); + System.out.println("materialNumֵ"+materialNum); + } + } + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + + } + + } + + + public boolean NumIsNull() { + for(int i=0;i> tableVector22 = new Vector<>();// + for (int i = 0; i < rowNum; i++) { + + Vector rowVector = new Vector<>(); + rowVector.add(i + 1); + rowVector.add(model2.getValueAt(i, 1)); + rowVector.add(model2.getValueAt(i, 2)); + rowVector.add(model2.getValueAt(i, 3)); + rowVector.add(model2.getValueAt(i, 4)); + rowVector.add(model2.getValueAt(i, 5)); + rowVector.add(model2.getValueAt(i, 6)); + rowVector.add(model2.getValueAt(i, 7)); + tableVector22.add(rowVector); + } + tableVector2.clear(); + tableVector2 = tableVector22; + } + + DefaultTableModel dtm = (DefaultTableModel) mainTable2.getModel();// ȡģ + + dtm.setDataVector(tableVector2, headVector2);// + mainTable2.updateUI();// ʾ + } else { + return; + } + } + + + /** + * ǷתΪDouble + * @return + */ + public boolean IsDouble(String str) { + if(str==null||str.equals("")) { + return false; + } + if(str.matches("[0-9]+[\\.]?[0-9]*")||str.matches("[0-9]+[\\/]?[0-9]*")) { + return true; + } + return false; + } + + /** + * ѡСʱ± + */ + private void getTableValue() { + if (parent == null || child == null) { + return; + } + tableVector1.clear(); + System.out.println(PtoCMap.get(parent).get(child)); + + Workbook wb = null; + Sheet sheet = null; +// Row row = null; + wb = readExcel(getFile(PtoCMap.get(parent).get(child)).getAbsolutePath()); + // ȡһsheet + sheet = (Sheet) wb.getSheetAt(0); + // ȡ + //int rowNum = ((org.apache.poi.ss.usermodel.Sheet) sheet).getPhysicalNumberOfRows(); + int rowNum = sheet.getPhysicalNumberOfRows(); + for (int i = 1; i rowVector = new Vector<>(); + rowVector.add(false); + rowVector.add(i); +// sheet.getRow(i).getCell(0).setCellType(Cell.CELL_TYPE_STRING);// õԪΪString,ܻȡstringֵ +// rowVector.add(sheet.getRow(i).getCell(0).getStringCellValue()); +// +// sheet.getRow(i).getCell(1).setCellType(Cell.CELL_TYPE_STRING); +// rowVector.add(sheet.getRow(i).getCell(1).getStringCellValue()); +// +// //sheet.getRow(i).getCell(2).setCellType(Cell.CELL_TYPE_STRING); +// //׼ʱȡָʽ +// rowVector.add(sheet.getRow(i).getCell(2).getNumericCellValue()); +// sheet.getRow(i).getCell(3).setCellType(Cell.CELL_TYPE_STRING); +// rowVector.add(sheet.getRow(i).getCell(3).getStringCellValue()); + rowVector.add(getSheetValue(sheet,i,0)); + rowVector.add(getSheetValue(sheet,i,1)); + rowVector.add(getSheetValue(sheet,i,2)); + rowVector.add(getSheetValue(sheet,i,3)); + + tableVector1.add(rowVector); + } + + DefaultTableModel dtm1 = (DefaultTableModel) mainTable1.getModel();// ȡģ + dtm1.setDataVector(tableVector1, headVector1);// + TableColumn tcm1 = mainTable1.getColumnModel().getColumn(0); + tcm1.setCellEditor(mainTable1.getDefaultEditor(Boolean.class)); + tcm1.setCellRenderer(mainTable1.getDefaultRenderer(Boolean.class)); + + mainTable1.updateUI();// ʾ + mainTable1.getColumn("select").setHeaderRenderer(check); + + //ѡڵұ߱ +// DefaultTableModel dtm2 = (DefaultTableModel) mainTable2.getModel();// ȡģ +// tableVector2.clear(); +// dtm2.setDataVector(tableVector2, headVector2);// +// mainTable2.updateUI();// ʾ + } + +// /** +// * +// * @param name +// * @param brand +// * @param processpara +// * @param basis +// * @param technicalind +// * @param remarks +// */ +// private void searchData(String name,String brand,String processpara,String basis,String technicalind,String remarks) { +// +// StringBuilder sql=new StringBuilder("select * from TC_ProcessKnow_View where 1=1"); +// if(name!=null&&!name.equals("")) { +// sql.append(" and item_name='"+name+"'"); +// } +// if(brand!=null&&!brand.equals("")) { +// sql.append(" and brand='"+brand+"'"); +// } +// if(processpara!=null&&!processpara.equals("")) { +// sql.append(" and processpara='"+processpara+"'"); +// } +// if(basis!=null&&!basis.equals("")) { +// sql.append(" and basis='"+basis+"'"); +// } +// if(technicalind!=null&&!technicalind.equals("")) { +// sql.append(" and technicalind='"+technicalind+"'"); +// } +// if(remarks!=null&&!remarks.equals("")) { +// sql.append(" and remarks='"+remarks+"'"); +// } +// //Ϊ +// if(sql.toString().equals("select * from TC_ProcessKnow_View where 1=1")) { +// System.out.println("δд"); +// tableVector.clear(); +// DefaultTableModel dtm=(DefaultTableModel)mainTable.getModel();//ȡģ +// dtm.setDataVector(tableVector,headVector);// +// mainTable.updateUI();//ʾ +// return; +// }else { +// sql.append(" and parent="+parent+" and child="+child); +// System.out.println(sql); +// tableVector.clear(); +// } +// SqlUtilT.getTCConnection(); +// ResultSet rs = null; +// try { +// rs = SqlUtilT.read(sql.toString()); +// while (rs.next()) { +// Vector rowVector = new Vector(); +// rowVector.add(rs.getString("ID")); +// rowVector.add(rs.getString("REV")); +// rowVector.add(rs.getString("ITEM_NAME")); +// rowVector.add(rs.getString("BRAND")); +// rowVector.add(rs.getString("PROCESSPARA")); +// rowVector.add(rs.getString("BASIS")); +// rowVector.add(rs.getString("TECHNICALIND")); +// rowVector.add(rs.getString("REMARKS")); +// tableVector.add(rowVector); +// } +// DefaultTableModel dtm=(DefaultTableModel)mainTable.getModel();//ȡģ +// dtm.setDataVector(tableVector,headVector);// +// mainTable.updateUI();//ʾ +// } catch (SQLException e) { +// // Auto-generated catch block +// e.printStackTrace(); +// } +// } +// + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.setShowsRootHandles(false); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tree.putClientProperty("JTree.lineStyle", "Angled"); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + // cellRenderer.setOpenIcon(new ImageIcon("Swing/1.jpg")); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + + } + + /** + * + * @param uid:ݼuid + * @return + */ + public File getFile(String uid) { + TCComponentDataset dat; + try { + dat = (TCComponentDataset) session.stringToComponent(uid); + + TCComponentTcFile[] tcFile = dat.getTcFiles(); + // if(tcFile != null && tcFile.length == 0) + if (tcFile == null || tcFile.length == 0) { + System.out.println("ͨuid:" + uid + ",δҵݼ"); + } else { + return tcFile[0].getFmsFile(); + } + } catch (TCException e) { + // Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +// + public Workbook readExcel(String filePath) { + Workbook wb = null; + if (filePath == null) { + return null; + } + String extString = filePath.substring(filePath.indexOf('.')); + InputStream is = null; + try { + is = new FileInputStream(filePath); + if (".xls".equals(extString)) { + return wb = new HSSFWorkbook(is); + } else if (".xlsx".equals(extString)) { + return wb = new XSSFWorkbook(is); + } else { + return wb = null; + } + + }catch (NoClassDefFoundError e) { + System.out.println(e.toString()); + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(is != null) + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return wb; + } + + + /** + * ȡexcel + * @param sheet + * @param row + * @param column + * @return + */ + public String getSheetValue(Sheet sheet,int row,int column) { +// sheet.getRow(row).getCell(column).setCellType(Cell.CELL_TYPE_STRING);//õԪΪString,ܻȡstringֵ +// return sheet.getRow(row).getCell(column).getStringCellValue(); + String cellValue=""; + Cell cell = sheet.getRow(row).getCell(column); + if (null != cell) { + // жݵ + switch (cell.getCellType()) { + case Cell.CELL_TYPE_NUMERIC: // +// String value=String.valueOf(cell.getNumericCellValue()); +// if(value.contains(".")) { +// +// } +// DecimalFormat df = new DecimalFormat("0"); +// cellValue = df.format(cell.getNumericCellValue()); + if(cell.getNumericCellValue()==0.0) { + cellValue="0"; + }else { + cellValue=String.valueOf(cell.getNumericCellValue()); + } + + break; + case Cell.CELL_TYPE_STRING: // ַ + cellValue = cell.getStringCellValue(); + break; + case Cell.CELL_TYPE_BOOLEAN: // Boolean + cellValue = cell.getBooleanCellValue() + ""; + break; + case Cell.CELL_TYPE_FORMULA: // ʽ + cellValue = cell.getCellFormula() + ""; + break; + case Cell.CELL_TYPE_BLANK: // ֵ + cellValue = ""; + break; + case Cell.CELL_TYPE_ERROR: // + cellValue = "Ƿַ"; + break; + default: + cellValue = "δ֪"; + break; + } + } + return cellValue; + } + + + + public void Init() { + JFrame jf=new JFrame("ͼƬչʾ"); + + //1.ͼƬӵǩѱǩĴСΪͼƬСͬѱǩڷֲײ㣻 + ImageIcon bg=new ImageIcon("C:\\Users\\Administrator\\Desktop\\Ŀ\\1.jpg"); +// JLabel label=new JLabel(bg); + //label.setSize(bg.getIconWidth(),bg.getIconHeight()); + //jf.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE)); + //2.ѴΪ岢Ϊ͸֡ +// JPanel pan=(JPanel)jf.getContentPane(); +// pan.setOpaque(false); +// pan.setLayout(new FlowLayout()); + JLabel jl=new JLabel(); + jl.setIcon(new ImageIcon("C:\\Users\\Administrator\\Desktop\\Ŀ\\1.jpg")); + jf.setAlwaysOnTop(true); + jf.setSize(bg.getIconWidth(),bg.getIconHeight()); + jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + jf.add(jl); + jf.setVisible(true); + } + +} + + + +class TableCellTextAreaRenderer extends JTextArea implements TableCellRenderer { + /** + * + */ + private static final long serialVersionUID = 1L; + + public TableCellTextAreaRenderer() { + setLineWrap(true); + setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + if (isSelected) { + setBackground(new Color(176,224,230)); + setForeground(Color.black); + } + else { + setBackground(Color.white); + setForeground(Color.black); + } + // 㵱еѸ߶ + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setText("" + table.getValueAt(row, i)); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if (table.getRowHeight(row) != maxPreferredHeight) // Ϲæ + table.setRowHeight(row, maxPreferredHeight); + setText(value == null ? "" : value.toString()); + return this; + } +} + + +class MyCheckBoxRenderer extends JCheckBox implements TableCellRenderer { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public MyCheckBoxRenderer() { + + this.setBorderPainted(true); + + } + + @Override + + public Component getTableCellRendererComponent(JTable table, Object value, + + boolean isSelected, boolean hasFocus, int row, int column) { + +// Auto-generated method stub + + return this; + + } + +} diff --git a/src/cn/net/connor/process/hourcalculation/selectionCommand.java b/src/cn/net/connor/process/hourcalculation/selectionCommand.java new file mode 100644 index 0000000..961c53e --- /dev/null +++ b/src/cn/net/connor/process/hourcalculation/selectionCommand.java @@ -0,0 +1,155 @@ +package cn.net.connor.process.hourcalculation; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.imageio.ImageIO; +import javax.mail.Flags.Flag; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.xml.crypto.Data; + +import com.sun.prism.impl.Disposer.Target; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.tcservices.TcServicesService; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.process.meopviewfx.bean.KTableRow; +import cn.net.connor.process.meopviewfx.bean.PropConfig; +import javafx.scene.control.TableView; + + + +public class selectionCommand extends AbstractAIFCommand { + + private TCComponentBOMLine comp; + private TCSession session; + private TableView table; + private List propConfigs; + private TCComponentBOMLine target; + + public JTextField Field1=new JTextField(); + public JTextField Field2=new JTextField(); + public JTextField Field3=new JTextField(); + public JTextField Field4=new JTextField(); + public JTextField Field5=new JTextField(); + + public selectionCommand(TCComponentBOMLine target,JTextField Field1,JTextField Field2,JTextField Field3,JTextField Field4,JTextField Field5) { + this.Field1=Field1; + this.Field2=Field2; + this.Field3=Field3; + this.Field4=Field4; + this.Field5=Field5; + this.target=target; + // TODO Auto-generated constructor stub + try { + executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + System.out.println("select different dialog by selection"); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + //õǰѡĶͼƣѡбȶ + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("AVIC_HoursCalculation_Class"); + if(strs==null||strs.length==0) { + MessageBox.post("ѡĹûйʱãԱϵ", "", MessageBox.ERROR); + return; + } + + String type=this.target.getItemRevision().getType(); + String name=this.target.getItemRevision().getStringProperty("object_name"); + System.out.println(type+":"+name); + + + boolean isFind=true; + for(String str:strs) {//ȱƲΪյ + if(str.split("=").length==3) { + if(str.split("=")[0].equals(type)&&!str.split("=")[1].equals("")&&name.indexOf(str.split("=")[1])>=0) { + if(str.split("=")[2].equals("װ估ǯʱ")) { + new hourCCommand(session,target,Field1,Field2,Field3,Field4,Field5); + return; + }else if(str.split("=")[2].equals("ӹʱ")) { + new FitterCommand(session,target,Field1,Field2,Field3,Field4); + return; + } + } + } + } + + for(String str:strs) {//ƲΪյûҵٱΪյ + if(str.split("=").length==3) { + if(str.split("=")[0].equals(type)&&name.indexOf(str.split("=")[1])>=0) { + if(str.split("=")[2].equals("װ估ǯʱ")) { + new hourCCommand(session,target,Field1,Field2,Field3,Field4,Field5); + return; + }else if(str.split("=")[2].equals("ӹʱ")) { + new FitterCommand(session,target,Field1,Field2,Field3,Field4); + return; + } + } + } + } + + + + + for(String str:strs) { + if(str.split("=").length==2) { + if(str.split("=")[0].equals(type)) { + if(str.split("=")[1].equals("װ估ǯʱ")) { + new hourCCommand(session,target,Field1,Field2,Field3,Field4,Field5); + return; +// new FitterCommand(session,target,Field1,Field2); +// return; + }else if(str.split("=")[1].equals("ӹʱ")) { + new FitterCommand(session,target,Field1,Field2,Field3,Field4); + return; + } + } + } + } + + MessageBox.post("ѡĹûйʱãԱϵ", "", MessageBox.ERROR); + + } +} diff --git a/src/cn/net/connor/process/meopmodel/DesignModelOperation.java b/src/cn/net/connor/process/meopmodel/DesignModelOperation.java new file mode 100644 index 0000000..e598c58 --- /dev/null +++ b/src/cn/net/connor/process/meopmodel/DesignModelOperation.java @@ -0,0 +1,133 @@ +package cn.net.connor.process.meopmodel; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.Registry; + +import cn.net.connor.process.ProcessUtil; +import k.KOperation2; +import k.util.KUtil; + +public class DesignModelOperation extends KOperation2 { + + private TCComponentBOPLine meopLine; + private TCComponentItemType itemType; + private TCComponentBOMLine processLine; + private TCComponentItemRevision meTargetRev; + private List datasets; + public static final String TYPE_ITEM = "Ac5_GXMX"; + public static final String REL_REV_DATASET = "IMAN_specification"; + public static final String TYPE_DATASET = "CATPart"; + private static final Registry REG = Registry.getRegistry(DesignModelOperation.class); + + public DesignModelOperation(AbstractAIFApplication app, String opName, TCComponentBOPLine meopLine) { + super(app, opName); + this.meopLine = meopLine; + } + + @Override + public boolean init() throws Exception { + if (this.meopLine == null) { + throw new TCException("meopLine can not be null"); + } + try { + this.itemType = (TCComponentItemType) session.getTypeComponent(TYPE_ITEM); + } catch (Exception e) { + e.printStackTrace(); + } + if (this.itemType == null) { + throw new TCException("Type is not defined: " + TYPE_ITEM); + } + TCComponentBOMLine pLine = this.meopLine.parent(); + while (pLine != null) { + if (ProcessUtil.isMEProcess(pLine.getItem().getType())) { + this.processLine = pLine; + break; + } + pLine = pLine.parent(); + } + System.out.println("Process line: " + this.processLine); + if (this.processLine == null) { + throw new TCException(REG.getString("meprocessnotfound.ERROR")); + } + TCComponent[] meTargetRevs = this.processLine.getItemRevision().getRelatedComponents("IMAN_METarget"); + System.out.println("METargets: " + Arrays.toString(meTargetRevs)); + this.meTargetRev = getLatestReleasedRev(meTargetRevs); + System.out.println("Latest Released Rev: " + meTargetRev); + if (this.meTargetRev == null) { + throw new TCException(REG.getString("releasedmetargetnotfound.ERROR")); + } + this.datasets = KUtil.getChildComponents(meTargetRev, TYPE_DATASET, REL_REV_DATASET); + System.out.println("Datasets: " + datasets); + return true; + } + + public static TCComponentItemRevision getLatestReleasedRev(TCComponent[] comps) { + int size = comps == null ? 0 : comps.length; + if (size == 0) { + return null; + } + TCComponentItemRevision res = null; + Date maxDate = null; + try { + for (int i = 0; i < size; i++) { + TCComponent temp = comps[i]; + if (!(temp instanceof TCComponentItemRevision)) { + continue; + } + Date tempDate = temp.getDateProperty("date_released"); + if (tempDate == null) { + continue; + } + if (maxDate == null || tempDate.after(maxDate)) { + maxDate = tempDate; + res = (TCComponentItemRevision) temp; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + @Override + public void execute() throws Exception { + String objectName = this.meTargetRev.getStringProperty("object_name") + REG.getString("name.SUFFIX"); + String itemID = itemType.getNewID(); + String revID = itemType.getNewRev(null); + TCComponentItem newItem = itemType.create(itemID, revID, TYPE_ITEM, objectName, "", null); + System.out.println("New item: " + newItem); + newItem.refresh(); + TCComponentItemRevision newRev = newItem.getLatestItemRevision(); + System.out.println("New rev: " + newRev); + newRev.refresh(); + TCComponentBOMLine newLine = this.meopLine.add(newItem, newRev, null, false); + System.out.println("New line: " + newLine); + int datasetCnt = this.datasets == null ? 0 : this.datasets.size(); + for (int i = 0; i < datasetCnt; i++) { + TCComponentDataset dataset = (TCComponentDataset) datasets.get(i); + TCComponentDataset newDataset = dataset.saveAs(dataset.getStringProperty("object_name")); + System.out.println("New dataset: " + newDataset); + newRev.add(REL_REV_DATASET, newDataset); + } + newRev.refresh(); + this.meopLine.refresh(); + } + + @Override + public void clearCache() throws Exception { + + } + +} diff --git a/src/cn/net/connor/process/meopmodel/MeopModelBean.java b/src/cn/net/connor/process/meopmodel/MeopModelBean.java new file mode 100644 index 0000000..70e4e78 --- /dev/null +++ b/src/cn/net/connor/process/meopmodel/MeopModelBean.java @@ -0,0 +1,84 @@ +package cn.net.connor.process.meopmodel; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +import cn.net.connor.process.ProcessUtil; +import k.util.KUtil; + +public class MeopModelBean { + + private TCComponentBOPLine meopLine; + private List gxmxRevs; + private String opNum; + private String opName; + + private MeopModelBean(TCComponentBOPLine meopLine, List gxmxRevs, String opNum, String opName) { + this.meopLine = meopLine; + this.gxmxRevs = gxmxRevs; + this.opNum = opNum; + this.opName = opName; + } + + public TCComponentBOPLine getMeopLine() { + return meopLine; + } + + public List getGxmxRevs() { + return gxmxRevs; + } + + public static MeopModelBean parse(TCComponentBOPLine meopLine) throws Exception { + System.out.println("check line: " + meopLine); + if (meopLine == null) { + return null; + } + TCComponentItem meopItem = meopLine.getItem(); + if (meopItem == null) { + System.out.println(">> get item failed"); + return null; + } + TCComponentItemRevision meopRev = meopLine.getItemRevision(); + if(meopRev==null) { + System.out.println(">> get itemrevision failed"); + return null; + } + if (!ProcessUtil.isMEOP(meopItem.getType())) { + System.out.println(">> not meop"); + return null; + } + AIFComponentContext[] cc = meopLine.getChildren(); + List gxmxRevs = new ArrayList(); + int len = KUtil.getLen(cc); + for (int i = 0; i < len; i++) { + TCComponentBOPLine cLine = (TCComponentBOPLine) cc[i].getComponent(); + TCComponentItemRevision cRev = cLine.getItemRevision(); + String cType = cRev == null ? "" : cRev.getItem().getType(); + System.out.println(">> " + cRev + "|" + cType); + if (DesignModelOperation.TYPE_ITEM.equals(cType)) { + gxmxRevs.add(cRev); + } + } + if (gxmxRevs.size()==0) { + System.out.println(">> no gxmx"); + return null; + } + String opNum = meopRev.getRelatedComponent("IMAN_master_form_rev").getStringProperty("ac5_OperationNumber"); + String opName = meopRev.getStringProperty("object_name"); + return new MeopModelBean(meopLine, gxmxRevs, opNum, opName); + } + + public Object[] getRowData() { + return new Object[] {this, opName}; + } + + @Override + public String toString() { + return opNum; + } +} diff --git a/src/cn/net/connor/process/meopmodel/MeopModelDialog.java b/src/cn/net/connor/process/meopmodel/MeopModelDialog.java new file mode 100644 index 0000000..52a467b --- /dev/null +++ b/src/cn/net/connor/process/meopmodel/MeopModelDialog.java @@ -0,0 +1,96 @@ +package cn.net.connor.process.meopmodel; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +import k.KDialog; +import k.KDialogController; + +@SuppressWarnings("serial") +public class MeopModelDialog extends KDialog{ + private static final Registry REG = Registry.getRegistry(MeopModelDialog.class); + private MeopModelDialogController controller; + private JButton b_ok; + private JButton b_cancel; + protected DefaultTableModel tableModel; + protected JTable table; + public MeopModelDialog(KDialogController controller) { + super(controller); + this.controller = (MeopModelDialogController)controller; + } + + @Override + protected void addListeners() { + b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + try { + controller.doCreate(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(MeopModelDialog.this, e); + } + } + }); + b_cancel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + @Override + protected void initUI() { + this.setTitle(""); + // this.setPreferredSize(new Dimension(300, 300)); + this.setLayout(new BorderLayout()); + this.add(BorderLayout.CENTER, initTablePanel()); + this.add(BorderLayout.SOUTH, initBtnPanel()); + } + + private Component initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5)); + panel.add(b_ok = new JButton(REG.getString("ok.BTN"))); + panel.add(b_cancel = new JButton(REG.getString("cancel.BTN"))); + return panel; + } + + private Component initTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); + this.tableModel = new DefaultTableModel(); + this.table = new JTable(tableModel) { + public boolean isCellEditable(int row, int column) { + return false; + }; + }; + this.table.getTableHeader().setReorderingAllowed(false); + this.table.setRowHeight(23); + String[] header = new String[] {REG.getString("opnum.COL"), REG.getString("opname.COL")}; + this.tableModel.setDataVector(null, header); + JScrollPane scroll = new JScrollPane(table); + panel.add(BorderLayout.CENTER, scroll); + int rowCnt = controller.meopModelBeans.size(); + for(int i=0;i meopModelBeans = new ArrayList(); + private MeopModelDialog dialog; + private TCComponentItemType itemType; + private static final Registry REG = Registry.getRegistry(MeopModelDialogController.class); + public MeopModelDialogController(AbstractAIFApplication app, TCComponentBOPLine meopLine) { + super(app); + this.targetLine = meopLine; + } + + @Override + public boolean init() throws Exception { + this.dialog = (MeopModelDialog)aifDialog; + TCComponentBOMLine pLine = targetLine.parent(); + AIFComponentContext[] cc = pLine.getChildren(); + int len = KUtil.getLen(cc); + for(int i=0; i gxmxRevs = bean.getGxmxRevs(); + System.out.println("template: "+meopLine+" -> "+gxmxRevs); + int cnt = gxmxRevs.size(); + for(int i=0; i deepCopyInfos = new ArrayList(); + List datasets = KUtil.getChildComponents(rev, DesignModelOperation.TYPE_DATASET, DesignModelOperation.REL_REV_DATASET); + System.out.println(">> find datasets: "+datasets); + int dsCnt = datasets == null?0:datasets.size(); + for(int j=0; j> new Item: "+newItem); + newItem.refresh(); + TCComponentItemRevision newRev = newItem.getLatestItemRevision(); + System.out.println(">> new rev: " + newRev); + newRev.refresh(); + for(int j=0; j> new dataset: " + newDataset); + newRev.add(DesignModelOperation.REL_REV_DATASET, newDataset); + } + newRev.refresh(); + TCComponentBOMLine newLine = targetLine.add(newItem, newRev, null, false); + System.out.println(">> new line: " + newLine); + } + targetLine.refresh(); + } + + @Override + public void clearCache() throws Exception { + + } + }.executeModeless(); + + } + +} diff --git a/src/cn/net/connor/process/meopmodel/meopmodel.properties b/src/cn/net/connor/process/meopmodel/meopmodel.properties new file mode 100644 index 0000000..94eae19 --- /dev/null +++ b/src/cn/net/connor/process/meopmodel/meopmodel.properties @@ -0,0 +1,14 @@ +meopmodeloption.MESSAGE=\u4ECE\u5DE5\u5E8F\u63D0\u53D6\u5DE5\u5E8F\u6A21\u578B\u6216\u4ECE\u8BBE\u8BA1\u63D0\u53D6\u5DE5\u5E8F\u6A21\u578B +meopmodel=\u5DE5\u5E8F\u6A21\u578B +designmodel=\u8BBE\u8BA1\u6A21\u578B +designmodel.STATUS=\u4ECE\u8BBE\u8BA1\u63D0\u53D6\u5DE5\u5E8F\u6A21\u578B +meprocessnotfound.ERROR=\u672A\u627E\u5230\u4E0A\u5C42\u5DE5\u827A +releasedmetargetnotfound.ERROR=\u672A\u627E\u5230\u6700\u65B0\u7684\u53D1\u5E03\u7248\u672C\u7684\u5236\u9020\u76EE\u6807 +name.SUFFIX=_\u5DE5\u5E8F\u6A21\u578B +nomeopmodel.ERROR=\u672A\u627E\u5230\u5DE5\u5E8F\u6A21\u578B\u6570\u636E +ok.BTN=\u786E\u5B9A +cancel.BTN=\u53D6\u6D88 +opnum.COL=\u5DE5\u5E8F\u53F7 +opname.COL=\u5DE5\u5E8F\u540D\u79F0 +create.STATUS=\u751F\u6210\u5DE5\u5E8F\u4E09\u7EF4\u6A21\u578B +gxmxsaveas.STATUS=\u53E6\u5B58\u5DE5\u5E8F\u6A21\u578B \ No newline at end of file diff --git a/src/cn/net/connor/process/meopviewfx/MEOPEditView.java b/src/cn/net/connor/process/meopviewfx/MEOPEditView.java new file mode 100644 index 0000000..90024e1 --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/MEOPEditView.java @@ -0,0 +1,60 @@ +package cn.net.connor.process.meopviewfx; + +import java.util.List; + +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchPart; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.ui.views.AbstractContentViewPart; + +import cn.net.connor.process.meopviewfx.ui.MEOPPanel; +import javafx.embed.swt.FXCanvas; + +public class MEOPEditView extends AbstractContentViewPart { + public static final String ID = MEOPEditView.class.getName(); + private Object currentObj = null; + private MEOPPanel meopPanel; + + @Override + protected void processEmptySelection(IWorkbenchPart iWorkbenchPart, List list) { + if (list == null || list.size() != 1) { + return; + } + final Object target = list.get(0); + if (target != null && !(target.equals(currentObj))) { + System.out.println("Select: " + target); + currentObj = target; + new Thread(new Runnable() { + @Override + public void run() { + if(meopPanel!=null) + meopPanel.updateSelection(target); + } + }).start(); + } + } + + public MEOPEditView() { + this.setProcessNullSelectionsEnabled(true); + this.setUseScrolledForm(false); + this.setShowHeader(true); + this.setMultiSelectionSupported(true); + this.setUISupportsAssociate(false); + this.setUISupportsSetScope(false); + this.setUISupportsViewLocking(true); + this.setUseInitialInputJobEnabled(false); + this.setProcessSelectionFromSiblingViewEnabled(true); + } + + @Override + protected void createContent(Composite parent) { + System.out.println("Init UI..."); + parent.setLayout(new FillLayout()); + FXCanvas fxCanvas = new FXCanvas(parent, 16777216); + fxCanvas.setScene((this.meopPanel = new MEOPPanel(AIFUtility.getCurrentApplication().getDesktop())).getScene()); + System.out.println("Init UI Complete"); + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/process/meopviewfx/bean/KTableRow.java b/src/cn/net/connor/process/meopviewfx/bean/KTableRow.java new file mode 100644 index 0000000..a32e332 --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/bean/KTableRow.java @@ -0,0 +1,190 @@ +package cn.net.connor.process.meopviewfx.bean; + +import java.util.HashMap; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; + +import javafx.beans.property.SimpleStringProperty; +import k.util.KUtil; + +public class KTableRow { + + public static final String BOMLINE = "BOMLINE"; + public static final String ITEM = "ITEM"; + public static final String ITEMMASTER = "ITEMMASTER"; + public static final String REV = "REV"; + public static final String REVMASTER = "REVMASTER"; + + private TCComponentBOMLine bomline; + private TCComponentItem item; + private TCComponentItemRevision rev; + private TCComponent itemMaster; + private TCComponent revMaster; + + public KTableRow(TCComponentBOMLine bomline, TCComponentItem item, TCComponentItemRevision rev, TCComponent itemMaster, TCComponent revMaster) { + this.bomline = bomline; + this.item = item; + this.rev = rev; + this.itemMaster = itemMaster; + this.revMaster = revMaster; + } + + public Map stringProps = new HashMap(); + private Map savedValues = new HashMap(); + + public boolean parseConfig(PropConfig config) throws Exception{ + if(config==null) { + return true; + } + String value = getTCValue(config.propLoc, config.propName); + stringProps.put(config, new SimpleStringProperty(value)); + savedValues.put(config, value); + if (!KUtil.isEmpty(config.filterValue)) { + //&& !config.filterValue.equals(value) + // 20200722 split filter + String[] filters = config.filterValue.split(";"); + boolean checkOK = false; + for (String string : filters) { + if(string.equals(value)) { + checkOK=true; + break; + } + } + return checkOK; + } + return true; + } + + public String getTCValue(String proploc, String propName) throws Exception{ + TCComponent comp = getTCComponent(proploc); + if(comp == null) { + return ""; + } + return comp.getStringProperty(propName); + } + + public TCComponent getTCComponent(String proploc) { + if(KUtil.isEmpty(proploc)) { + return bomline; + } + proploc = proploc.toUpperCase(); + switch (proploc) { + case BOMLINE: + return bomline; + case ITEM: + return item; + case REV: + return rev; + case ITEMMASTER: + return itemMaster; + case REVMASTER: + return revMaster; + default: + System.out.println(">> Prop location error: " + proploc); + break; + } + return null; + } + + public boolean loadTCValues(Map bomlinePropMap , Map itemPropMap,Map revPropMap, Map itemMasterPropMap,Map revMasterPropMap ) { + boolean modified = false; + for (PropConfig config : stringProps.keySet()) { + if(!config.canEdit) { + continue; + } + String value = stringProps.get(config).getValueSafe(); + if(savedValues.containsKey(config)) { + String savedValue = savedValues.get(config); + if(value.equals(savedValue)) { + continue; + } + } + modified = true; + String propName = config.propName; + String proploc = config.propLoc.toUpperCase(); + System.out.println(">> "+proploc+"."+propName+" = "+value); + switch(proploc) { + case BOMLINE: + bomlinePropMap.put(propName, value); + break; + case ITEM: + itemPropMap.put(propName, value); + if("object_name".equals(propName)) { + revPropMap.put(propName, value); + } + break; + case REV: + revPropMap.put(propName, value); + if("object_name".equals(propName)) { + itemPropMap.put(propName, value); + } + break; + case ITEMMASTER: + itemMasterPropMap.put(propName, value); + break; + case REVMASTER: + revMasterPropMap.put(propName, value); + break; + default: + System.out.println(">> Prop location error: " + proploc); + break; + } + } + return modified; + } + + public void saveTCData(TCComponentBOMLine parentLine, TCComponentItemType itemType) throws Exception{ + if(bomline==null) { + if(itemType!=null&&parentLine!=null) { + System.out.println("Create New Row..."); + item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), itemType.getName(), "-", "", null); + System.out.println(">> new item: "+item); + rev= item.getLatestItemRevision(); + itemMaster = item.getRelatedComponent("IMAN_master_form"); + revMaster = rev.getRelatedComponent("IMAN_master_form_rev"); + bomline = parentLine.add(item, rev, null, false, ""); + } + } + if(bomline==null) { + return; + } + System.out.println("Update: "+bomline); + Map revPropMap = new HashMap<>(); + Map revMasterPropMap = new HashMap<>(); + Map itemPropMap = new HashMap<>(); + Map itemMasterPropMap = new HashMap<>(); + Map bomlinePropMap = new HashMap<>(); + if(!loadTCValues(bomlinePropMap, itemPropMap, revPropMap, itemMasterPropMap, revMasterPropMap)) { + return; + } + if(itemPropMap.size()>0) { + item.setProperties(itemPropMap); + } + if(revPropMap.size()>0) { + rev.setProperties(revPropMap); + } + if(itemMasterPropMap.size()>0) { + itemMaster.setProperties(itemMasterPropMap); + } + if(revMasterPropMap.size()>0) { + revMaster.setProperties(revMasterPropMap); + } + if(bomlinePropMap.size()>0) { + bomline.setProperties(bomlinePropMap); + } + bomline.refresh(); + } + + public void removeLine(TCComponentBOMLine parentLine) throws Exception{ + if(bomline!=null) { + System.out.println(">> Remove: "+bomline); + bomline.cut(); + } + } + +} diff --git a/src/cn/net/connor/process/meopviewfx/bean/PropConfig.java b/src/cn/net/connor/process/meopviewfx/bean/PropConfig.java new file mode 100644 index 0000000..1a0075b --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/bean/PropConfig.java @@ -0,0 +1,53 @@ +package cn.net.connor.process.meopviewfx.bean; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; + +import javafx.scene.control.Control; + +public class PropConfig { + public String propName; + public String propDisplayName; + public String propLoc; + public TCComponentListOfValues lov; + public String filterValue; + public TCPropertyDescriptor propDesc; + public int width; + public int maxCharacterInRow; + public boolean canEdit; + private Control control; + private Object savedValue; + + public PropConfig(String propLoc, TCPropertyDescriptor propDesc, String filterValue, int width, int maxCharacterInRow) { + this.propName = propDesc.getName(); + this.propDisplayName = propDesc.getDisplayName(); + this.propLoc = propLoc; + this.filterValue = filterValue; + this.lov = propDesc.getLOV(); + this.propDesc = propDesc; + this.width = width; + this.maxCharacterInRow = maxCharacterInRow; + this.canEdit = propDesc.isModifiable()&&!"bl_occ_type".equals(propName)&&!"item_id".equals(propName); + System.out.println(propName+" >> "+lov+" >> "+canEdit+" >> "+width); + } + + public void setSavedValue(Object savedValue) { + this.savedValue = savedValue; + } + + public boolean valueChanged(Object newValue) { + if(savedValue!=null) { + return !savedValue.equals(newValue); + } + return newValue!=null; + } + + public void setControl(Control control) { + this.control = control; + } + + public Control getControl() { + return control; + } + +} diff --git a/src/cn/net/connor/process/meopviewfx/bean/TextBean.java b/src/cn/net/connor/process/meopviewfx/bean/TextBean.java new file mode 100644 index 0000000..9c300ae --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/bean/TextBean.java @@ -0,0 +1,62 @@ +package cn.net.connor.process.meopviewfx.bean; + +import java.util.ArrayList; +import java.util.List; + +import k.util.KUtil; + +public class TextBean { + + private String text; + private String realValue; + public List children = new ArrayList(); + private String itemId; + private String revId; + + public TextBean(String text, String itemId, String revId) { + this.text = text; + this.itemId = itemId; + this.revId = revId; + } + + public TextBean(String text) { + this.text = text; + } + + public void setRealValue(String realValue) { + this.realValue = realValue; + } + + public String getRealValue() { + return KUtil.isEmpty(realValue) ? text : realValue; + } + + public String getDisplayValue() { + return text; + } + + public String getMKHId() { + return itemId; + } + + public String getMKHRev() { + return revId; + } + + @Override + public String toString() { + return getDisplayValue(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj instanceof TextBean) { + return text.equals(((TextBean) obj).text); + } + return false; + } + +} diff --git a/src/cn/net/connor/process/meopviewfx/dialog/TestDialog.java b/src/cn/net/connor/process/meopviewfx/dialog/TestDialog.java new file mode 100644 index 0000000..f551553 --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/dialog/TestDialog.java @@ -0,0 +1,34 @@ +package cn.net.connor.process.meopviewfx.dialog; + +import java.awt.BorderLayout; +import java.awt.Dimension; + +import cn.net.connor.process.meopviewfx.ui.MEOPPanel; +import javafx.embed.swing.JFXPanel; +import k.KDialog; +import k.KDialogController; + +@SuppressWarnings("serial") +public class TestDialog extends KDialog{ + + public TestDialog(KDialogController controller) { + super(controller); + // TODO Auto-generated constructor stub + } + + @Override + protected void addListeners() { + // TODO Auto-generated method stub + + } + + @Override + protected void initUI() { + this.setPreferredSize(new Dimension(800, 600)); + this.setLayout(new BorderLayout()); + JFXPanel panel = new JFXPanel(); + panel.setScene(new MEOPPanel(this).getScene()); + this.add(BorderLayout.CENTER, panel); + } + +} diff --git a/src/cn/net/connor/process/meopviewfx/dialog/TestDialogController.java b/src/cn/net/connor/process/meopviewfx/dialog/TestDialogController.java new file mode 100644 index 0000000..08a21c4 --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/dialog/TestDialogController.java @@ -0,0 +1,18 @@ +package cn.net.connor.process.meopviewfx.dialog; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import k.KDialogController; + +public class TestDialogController extends KDialogController{ + + public TestDialogController(AbstractAIFApplication app) { + super(app); + } + + @Override + public boolean init() throws Exception { + return true; + } + +} diff --git a/src/cn/net/connor/process/meopviewfx/ui/KFXEditableStringAreaHtmlTableCell.java b/src/cn/net/connor/process/meopviewfx/ui/KFXEditableStringAreaHtmlTableCell.java new file mode 100644 index 0000000..6392b24 --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/ui/KFXEditableStringAreaHtmlTableCell.java @@ -0,0 +1,183 @@ +package cn.net.connor.process.meopviewfx.ui; + +import javax.swing.JTextArea; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import com.teamcenter.rac.stylesheet.gdt.GdtDialog; +import com.teamcenter.rac.stylesheet.gdt.GdtEditor; +import com.teamcenter.rac.stylesheet.gdt.GenerateGDTHTML; +import com.teamcenter.rac.util.UIUtilities; + +import cn.net.connor.process.meopviewfx.bean.KTableRow; +import cn.net.connor.process.meopviewfx.bean.PropConfig; +import javafx.application.Platform; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.concurrent.Worker.State; +import javafx.event.Event; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableColumn.CellEditEvent; +import javafx.scene.control.TablePosition; +import javafx.scene.control.TableRow; +import javafx.scene.control.TableView; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.Region; +import javafx.scene.web.WebView; + +/** + * select color: + * + * .table-row-cell .ktext { -fx-fill: black; } + * + * .table-row-cell:selected .ktext { -fx-fill: white; } + * + * .table-cell .ktext { -fx-fill: black; } + * + * .table-cell:selected .ktext { -fx-fill: white; } + * + * @author Administrator + * + * @param + * @param + */ + +public class KFXEditableStringAreaHtmlTableCell extends TableCell { + private WebView webView; + private PropConfig config; + + public KFXEditableStringAreaHtmlTableCell(PropConfig config) { + super(); + this.config = config; + } + + @Override + public void startEdit() { + super.startEdit(); + } + + @Override + public void cancelEdit() { + super.cancelEdit(); + // setText((String) getItem()); + // setGraphic(null); + setGraphic(webView); + } + + @Override + public void updateItem(String item, boolean empty) { + super.updateItem(item, empty); + if (webView == null) { + createWebView(); + } + if (empty) { + setText(null); + setGraphic(null); + } else { + webView.setPrefHeight(Region.USE_COMPUTED_SIZE); + String newValue = item; + Platform.runLater(() -> { + try { + // System.out.println("Load Html: " + newValue); + String html = newValue == null || newValue.startsWith("") ? newValue : GenerateGDTHTML.generatePage(newValue); + // System.out.println(">> " + html); + webView.getEngine().loadContent(html); + } catch (Exception e) { + e.printStackTrace(); + } + }); + setGraphic(webView); + } + } + + private void createWebView() { + webView = new WebView(); + webView.setPrefHeight(Region.USE_COMPUTED_SIZE); + webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, State oldValue, State newValue) { + if (newValue != State.SUCCEEDED) { + return; + } + try { + Object res = webView.getEngine().executeScript( + "var body = document.body, html = document.documentElement; Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );"); + // System.out.println("Height: " + res); + int height = Integer.parseInt(res.toString()); + // int width = Integer.parseInt(webView.getEngine().executeScript("var body = + // document.body, html = document.documentElement; Math.max( body.scrollWidth, + // body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth + // );").toString()); + webView.setPrefHeight(height+5); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + if (isEditable()) { + webView.setOnMouseClicked(e -> { + if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) { + return; + } + TableRow row = getTableRow(); + KTableRow bean = (KTableRow) getTableView().getItems().get(row.getIndex()); + String oldValue = bean.stringProps.get(config).getValueSafe(); + System.out.println("Modify [" + row + "]: " + oldValue); + Display localDisplay = Display.getCurrent(); + if (localDisplay == null) { + localDisplay = Display.getDefault(); + } + GdtEditor editor = new GdtEditor(new JTextArea(oldValue)); + editor.setValue(oldValue); + localDisplay.asyncExec(new Runnable() { + public void run() { + Shell localShell = UIUtilities.getCurrentModalShell(); + GdtDialog gdtDialog = new GdtDialog(localShell, null, editor, true) { + public boolean close() { + try { + String newValue = editor.getValue(); + System.out.println("New Value: " + newValue); + bean.stringProps.get(config).setValue(newValue); + + } catch (Exception e) { + e.printStackTrace(); + } + return super.close(); + } + }; + editor.setGdtDialog(gdtDialog); + gdtDialog.open(); + } + }); + }); + } + // webView.prefWidthProperty().bind(getTableColumn().widthProperty().subtract(20)); + } + + protected String getString() { + return getItem() == null ? "" : getItem().toString(); + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void commitEdit(String item) { + if (isEditing()) { + super.commitEdit(item); + } else { + final TableView table = getTableView(); + if (table != null) { + TablePosition position = new TablePosition(getTableView(), getTableRow().getIndex(), getTableColumn()); + CellEditEvent editEvent = new CellEditEvent(table, position, TableColumn.editCommitEvent(), item); + Event.fireEvent(getTableColumn(), editEvent); + } + updateItem(item, false); + if (table != null) { + table.edit(-1, null); + } + // super.commitEdit(item); // 20201217 bug fix + } + } + +} diff --git a/src/cn/net/connor/process/meopviewfx/ui/MEOPPanel.fxml b/src/cn/net/connor/process/meopviewfx/ui/MEOPPanel.fxml new file mode 100644 index 0000000..c0a2815 --- /dev/null +++ b/src/cn/net/connor/process/meopviewfx/ui/MEOPPanel.fxml @@ -0,0 +1,92 @@ + + + + + + + + + + + +
+ + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ + + + + + + + + + +