first commit

main
洪丞进 2 weeks ago
commit 7c444e1715

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/xz-1.8.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-compress-1.20.jar"/>
<classpathentry exported="true" kind="lib" path="lib/zip4j-1.3.2.jar" sourcepath="C:/Users/ADMINI~1/AppData/Local/Temp/.org.sf.feeling.decompiler1600934136321/source/zip4j-1.3.2-sources.jar"/>
<classpathentry kind="lib" path="lib/ojdbc6.jar"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/groovy-all-2.4.7.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored

@ -0,0 +1 @@
/bin/

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>cn.net.connor.process</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -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

@ -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

@ -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

@ -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
<definition id="com.teamcenter.rac.common.textActive">
<with variable="activeContexts">
<iterate operator="or" ifEmpty="false">
<or>
<equals value="com.teamcenter.rac.aifrcp.swingtext"/>
<equals value="com.teamcenter.rac.aifrcp.swttext"/>
</or>
</iterate>
</with>
</definition>
```
修改为
```xml
<definition id="com.teamcenter.rac.common.textActive">
<or>
<with variable="activeContexts">
<iterate operator="or" ifEmpty="false">
<or>
<equals value="com.teamcenter.rac.aifrcp.swingtext"/>
<equals value="com.teamcenter.rac.aifrcp.swttext"/>
</or>
</iterate>
</with>
<with variable="activePartId">
<equals value="cn.net.connor.process.meopview.MEOPEditView"/>
</with>
</or>
</definition>
```
## 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
对齐:在标题名称中加入适量空格进行对齐
标题换行:<html>第一行<br/>第二行</html>
特殊配置:
#TITLE=窗口标题
#SIZE=窗口宽度,窗口高度
#COLUME=属性列数量
#INFO=修改完成的提示内容
#DONT_CLOSE_DIALOG (添加此行则在修改完成后不关闭窗口)
```
示例
```text
#物料编码: =item.item_id
物料名称: =item.object_name
Assist1=revmaster.ac5_Assist1
<html>Assist2<br/>第二行</html>=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
<command commandId="cn.net.connor.process.commands.OpenPCBCommand2" id="popups.openpcbds">
<visibleWhen>
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test
property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
</and>
</visibleWhen>
</command>
```
## 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
配置方式和工艺卡片导出方式相同,非列属性部分有工艺行和制造目标,列属性部分为工序
需要的特殊配置:
订单编号、数量、是否首件鉴定,这三个界面中查询到的值以书签的形式插入到模板中,书签的名称和界面中列名相同
导出时自动填写到书签的位置
```

@ -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/

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,589 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.views">
<category id="cn.net.connor.process.view" name="工艺视图"/>
<view
category="cn.net.connor.process.view"
closable="true"
allowMultiple="false"
icon="icons/meprocess_16.png"
class="cn.net.connor.process.processview.ProcessPropertyView"
id="cn.net.connor.process.processview.ProcessPropertyView"
name="工艺工序编辑">
</view>
<view
category="cn.net.connor.process.view"
closable="true"
allowMultiple="false"
icon="icons/meoperation_16.png"
class="cn.net.connor.process.meopviewfx.MEOPEditView"
id="cn.net.connor.process.meopview.MEOPEditView"
name="工道编辑">
</view>
</extension>
<extension point="com.teamcenter.rac.aifrcp.viewDefs">
<view
alwaysUseSetRootInputObject="true"
autoCloseEnabled="true"
folderId="RAC_Folder_UR"
id="cn.net.connor.process.processview.ProcessPropertyView"
selectionInPrimaryEffectsInvisbleSecondary="false"
selectionInSecondaryEffectsPrimary="false"
type="secondary">
</view>
<view
alwaysUseSetRootInputObject="true"
autoCloseEnabled="true"
folderId="RAC_Folder_UR"
id="cn.net.connor.process.meopview.MEOPEditView"
selectionInPrimaryEffectsInvisbleSecondary="false"
selectionInSecondaryEffectsPrimary="false"
type="secondary">
</view>
</extension>
<extension point="org.eclipse.ui.commands">
<command name="Test" id="cn.net.connor.process.commands.TestCommand"/>
<command name="创建工艺" id="cn.net.connor.process.commands.NewProcessCommand"/>
<command name="创建工序" id="cn.net.connor.process.commands.NewMeopCommand"/>
<command name="修改工序号" id="cn.net.connor.process.commands.ModifyMeopNoCommand"/>
<command name="工装BOM明细表" id="cn.net.connor.process.commands.GZBomExportCommand"/>
<command name="生成工艺卡片" id="cn.net.connor.process.commands.ProcessCardCommand"/>
<command name="A3幅面附表" id="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_"/>
<command name="A4幅面附表" id="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_"/>
<command name="生成工艺规程" id="cn.net.connor.process.commands.ProcessProcedureCommand"/>
<command name="材料试件编辑" id="cn.net.connor.process.commands.EditItemCommand"/>
<command name="在AD中打开" id="cn.net.connor.process.commands.OpenPCBCommand3"/>
<command name="内部截图" id="cn.net.connor.process.commands.ScreenShotCommand"/>
<command name="外部截图" id="cn.net.connor.process.commands.ScreenShotCommand#true"/>
<command name="工艺分工" id="cn.net.connor.process.commands.ProcTaskCommand"/>
<command name="流程名称提取" id="cn.net.connor.process.commands.WorkflowNameCommand"/>
<command name="工艺工序编辑" id="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView"/>
<command name="工道编辑" id="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView"/>
<command name="生成工序三维模型" id="cn.net.connor.process.commands.MeopModelCommand"/>
<command name="通过产品查询特殊过程" id="cn.net.connor.process.commands.TSGCExportCommand"/>
<command name="特殊过程被引用情况查询" id="cn.net.connor.process.commands.TSGCRefExportCommand"/>
<command name="工艺升版" id="cn.net.connor.process.commands.ReviseMEProcessCommand"/>
<command name="过程记录卡" id="cn.net.connor.process.commands.GCJLKCommand"/>
<command name="工艺知识库" id="cn.net.connor.process.commands.GYZSKCommand"/>
<command name="打开附件视图" id="cn.net.connor.process.commands.OpenViewCommand#com.teamcenter.rac.cme.attachments"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="cn.net.connor.process.commands.TestCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.NewProcessCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.NewMeopCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ModifyMeopNoCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.GZBomExportCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessCardCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessProcedureCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ScreenShotCommand#true" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ScreenShotCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.EditItemCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenPCBCommand3" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcTaskCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.WorkflowNameCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.MeopModelCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.TSGCExportCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.TSGCRefExportCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ReviseMEProcessCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.GCJLKCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.GYZSKCommand" class="cn.net.connor.process.Processknowledgebase.SJJHHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenViewCommand#com.teamcenter.rac.cme.attachments" class="k.KHandler"/>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="cn.net.connor.process.commands.TestCommand"
sequence="M3+D"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.NewProcessCommand"
sequence="M3+B"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.NewMeopCommand"
sequence="M3+C"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.EditItemCommand"
sequence="M3+S"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ModifyMeopNoCommand"
sequence="M3+V"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ReviseMEProcessCommand"
sequence="M3+R"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ProcessCardCommand"
sequence="M3+N"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ProcessProcedureCommand"
sequence="M3+M"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_"
sequence="M3+J"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_"
sequence="M3+R"
schemeId="com.teamcenter.rac.scheme">
</key>
<!--key
commandId="cn.net.connor.process.commands.ScreenShotCommand"
sequence="M3+U"
schemeId="com.teamcenter.rac.scheme">
</key>
<key
commandId="cn.net.connor.process.commands.ScreenShotCommand#true"
sequence="M3+Y"
schemeId="com.teamcenter.rac.scheme">
</key-->
<key
commandId="cn.net.connor.process.commands.OpenViewCommand#com.teamcenter.rac.cme.attachments"
sequence="M3+O"
schemeId="com.teamcenter.rac.scheme">
</key>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=designMenu">
<menu label="工艺管理" id="cn.net.connor.process.mainmenu">
<separator name ="sp1" visible="false"/>
<separator name ="sp2" visible="false"/>
<separator name ="sp3" visible="false"/>
<menu label="生成工艺卡" id="cn.net.connor.process.mainmenu.card"/>
<menu label="生成工艺附表" id="cn.net.connor.process.mainmenu.gxfb"/>
<separator name ="sp4" visible="false"/>
<separator name ="sp5" visible="false"/>
<menu label="工艺报表" id="cn.net.connor.process.mainmenu.gybb"/>
<separator name ="sp6" visible="true"/>
<menu label="截图工具" id="cn.net.connor.process.mainmenu.screenshot"/>
</menu>
<menu label="客户化功能" id="cn.net.connor.process.khhgn"/>
<menu label="通用菜单" id="cn.net.connor.process.tycd"/>
</menuContribution>
<menuContribution locationURI="menu:cust.reportMenu.process?after=sp2">
<command commandId="cn.net.connor.process.commands.GCJLKCommand" id="cn.net.connor.process.mainmenu.gybb.gcjlk">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.GCJLKCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.TSGCExportCommand" id="cn.net.connor.process.tycd.tsgcexport">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.TSGCExportCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.TSGCRefExportCommand" id="cn.net.connor.process.tycd.tsgcrefexport">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.TSGCRefExportCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<!--menuContribution locationURI="menu:cn.net.connor.process.mainmenu.screenshot?after=additions">
<command commandId="cn.net.connor.process.commands.ScreenShotCommand" id="cn.net.connor.process.mainmenu.screenshot.external">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ScreenShotCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ScreenShotCommand#true" id="cn.net.connor.process.mainmenu.screenshot.internal">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ScreenShotCommand#true"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution-->
<menuContribution locationURI="menu:cust.design.gzMenu?after=additions">
<command commandId="cn.net.connor.process.commands.GZBomExportCommand" id="cn.net.connor.process.mainmenu.newprocess">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.pse.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.GZBomExportCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu?after=sp1">
<command icon="icons/meprocess_16.png" commandId="cn.net.connor.process.commands.NewProcessCommand" id="cn.net.connor.process.mainmenu.newprocess">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.NewProcessCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.NewMeopCommand" icon="icons/meoperation_16.png" id="popups.newmeop">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.NewMeopCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.EditItemCommand" id="popups.edititem">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.EditItemCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<!--
<command commandId="cn.net.connor.process.commands.GYZSKCommand" id="cn.net.connor.process.commands.gyzsk">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.GYZSKCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>-->
<command commandId="cn.net.connor.process.commands.ModifyMeopNoCommand" id="cn.net.connor.process.mainmenu.modifymeopno">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ModifyMeopNoCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ProcTaskCommand" id="cn.net.connor.process.mainmenu.proctask">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcTaskCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView" icon="icons/meprocess_16.png" id="cn.net.connor.process.mainmenu.gygxbj">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView" icon="icons/meoperation_16.png" id="cn.net.connor.process.mainmenu.gdbj">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu?after=sp3">
<!--command commandId="cn.net.connor.process.commands.ReviseMEProcessCommand" id="cn.net.connor.process.mainmenu.revisemeprocess">
<visibleWhen>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ReviseMEProcessCommand"/>
</iterate>
</not>
</with>
</visibleWhen>
</command-->
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu?after=sp4">
<command commandId="cn.net.connor.process.commands.MeopModelCommand" id="cn.net.connor.process.mainmenu.meopmodel">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
</and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.MeopModelCommand"/>
</iterate>
</not>
</with>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu.gxfb?after=additions">
<command commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_" id="cn.net.connor.process.mainmenu.gxfb.a3">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_" id="cn.net.connor.process.mainmenu.gxfb.a4">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu.card?after=additions">
<command commandId="cn.net.connor.process.commands.ProcessCardCommand" id="cn.net.connor.process.mainmenu.card.processcard">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessCardCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ProcessProcedureCommand" id="cn.net.connor.process.mainmenu.card.processproc">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessProcedureCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command commandId="cn.net.connor.process.commands.NewProcessCommand" icon="icons/meprocess_16.png" id="popups.newprocess">
<visibleWhen>
<and>
<!--<reference
definitionId="com.teamcenter.rac.ui.inMainPerspective">
</reference>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponentItem">
<or>
<test
property="com.teamcenter.rac.kernel.TCComponent.property"
args="object_type" value="Ac5_Part">
</test>
<test
property="com.teamcenter.rac.kernel.TCComponent.property"
args="object_type" value="产品开发申请书">
</test>
</or>
</adapt>
</iterate>-->
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.NewProcessCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.OpenPCBCommand3" id="popups.openpcbds">
<visibleWhen>
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test
property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.OpenPCBCommand3"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.NewMeopCommand" icon="icons/meoperation_16.png" id="popups.newmeop">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.NewMeopCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.WorkflowNameCommand" id="popups.workflowname">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.WorkflowNameCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.EditItemCommand" id="popups.edititem">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.EditItemCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,376 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.views">
<category id="cn.net.connor.process.view" name="工艺视图"/>
<view
category="cn.net.connor.process.view"
closable="true"
allowMultiple="false"
icon="icons/meprocess_16.png"
class="cn.net.connor.process.processview.ProcessPropertyView"
id="cn.net.connor.process.processview.ProcessPropertyView"
name="工艺工序编辑">
</view>
<view
category="cn.net.connor.process.view"
closable="true"
allowMultiple="false"
icon="icons/meoperation_16.png"
class="cn.net.connor.process.meopviewfx.MEOPEditView"
id="cn.net.connor.process.meopview.MEOPEditView"
name="工道编辑">
</view>
</extension>
<extension point="com.teamcenter.rac.aifrcp.viewDefs">
<view
alwaysUseSetRootInputObject="true"
autoCloseEnabled="true"
folderId="RAC_Folder_UR"
id="cn.net.connor.process.processview.ProcessPropertyView"
selectionInPrimaryEffectsInvisbleSecondary="false"
selectionInSecondaryEffectsPrimary="false"
type="secondary">
</view>
<view
alwaysUseSetRootInputObject="true"
autoCloseEnabled="true"
folderId="RAC_Folder_UR"
id="cn.net.connor.process.meopview.MEOPEditView"
selectionInPrimaryEffectsInvisbleSecondary="false"
selectionInSecondaryEffectsPrimary="false"
type="secondary">
</view>
</extension>
<extension point="org.eclipse.ui.commands">
<command name="Test" id="cn.net.connor.process.commands.TestCommand"/>
<command name="创建工艺" id="cn.net.connor.process.commands.NewProcessCommand"/>
<command name="创建工序" id="cn.net.connor.process.commands.NewMeopCommand"/>
<command name="修改工序号" id="cn.net.connor.process.commands.ModifyMeopNoCommand"/>
<command name="工装BOM明细表" id="cn.net.connor.process.commands.GZBomExportCommand"/>
<command name="生成工艺卡片" id="cn.net.connor.process.commands.ProcessCardCommand"/>
<command name="A3" id="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_"/>
<command name="A4" id="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_"/>
<command name="生成工艺规程" id="cn.net.connor.process.commands.ProcessProcedureCommand"/>
<command name="材料试件编辑" id="cn.net.connor.process.commands.EditItemCommand"/>
<command name="在AD中打开" id="cn.net.connor.process.commands.OpenPCBCommand3"/>
<command name="内部截图" id="cn.net.connor.process.commands.ScreenShotCommand"/>
<command name="外部截图" id="cn.net.connor.process.commands.ScreenShotCommand#true"/>
<command name="工艺分工" id="cn.net.connor.process.commands.ProcTaskCommand"/>
<command name="流程名称提取" id="cn.net.connor.process.commands.WorkflowNameCommand"/>
<command name="工艺工序编辑" id="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView"/>
<command name="工道编辑" id="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView"/>
<command name="生成工序三维模型" id="cn.net.connor.process.commands.MeopModelCommand"/>
<command name="通过产品查询特殊过程" id="cn.net.connor.process.commands.TSGCExportCommand"/>
<command name="特殊过程被引用情况查询" id="cn.net.connor.process.commands.TSGCRefExportCommand"/>
<command name="工艺升版" id="cn.net.connor.process.commands.ReviseMEProcessCommand"/>
<command name="过程记录卡" id="cn.net.connor.process.commands.GCJLKCommand"/>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler commandId="cn.net.connor.process.commands.TestCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.NewProcessCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.NewMeopCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ModifyMeopNoCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.GZBomExportCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessCardCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcessProcedureCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ScreenShotCommand#true" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ScreenShotCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.EditItemCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenPCBCommand3" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ProcTaskCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.WorkflowNameCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.MeopModelCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.TSGCExportCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.TSGCRefExportCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.ReviseMEProcessCommand" class="k.KHandler"/>
<handler commandId="cn.net.connor.process.commands.GCJLKCommand" class="k.KHandler"/>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="cn.net.connor.process.commands.TestCommand"
sequence="M3+D"
schemeId="com.teamcenter.rac.scheme">
</key>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=designMenu">
<menu label="工艺管理" id="cn.net.connor.process.mainmenu">
<separator name ="sp1" visible="false"/>
<separator name ="sp2" visible="true"/>
<menu label="生成工艺卡" id="cn.net.connor.process.mainmenu.card"/>
<menu label="生成工序附表" id="cn.net.connor.process.mainmenu.gxfb"/>
<menu label="工艺报表" id="cn.net.connor.process.mainmenu.gybb"/>
<separator name ="sp3" visible="true"/>
<menu label="截图工具" id="cn.net.connor.process.mainmenu.screenshot"/>
</menu>
<menu label="客户化功能" id="cn.net.connor.process.khhgn"/>
<menu label="通用菜单" id="cn.net.connor.process.tycd"/>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu.gybb?after=additions">
<command commandId="cn.net.connor.process.commands.GCJLKCommand" id="cn.net.connor.process.mainmenu.gybb.gcjlk"/>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.tycd?after=additions">
<command commandId="cn.net.connor.process.commands.TSGCExportCommand" id="cn.net.connor.process.tycd.tsgcexport"/>
<command commandId="cn.net.connor.process.commands.TSGCRefExportCommand" id="cn.net.connor.process.tycd.tsgcrefexport"/>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu.screenshot?after=additions">
<command commandId="cn.net.connor.process.commands.ScreenShotCommand" id="cn.net.connor.process.mainmenu.screenshot.external">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ScreenShotCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ScreenShotCommand#true" id="cn.net.connor.process.mainmenu.screenshot.internal">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ScreenShotCommand#true"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cust.design.gzMenu?after=additions">
<command commandId="cn.net.connor.process.commands.GZBomExportCommand" id="cn.net.connor.process.mainmenu.newprocess">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.pse.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.GZBomExportCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu?after=sp1">
<command icon="icons/meprocess_16.png" commandId="cn.net.connor.process.commands.NewProcessCommand" id="cn.net.connor.process.mainmenu.newprocess">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.NewProcessCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ModifyMeopNoCommand" id="cn.net.connor.process.mainmenu.modifymeopno">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ModifyMeopNoCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ProcTaskCommand" id="cn.net.connor.process.mainmenu.proctask">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcTaskCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView" icon="icons/meprocess_16.png" id="cn.net.connor.process.mainmenu.gygxbj">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.processview.ProcessPropertyView"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView" icon="icons/meoperation_16.png" id="cn.net.connor.process.mainmenu.gdbj">
<visibleWhen>
<and>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.OpenViewCommand#cn.net.connor.process.meopview.MEOPEditView"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.MeopModelCommand" id="cn.net.connor.process.mainmenu.meopmodel">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ReviseMEProcessCommand" id="cn.net.connor.process.mainmenu.revisemeprocess">
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu.gxfb?after=additions">
<command commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_" id="cn.net.connor.process.mainmenu.gxfb.a3">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A3_"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_" id="cn.net.connor.process.mainmenu.gxfb.a4">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessCardCommand#Connor_AVIC_GYKPSC_CATE_A4_"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="menu:cn.net.connor.process.mainmenu.card?after=additions">
<command commandId="cn.net.connor.process.commands.ProcessCardCommand" id="cn.net.connor.process.mainmenu.card.processcard">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessCardCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.ProcessProcedureCommand" id="cn.net.connor.process.mainmenu.card.processproc">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="cn.net.connor.process.commands.ProcessProcedureCommand"/>
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command commandId="cn.net.connor.process.commands.NewProcessCommand" icon="icons/meprocess_16.png" id="popups.newprocess">
<visibleWhen>
<and>
<!--<reference
definitionId="com.teamcenter.rac.ui.inMainPerspective">
</reference>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponentItem">
<or>
<test
property="com.teamcenter.rac.kernel.TCComponent.property"
args="object_type" value="Ac5_Part">
</test>
<test
property="com.teamcenter.rac.kernel.TCComponent.property"
args="object_type" value="产品开发申请书">
</test>
</or>
</adapt>
</iterate>-->
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.OpenPCBCommand3" id="popups.openpcbds">
<visibleWhen>
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test
property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.NewMeopCommand" icon="icons/meoperation_16.png" id="popups.newmeop">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
</and>
</visibleWhen>
</command>
<command commandId="cn.net.connor.process.commands.WorkflowNameCommand" id="popups.workflowname">
</command>
<command commandId="cn.net.connor.process.commands.EditItemCommand" id="popups.edititem">
<visibleWhen>
<and>
<reference
definitionId="com.teamcenter.rac.cme.mpp.inMainView">
</reference>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>

@ -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;
}
}

@ -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);
}
}

@ -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());
}
}

@ -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;
}
}

@ -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<CustomLovBean> sub = new ArrayList<CustomLovBean>();
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<CustomLovBean> getSub() {
return sub;
}
public boolean hasChild() {
return sub.size() != 0;
}
public void addSub(CustomLovBean clb) {
sub.add(clb);
}
}

@ -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();
}
}
}

@ -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<KTableRow> table;
private List<PropConfig> propConfigs;
public SJJHCommand(TCComponentBOMLine comp,TableView<KTableRow> table,List<PropConfig> 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<String,CustomLovBean> parentMap=new HashMap<String, CustomLovBean>();//存放
Map<String,List<String>> PtoCMap=new HashMap<String,List<String>>();//
// 获取数据库连接
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<String> list=new ArrayList<String>();
list.add(child);
parentLov.addSub(childLov);
PtoCMap.put(parent, list);
}else {
List<String> list=PtoCMap.get(parent);
if(!list.contains(child)) {
list.add(child);
PtoCMap.put(parent, list);
}
}
}
Set<String> parents=PtoCMap.keySet();
for (String parent : parents) {
CustomLovBean parentTree=new CustomLovBean(parent);
List<String> childs=PtoCMap.get(parent);
for(String child:childs) {
parentTree.addSub(new CustomLovBean(child));
}
top.addSub(parentTree);
}
new SJJHDialog(comp,table,top,propConfigs);
}
}

@ -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<PropConfig> propConfigs;
private CustomLovBean top;
private String parent;
private String child;
private TableView<KTableRow> table;
// private int currentCaret=0;
private List<List<String>> WeldDatas = new ArrayList<List<String>>();// 接头数据
public SJJHDialog(TCComponentBOMLine comp, TableView<KTableRow> table, CustomLovBean top,
List<PropConfig> 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<KTableRow, String> cell = (KFXEditableStringAreaTableCell<KTableRow, String>) 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<CustomLovBean> 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;
}
}

@ -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;
}
}

@ -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();
}
}
}
}
}
}

@ -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;
}
}

@ -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<PrefComponent> prefComponents;
//private Map<String, JTextComponent> otherComps;
private ChooseDialog dialog;
protected File excelFile;
protected List<Config> configs = new ArrayList<KExcelTable.Config>();
protected List<String> searchCols = new ArrayList<String>();
protected Map<String,JTextField> searchComps = new HashMap<String, JTextField>();
protected KExcelTable tableBean;
public ChooseDialogController(AbstractAIFApplication app, String type, PrefComponent bean, List<PrefComponent> 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;i<len;i++) {
String pref = config[i];
String[] split = pref.split("=",-1);
int splitCnt = KUtil.getLen(split);
String tableCol = null, excelCol = null, propConfig = null;
int prefW = 100;
if(splitCnt>0) {
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<String,String> searchInfo = new HashMap<String, String>();
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<Config, String> 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();
}
}

@ -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_")));
}
}

@ -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)));
}
}

@ -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")));
}
}

@ -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();
}
}

@ -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)));
}
}

@ -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)));
}
}

@ -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)));
}
}

@ -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")));
}
}

@ -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")));
}
}

@ -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")));
}
}

@ -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();
}
}
});
}
}

@ -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)));
}
}

@ -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)));
}
}

@ -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)));
}
}

@ -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")));
}
}

@ -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);
}
}

@ -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")));
}
}

@ -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)));
}
}

@ -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, "")));
}
}

@ -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")));
}
}

@ -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<headerWidth.length; i++) {
colModel.getColumn(i).setPreferredWidth(headerWidth[i]);
}
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(500, 300));
panel.add(BorderLayout.CENTER, scroll);
return panel;
}
private Component initQueryPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(5, 6, 5, 0));
KUtil.newRow(panel, new JLabel(REG.getString("itemid.LABEL")), s, 1);
KUtil.addCol(panel, this.tf_ItemID = new JTextField(18), s, 1, 0);
KUtil.addCol(panel, new JLabel(" "+REG.getString("revid.LABEL")), s, 1, 0);
KUtil.addCol(panel, this.tf_RevID = new JTextField(5), s, 1, 0);
KUtil.addCol(panel, new JLabel(" "), s, 1, 1);
s.insets.right = 5;
KUtil.addCol(panel, this.b_query = new JButton(REG.getString("query.BTN")), s, 1, 0);
this.tf_ItemID.setText(controller.targetItemID);
this.tf_RevID.setText(controller.targetRevID);
this.tf_ItemID.setEditable(false);
this.tf_RevID.setEditable(false);
return panel;
}
}

@ -0,0 +1,195 @@
package cn.net.connor.process.gcjlk;
import java.io.File;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.filechooser.FileSystemView;
import com.teamcenter.rac.aif.AbstractAIFApplication;
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.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOPWindow;
import com.teamcenter.rac.kernel.TCComponentBOPWindowType;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
import cn.net.connor.process.ProcessUtil;
import k.KDialogController;
import k.KOperation2;
import k.util.KSqlUtil;
import k.util.KUtil;
import k.word.KWord;
import k.word.KWordUtil;
public class GCJLKDialogController extends KDialogController {
private TCComponentItemRevision targetRev;
private TCComponentItemRevision procRev;
protected String targetItemID = "";
protected String targetRevID = "";
private GCJLKDialog dialog;
private String dbUrl;
private String dbUser;
private String dbPwd;
private String sql;
private KWord kWord;
private static final Registry REG = Registry.getRegistry(GCJLKDialogController.class);
private static final String PREF_QUERY_GCJLK = "CONNOR_AVIC_GCJLK_Query";
private static final String PREF_EXPORT_GCJLK = "CONNOR_AVIC_GCJLK_Export";
public GCJLKDialogController(AbstractAIFApplication app) {
super(app);
}
@Override
public boolean init() throws Exception {
this.dialog = (GCJLKDialog) aifDialog;
InterfaceAIFComponent target = app.getTargetComponent();
System.out.println("Select: " + target);
if (target != null && (target instanceof TCComponentItemRevision)) {
this.targetRev = (TCComponentItemRevision) target;
}
if (this.targetRev == null) {
throw new TCException(REG.getString("selectrev.WARN"));
}
AIFComponentContext[] proc = targetRev.whereReferencedByTypeRelation(null, new String[] { "IMAN_METarget" });
System.out.println("proc: " + targetRev + " -> " + 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<String[]> 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<String, String> overwriteTexts = new HashMap<String, String>();
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<KWord> kWords = new ArrayList<KWord>();
kWords.add(kWord);
List<TCComponentBOMLine> targetLines = new ArrayList<TCComponentBOMLine>();
List<TCComponentItemRevision> meTargetRevs = new ArrayList<TCComponentItemRevision>();
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();
}
}

@ -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

@ -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<Config> configs = new ArrayList<GZBomExportOperation.Config>();
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<len;i++) {
String pref = prefs[i].trim();
if(pref.length()==1&&Character.isDigit(pref.charAt(0))) {
int num = pref.charAt(0)-'0';
if(num>=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<colCnt;i++) {
int col = STARTCOL+i;
Config config = this.configs.get(i);
String val;
if(KUtil.isEmpty(config.propName)) {
val = "";
}else {
val = config.isBomProp? parentLine.getProperty(config.propName):(form==null?"":form.getProperty(config.propName));
}
POIUtil.setValue(row, col, val, cellStyle);
}
AIFComponentContext[] cLines = parentLine.getChildren();
int len = KUtil.getLen(cLines);
for(int i=0;i<len;i++) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cLines[i].getComponent();
exportLine(cLine);
}
}
@Override
public void execute() throws Exception {
String time = KUtil.isEmpty(dateformat)?"":KUtil.getDateStr(new Date(), dateformat);
File file = KUtil.chooseSaveFile(((PSEApplicationService) app).getApplicationPanel(), FILENAME+time+".xlsx");
if(file==null) {
System.out.println("Cancel Export");
return;
}
System.out.println("Save File: "+file.getAbsolutePath());
InputStream input = this.getClass().getResourceAsStream("template.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(input);
this.cellStyle = POIUtil.getCellStyle(wb, null, false);
input.close();
this.sheet = wb.getSheetAt(0);
exportLine(topLine);
FileOutputStream os = new FileOutputStream(file);
wb.write(os);
os.flush();
os.close();
int op = JOptionPane.showOptionDialog(((PSEApplicationService) app).getApplicationPanel(), ProcessLocale.getString("exportsuccess.INFO"), "", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null);
if(op==JOptionPane.YES_OPTION) {
KUtil.openFile(file);
}
}
}

@ -0,0 +1,186 @@
package cn.net.connor.process.hourcalculation;
import java.io.InputStream;
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.kernel.*;
import com.teamcenter.rac.aif.AbstractAIFCommand;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCPreferenceService;
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.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 org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class FitterCommand extends AbstractAIFCommand {
private TCComponentBOMLine comp;
private TCSession session;
private TableView<KTableRow> table;
private List<PropConfig> 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_xml请检查xml文件的配置。", "错误", 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<String, Map<String, String>> PtoCMap = new HashMap<String, Map<String, String>>();//
//记录树结构
Map<String, List<String>> treeMap=new HashMap<String, List<String>>();
// 创建解析对象
SAXReader sax = new SAXReader();
Document doc = sax.read(MethodUtil.getDatByUid(puid,session));
// 获取根元素
Element root = doc.getRootElement();
// 获取根元素下的所有子元素:大类
List<Element> parents = root.elements();
//大类的排序
List<String> parentList=new ArrayList<String>();
// 获取大类
for (Element parent : parents) {// 第一层级大类
// System.out.println("大类:"+parent.attribute("name").getValue());
List<String> childList=new ArrayList<String>();
// 大类名称
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<Element> childs = parent.elements();
for (Element child : childs) {
Map<String, String> map=new HashMap<String, String>();
String childName = child.attribute("name").getValue();
String childType = child.attribute("type").getValue();
//System.out.println("小类的名称为:"+childName+"====>类型为:"+childType);
childList.add(childName);
String attributes="";
// 小类的数据
List<Element> 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<String> parentNames=treeMap.keySet();
for (String parent : parentList) {
CustomLovBean parentTree=new CustomLovBean(parent);
List<String> 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);
}
}

File diff suppressed because it is too large Load Diff

@ -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;
}
}

@ -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("公式中存在未赋值的变量");
}
}
}

@ -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<KTableRow> table, List<PropConfig> 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<String,CustomLovBean> parentMap=new HashMap<String, CustomLovBean>();//存放
Map<String, Map<String, String>> PtoCMap = new HashMap<String, Map<String, String>>();//
//大类的排序
List<String> parentList=new ArrayList<String>();
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<String,String> map=new HashMap<String, String>();
map.put(value[1],value[2]);
PtoCMap.put(value[0], map);
}else {
Map<String,String> map=PtoCMap.get(value[0]);
map.put(value[1],value[2]);
PtoCMap.put(value[0], map);
}
}
}
}
//Set<String> parents=PtoCMap.keySet();
for (String parent : parentList) {
CustomLovBean parentTree=new CustomLovBean(parent);
Map<String, String> children=PtoCMap.get(parent);
Set<String> 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);
}
}

File diff suppressed because it is too large Load Diff

@ -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<KTableRow> table;
private List<PropConfig> 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);
}
}

@ -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<TCComponent> 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 {
}
}

@ -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<TCComponentItemRevision> gxmxRevs;
private String opNum;
private String opName;
private MeopModelBean(TCComponentBOPLine meopLine, List<TCComponentItemRevision> gxmxRevs, String opNum, String opName) {
this.meopLine = meopLine;
this.gxmxRevs = gxmxRevs;
this.opNum = opNum;
this.opName = opName;
}
public TCComponentBOPLine getMeopLine() {
return meopLine;
}
public List<TCComponentItemRevision> 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<TCComponentItemRevision> gxmxRevs = new ArrayList<TCComponentItemRevision>();
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;
}
}

@ -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<rowCnt;i++) {
this.tableModel.addRow(controller.meopModelBeans.get(i).getRowData());
}
this.table.getColumnModel().getColumn(0).setPreferredWidth(120);
this.table.getColumnModel().getColumn(1).setPreferredWidth(240);
return panel;
}
}

@ -0,0 +1,126 @@
package cn.net.connor.process.meopmodel;
import java.util.ArrayList;
import java.util.List;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.DeepCopyInfo;
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 k.KDialogController;
import k.KOperation2;
import k.util.KUtil;
public class MeopModelDialogController extends KDialogController{
private TCComponentBOPLine targetLine;
protected List<MeopModelBean> meopModelBeans = new ArrayList<MeopModelBean>();
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<len; i++) {
TCComponentBOPLine cLine = (TCComponentBOPLine) cc[i].getComponent();
MeopModelBean bean = MeopModelBean.parse(cLine);
if(bean==null) {
continue;
}
meopModelBeans.add(bean);
}
if(this.meopModelBeans.size()==0) {
throw new TCException(REG.getString("nomeopmodel.ERROR"));
}
try {
this.itemType = (TCComponentItemType) session.getTypeComponent(DesignModelOperation.TYPE_ITEM);
} catch (Exception e) {
e.printStackTrace();
}
if (this.itemType == null) {
throw new TCException("Type is not defined: " + DesignModelOperation.TYPE_ITEM);
}
return true;
}
public void doCreate() throws Exception{
int rowNum = dialog.table.getSelectedRow();
System.out.println("select row: "+rowNum);
if(rowNum<0) {
return;
}
dialog.disposeDialog();
new KOperation2(app, REG.getString("create.STATUS")) {
@Override
public boolean init() throws Exception {
return true;
}
@Override
public void execute() throws Exception {
MeopModelBean bean = (MeopModelBean) dialog.table.getValueAt(rowNum, 0);
TCComponentBOPLine meopLine = bean.getMeopLine();
List<TCComponentItemRevision> gxmxRevs = bean.getGxmxRevs();
System.out.println("template: "+meopLine+" -> "+gxmxRevs);
int cnt = gxmxRevs.size();
for(int i=0; i<cnt ; i++) {
session.setStatus(String.format("( %d / %d ) %s", i+1, cnt, REG.getString("gxmxsaveas.STATUS")));
TCComponentItemRevision rev = gxmxRevs.get(i);
System.out.println("copy "+rev);
String itemID = itemType.getNewID();
String revID = itemType.getNewRev(null);
String objectName = rev.getStringProperty("object_name");
List<DeepCopyInfo> deepCopyInfos = new ArrayList<DeepCopyInfo>();
List<TCComponent> 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<dsCnt; j++) {
TCComponent ds = datasets.get(j);
DeepCopyInfo deepCopyInfo = new DeepCopyInfo(ds, DeepCopyInfo.COPY_NOT_ACTION, ds.getStringProperty("object_name")+" do not copy", DesignModelOperation.REL_REV_DATASET, false, false, false);
deepCopyInfos.add(deepCopyInfo);
}
TCComponentItem newItem = rev.saveAsItem(itemID, revID, objectName, "", false, deepCopyInfos.toArray(new DeepCopyInfo[] {}));
System.out.println(">> new Item: "+newItem);
newItem.refresh();
TCComponentItemRevision newRev = newItem.getLatestItemRevision();
System.out.println(">> new rev: " + newRev);
newRev.refresh();
for(int j=0; j<dsCnt; j++) {
TCComponentDataset ds = (TCComponentDataset) datasets.get(j);
TCComponentDataset newDataset = ds.saveAs(ds.getStringProperty("object_name"));
System.out.println(">> 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();
}
}

@ -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

@ -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<Object> 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");
}
}

@ -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<PropConfig, SimpleStringProperty> stringProps = new HashMap<PropConfig, SimpleStringProperty>();
private Map<PropConfig,String> savedValues = new HashMap<PropConfig, String>();
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<String, String> bomlinePropMap , Map<String, String> itemPropMap,Map<String, String> revPropMap, Map<String, String> itemMasterPropMap,Map<String, String> 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<String, String> revPropMap = new HashMap<>();
Map<String, String> revMasterPropMap = new HashMap<>();
Map<String, String> itemPropMap = new HashMap<>();
Map<String, String> itemMasterPropMap = new HashMap<>();
Map<String, String> 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();
}
}
}

@ -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;
}
}

@ -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<TextBean> children = new ArrayList<TextBean>();
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;
}
}

@ -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);
}
}

@ -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;
}
}

@ -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 <T>
* @param <E>
*/
public class KFXEditableStringAreaHtmlTableCell<T, E> extends TableCell<T, String> {
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("<html>") ? 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<State>() {
@Override
public void changed(ObservableValue<? extends State> 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
}
}
}

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cn.net.connor.process.meopviewfx.ui.MEOPPanelController">
<children>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<center>
<SplitPane dividerPositions="1.0" prefHeight="160.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<SplitPane dividerPositions="0.4" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0">
<items>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<center>
<TableView fx:id="table1" editable="true" prefHeight="200.0" prefWidth="200.0" style="-fx-faint-focus-color: transparent; -fx-focus-color: rgba(0,0,0,0.2); -fx-background-insets: 0;" BorderPane.alignment="CENTER" />
</center>
</BorderPane>
<BorderPane minHeight="0.0">
<top>
<ScrollPane fitToWidth="true" style="-fx-background-insets: 0;">
<content>
<FlowPane fx:id="propPane" hgap="8.0" vgap="5.0" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="5.0" />
</BorderPane.margin>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</FlowPane>
</content>
<BorderPane.margin>
<Insets bottom="5.0" />
</BorderPane.margin>
</ScrollPane>
</top>
<center>
<TableView fx:id="table2" editable="true" minHeight="0.0" prefHeight="200.0" prefWidth="200.0" style="-fx-faint-focus-color: transparent; -fx-focus-color: rgba(0,0,0,0.2);" visible="false" BorderPane.alignment="CENTER" />
</center>
<right>
<VBox fx:id="buttonBox" minHeight="0.0" spacing="5.0" visible="false" BorderPane.alignment="CENTER">
<padding>
<Insets left="5.0" />
</padding>
<children>
<Button fx:id="b_AddRow" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#addRowButtonClicked" prefHeight="25.0" prefWidth="25.0" />
<Button fx:id="b_DelRow" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#delRowButtonClicked" prefHeight="25.0" prefWidth="25.0" />
<Button fx:id="b_MoveUp" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#moveUpButtonClicked" prefHeight="25.0" prefWidth="25.0" />
<Button fx:id="b_MoveDown" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#moveDownButtonClicked" prefHeight="25.0" prefWidth="25.0" />
<Button fx:id="b_Search" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" onAction="#searchButtonClicked" prefHeight="25.0" prefWidth="25.0" />
</children>
</VBox>
</right>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</BorderPane>
</items>
</SplitPane>
<TabPane fx:id="textTab" prefHeight="200.0" prefWidth="200.0" side="RIGHT" tabClosingPolicy="UNAVAILABLE" />
</items>
</SplitPane>
</center>
<bottom>
<GridPane hgap="20.0" BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Button mnemonicParsing="false" onAction="#reloadDataButtonClick" text=" 更新 " />
<Button mnemonicParsing="false" onAction="#saveButtonClick" text=" 保存 " GridPane.columnIndex="1" />
</children>
<padding>
<Insets bottom="5.0" left="10.0" right="5.0" top="5.0" />
</padding>
</GridPane>
</bottom>
</BorderPane>
<AnchorPane fx:id="cover" prefHeight="200.0" prefWidth="200.0" visible="false">
<children>
<ProgressIndicator prefHeight="30.0" prefWidth="30.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" />
</children>
</AnchorPane>
</children>
</StackPane>

@ -0,0 +1,46 @@
package cn.net.connor.process.meopviewfx.ui;
import java.awt.Window;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.pse.common.BOMLineNode;
import k.ui.KFXPanel;
import k.util.KUtil;
public class MEOPPanel extends KFXPanel{
private MEOPPanelController controller;
public MEOPPanel(Window dialog) {
super(dialog, MEOPPanel.class, "style.css");
this.controller = (MEOPPanelController)aifController;
initData();
}
public void refreshUI(TCComponentBOMLine targetLine) throws Exception{
this.controller.refreshUI(targetLine);
}
public synchronized void updateSelection(Object targetObj) {
System.out.println("Update: "+targetObj);
if (targetObj != null && targetObj instanceof AIFComponentContext) {
targetObj = ((AIFComponentContext) targetObj).getComponent();
}
if (targetObj != null && targetObj instanceof BOMLineNode) {
targetObj = ((BOMLineNode) targetObj).getComponent();
}
if (targetObj == null || !(targetObj instanceof TCComponentBOMLine)) {
} else {
TCComponentBOMLine targetLine = (TCComponentBOMLine) targetObj;
try {
refreshUI(targetLine);
} catch (Exception e) {
KUtil.error(getParentDialog(), e.getMessage());
e.printStackTrace();
}
}
}
}

@ -0,0 +1,312 @@
package cn.net.connor.process.meopviewfx.ui;
import java.util.Map;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.util.MessageBox;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.meopviewfx.bean.KTableRow;
import cn.net.connor.process.meopviewfx.bean.TextBean;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseButton;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import k.ui.KFXPanel;
import k.ui.KFXPanelController;
import k.util.KUtil;
public class MEOPPanelController extends KFXPanelController {
public static final String PREF_BOM_TABLE = "Connor_AVIC_GXBZ_Bomline";
public static final String PREF_PREFIX_BOM_TABLE_WITH_TYPE = "Connor_AVIC_GXBZ_";
public static final String PREF_PREFIX_PROP_FLOW_WITH_TYPE = "Connor_AVIC_GXBZ_Property_";
@FXML
private TableView<KTableRow> table1;
@FXML
private TableView<KTableRow> table2;
@FXML
private FlowPane propPane;
@FXML
private AnchorPane cover;
@FXML
private Button b_AddRow;
@FXML
private Button b_DelRow;
@FXML
private Button b_Search;
@FXML
private Button b_MoveUp;
@FXML
private Button b_MoveDown;
@FXML
private VBox buttonBox;
@FXML
private TabPane textTab;
private boolean busy = false;
private TableLoader table1Loader = new TableLoader();
private TableLoader table2Loader = new TableLoader();
private PropFlowLoader propLoader = new PropFlowLoader();
// private MEOPPanel panel;
public Image folder = new Image(MEOPPanelController.class.getResourceAsStream("/icons/folder_24.png"), 18, 18, true, false);
public Image text = new Image(MEOPPanelController.class.getResourceAsStream("/icons/text.png"), 18, 18, true, false);
private TCComponentBOMLine targetLine;
@Override
public void initData(KFXPanel panel) throws Exception {
// this.panel = (MEOPPanel) panel;
// table1.getSelectionModel().setCellSelectionEnabled(true);
// table2.getSelectionModel().setCellSelectionEnabled(true);
b_AddRow.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/add_24px.png"), 19, 19, true, false)));
b_DelRow.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/delete_24px.png"), 19, 19, true, false)));
b_MoveUp.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/up_24px.png"), 19, 19, true, false)));
b_MoveDown.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/down_24px.png"), 19, 19, true, false)));
b_Search.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("/icons/search_24px.png"), 19, 19, true, false)));
table1.setVisible(table1Loader.load(table1, PREF_BOM_TABLE));
if(table1.isVisible()) {
String colName = ProcessLocale.getString("index.COL");
TableColumn<KTableRow, String> c = new TableColumn<KTableRow, String>(colName);
c.setCellFactory(col -> new TableCell<KTableRow, String>(){
@Override
public void updateIndex(int index) {
super.updateIndex(index);
if (isEmpty() || index < 0) {
setText(null);
} else {
setText(Integer.toString(index+1));
}
}
});
Platform.runLater(() -> {
c.setEditable(false);
c.setSortable(false);
c.setPrefWidth(70);
table1.getColumns().add(0, c);
});
}
// load special text
Map<String, TextBean> textMap = new TextTreeLoader().loadText();
for (String sheetName : textMap.keySet()) {
TextBean bean = textMap.get(sheetName);
Tab tab = new Tab(sheetName);
textTab.getTabs().add(tab);
TreeView<TextBean> tree = new TreeView<TextBean>();
TreeItem<TextBean> rootNode = new TreeItem<TextBean>(bean, new ImageView(folder));
tree.setRoot(rootNode);
tree.setShowRoot(false);
rootNode.setExpanded(true);
loadTree(rootNode, bean);
tab.setContent(tree);
tree.setOnMouseClicked(e -> {
if (e.getButton() != MouseButton.PRIMARY || e.getClickCount() != 2) {
return;
}
TreeItem<TextBean> treeItem = tree.getSelectionModel().getSelectedItem();
if (treeItem.getChildren().size() > 0) {
return;
}
TextBean textBean = treeItem.getValue();
String text = textBean.getRealValue();
System.out.println("Insert: " + text);
long time = Math.max(table1Loader.focuseTime, table2Loader.focuseTime);
time = Math.max(time, propLoader.focuseTime);
if (propLoader.focuseTime == time) {
propLoader.insertText(text);
}
if (table1Loader.focuseTime == time) {
table1Loader.insertText(text);
}
if (table2Loader.focuseTime == time) {
String parentText = treeItem.getParent()==null?"":treeItem.getParent().getValue().getRealValue();
table2Loader.insertText(text, parentText, textBean.getMKHId(), textBean.getMKHRev());
}
});
}
}
public void reloadDataButtonClick() {
new Thread(()->{
KUtil.session.setStatus("Reloading...");
setProgressVisible(true);
try {
reloadData(null);
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e);
}
setProgressVisible(false);
System.out.println("Reload Complete");
}).start();
}
public void saveButtonClick() {
new Thread(() -> {
KUtil.session.setStatus("Saving...");
setProgressVisible(true);
try {
saveData();
reloadData(null);
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e);
}
setProgressVisible(false);
System.out.println("Save Complete");
}).start();
}
public synchronized void reloadData(TCComponentBOMLine targetLine) throws Exception {
if (targetLine == null) {
targetLine = this.targetLine;
// AIFComponentContext cc =
// AIFUtility.getCurrentApplication().getTargetContext();
// System.out.println("Select: "+cc);
// if(cc!=null&&cc.getComponent()!=null&&(cc.getComponent() instanceof
// TCComponentBOMLine)){
// targetLine = (TCComponentBOMLine) cc.getComponent();
// }
}
if (targetLine == null) {
return;
}
this.targetLine = targetLine;
System.out.println("Load Line: " + targetLine);
TCComponentItemType itemType = targetLine == null ? null : targetLine.getItem().getTypeComponent();
String prefName = itemType == null ? null : PREF_PREFIX_BOM_TABLE_WITH_TYPE + itemType.getTypeName();
boolean table2Visible = table2Loader.load(table2, prefName);
String prefName2 = itemType == null ? null : PREF_PREFIX_PROP_FLOW_WITH_TYPE + itemType.getTypeName();
boolean propVisible = propLoader.load(propPane, prefName2, itemType);
if (!Platform.isFxApplicationThread()) {
Platform.runLater(() -> {
table2.setVisible(table2Visible);
buttonBox.setVisible(table2Visible);
propPane.setVisible(propVisible);
try {
propLoader.loadTCData(this.targetLine);
table1Loader.loadTCData(this.targetLine, true);
table2Loader.loadTCData(this.targetLine, false);
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e);
}
});
} else {
table2.setVisible(table2Visible);
buttonBox.setVisible(table2Visible);
propPane.setVisible(propVisible);
propLoader.loadTCData(targetLine);
table1Loader.loadTCData(targetLine, true);
table2Loader.loadTCData(targetLine, false);
}
}
public void saveData() throws Exception {
if (targetLine == null) {
return;
}
propLoader.saveTCData(targetLine);
table1Loader.saveTCData(targetLine);
table2Loader.saveTCData(targetLine);
targetLine.refresh();
}
private void loadTree(TreeItem<TextBean> rootNode, TextBean bean) {
int childCnt = bean.children.size();
for (int i = 0; i < childCnt; i++) {
TextBean childBean = bean.children.get(i);
boolean isFolder = childBean.children.size() > 0;
TreeItem<TextBean> cNode = isFolder ? new TreeItem<TextBean>(childBean, new ImageView(folder)) : new TreeItem<TextBean>(childBean, new ImageView(text));
rootNode.getChildren().add(cNode);
if (isFolder) {
loadTree(cNode, childBean);
}
}
}
public void refreshUI(TCComponentBOMLine targetLine) throws Exception {
if(busy) {
System.out.println("Task Running. Skip load: "+targetLine);
return;
}
setProgressVisible(true);
try {
reloadData(targetLine);
} finally {
setProgressVisible(false);
}
// this.targetLine = targetLine;
// TCComponentItemType itemType = targetLine == null ? null :
// targetLine.getItem().getTypeComponent();
// String prefName = itemType == null ? null : PREF_PREFIX_BOM_TABLE_WITH_TYPE +
// itemType.getTypeName();
// boolean table2Visible = table2Loader.load(table2, prefName);
// String prefName2 = itemType == null ? null : PREF_PREFIX_PROP_FLOW_WITH_TYPE
// + itemType.getTypeName();
// boolean propVisible = propLoader.load(propPane, prefName2, itemType);
// Platform.runLater(() -> {
// table2.setVisible(table2Visible);
// buttonBox.setVisible(table2Visible);
// propPane.setVisible(propVisible);
// });
// reloadData();
}
public void addRowButtonClicked() {
table2Loader.addRow();
}
public void delRowButtonClicked() {
table2Loader.removeRow();
}
public void moveUpButtonClicked() {
table2Loader.moveUp();
}
public void moveDownButtonClicked() {
table2Loader.moveDown();
}
public void searchButtonClicked() {
table2Loader.search(targetLine);
}
public void setProgressVisible(boolean visible) {
this.busy = visible;
if (cover != null) {
if (Platform.isFxApplicationThread()) {
cover.setVisible(visible);
} else {
Platform.runLater(() -> {
cover.setVisible(visible);
});
}
try {
Thread.sleep(10);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,299 @@
package cn.net.connor.process.meopviewfx.ui;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.time.LocalDate;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
import com.teamcenter.rac.treetable.SwingTextContextActivator;
import cn.net.connor.process.ProcessLocale;
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.geometry.Pos;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Control;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import k.ui.KFXTextLocator;
import k.ui.KLOVComboBox;
import k.util.KUtil;
@SuppressWarnings("unchecked")
public class PropFlowLoader extends KFXTextLocator {
protected List<PropConfig> propConfigs = new ArrayList<PropConfig>();
public boolean load(FlowPane flowPane, String prefName, TCComponentItemType itemType) throws Exception {
clearLocatorData();
Platform.runLater(() -> {
flowPane.getChildren().clear();
});
propConfigs.clear();
if (KUtil.isEmpty(prefName) || itemType == null) {
return false;
}
System.out.println("Load FlowPane from pref: " + prefName);
String[] prefVals = KUtil.getPrefVals(KUtil.session, prefName);
int len = KUtil.getLen(prefVals);
if (len <= 1) {
return false;
}
System.out.println(">> Item Type: " + itemType.getDisplayTypeName());
TCComponentType revMasterType = null;
TCComponentItemRevisionType revType = itemType.getItemRevisionType();
revMasterType = KUtil.session.getTypeComponent(revType.getTypeName() + "Master");
if (revMasterType == null) {
revMasterType = KUtil.session.getTypeComponent(revType.getTypeName() + " Master");
}
if (revMasterType == null) {
throw new Exception(String.format(ProcessLocale.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master"));
}
for (int i = 0; i < len; i++) {
String propName = prefVals[i];
System.out.println("Load Config: " + propName);
if (KUtil.isEmpty(propName)) {
continue;
}
String propLoc = KTableRow.REVMASTER;
String filterValue = null;
int width = 0;
// while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
// width = width * 10 + (propName.charAt(0) - '0');
// propName = propName.substring(1);
// }
// int ind = propName.indexOf('.');
// if (ind > 0) {
// propLoc = propName.substring(0, ind);
// propName = propName.substring(ind + 1);
// }
int ind = propName.indexOf('=');
if (ind > 0) {
filterValue = propName.substring(ind + 1);
propName = propName.substring(0, ind);
}
TCPropertyDescriptor propDesc;
if (propName.startsWith("*")) {
propLoc = KTableRow.REV;
propName = propName.substring(1);
propDesc = revType.getPropDesc(propName);
if (propDesc == null) {
throw new Exception(String.format(ProcessLocale.getString("propnotdefinedintype.ERROR2"), propName, revType.getDisplayTypeName()));
}
} else {
propDesc = revMasterType.getPropDesc(propName);
if (propDesc == null) {
throw new Exception(String.format(ProcessLocale.getString("propnotdefinedintype.ERROR2"), propName, revMasterType.getDisplayTypeName()));
}
}
this.propConfigs.add(new PropConfig(propLoc, propDesc, filterValue, width, 0));
}
System.out.println("Load complete");
int size = this.propConfigs.size();
if (size == 0) {
return false;
}
for (int i = 0; i < size; i++) {
PropConfig config = propConfigs.get(i);
addPropPane(flowPane, config);
}
return true;
}
public void loadTCData(TCComponentBOMLine targetLine) throws Exception {
if (targetLine == null) {
return;
}
TCComponent revMaster = targetLine == null ? null : targetLine.getItemRevision().getRelatedComponent("IMAN_master_form_rev");
TCComponent rev = targetLine == null ? null : targetLine.getItemRevision();
int size = this.propConfigs.size();
if (size == 0) {
return;
}
for (int j = 0; j < size; j++) {
PropConfig config = propConfigs.get(j);
Control control = config.getControl();
if (control == null) {
continue;
}
TCComponent comp = KTableRow.REV.equals(config.propLoc) ? rev : revMaster;
if (control instanceof TextField) {
String text = comp.getStringProperty(config.propName);
((TextField) control).setText(text);
config.setSavedValue(text);
} else if (control instanceof DatePicker) {
Date date = comp.getDateProperty(config.propName);
((DatePicker) control).setValue(KUtil.dateToLocalDate(date));
config.setSavedValue(date);
} else if (control instanceof KLOVComboBox) {
String text = comp.getStringProperty(config.propName);
((KLOVComboBox) control).setValue(text);
config.setSavedValue(text);
} else if (control instanceof ComboBox) {
String text = comp.getStringProperty(config.propName);
((ComboBox<String>) control).setValue(text);
config.setSavedValue(text);
}
}
}
public void saveTCData(TCComponentBOMLine targetLine) throws Exception {
if (targetLine == null) {
return;
}
System.out.println("Update Property: " + targetLine);
TCComponentItemRevision rev = targetLine == null ? null : targetLine.getItemRevision();
TCComponent revMaster = targetLine == null ? null : targetLine.getItemRevision().getRelatedComponent("IMAN_master_form_rev");
int size = this.propConfigs.size();
if (size == 0) {
return;
}
for (int j = 0; j < size; j++) {
PropConfig config = propConfigs.get(j);
Control control = config.getControl();
if (control == null || !config.canEdit) {
continue;
}
TCComponent comp = KTableRow.REV.equals(config.propLoc) ? rev : revMaster;
String propName = config.propName;
if (control instanceof TextField) {
String value = ((TextField) control).getText();
if (config.valueChanged(value)) {
System.out.println(">> " + propName + " = " + value);
comp.setStringProperty(propName, value);
}
} else if (control instanceof DatePicker) {
Date value = KUtil.localDateToDate(((DatePicker) control).getValue());
if (config.valueChanged(value)) {
System.out.println(">> " + propName + " = " + value);
comp.setDateProperty(propName, value);
}
} else if (control instanceof KLOVComboBox) {
String value = ((KLOVComboBox) control).getSelectionModel().getSelectedItem();
if (config.valueChanged(value)) {
System.out.println(">> " + propName + " = " + value);
comp.setStringProperty(propName, value);
}
} else if (control instanceof ComboBox) {
String value = ((ComboBox<String>) control).getSelectionModel().getSelectedItem();
if (config.valueChanged(value)) {
System.out.println(">> " + propName + " = " + value);
comp.setStringProperty(propName, value);
}
}
}
rev.refresh();
revMaster.refresh();
}
private void addPropPane(FlowPane flowPane, PropConfig config) throws Exception {
String title = config.propDisplayName;
TCComponentListOfValues lov = config.lov;
// HBox propPane = new HBox();
BorderPane propPane = new BorderPane();
// propPane.setSpacing(5);
// propPane.setAlignment(Pos.CENTER_LEFT);
propPane.setPrefWidth(280);
Label label = new Label(title + " ");
label.setAlignment(Pos.CENTER_RIGHT);
label.setMinWidth(80);
Platform.runLater(() -> {
// propPane.getChildren().add(label);
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
propPane.setLeft(label);
flowPane.getChildren().add(propPane);
});
if (config.propDesc.isType(TCProperty.PROP_date)) {
DatePicker dp = new DatePicker();
config.setControl(dp);
dp.setDisable(!config.canEdit);
} else if (lov == null) {
if (!KUtil.isEmpty(config.filterValue)) {
String[] split = config.filterValue.split(";");
ComboBox<String> cb = new ComboBox<String>();
cb.getItems().add("");
for (String string : split) {
cb.getItems().add(string);
}
cb.setMaxWidth(300);
config.setControl(cb);
cb.setDisable(!config.canEdit);
} else {
TextField tf = new TextField();
config.setControl(tf);
tf.setEditable(config.canEdit);
tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue) {
System.out.println("focus get: " + title);
updateControl(tf);
} else {
System.out.println("focus lost: " + title);
}
}
});
tf.caretPositionProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (tf.isFocused()) {
System.out.println("caret: " + oldValue + " -> " + newValue);
currentCaret = newValue.intValue();
}
}
});
tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> paramObservableValue, Boolean oldValue, Boolean newValue) {
if (newValue) {
SwingTextContextActivator.instance().activateContext();
} else {
SwingTextContextActivator.instance().deactivateContext();
}
}
});
}
} else {
KLOVComboBox cb = new KLOVComboBox(lov);
cb.setMaxWidth(300);
config.setControl(cb);
cb.setDisable(!config.canEdit);
}
Platform.runLater(() -> {
propPane.setCenter(config.getControl());
});
}
@Override
public void insertText(String text) {
if (KUtil.isEmpty(text)) {
return;
}
Control currentControl = getCurrentControl();
if (currentControl == null) {
return;
}
if (currentControl instanceof TextField) {
((TextField) currentControl).insertText(currentCaret, text);
currentCaret += text.length();
int temp = currentCaret;
currentControl.requestFocus();
((TextField) currentControl).positionCaret(temp);
}
}
}

@ -0,0 +1,751 @@
package cn.net.connor.process.meopviewfx.ui;
import java.util.ArrayList;
import java.util.List;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMLineType;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCPropertyDescriptor;
import com.teamcenter.rac.treetable.SwingTextContextActivator;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.Processknowledgebase.SJJHCommand;
import cn.net.connor.process.meopviewfx.bean.KTableRow;
import cn.net.connor.process.meopviewfx.bean.PropConfig;
import javafx.application.Platform;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.Control;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.scene.input.MouseEvent;
import javafx.util.Callback;
import k.ui.KFXEditableStringAreaTableCell;
import k.ui.KFXTextLocator;
import k.util.KChineseSpliter;
import k.util.KUtil;
public class TableLoader extends KFXTextLocator {
protected List<PropConfig> propConfigs = new ArrayList<PropConfig>();
private TableView<KTableRow> table;
protected TCComponentItemType itemType;
protected TCComponentItemRevisionType revType;
protected TCComponentType itemMasterType;
protected TCComponentType revMasterType;
// protected List<KTableRow> newRows = new ArrayList<KTableRow>();
protected List<KTableRow> removeRows = new ArrayList<KTableRow>();
protected PropConfig sequenceConfig1 = null;
protected int maxSeqNo1 = 0;
protected PropConfig sequenceConfig2 = null;
protected int maxSeqNo2 = 0;
protected String[] gdtPropNames;
private TableColumn<KTableRow, String> nameCol;
private TableColumn<KTableRow, String> mkhIdCol;
private TableColumn<KTableRow, String> mkhRevCol;
public static final String PREF_GDT_PROP = "GDT_properties";
public static Control currentControlSearch;
public static int currentCaretSearch=0;
public boolean load(TableView<KTableRow> table, String prefName) throws Exception {
this.table = table;
//+++
this.table.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
//双击
// if (event.getClickCount() == 2
// ||event.getClickCount() == 1) {
currentControlSearch=getCurrentControl();
currentCaretSearch=currentCaret;
System.out.println("+++++"+currentCaretSearch);
//}
}
});
this.table.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> paramObservableValue, Boolean oldValue, Boolean newValue) {
if (newValue) {
SwingTextContextActivator.instance().activateContext();
} else {
SwingTextContextActivator.instance().deactivateContext();
}
}
});
//+++
clearLocatorData();
Platform.runLater(() -> {
table.getColumns().clear();
table.getItems().clear();
});
propConfigs.clear();
sequenceConfig1 = null;
sequenceConfig2 = null;
if (KUtil.isEmpty(prefName)) {
return false;
}
System.out.println("Load table from pref: " + prefName);
String[] prefVals = KUtil.getPrefVals(KUtil.session, prefName);
int len = KUtil.getLen(prefVals);
if (len <= 1) {
return false;
}
String itemTypeName = prefVals[0];
System.out.println(">> Item Type: " + itemTypeName);
TCComponentBOMLineType boplineType = null;
itemType = null;
revType = null;
itemMasterType = null;
revMasterType = null;
boplineType = (TCComponentBOMLineType) KUtil.session.getTypeComponent("BOMLine");
if (boplineType == null) {
throw new Exception("Type not found: BOPLine");
}
if (!KTableRow.BOMLINE.equalsIgnoreCase(itemTypeName)) {
itemType = (TCComponentItemType) KUtil.session.getTypeComponent(itemTypeName);
if (itemType == null) {
throw new Exception(String.format(ProcessLocale.getString("typenotfound.ERROR1"), itemTypeName));
}
revType = itemType.getItemRevisionType();
itemMasterType = KUtil.session.getTypeComponent(itemTypeName + "Master");
if (itemMasterType == null) {
itemMasterType = KUtil.session.getTypeComponent(itemTypeName + " Master");
}
if (itemMasterType == null) {
throw new Exception(String.format(ProcessLocale.getString("typenotfound.ERROR1"), itemTypeName + "Master"));
}
revMasterType = KUtil.session.getTypeComponent(revType.getTypeName() + "Master");
if (revMasterType == null) {
revMasterType = KUtil.session.getTypeComponent(revType.getTypeName() + " Master");
}
if (revMasterType == null) {
throw new Exception(String.format(ProcessLocale.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master"));
}
}
for (int i = 1; i < len; i++) {
String propName = prefVals[i];
System.out.println("Load Config: " + propName);
if (KUtil.isEmpty(propName)) {
continue;
}
String propLoc = null;
String filterValue = null;
int width = 0;
int maxCharacter = 0;
if ('-' == propName.charAt(0)) {
width = -1;
propName = propName.substring(1);
} else {
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
width = width * 10 + (propName.charAt(0) - '0');
propName = propName.substring(1);
}
if (propName.startsWith("$")) {
propName = propName.substring(1);
while (!KUtil.isEmpty(propName) && Character.isDigit(propName.charAt(0))) {
maxCharacter = maxCharacter * 10 + (propName.charAt(0) - '0');
propName = propName.substring(1);
}
}
}
int ind = propName.indexOf('.');
if (ind > 0) {
propLoc = propName.substring(0, ind);
propName = propName.substring(ind + 1);
}
ind = propName.indexOf('=');
if (ind > 0) {
filterValue = propName.substring(ind + 1);
propName = propName.substring(0, ind);
}
// System.out.println(propName + "|" + filterValue);
TCComponentType type = null;
if (KUtil.isEmpty(propLoc)) {
type = boplineType;
propLoc = KTableRow.BOMLINE;
} else {
switch (propLoc.toUpperCase()) {
case KTableRow.BOMLINE:
type = boplineType;
break;
case KTableRow.ITEM:
type = itemType;
break;
case KTableRow.REV:
type = revType;
break;
case KTableRow.ITEMMASTER:
type = itemMasterType;
break;
case KTableRow.REVMASTER:
type = revMasterType;
break;
default:
System.out.println(">> Prop location error: " + propLoc);
break;
}
}
if (type != null) {
TCPropertyDescriptor propDesc = type.getPropDesc(propName);
if (propDesc == null) {
throw new Exception(String.format(ProcessLocale.getString("propnotdefinedintype.ERROR2"), propName, type.getDisplayTypeName()));
}
this.propConfigs.add(new PropConfig(propLoc, propDesc, filterValue, width, maxCharacter));
}
}
System.out.println("Load complete");
int size = this.propConfigs.size();
if (size == 0) {
return false;
}
this.gdtPropNames = KUtil.getPrefVals(KUtil.session, PREF_GDT_PROP);
for (int i = 0; i < size; i++) {
PropConfig config = propConfigs.get(i);
if ("bl_sequence_no".equals(config.propName)) {
this.sequenceConfig1 = config;
} else if (KTableRow.REVMASTER.equalsIgnoreCase(config.propLoc) && "ac5_WorkstepNumber".equals(config.propName)) { // TODO ac5_WorkstepNumber
this.sequenceConfig2 = config;
}
addTableCol(table, config);
}
// Platform.runLater(()->{
//
// KTableRow row = new KTableRow();
// for (PropConfig string : propConfigs) {
// row.stringProps.put(string, new
// SimpleStringProperty(string.lov!=null?"":string.propName));
// }
// table.getItems().add(row);
// });
return true;
}
public KTableRow getNewRow() {
KTableRow row = new KTableRow(null, null, null, null, null);
for (PropConfig propConfig : propConfigs) {
row.stringProps.put(propConfig, new SimpleStringProperty(""));
}
return row;
}
public void loadTCData(TCComponentBOMLine targetLine, boolean useLatestRev) throws Exception {
Platform.runLater(() -> {
table.getItems().clear();
});
if (targetLine == null) {
return;
}
int size = this.propConfigs.size();
if (size == 0) {
return;
}
removeRows.clear();
maxSeqNo1 = 0;
maxSeqNo2 = 0;
AIFComponentContext[] cc = targetLine.getChildren();
int len = KUtil.getLen(cc);
for (int i = 0; i < len; i++) {
TCComponentBOMLine bomine = (TCComponentBOMLine) cc[i].getComponent();
String seq = bomine.getStringProperty("bl_sequence_no");
if (!KUtil.isEmpty(seq)) {
try {
int seqNum = Integer.parseInt(seq);
seqNum = seqNum / 10;
if (seqNum > maxSeqNo1) {
maxSeqNo1 = seqNum;
}
} catch (Exception e) {
e.printStackTrace();
}
}
TCComponentItem item = bomine.getItem();
if (this.itemType != null && !this.itemType.getName().equals(item.getType())) {
continue;
}
TCComponentItemRevision rev = useLatestRev ? item.getLatestItemRevision() : bomine.getItemRevision();
TCComponent itemMaster = item.getRelatedComponent("IMAN_master_form");
TCComponent revMaster = rev.getRelatedComponent("IMAN_master_form_rev");
KTableRow row = new KTableRow(bomine, item, rev, itemMaster, revMaster);
boolean checkOK = true;
for (int j = 0; j < size; j++) {
PropConfig config = propConfigs.get(j);
if (!row.parseConfig(config)) {
checkOK = false;
break;
}
}
if (checkOK) {
if (this.sequenceConfig2 != null) {
String seq2 = row.getTCValue(this.sequenceConfig2.propLoc, this.sequenceConfig2.propName);
if (!KUtil.isEmpty(seq2)) {
try {
int seqNum = Integer.parseInt(seq2);
if (seqNum > maxSeqNo2) {
maxSeqNo2 = seqNum;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Platform.runLater(() -> {
table.getItems().add(row);
});
}
}
maxSeqNo1++;
maxSeqNo2++;
System.out.println("Max Sequence: " + maxSeqNo1 + " and " + maxSeqNo2);
}
public void saveTCData(TCComponentBOMLine parentLine) throws Exception {
while (removeRows.size() > 0) {
removeRows.get(0).removeLine(parentLine);
removeRows.remove(0);
}
KTableRow[] rows = table.getItems().toArray(new KTableRow[] {});
int len = KUtil.getLen(rows);
for (int i = 0; i < len; i++) {
KTableRow row = rows[i];
row.saveTCData(parentLine, itemType);
}
}
public void addRow() {
KTableRow row = getNewRow();
// if (sequenceConfig1 != null) {
// row.stringProps.get(sequenceConfig1).setValue("" + (maxSeqNo1 * 10));
// maxSeqNo1++;
// }
// if (sequenceConfig2 != null) {
// row.stringProps.get(sequenceConfig2).setValue("" + maxSeqNo2);
// maxSeqNo2++;
// }
table.getItems().add(row);
table.getSelectionModel().select(row);
table.scrollTo(row);
resetSequence();
}
public void removeRow() {
KTableRow row = table.getSelectionModel().getSelectedItem();
System.out.println("Remove: " + table.getSelectionModel().getSelectedIndex());
if (row == null) {
return;
}
table.getItems().remove(row);
removeRows.add(row);
resetSequence();
}
public void resetSequence() {
if (sequenceConfig1 == null && sequenceConfig2 == null) {
return;
}
int rowCnt = table.getItems().size();
for (int i = 0; i < rowCnt; i++) {
int seq = i + 1;
KTableRow row = table.getItems().get(i);
if (sequenceConfig1 != null) {
row.stringProps.get(sequenceConfig1).setValue("" + (seq * 10));
}
if (sequenceConfig2 != null) {
row.stringProps.get(sequenceConfig2).setValue("" + seq);
}
}
maxSeqNo1 = rowCnt + 1;
maxSeqNo2 = rowCnt + 1;
}
public void moveUp() {
int index = table.getSelectionModel().getSelectedIndex();
System.out.println("Move UP: " + index);
if (index <= 0) {
return;
}
KTableRow item = table.getItems().get(index);
KTableRow sideItem = table.getItems().get(index - 1);
if (sequenceConfig1 != null) {
String itemSeq = item.stringProps.get(sequenceConfig1).getValueSafe();
String sideItemSeq = sideItem.stringProps.get(sequenceConfig1).getValueSafe();
item.stringProps.get(sequenceConfig1).setValue(sideItemSeq);
sideItem.stringProps.get(sequenceConfig1).setValue(itemSeq);
}
if (sequenceConfig2 != null) {
String itemSeq = item.stringProps.get(sequenceConfig2).getValueSafe();
String sideItemSeq = sideItem.stringProps.get(sequenceConfig2).getValueSafe();
item.stringProps.get(sequenceConfig2).setValue(sideItemSeq);
sideItem.stringProps.get(sequenceConfig2).setValue(itemSeq);
}
table.getItems().remove(item);
table.getItems().add(index - 1, item);
table.getSelectionModel().clearAndSelect(index - 1);
}
public void moveDown() {
int index = table.getSelectionModel().getSelectedIndex();
System.out.println("Move Down: " + index);
if (index >= table.getItems().size() - 1) {
return;
}
KTableRow item = table.getItems().get(index);
KTableRow sideItem = table.getItems().get(index + 1);
if (sequenceConfig1 != null) {
String itemSeq = item.stringProps.get(sequenceConfig1).getValueSafe();
String sideItemSeq = sideItem.stringProps.get(sequenceConfig1).getValueSafe();
item.stringProps.get(sequenceConfig1).setValue(sideItemSeq);
sideItem.stringProps.get(sequenceConfig1).setValue(itemSeq);
}
if (sequenceConfig2 != null) {
String itemSeq = item.stringProps.get(sequenceConfig2).getValueSafe();
String sideItemSeq = sideItem.stringProps.get(sequenceConfig2).getValueSafe();
item.stringProps.get(sequenceConfig2).setValue(sideItemSeq);
sideItem.stringProps.get(sequenceConfig2).setValue(itemSeq);
}
table.getItems().remove(item);
table.getItems().add(index + 1, item);
table.getSelectionModel().clearAndSelect(index + 1);
}
public void search(TCComponentBOMLine target) {
//EventDispatcher ss =table.get;
//String string= table.getColumns().get(2).getTypeSelector;
// //System.out.println("------>"+ss.dispatchEvent(arg0, arg1));
// insertText("test");
//
//
//System.out.println("名称==>"+target.getItemRevision().getStringProperty("object_name"));
new Thread(new SJJHCommand(target,table,propConfigs)).start();
// //
// int index = table.getSelectionModel().getSelectedIndex();
// KTableRow item = table.getItems().get(index);
// for (int i = 0; i < this.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+"\n"+"test");
// //itemSeq="";
// break;
// }
// }
}
private void addTableCol(TableView<KTableRow> table, PropConfig config) throws Exception {
String header = config.propDisplayName;
TCComponentListOfValues lov = config.lov;
// gdt properties
if (!KUtil.isEmpty(config.propName) && KUtil.inArray(config.propName, gdtPropNames) >= 0) {
TableColumn<KTableRow, String> c = new TableColumn<KTableRow, String>(header);
c.setCellValueFactory(p -> p.getValue().stringProps.get(config));
c.setCellFactory(new Callback<TableColumn<KTableRow, String>, TableCell<KTableRow, String>>() {
@Override
public TableCell<KTableRow, String> call(TableColumn<KTableRow, String> param) {
return new KFXEditableStringAreaHtmlTableCell<KTableRow, String>(config);
}
});
if (config.width > 0) {
c.setPrefWidth(config.width);
} else if (config.width < 0) {
c.setMinWidth(0);
c.setMaxWidth(0);
c.setPrefWidth(0);
}
Platform.runLater(() -> {
c.setSortable(false);
c.setEditable(config.canEdit);
table.getColumns().add(c);
});
return;
}
if (lov == null) {
TableColumn<KTableRow, String> c = new TableColumn<KTableRow, String>(header);
if ("object_name".equals(config.propName) && "rev".equalsIgnoreCase(config.propLoc)) { // kk 20210324 閸婃帗鏆熺粭顑跨癌鐞涘苯鍟撻柆鎾跺閺堫剙鐫橀幀顪礲ject_name
this.nameCol = c;
}else if("ac5_MKHGYBH".equals(config.propName) && "revmaster".equalsIgnoreCase(config.propLoc)) { // kk 20211214 id閸滃瞼澧楅張顒<E5BCB5>寮介崘锟<E5B498>
this.mkhIdCol = c;
}else if("ac5_MKHGYBB".equals(config.propName) && "revmaster".equalsIgnoreCase(config.propLoc)) { // kk 20211214 id閸滃瞼澧楅張顒<E5BCB5>寮介崘锟<E5B498>
this.mkhRevCol = c;
}
c.setCellValueFactory(p -> p.getValue().stringProps.get(config));
c.setCellFactory(new Callback<TableColumn<KTableRow, String>, TableCell<KTableRow, String>>() {
@Override
public TableCell<KTableRow, String> call(TableColumn<KTableRow, String> param) {
KFXEditableStringAreaTableCell<KTableRow, String> cell = new KFXEditableStringAreaTableCell<KTableRow, String>(TableLoader.this) {
public void commitEdit(String item) {
if (config.maxCharacterInRow > 0 && item != null) {
String newValue = item.replace("\r", "");
String[] split = newValue.split("\n", -1);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < split.length; i++) {
String s = split[i];
if (i > 0) {
sb.append("\n");
}
List<String> csplit = KChineseSpliter.getDivideVals(s, config.maxCharacterInRow, "\n");
for (int j = 0; j < csplit.size(); j++) {
if (j > 0) {
sb.append("\r");
}
sb.append(csplit.get(j));
}
// while (s.length() > config.maxCharacterInRow) {
// sb.append(s.substring(0, config.maxCharacterInRow)).append("\r");
// s = s.substring(config.maxCharacterInRow);
// insertPos.add(sb.length() - 1);
// }
// sb.append(s);
}
item = sb.toString();
System.out.println("=====================\n" + newValue + "\n>>\n" + item + "\n\"=====================");
}
super.commitEdit(item);
};
};
//TODO
cell.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> paramObservableValue, Boolean oldValue, Boolean newValue) {
System.out.println("cell.focusedProperty().addListener.changed()");
if (newValue) {
SwingTextContextActivator.instance().activateContext();
} else {
SwingTextContextActivator.instance().deactivateContext();
}
}
});
System.out.println("cell.focusedProperty().addListener");
return cell;
}
});
if (config.width > 0) {
c.setPrefWidth(config.width);
} else if (config.width < 0) {
c.setMinWidth(0);
c.setMaxWidth(0);
c.setPrefWidth(0);
}
Platform.runLater(() -> {
c.setSortable(false);
c.setEditable(config.canEdit);
table.getColumns().add(c);
});
} else {
ObservableList<String> options = FXCollections.observableArrayList();
String[] disVals = lov.getListOfValues().getLOVDisplayValues();
options.add("");
for (String string : disVals) {
options.add(string);
}
TableColumn<KTableRow, String> c = new TableColumn<KTableRow, String>(header);
c.setCellValueFactory(p -> p.getValue().stringProps.get(config));
c.setCellFactory(new Callback<TableColumn<KTableRow, String>, TableCell<KTableRow, String>>() {
@Override
@SuppressWarnings("unchecked")
public TableCell<KTableRow, String> call(TableColumn<KTableRow, String> param) {
return new ComboBoxTableCell<KTableRow, String>(null, options) {
@Override
public void updateItem(String t, boolean bl) {
super.updateItem(t, bl);
if (KUtil.isEmpty(t)) {
return;
}
System.out.println("Update LOV Item: " + t);
TableRow<KTableRow> row = getTableRow();
if (row == null || row.getItem() == null) {
return;
}
KTableRow bean = row.getItem();
if (bean.stringProps.containsKey(config)) {
String val = bean.stringProps.get(config).getValueSafe();
if (!KUtil.isEmpty(val)) {
try {
val = KUtil.getLovDisplayableValue(lov, val);
System.out.println(">> display value: " + val);
super.updateItem(val, bl);
} catch (Exception e) {
e.printStackTrace();
// MessageBox.post(e);
}
}
}
}
@Override
public void commitEdit(String t) {
super.commitEdit(t);
System.out.println("Change LOV value: " + t);
try {
TableRow<KTableRow> row = getTableRow();
if (row == null || row.getItem() == null) {
return;
}
KTableRow bean = row.getItem();
if (bean.stringProps.containsKey(config)) {
String realVal = KUtil.getLovValue(lov, t);
System.out.println(">> real value: " + realVal);
bean.stringProps.get(config).setValue(realVal);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
}
});
if (config.width > 0) {
c.setPrefWidth(config.width);
}
Platform.runLater(() -> {
c.setEditable(config.canEdit);
c.setSortable(false);
table.getColumns().add(c);
});
}
}
@SuppressWarnings("unchecked")
@Override
public void insertText(String text) {
if (KUtil.isEmpty(text)) {
return;
}
Control currentControl = getCurrentControl();
if (currentControl == null) {
return;
}
if (currentControl instanceof KFXEditableStringAreaTableCell) {
KFXEditableStringAreaTableCell<KTableRow, String> cell = (KFXEditableStringAreaTableCell<KTableRow, String>) 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();
}
}
@SuppressWarnings("unchecked")
public void insertText(String text, String parentText, String mhkId, String mhkRev) {
if (KUtil.isEmpty(text)) {
return;
}
Control currentControl = getCurrentControl();
if (currentControl == null) {
return;
}
if (currentControl instanceof KFXEditableStringAreaTableCell) {
KFXEditableStringAreaTableCell<KTableRow, String> cell = (KFXEditableStringAreaTableCell<KTableRow, String>) currentControl;
try {
System.out.println("Name: " + parentText);
if (parentText != null && this.nameCol != null && cell.getTableColumn() != this.nameCol) {
SimpleStringProperty value = (SimpleStringProperty) this.nameCol.getCellObservableValue((KTableRow) (cell.getTableRow().getItem()));
System.out.println(value);
value.setValue(parentText);
}
} catch (Exception e1) {
e1.printStackTrace();
}
try {
System.out.println("MKH Id: " + mhkId);
if (mhkId != null && this.mkhIdCol != null && cell.getTableColumn() != this.mkhIdCol) {
SimpleStringProperty value = (SimpleStringProperty) this.mkhIdCol.getCellObservableValue((KTableRow) (cell.getTableRow().getItem()));
System.out.println(value);
value.setValue(mhkId);
}
} catch (Exception e1) {
e1.printStackTrace();
}
try {
System.out.println("MKH Rev: " + mhkRev);
if (mhkRev != null && this.mkhRevCol != null && cell.getTableColumn() != this.mkhRevCol) {
SimpleStringProperty value = (SimpleStringProperty) this.mkhRevCol.getCellObservableValue((KTableRow) (cell.getTableRow().getItem()));
System.out.println(value);
value.setValue(mhkRev);
}
} catch (Exception e1) {
e1.printStackTrace();
}
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();
}
}
}

@ -0,0 +1,269 @@
package cn.net.connor.process.meopviewfx.ui;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCell;
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.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentFolder;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.meopviewfx.bean.TextBean;
import k.util.KSql;
import k.util.KSqlUtil;
import k.util.KUtil;
public class TextTreeLoader {
private static final String PREF_COMMON_FOLDER = "Connor_AVIC_GXBZ_Common_Folder";
private static final String PREF_PERSONAL_FOLDER = "Connor_AVIC_GXBZ_Personal_Folder";
private static final String FLAG_REALVALUE = "#RV#";
private static final String PREFFLAG_REALVALUE = "#RealValue#";
public static class FileBean {
File file;
int realValueCol;
public FileBean(File file, int realValueCol) {
this.file = file;
this.realValueCol = realValueCol;
}
}
public Map<String, TextBean> loadText() throws Exception {
Map<String, TextBean> textMap = new LinkedHashMap<String, TextBean>();
String key = ProcessLocale.getString("mkhgy");
//String sql = "select pac5_JG1, pac5_JG2, pac5_JG3, pac5_JG4, pac5_JG5, pac5_JG6 from pAc5_MKHGYRevMasters";
String sql = "select pac5_JG1, pac5_JG2, pac5_JG3, pac5_JG4, pac5_JG5, pac5_JG6, t4.pitem_id, t3.pitem_revision_id from pAc5_MKHGYRevMasters t0\r\n" +
"left join pform t1 on t0.puid = t1.rdata_fileu\r\n" +
"left join (select * from pimanrelation where rrelation_typeu = (select puid from pimantype where ptype_name = 'IMAN_master_form')) t2 on t2.rsecondary_objectu = t1.puid\r\n" +
"left join pitemrevision t3 on t3.puid = t2.rprimary_objectu\r\n" +
"left join pitem t4 on t4.puid = t3.ritems_tagu";
sql+="\r\nleft join (\r\n" +
" select r1.puid from pAc5_MKHGYRevision r1\r\n" +
" left join pitemrevision r2 on r2.puid = r1.puid\r\n" +
" where \r\n" +
" (select pdate_released from pworkspaceobject where puid = r2.puid) is not null\r\n" +
" and (select pdate_released from pworkspaceobject where puid = r2.puid) = "
+ "( select max(dr) from (select (select pdate_released from pworkspaceobject where puid = pitemrevision.puid) dr from pitemrevision where ritems_tagu = r2.ritems_tagu) )\r\n" +
" and r2.psequence_id = (select max(psequence_id) from pitemrevision where ritems_tagu = r2.ritems_tagu and pitem_revision_id = r2.pitem_revision_id)\r\n" +
") t5 on t5.puid = t3.puid\r\n" +
"where (t0.pac5_Effictiveness is null or t0.pac5_Effictiveness!='" + ProcessLocale.getString("shixiao") + "') and t5.puid is not null";//失效
System.out.println("sql:" + sql);
Connection conn = KSqlUtil.getOracleConnection(KSql.PREF_DB_CONN);
List<String[]> data = null;
int colCnt = 8;
TextBean root = new TextBean(key);
textMap.put(key, root);
try {
data = KSqlUtil.queryStringArray(conn, sql, null, colCnt);
} finally {
KSqlUtil.free(conn);
}
int cnt = data == null?0:data.size();
for(int i=0; i<cnt ;i++) {
String[] rowData = data.get(i);
TextBean parent = root;
String itemId = rowData[colCnt-2];
String revId = rowData[colCnt-1];
for(int c=0; c<colCnt-2; c++) {
String text = rowData[c];
if(KUtil.isEmpty(text)) {
break;
}
TextBean child = new TextBean(text, itemId, revId);
int ind = parent.children.indexOf(child);
if(ind>=0) {
parent = parent.children.get(ind);
}else {
parent.children.add(child);
parent = child;
}
}
}
return textMap;
}
public Map<String, TextBean> loadTextFromExcels() throws Exception {
Map<String, TextBean> textMap = new LinkedHashMap<String, TextBean>();
List<FileBean> docFiles = getConfigFile();
int size = docFiles.size();
if (size == 0) {
System.out.println("Special Text File not found");
return textMap;
}
for (int i = 0; i < size; i++) {
FileBean docFile = docFiles.get(i);
System.out.println("Load File: " + docFile.file.getAbsolutePath());
InputStream in = new FileInputStream(docFile.file);
XSSFWorkbook wb = new XSSFWorkbook(in);
in.close();
int sheetCnt = wb.getNumberOfSheets();
for (int j = 0; j < sheetCnt; j++) {
XSSFSheet sheet = wb.getSheetAt(0);
String sheetName = sheet.getSheetName();
System.out.println(">> Load Sheet: " + sheetName);
if (textMap.containsKey(sheetName)) {
System.out.println("SKIP");
continue;
}
TextBean bean = readSheet(sheet, docFile.realValueCol);
if (bean != null && bean.children.size() > 0) {
textMap.put(sheetName, bean);
} else {
System.out.println("No Data");
}
}
}
return textMap;
}
private TextBean readSheet(XSSFSheet sheet, int realValueCol) throws Exception {
TextBean root = new TextBean(sheet.getSheetName());
int firstRow = sheet.getFirstRowNum();
int lastRow = sheet.getLastRowNum();
Map<Integer, TextBean> parents = new HashMap<Integer, TextBean>();
parents.put(0, root);
for (int i = firstRow; i <= lastRow; i++) {
XSSFRow row = sheet.getRow(i);
if (row == null) {
continue;
}
int firstCol = row.getFirstCellNum();
if (firstCol < 0) {
firstCol = 0;
}
int lastCol = row.getLastCellNum();
for (int j = firstCol; j <= lastCol; j++) {
XSSFCell cell = row.getCell(j);
if (cell == null || cell.getCellType() != XSSFCell.CELL_TYPE_STRING) {
continue;
}
if (!parents.containsKey(j)) {
continue;
}
String text = cell.getStringCellValue();
if (KUtil.isEmpty(text)) {
continue;
}
if (j == realValueCol) {
parents.get(j).setRealValue(text);
continue;
}
if (text.startsWith(FLAG_REALVALUE)) {
parents.get(j).setRealValue(text.substring(FLAG_REALVALUE.length()));
continue;
}
TextBean bean = new TextBean(text);
// for(int k=j+1;k<=lastCol;k++) {
// XSSFCell realValueCell = row.getCell(k);
// if(realValueCell!=null&&realValueCell.getCellType()==XSSFCell.CELL_TYPE_STRING)
// {
// String realValue = realValueCell.getStringCellValue();
// if(!KUtil.isEmpty(realValue)) {
// bean.setRealValue(realValue);
// break;
// }
// }
// }
parents.get(j).children.add(bean);
parents.put(j + 1, bean);
// break;
}
}
return root;
}
protected List<FileBean> getConfigFile() {
List<FileBean> files = new ArrayList<>();
try {
addFileFromPref(files, PREF_COMMON_FOLDER, "");
} catch (Exception e) {
System.out.println("Load Text Tree From <" + PREF_COMMON_FOLDER + "> Error");
e.printStackTrace();
}
try {
addFileFromPref(files, PREF_PERSONAL_FOLDER, KUtil.session.getUser().getUserId());
} catch (Exception e) {
System.out.println("Load Text Tree From <" + PREF_PERSONAL_FOLDER + "> Error");
e.printStackTrace();
}
return files;
}
private void addFileFromPref(List<FileBean> files, String prefName, String subFolder) throws Exception {
String uid = KUtil.getPrefVal(KUtil.session, prefName);
if (KUtil.isEmpty(uid)) {
return;
}
int realValueColumn = -1;
int ind = uid.indexOf(PREFFLAG_REALVALUE);
if (ind > 0) {
String numStr = uid.substring(ind + PREFFLAG_REALVALUE.length());
uid = uid.substring(0, ind);
try {
realValueColumn = Integer.parseInt(numStr);
} catch (Exception e) {
e.printStackTrace();
}
}
TCComponent comp = KUtil.session.stringToComponent(uid);
if (comp == null) {
return;
}
if (comp instanceof TCComponentFolder) {
TCComponentFolder folder = (TCComponentFolder) comp;
AIFComponentContext[] children = folder.getChildren();
if (!KUtil.isEmpty(subFolder)) {
for (AIFComponentContext c : children) {
InterfaceAIFComponent child = c.getComponent();
if (child instanceof TCComponentFolder) {
if (subFolder.equals(((TCComponentFolder) child).getStringProperty("object_name"))) {
children = child.getChildren();
break;
}
}
}
}
for (AIFComponentContext c : children) {
InterfaceAIFComponent child = c.getComponent();
if ("MSExcelX".equals(child.getType())) {
File[] dbFiles = ((TCComponentDataset) child).getFiles("");
if (dbFiles != null) {
for (int i = 0; i < dbFiles.length; i++) {
files.add(new FileBean(dbFiles[i], realValueColumn));
}
}
}
}
} else if (comp instanceof TCComponentDataset) {
TCComponentDataset dataset = (TCComponentDataset) comp;
if ("MSExcelX".equals(dataset.getType())) {
File[] dbFiles = dataset.getFiles("");
if (dbFiles != null) {
for (int i = 0; i < dbFiles.length; i++) {
files.add(new FileBean(dbFiles[i], realValueColumn));
}
}
}
}
}
}

@ -0,0 +1,27 @@
.root {
-fx-font-family: "Microsoft YaHei";
}
.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;
}
.tab-pane .tab-header-area {
-fx-padding: 5 2 0 0;
}
* :disabled {
-fx-opacity: 0.85;
}

@ -0,0 +1,174 @@
package cn.net.connor.process.modifymeopno;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
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.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
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 ModifyMeopNoDialog extends KDialog {
protected JButton b_ok;
protected DefaultTableModel tableModel;
protected JTable table;
private ModifyMeopNoDialogController controller;
protected JButton b_delete;
protected JButton b_moveup;
protected JButton b_movedown;
public ModifyMeopNoDialog(KDialogController controller) {
super(controller);
this.controller = (ModifyMeopNoDialogController) controller;
}
@Override
protected void addListeners() {
this.b_delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
controller.delete();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(ModifyMeopNoDialog.this, e1);
}
}
});
this.b_moveup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
controller.moveup();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(ModifyMeopNoDialog.this, e1);
}
}
});
this.b_movedown.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
controller.movedown();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(ModifyMeopNoDialog.this, e1);
}
}
});
this.b_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
});
}
@Override
protected void initUI() {
this.setTitle(ProcessLocale.getString("modifymeopno.TITLE"));
this.setPreferredSize(new Dimension(800, 600));
this.setLayout(new BorderLayout());
this.add(BorderLayout.CENTER, initTablePanel());
this.add(BorderLayout.EAST, initBtnPanel());
try {
controller.readMeop();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(this, e);
}
controller.checkRelease();
}
private Component initBtnPanel() {
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createEmptyBorder(16, 0, 7, 7));
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(0, 0, 12, 0));
KUtil.newRow(panel, this.b_delete = new JButton(ProcessLocale.getString("delete")), s, 1);
KUtil.newRow(panel, this.b_moveup = new JButton(ProcessLocale.getString("moveup")), s, 1);
KUtil.newRow(panel, this.b_movedown = new JButton(ProcessLocale.getString("movedown")), s, 1);
KUtil.newRow(panel, this.b_ok = new JButton(ProcessLocale.getString("ok")), s, 1);
s.weighty = 1;
KUtil.newRow(panel, new JLabel(), s, 1);
return panel;
}
private Component initTablePanel() {
this.tableModel = new DefaultTableModel();
this.table = new JTable(tableModel) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
table.setRowHeight(23);
tableModel.setDataVector(null, controller.tableHeaders);
table.getTableHeader().setReorderingAllowed(false);
table.setDefaultRenderer(Object.class, new ColorTableRenderer());
int colCnt = KUtil.getLen(controller.tableHeaders);
TableColumnModel colModel = this.table.getColumnModel();
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(controller.tableHeaderWidth[i]);
}
colModel.getColumn(0).setMinWidth(0);
colModel.getColumn(0).setMaxWidth(0);
if (colCnt > 5) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
}
JScrollPane scroll = new JScrollPane(table);
scroll.setBorder(null);
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
return panel;
}
public static class ColorTableRenderer extends DefaultTableCellRenderer {
public static final Color DEFBLUE = new Color(51, 153, 255);
public static final Color RED = new Color(255, 59, 48);
public static final Color GREEN = new Color(158, 234, 106);
@Override
public Component getTableCellRendererComponent(JTable t, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (hasFocus) {
setBackground(DEFBLUE);
} else {
Object obj = t.getValueAt(row, 0);
if(obj instanceof ModifyMeopNoRow) {
if(((ModifyMeopNoRow) obj).isReleased()) {
setBackground(RED);
}else {
setBackground(GREEN);
}
}else {
setBackground(Color.WHITE);
}
}
return super.getTableCellRendererComponent(t, value, isSelected, hasFocus, row, column);
}
}
}

@ -0,0 +1,262 @@
package cn.net.connor.process.modifymeopno;
import java.util.Arrays;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.ProcessUtil;
import cn.net.connor.process.newmeop.NewMeopDialogController;
import k.KDialogController;
import k.util.KUtil;
public class ModifyMeopNoDialogController extends KDialogController {
public static final String PREF_MEOP_TYPE = "Connor_AVIC_SQGXH_GXLX";
public static final String PREF_MEOP_TABLE = "Connor_AVIC_SQGXH_SXBJ";
private String[] meopTypes;
protected String[] tableHeaders;
protected int[] tableHeaderWidth;
private String[] tableProps;
private ModifyMeopNoDialog dialog;
private TCComponentBOMLine procLine;
private TCComponentItemRevision targetRev;
public ModifyMeopNoDialogController(AbstractAIFApplication app) {
super(app);
}
@Override
public boolean init() throws Exception {
this.dialog = (ModifyMeopNoDialog) aifDialog;
InterfaceAIFComponent comp = app.getTargetComponent();
System.out.println("Select: " + comp);
if (comp != null) {
if (comp instanceof TCComponentBOMLine) {
this.procLine = (TCComponentBOMLine) comp;
TCComponentItemRevision rev = this.procLine.getItemRevision();
System.out.println(">> " + rev.getType());
if (ProcessUtil.isMEProcess(rev.getItem().getType())) {
// if (rev instanceof TCComponentMEProcessRevision) {
this.targetRev = rev;
}
}
}
if (targetRev == null) {
KUtil.warn(dialog, ProcessLocale.getString("selectprocessrev.ERROR"));
return false;
}
this.meopTypes = KUtil.getPrefVals(session, PREF_MEOP_TYPE);
String[] tableConfigs = KUtil.getPrefVals(session, PREF_MEOP_TABLE);
if (KUtil.getLen(meopTypes) == 0) {
KUtil.warn(dialog, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TYPE));
return false;
}
if (KUtil.getLen(tableConfigs) == 0) {
KUtil.warn(dialog, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TABLE));
return false;
}
int colCnt = KUtil.getLen(tableConfigs);
tableHeaders = new String[colCnt + 1];
tableHeaderWidth = new int[colCnt + 1];
tableHeaders[0] = "Hidden";
tableHeaderWidth[0] = 0;
tableProps = new String[colCnt];
for (int i = 0; i < colCnt; i++) {
int colIndex = i + 1;
String config = tableConfigs[i];
int ind = config.lastIndexOf('=');
if (ind > 0) {
tableHeaders[colIndex] = config.substring(0, ind);
tableProps[i] = config.substring(ind + 1);
} else {
tableHeaders[colIndex] = config;
tableProps[i] = config;
}
int width = 0;
while (tableHeaders[colIndex].length() > 0 && Character.isDigit(tableHeaders[colIndex].charAt(0))) {
width = width * 10 + (tableHeaders[colIndex].charAt(0) - '0');
tableHeaders[colIndex] = tableHeaders[colIndex].substring(1);
}
if (width < 1) {
width = 120;
}
tableHeaderWidth[colIndex] = width;
}
return true;
}
protected void readMeop() throws Exception {
System.out.println("Load Meop: " + this.procLine + " | " + Arrays.toString(meopTypes));
if (this.procLine == null) {
return;
}
KUtil.setByPass(true);
try {
this.procLine.refresh();
AIFComponentContext[] cc = this.procLine.getChildren();
int len = KUtil.getLen(cc);
for (int i = 0; i < len; i++) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cc[i].getComponent();
String cType = cLine.getItem().getType();
System.out.println((i + 1) + ". " + cLine + " -> " + cType);
if (KUtil.inArray(cType, meopTypes) >= 0) {
dialog.tableModel.addRow(new ModifyMeopNoRow(cLine).getRowData(tableProps));
}
}
} finally {
KUtil.setByPass(false);
}
}
protected void delete() throws Exception {
int selectedRow = dialog.table.getSelectedRow();
System.out.println("Delete: " + selectedRow);
if (selectedRow < 0) {
return;
}
ModifyMeopNoRow bean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow, 0);
TCComponentBOMLine bomline = bean.getBomline();
System.out.println("Remove Line: " + bomline);
KUtil.setByPass(true);
try {
int currentSeq = NewMeopDialogController.getMeopNo(bomline);
System.out.println("Current Seq: " + currentSeq);
bomline.cut();
dialog.tableModel.removeRow(selectedRow);
if (checkSeq(currentSeq)) {
int rowCnt = dialog.table.getRowCount();
for (int i = selectedRow; i < rowCnt; i++) {
bean = (ModifyMeopNoRow) dialog.table.getValueAt(i, 0);
bomline = bean.getBomline();
bomline.refresh();
int seq = NewMeopDialogController.getMeopNo(bomline);
// int seq = Integer.parseInt(bomline.getStringProperty("bl_sequence_no"));
System.out.println("Change Sequence: " + bomline + " " + seq + " -> " + (seq - 5));
seq -= 5;
NewMeopDialogController.setMeopNo(bomline, seq);
// bomline.setProperty("bl_sequence_no", "" + seq);
bomline.refresh();
dialog.tableModel.removeRow(i);
dialog.tableModel.insertRow(i, bean.getRowData(tableProps));
}
} else {
System.out.println("Skip Change");
}
procLine.refresh();
} finally {
KUtil.setByPass(false);
}
checkRelease();
}
protected boolean checkSeq(int seq) {
return seq > 0 && seq % 5 == 0;
}
protected void checkRelease() {
int rowCnt = dialog.table.getRowCount();
boolean hasRelease = false;
for (int i = 0; i < rowCnt; i++) {
if (!((ModifyMeopNoRow) dialog.table.getValueAt(i, 0)).isReleased()) {
hasRelease = true;
break;
}
}
//lidy20241016当界面上存在能修改的工序时即使部分工序为红色发布没有写权限不能编辑也能使用此功能
dialog.b_moveup.setEnabled(hasRelease);
dialog.b_movedown.setEnabled(hasRelease);
}
protected void moveup() throws Exception {
int selectedRow = dialog.table.getSelectedRow();
System.out.println("Move Up: " + selectedRow);
if (selectedRow <= 0) {
return;
}
ModifyMeopNoRow bean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow, 0);
ModifyMeopNoRow otherbean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow - 1, 0);
//lidy20241016如果”上移“或”下移“后的条目是红色程序不允许本次调整并提示
if(bean.isReleased() || otherbean.isReleased()) {
throw new Exception(ProcessLocale.getString("ModifyMeopNo.check"));
}
KUtil.setByPass(true);
try {
TCComponentBOMLine bomline = bean.getBomline();
System.out.println("Select Line: " + bomline);
TCComponentBOMLine otherBomline = otherbean.getBomline();
System.out.println("Other Line: " + otherBomline);
int blseq = Integer.parseInt(bomline.getStringProperty("bl_sequence_no"));
int otherblSeq = Integer.parseInt(otherBomline.getStringProperty("bl_sequence_no"));
bomline.setProperty("bl_sequence_no", otherblSeq + "");
otherBomline.setProperty("bl_sequence_no", blseq + "");
int seq = NewMeopDialogController.getMeopNo(bomline);
int otherSeq = NewMeopDialogController.getMeopNo(otherBomline);
if (checkSeq(seq) && checkSeq(otherSeq)) {
NewMeopDialogController.setMeopNo(bomline, otherSeq);
NewMeopDialogController.setMeopNo(otherBomline, seq);
}else {
System.out.println("Skip Change");
}
bomline.refresh();
otherBomline.refresh();
procLine.refresh();
dialog.tableModel.removeRow(selectedRow);
dialog.tableModel.removeRow(selectedRow - 1);
dialog.tableModel.insertRow(selectedRow - 1, otherbean.getRowData(tableProps));
dialog.tableModel.insertRow(selectedRow - 1, bean.getRowData(tableProps));
dialog.table.getSelectionModel().setSelectionInterval(selectedRow - 1, selectedRow - 1);
} finally {
KUtil.setByPass(false);
}
}
protected void movedown() throws Exception {
int selectedRow = dialog.table.getSelectedRow();
System.out.println("Move Down: " + selectedRow);
int rowCnt = dialog.table.getRowCount();
if (selectedRow < 0 || selectedRow == rowCnt - 1) {
return;
}
ModifyMeopNoRow bean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow, 0);
ModifyMeopNoRow otherbean = (ModifyMeopNoRow) dialog.table.getValueAt(selectedRow + 1, 0);
//lidy20241016如果”上移“或”下移“后的条目是红色程序不允许本次调整并提示
if(bean.isReleased() || otherbean.isReleased()) {
throw new Exception(ProcessLocale.getString("ModifyMeopNo.check"));
}
KUtil.setByPass(true);
try {
TCComponentBOMLine bomline = bean.getBomline();
System.out.println("Select Line: " + bomline);
TCComponentBOMLine otherBomline = otherbean.getBomline();
System.out.println("Other Line: " + otherBomline);
int blseq = Integer.parseInt(bomline.getStringProperty("bl_sequence_no"));
int otherblSeq = Integer.parseInt(otherBomline.getStringProperty("bl_sequence_no"));
bomline.setProperty("bl_sequence_no", otherblSeq + "");
otherBomline.setProperty("bl_sequence_no", blseq + "");
int seq = NewMeopDialogController.getMeopNo(bomline);
int otherSeq = NewMeopDialogController.getMeopNo(otherBomline);
if (checkSeq(seq) && checkSeq(otherSeq)) {
NewMeopDialogController.setMeopNo(bomline, otherSeq);
NewMeopDialogController.setMeopNo(otherBomline, seq);
}else {
System.out.println("Skip Change");
}
bomline.refresh();
otherBomline.refresh();
procLine.refresh();
dialog.tableModel.removeRow(selectedRow + 1);
dialog.tableModel.removeRow(selectedRow);
dialog.tableModel.insertRow(selectedRow, bean.getRowData(tableProps));
dialog.tableModel.insertRow(selectedRow, otherbean.getRowData(tableProps));
dialog.table.getSelectionModel().setSelectionInterval(selectedRow + 1, selectedRow + 1);
} finally {
KUtil.setByPass(false);
}
}
}

@ -0,0 +1,63 @@
package cn.net.connor.process.modifymeopno;
import java.util.HashMap;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import k.util.KUtil;
import k.util.PropLocation;
public class ModifyMeopNoRow {
private TCComponentBOMLine bomline;
private boolean isReleased;
private HashMap<String, TCComponent> markedComponents;
public ModifyMeopNoRow(TCComponentBOMLine cLine) throws Exception {
this.bomline = cLine;
this.bomline.refresh();
TCComponentItemRevision rev = cLine.getItemRevision();
if(rev==null) {
throw new Exception("revision not found: "+cLine);
}
rev.refresh();
markedComponents = new HashMap<String, TCComponent>();
PropLocation.initLocationMap(markedComponents , getBomline());
this.isReleased=KUtil.isReleased(rev);
}
public boolean isReleased() {
return this.isReleased;
}
public Object[] getRowData(String[] tableProps) throws Exception{
int len = KUtil.getLen(tableProps);
Object[] data = new Object[len+1];
data[0] = this;
for(int i=0; i<len; i++) {
String[] config = tableProps[i].split("\\.");
if(KUtil.getLen(config)!=2) {
data[i+1] = tableProps[i];
continue;
}
String propLoc = config[0].toUpperCase();
if(markedComponents.containsKey(propLoc)) {
data[i+1] = markedComponents.get(propLoc).getProperty(config[1]);
}else {
data[i+1] = tableProps[i];
}
}
return data;
}
@Override
public String toString() {
return getBomline().toString();
}
public TCComponentBOMLine getBomline() {
return bomline;
}
}

@ -0,0 +1,139 @@
package cn.net.connor.process.newmeop;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Map;
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.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
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 MeopNoDialog extends KDialog {
private JButton b_insert;
private JButton b_ok;
protected DefaultTableModel tableModel;
protected JTable table;
private MeopNoDialogController controller;
private boolean ok = false;
public MeopNoDialog(AbstractAIFDialog parent, boolean model, KDialogController controller) {
super(parent, model, controller);
this.controller = (MeopNoDialogController) controller;
}
@Override
protected void addListeners() {
this.b_insert.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
controller.insert();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(MeopNoDialog.this, e1);
}
}
});
this.b_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean meopno = false;
try {
//lidy20240926判断插入的工序号与当前工艺下已存在的工序的工序号是否相同
ArrayList<Integer> list = new ArrayList<>();
for(int i = 0; i < table.getRowCount(); i++) {
int no = Integer.parseInt("" + table.getValueAt(i, 0));
if(list.contains(no)) {
meopno = true;
throw new Exception(no + ProcessLocale.getString("meopno"));
}
list.add(no);
}
ok = true;
disposeDialog();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(MeopNoDialog.this, ProcessLocale.getString("error") +
(meopno ? e1.getMessage() : e1), "ERROR", MessageBox.ERROR);
}
}
});
}
public Map<String, String> getMeopInfo() throws Exception {
if (!initDialog()) {
return null;
}
controller.readMeop();
showDialog();
if (!ok) {
return null;
}
return controller.getInsertedData();
}
@Override
protected void initUI() {
this.setTitle(ProcessLocale.getString("applymeopno.TITLE"));
this.setPreferredSize(new Dimension(800, 600));
this.setLayout(new BorderLayout());
this.add(BorderLayout.CENTER, initTablePanel());
this.add(BorderLayout.EAST, initBtnPanel());
}
private Component initBtnPanel() {
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createEmptyBorder(16, 0, 7, 7));
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(0, 0, 12, 0));
KUtil.newRow(panel, this.b_insert = new JButton(ProcessLocale.getString("insert")), s, 1);
KUtil.newRow(panel, this.b_ok = new JButton(ProcessLocale.getString("ok")), s, 1);
s.weighty = 1;
KUtil.newRow(panel, new JLabel(), s, 1);
return panel;
}
private Component initTablePanel() {
this.tableModel = new DefaultTableModel();
this.table = new JTable(tableModel);
table.setRowHeight(23);
tableModel.setDataVector(null, controller.tableHeaders);
table.getTableHeader().setReorderingAllowed(false);
int colCnt = KUtil.getLen(controller.tableHeaders);
TableColumnModel colModel = this.table.getColumnModel();
for (int i = 0; i < colCnt; i++) {
colModel.getColumn(i).setPreferredWidth(controller.tableHeaderWidth[i]);
}
if (colCnt > 5) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
}
JScrollPane scroll = new JScrollPane(table);
scroll.setBorder(null);
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER, scroll);
panel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
return panel;
}
}

@ -0,0 +1,120 @@
package cn.net.connor.process.newmeop;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import cn.net.connor.process.ProcessLocale;
import k.KDialogController;
import k.util.KUtil;
public class MeopNoDialogController extends KDialogController {
public static final String PREF_MEOP_TYPE = "Connor_AVIC_SQGXH_GXLX";
public static final String PREF_MEOP_TABLE = "Connor_AVIC_SQGXH_SXBJ";
private String[] meopTypes;
protected String[] tableHeaders;
protected int[] tableHeaderWidth;
private String[] tableProps;
private MeopNoDialog dialog;
private TCComponentBOMLine procLine;
private int newRowNum = -1;
public MeopNoDialogController(AbstractAIFApplication app, TCComponentBOMLine procLine) {
super(app);
this.procLine = procLine;
}
@Override
public boolean init() throws Exception {
this.dialog = (MeopNoDialog) aifDialog;
this.meopTypes = KUtil.getPrefVals(session, PREF_MEOP_TYPE);
String[] tableConfigs = KUtil.getPrefVals(session, PREF_MEOP_TABLE);
if (KUtil.getLen(meopTypes) == 0) {
KUtil.warn(dialog, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TYPE));
return false;
}
if (KUtil.getLen(tableConfigs) == 0) {
KUtil.warn(dialog, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_MEOP_TABLE));
return false;
}
int colCnt = KUtil.getLen(tableConfigs);
tableHeaders = new String[colCnt];
tableHeaderWidth = new int[colCnt];
tableProps = new String[colCnt];
for (int i = 0; i < colCnt; i++) {
String config = tableConfigs[i];
int ind = config.lastIndexOf('=');
if (ind > 0) {
tableHeaders[i] = config.substring(0, ind);
tableProps[i] = config.substring(ind + 1);
} else {
tableHeaders[i] = config;
tableProps[i] = config;
}
int width = 0;
while (tableHeaders[i].length() > 0 && Character.isDigit(tableHeaders[i].charAt(0))) {
width = width * 10 + (tableHeaders[i].charAt(0) - '0');
tableHeaders[i] = tableHeaders[i].substring(1);
}
if (width < 1) {
width = 120;
}
tableHeaderWidth[i] = width;
}
return true;
}
protected void readMeop() throws Exception {
System.out.println("Load Meop: " + this.procLine+" | "+Arrays.toString(meopTypes));
if (this.procLine == null) {
return;
}
this.procLine.refresh();
AIFComponentContext[] cc = this.procLine.getChildren();
int len = KUtil.getLen(cc);
for (int i = 0; i < len; i++) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cc[i].getComponent();
String cType = cLine.getItem().getType();
System.out.println((i+1)+". "+cLine+" -> "+cType);
if(KUtil.inArray(cType, meopTypes)>=0) {
dialog.tableModel.addRow(new MeopNoRow(cLine).getRowData(tableProps));
}
}
}
public void insert() throws Exception {
int selectedRow = dialog.table.getSelectedRow();
System.out.println("Insert to: "+selectedRow);
if(selectedRow<0) {
newRowNum = dialog.table.getRowCount();
dialog.tableModel.addRow(new Object[] {});
}else {
newRowNum = selectedRow;
dialog.tableModel.insertRow(newRowNum, new Object[] {});
}
System.out.println("New RowNum: "+this.newRowNum);
}
public Map<String, String> getInsertedData(){
System.out.println("New RowNum: "+this.newRowNum);
if(this.newRowNum<0) {
return null;
}
Map<String, String> res = new HashMap<String, String>();
int colCnt = KUtil.getLen(tableProps);
for(int i=0; i<colCnt; i++) {
String value = (String) dialog.table.getValueAt(this.newRowNum, i);
if(value==null) {
value = "";
}
res.put(tableProps[i], value);
}
return res;
}
}

@ -0,0 +1,41 @@
package cn.net.connor.process.newmeop;
import java.util.HashMap;
import java.util.Map;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import k.util.KUtil;
import k.util.PropLocation;
public class MeopNoRow {
private TCComponentBOMLine bomline;
public MeopNoRow(TCComponentBOMLine cLine) {
this.bomline = cLine;
}
public Object[] getRowData(String[] tableProps) throws Exception{
int len = KUtil.getLen(tableProps);
Object[] data = new Object[len];
Map<String, TCComponent> markedComponents = new HashMap<String, TCComponent>();
PropLocation.initLocationMap(markedComponents , bomline);
for(int i=0; i<len; i++) {
String[] config = tableProps[i].split("\\.");
if(KUtil.getLen(config)!=2) {
data[i] = tableProps[i];
continue;
}
String propLoc = config[0].toUpperCase();
if(markedComponents.containsKey(propLoc)) {
data[i] = markedComponents.get(propLoc).getProperty(config[1]);
}else {
data[i] = tableProps[i];
}
}
return data;
}
}

@ -0,0 +1,289 @@
package cn.net.connor.process.newmeop;
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 java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import com.teamcenter.rac.util.MessageBox;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.newmeop.NewMeopDialogController.MEOPType;
import k.KDialog;
import k.KDialogController;
import k.util.KUtil;
@SuppressWarnings("serial")
public class NewMeopDialog extends KDialog {
private JButton b_ok;
private JButton b_cel;
protected DefaultListModel<MEOPType> lm_type;
protected JList<MEOPType> l_type;
private NewMeopDialogController controller;
private JButton b_assignId;
private PrefComponent idComponent;
private Map<PrefComponent,JButton> chooseComponents = new HashMap<PrefComponent, JButton>();
private PrefComponent sequenceComponent;
// private JButton b_assignMeopNo;
private JButton b_insertMeopNo;
public NewMeopDialog(KDialogController controller) {
super(controller);
this.controller = (NewMeopDialogController)controller;
}
private void setCompEnabled(boolean b) {
b_ok.setEnabled(b);
b_cel.setEnabled(b);
for (JButton btn : chooseComponents.values()) {
btn.setEnabled(b);
}
}
public void setAssignId(String newId) {
if(idComponent!=null&&b_assignId!=null) {
if(KUtil.isEmpty(newId)) {
idComponent.setValue(null);
b_assignId.setEnabled(true);
}else {
idComponent.setValue(newId);
b_assignId.setEnabled(false);
}
}
}
public void setMeopNo(String newId) {
if(sequenceComponent!=null && b_insertMeopNo!=null) {//&&b_assignMeopNo!=null
if(KUtil.isEmpty(newId)) {
sequenceComponent.setValue(null);
// b_assignMeopNo.setEnabled(true);
// b_insertMeopNo.setEnabled(true);
}else {
sequenceComponent.setValue(newId);
// b_assignMeopNo.setEnabled(false);
// b_insertMeopNo.setEnabled(false);
}
}
}
@Override
protected void addListeners() {
b_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
setCompEnabled(false);
try {
controller.doCreate();
controller.assignMeopNo();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(NewMeopDialog.this,e);
}
setCompEnabled(true);
}
}).start();
}
});
b_cel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
});
if(b_assignId!=null&&idComponent!=null) {
b_assignId.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
controller.assignId();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(NewMeopDialog.this,e1);
}
}
});
}
if(this.sequenceComponent!=null && this.b_insertMeopNo!=null) {
// b_assignMeopNo.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// try {
// controller.assignMeopNo();//TODO
// } catch (Exception e1) {
// e1.printStackTrace();
// MessageBox.post(NewMeopDialog.this,e1);
// }
// }
// });
b_insertMeopNo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
controller.insertMeopNo();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(NewMeopDialog.this,e1);
}
}
});
}
for (PrefComponent bean : chooseComponents.keySet()) {
JButton btn = chooseComponents.get(bean);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MEOPType typeComp = l_type.getSelectedValue();
if (typeComp == null) {
KUtil.warn(NewMeopDialog.this, ProcessLocale.getString("selectMeopType.INFO"));
return;
}
bean.performChoose(NewMeopDialog.this, typeComp.type, controller.getApp(), controller.prefComponents);
}
});
}
this.l_type.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent arg0) {
if(arg0.getValueIsAdjusting()) {
return;
}
System.out.println("Select Type Change > "+l_type.getSelectedValue());
setAssignId(null);
setMeopNo(null);
try {
controller.assignMeopNo();//TODO
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(NewMeopDialog.this,e1);
}
if(controller.shortDescPrefComp!=null&&l_type.getSelectedValue()!=null) {
controller.shortDescPrefComp.setValue(l_type.getSelectedValue().additional);
}
}
});
}
@Override
protected void initUI() {
this.setTitle(ProcessLocale.getString("newmeop.TITLE"));
this.setPreferredSize(new Dimension(780, 640));
this.setMinimumSize(new Dimension(780, 640));
this.setLayout(new BorderLayout());
this.add(BorderLayout.WEST, initTypePanel());
this.add(BorderLayout.CENTER, initPropPanel());
this.add(BorderLayout.SOUTH, initBtnPanel());
}
private Component initBtnPanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 5));
this.b_ok = new JButton(ProcessLocale.getString("ok"));
this.b_cel = new JButton(ProcessLocale.getString("cancel"));
panel.add(b_ok);
panel.add(b_cel);
return panel;
}
private Component initPropPanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER, initMEPropPanel());
panel.add(BorderLayout.SOUTH, initDESCPropPanel());
return panel;
}
private Component initDESCPropPanel() {
JPanel panel = new JPanel(new BorderLayout());
if(controller.shortDescPrefComp!=null) {
//panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5), ProcessLocale.getString("medesc.TITLE")));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5), controller.shortDescPrefComp.getLabel().getText()));
JScrollPane scroll = new JScrollPane(controller.shortDescPrefComp.getValueComp());
panel.add(BorderLayout.CENTER, scroll);
controller.prefComponents.add(controller.shortDescPrefComp);
}
return panel;
}
private Component initMEPropPanel() {
JPanel wrapper = new JPanel(new BorderLayout());
wrapper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5), ProcessLocale.getString("meinfo.TITLE")));
JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createEmptyBorder(20,30,20,30));
GridBagConstraints s = getGridBagConstraints(0, 0, new Insets(6, 6, 6, 6));
List<PrefComponent> comps = controller.prefComponents;
int colCnt = 1;
int size = comps.size();
for(int i=0;i<size;i++) {
PrefComponent prefComponent = comps.get(i);
if(i%colCnt==0) {
KUtil.newRow(panel, prefComponent.label, s, 1);
}else {
KUtil.addCol(panel, prefComponent.label, s, 1, 0);
}
KUtil.addCol(panel, prefComponent.getValueComp(), s, 1, 1);
if("item.item_id".equals(prefComponent.propConfig.toLowerCase())) {
KUtil.addCol(panel, this.b_assignId = new JButton(ProcessLocale.getString("assign")), s, 1, 0);
this.idComponent = prefComponent;
}else if(KUtil.getLen(prefComponent.chooseFromExcel)>0) {
JButton b_choose = new JButton(ProcessLocale.getString("select"));
KUtil.addCol(panel, b_choose, s, 1, 0);
chooseComponents.put(prefComponent, b_choose);
}else if("revmaster.ac5_OperationNumber".equalsIgnoreCase(prefComponent.propConfig)) {
// KUtil.addCol(panel,this.b_assignMeopNo = new JButton(ProcessLocale.getString("shenqing")), s, 1, 0);//TODO
KUtil.addCol(panel,this.b_insertMeopNo = new JButton(ProcessLocale.getString("insert")), s, 1, 0);
this.sequenceComponent = prefComponent;
try {
controller.assignMeopNo();
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(NewMeopDialog.this,e1);
}
}
}
s.weighty = 1;
KUtil.newRow(panel, new JLabel(""), s, 1);
JScrollPane scroll = new JScrollPane(panel);
//scroll.setBorder(null);
wrapper.add(BorderLayout.CENTER, scroll);
return wrapper;
}
private Component initTypePanel() {
JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(200,0));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(30, 5, 5, 0), ProcessLocale.getString("meoptype.TITLE")));
this.lm_type = new DefaultListModel<MEOPType>();
this.l_type = new JList<MEOPType>(lm_type);
for (MEOPType t : controller.meopTypes) {
this.lm_type.addElement(t);
}
this.l_type.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scroll = new JScrollPane(this.l_type);
panel.add(BorderLayout.CENTER, scroll);
return panel;
}
}

@ -0,0 +1,376 @@
package cn.net.connor.process.newmeop;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.teamcenter.rac.aif.AbstractAIFApplication;
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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.util.Registry;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.ProcessUtil;
import k.KDialogController;
import k.util.KUtil;
public class NewMeopDialogController extends KDialogController {
private NewMeopDialog dialog;
private TCComponentBOMLine targetLine;
private TCComponentItemRevision targetRev;
public static final String PREF_PREFIX = "Connor_AVIC_MEOP_";
public static final String PREF_PREFIX_EXCEL = "Connor_AVIC_MEOPEXCEL_";
public static final String PREF_PROPS = "Connor_AVIC_MEOP_Properties";
public static final String PREF_REL_LOV = "Connor_AVIC_MEOP_LOV_";
public static final Registry REG = Registry.getRegistry(NewMeopDialogController.class);
protected List<MEOPType> meopTypes = new ArrayList<NewMeopDialogController.MEOPType>();
protected List<PrefComponent> prefComponents = new ArrayList<PrefComponent>();
protected int propCols = 1;
protected PrefComponent shortDescPrefComp;
public class MEOPType {
protected String type;
protected String disType;
protected String additional;
protected TCComponentItemType itemType;
public MEOPType(String type, String disType, String additional) throws Exception {
this.type = type;
this.disType = disType;
this.additional = additional;
this.itemType = (TCComponentItemType) KUtil.session.getTypeComponent(type);
if (this.itemType == null) {
throw new Exception(String.format(ProcessLocale.getString("typenotfound.ERROR1"), type));
}
}
@Override
public String toString() {
return " " + disType;
}
}
public NewMeopDialogController(AbstractAIFApplication app) {
super(app);
}
@Override
public boolean init() throws Exception {
this.dialog = (NewMeopDialog) aifDialog;
InterfaceAIFComponent comp = app.getTargetComponent();
System.out.println("Select: " + comp);
if (comp != null) {
if (comp instanceof TCComponentBOMLine) {
this.targetLine = (TCComponentBOMLine) comp;
TCComponentItemRevision rev = this.targetLine.getItemRevision();
System.out.println(">> " + rev.getType());
if(ProcessUtil.isMEProcess(rev.getItem().getType())) {
//if (rev instanceof TCComponentMEProcessRevision) {
this.targetRev = rev;
}
}
}
if (targetRev == null) {
KUtil.warn(dialog, ProcessLocale.getString("selectprocessrev.ERROR"));
return false;
}
{
String prefName = PREF_PREFIX + this.targetRev.getType();
String[] prefVals = KUtil.getPrefVals(session, prefName);
int len = KUtil.getLen(prefVals);
for (int i = 0; i < len; i++) {
String type = prefVals[i];
String addition = "";
int ind = type.indexOf('=');
if (ind > 0) {
addition = type.substring(ind + 1).replace("\\n", "\n");
type = type.substring(0, ind);
}
String disType = KUtil.getTypeName(session, type);
if (KUtil.isEmpty(disType)) {
System.out.println("Error Config: " + prefVals[i]);
continue;
}
this.meopTypes.add(new MEOPType(type, disType, addition));
}
if (this.meopTypes.size() == 0) {
KUtil.warn(dialog, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), prefName));
return false;
}
}
{
String[] prefVals = KUtil.getPrefVals(session, PREF_PROPS);
int len = KUtil.getLen(prefVals);
for (int i = 0; i < len; i++) {
String pref = prefVals[i];
if (pref.length() == 1 && Character.isDigit(pref.charAt(0))) {
int col = pref.charAt(0) - '0';
if (col > 0) {
System.out.println("Reset Proc Col: " + col);
this.propCols = col;
}
continue;
}
PrefComponent prefComp = new PrefComponent(pref);
if (prefComp.init(session, targetRev, prefComponents)) {
prefComponents.add(prefComp);
} else {
System.out.println("Error Config: " + pref);
}
}
if (prefComponents.size() == 0) {
KUtil.warn(dialog, String.format(ProcessLocale.getString("prefnotconfiged.ERROR1"), PREF_PROPS));
return false;
}
String descPropName = NewMeopDialogController.REG.getString("shortdesc.PROPNAME");
this.shortDescPrefComp = new PrefComponent(descPropName);
if(!shortDescPrefComp.init(session, targetRev, prefComponents)) {
this.shortDescPrefComp = null;
}
}
return true;
}
public void assignId() throws Exception {
MEOPType type = dialog.l_type.getSelectedValue();
if (type == null) {
KUtil.warn(dialog, ProcessLocale.getString("selectMeopType.INFO"));
return;
}
TCComponentItemType itemType = type.itemType;
String newId = itemType.getNewID();
System.out.println("New ID: " + type.type + " -> " + newId);
dialog.setAssignId(newId);
}
public static int getMeopNo(TCComponentBOMLine line) throws Exception{
TCComponentItemRevision rev = line.getItemRevision();
if(rev==null) {
throw new TCException("获取版本失败:"+line);
}
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
if(form==null) {
throw new TCException("获取版本表单失败:"+rev);
}
form.refresh();
String seqStr = form.getStringProperty("ac5_OperationNumber");
System.out.println("Op Number: "+line+" -> "+seqStr);
int seq = 0;
if(!KUtil.isEmpty(seqStr)) {
try {
seq = Integer.parseInt(seqStr);
} catch (Exception e) {
e.printStackTrace();
}
}
return seq;
}
@SuppressWarnings("deprecation")
public static void setMeopNo(TCComponentBOMLine line, int meopNo) throws Exception{
System.out.println("Set Op Number: "+line+" -> "+meopNo);
// if(meopNo<0) {
// return;
// }
TCComponentItemRevision rev = line.getItemRevision();
if(rev==null) {
throw new TCException("获取版本失败:"+line);
}
TCComponent form = rev.getRelatedComponent("IMAN_master_form_rev");
if(form==null) {
throw new TCException("获取版本表单失败:"+rev);
}
form.refresh();
form.lock();
try {
form.setStringProperty("ac5_OperationNumber", meopNo+"");
form.save();
form.refresh();
} finally {
form.unlock();
}
}
public void assignMeopNo() throws Exception{
targetLine.refresh();
AIFComponentContext[] cc = targetLine.getChildren();
int maxSeq = 0;
int len = KUtil.getLen(cc);
for(int i=0;i<len;i++) {
TCComponentBOMLine cLine = (TCComponentBOMLine) cc[i].getComponent();
int seq = getMeopNo(cLine);
maxSeq = Math.max(seq, maxSeq);
}
maxSeq+=5;
System.out.println("New Sequence: "+maxSeq);
// dialog.setMeopNo(""+maxSeq);
dialog.setMeopNo(String.format("%02d", maxSeq));
}
public void insertMeopNo() throws Exception{
Map<String, String> propData = new MeopNoDialog(dialog, true, new MeopNoDialogController(app, targetLine)).getMeopInfo();
System.out.println("Prop Info: "+propData);
if(propData==null||propData.size()==0) {
return;
}
for (PrefComponent comp : prefComponents) {
String key = comp.getPropConfig();
if(propData.containsKey(key)) {
String value = propData.get(key);
System.out.println(String.format("set [%s]=[%s]", key, value));
if(key.equals("revmaster.ac5_OperationNumber") && value.length()==1)
comp.setValue("0"+value);
else
comp.setValue(value);
}
}
}
public void doCreate() throws Exception{
System.out.println("doCreate() = = = = = = = =");
MEOPType typeComp = dialog.l_type.getSelectedValue();
if (typeComp == null) {
KUtil.warn(dialog, ProcessLocale.getString("selectMeopType.INFO"));
return;
}
TCComponentItemType itemType = typeComp.itemType;
//Check Require
if(!checkRequire()) {
return;
}
String type = itemType.getName();
System.out.println("Select Type: " + type);
if (KUtil.isEmpty(type)) {
KUtil.info(dialog, ProcessLocale.getString("selectType.INFO"));
return;
}
if (!checkRequire()) {
return;
}
TCComponentItemRevisionType revType = itemType.getItemRevisionType();
String revTypeName = revType.getName();
String itemMasterTypeName = type+" Master";
String revMasterTypeName = revTypeName+" Master";
if(session.getTypeComponent(itemMasterTypeName)==null) {
itemMasterTypeName = type+"Master";
}
if(session.getTypeComponent(revMasterTypeName)==null) {
revMasterTypeName = revTypeName+"Master";
}
System.out.println("Revision Type: " + type);
System.out.println("Item Master Type: " + itemMasterTypeName);
System.out.println("Revision Master Type: " + revMasterTypeName);
Map<String, String> revPropMap = new HashMap<>();
Map<String, String> revMasterPropMap = new HashMap<>();
Map<String, String> itemPropMap = new HashMap<>();
Map<String, String> itemMasterPropMap = new HashMap<>();
Map<String, String> bomLinePropMap = new HashMap<>();
for (PrefComponent prefComponent : this.prefComponents) {
KUtil.initPropMap(prefComponent.propConfig,prefComponent.getValue(),itemPropMap,itemMasterPropMap,revPropMap,revMasterPropMap,bomLinePropMap);
}
/*String propType = "ac5_Type";
//propType = "object_desc";
if(revMasterPropMap.containsKey(propType)) {
String ac5Type = revMasterPropMap.get(propType);
System.out.println(propType+": "+ac5Type);
if(!KUtil.isEmpty(ac5Type)) {
revPropMap.put("item_revision_id", ac5Type+"00");
}
}*/
revPropMap.put("item_revision_id", targetLine.getItemRevision().getProperty("item_revision_id"));
CreateInput revMasterInput = new CreateInput();
revMasterInput.boName = revMasterTypeName;
revMasterInput.stringProps = revMasterPropMap;
CreateInput itemMasterInput = new CreateInput();
itemMasterInput.boName = itemMasterTypeName;
itemMasterInput.stringProps = itemMasterPropMap;
CreateInput revInput = new CreateInput();
revInput.boName = revTypeName;
revInput.stringProps = revPropMap;
Map<String, CreateInput[]> revMasterInfoMap = new HashMap<>();
revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput });
revInput.compoundCreateInput = revMasterInfoMap;
// create rev
CreateInput itemInput = new CreateInput();
itemInput.boName = type;
itemInput.stringProps = itemPropMap;
Map<String, CreateInput[]> revInfoMap = new HashMap<>();
revInfoMap.put("revision", new CreateInput[] { revInput });
revInfoMap.put("IMAN_master_form", new CreateInput[] {itemMasterInput});
itemInput.compoundCreateInput = revInfoMap;
// create info
CreateIn cI = new CreateIn();
cI.clientId = "CreateItem";
cI.data = itemInput;
// service
DataManagementService service = DataManagementService.getService(session);
// create
CreateResponse resp = service.createObjects(new CreateIn[] { cI });
KUtil.throwServiceDataError(resp.serviceData);
CreateOut[] cOs = resp.output;
TCComponentItem newItem = null;
if (cOs.length > 0) {
for (TCComponent s : cOs[0].objects) {
if (s instanceof TCComponentItem) {
newItem = (TCComponentItem) s;
}
}
}
System.out.println("New Item: "+newItem);
if(newItem==null) {
throw new Exception(ProcessLocale.getString("createprocess.ERROR"));
}
newItem.refresh();
TCComponentItemRevision newRev = newItem.getLatestItemRevision();
System.out.println("New Rev: "+newRev);
TCComponentBOMLine newLine = this.targetLine.add(newItem, newRev, null, false);
if(bomLinePropMap.size()>0) {
System.out.println("Set Bom Property: "+bomLinePropMap);
newLine.setProperties(bomLinePropMap);
newLine.refresh();
}
this.targetLine.refresh();
dialog.setAssignId(null);
dialog.setMeopNo(null);
//TODO
for(PrefComponent comp : prefComponents) {
if(!comp.hasDefault())
comp.setValue("");
}
}
private boolean checkRequire() {
List<String> requireTitles = new ArrayList<String>();
for (PrefComponent prefComponent : this.prefComponents) {
if (!prefComponent.checkRequire()) {
requireTitles.add(prefComponent.title.replace(" ", "").replace(":", "").replace(KUtil.getReg("CN_SYMBEL4"), "").replace(KUtil.getReg("CN_SYMBEL5"), ""));
}
}
if (requireTitles.size() > 0) {
KUtil.info(dialog, String.format(ProcessLocale.getString("requireprop.INFO1"), requireTitles.toString()));
return false;
}
return true;
}
public AbstractAIFApplication getApp() {
return app;
}
}

@ -0,0 +1,475 @@
package cn.net.connor.process.newmeop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JComponent;
import javax.swing.JLabel;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.iTextArea;
import com.teamcenter.rac.util.iTextField;
import com.teamcenter.rac.util.combobox.iComboBox;
import com.teamcenter.soa.client.model.LovValue;
import cn.net.connor.process.ProcessLocale;
import cn.net.connor.process.choose.ChooseDialog;
import cn.net.connor.process.choose.ChooseDialogController;
import k.util.KUtil;
public class PrefComponent {
public static final String REQUIRE = "*";
public static final String READONLY = "#";
public static final String TEXTAREA = "$";
public static final String SCYYJCX = "@";
private String configStr;
protected boolean require = false;
protected boolean readonly = false;
protected String title;
protected String propConfig;
protected String lovName;
private String[] additional;
private String[] lov;
private String[] displayLov;
private iTextField textField;
private iTextArea textArea;
private iComboBox comboBox;
protected JLabel label;
protected String[] chooseFromExcel;
//private Map<String, ChooseDialog> chooseDialogMap = new HashMap<String, ChooseDialog>();
protected boolean isTextArea = false;
private String savedValue;
private String fromProcess;
private String fromProcessValue;
private String propName;
private String displayCondition;
private List<JComponent> additionalComps = new ArrayList<JComponent>();
private boolean isScyyj = false;
public String[] getExcelConfig() {
return this.chooseFromExcel;
}
public String getTitle() {
return title;
}
public boolean canDisplay(TCComponentItemRevision rev) throws Exception{
if(KUtil.isEmpty(displayCondition)||rev==null) {
return true;
}
System.out.println("Check Property Display: "+rev+" -> "+displayCondition);
int ind = displayCondition.lastIndexOf(':');
if(ind<0) {
return true;
}
String propStr = displayCondition.substring(0, ind);
String checkValue = displayCondition.substring(ind+1);
String propValue = KUtil.getConfigPropValue(rev, propStr);
System.out.println("Prop Value: "+propValue);
return checkValue.equals(propValue);
}
public String getPropConfig() {
return propConfig;
}
public PrefComponent(String pref) {
this.configStr = pref;
}
public boolean init(TCSession session) throws Exception{
return init(session, null, null);
}
public boolean init(TCSession session, TCComponentItemRevision targetRev, List<PrefComponent> prefComponents) throws Exception {
if (KUtil.isEmpty(configStr)) {
return false;
}
System.out.println(configStr);
if (configStr.startsWith(REQUIRE)) {
configStr = configStr.substring(1);
this.require = true;
}
if (configStr.startsWith(READONLY)) {
configStr = configStr.substring(1);
this.readonly = true;
}
if (configStr.startsWith(TEXTAREA)) {
configStr = configStr.substring(1);
this.isTextArea = true;
}
System.out.println(configStr+">>"+SCYYJCX+">>"+configStr.startsWith(SCYYJCX));
if (configStr.startsWith(SCYYJCX)) {
configStr = configStr.substring(1);
this.isScyyj = true;
}
String[] split = configStr.split("=", -1);
int len = KUtil.getLen(split);
if (len > 0) {
this.title = split[0];
}
if (len > 1) {
this.propConfig = split[1];
}
if (len > 2) {
this.lovName = split[2];
}
if (len > 3) {
this.fromProcess = split[3];
}
if (len > 4) {
displayCondition = split[4];
}
if (KUtil.isEmpty(title)) {
return false;
}
if(!KUtil.isEmpty(fromProcess)) {
this.fromProcessValue = KUtil.getConfigPropValue(targetRev, fromProcess);
}
if (!KUtil.isEmpty(lovName)) {
int ind = lovName.indexOf(';');
if(ind>0) {
String[] lovValues = lovName.split(";");
int lovCnt = KUtil.getLen(lovValues);
this.lov = new String[lovCnt];
this.displayLov = new String[lovCnt];
for (int i = 0; i < lovCnt; i++) {
String realValue = lovValues[i];
String disValue = lovValues[i];
lov[i] = realValue;
displayLov[i] = disValue;
}
}else {
TCComponentListOfValues lovComp = KUtil.getLov(lovName);
if (lovComp == null) {
throw new Exception(String.format(ProcessLocale.getString("lovnotfound.ERROR1"), lovName));
}
if (lovComp.getListOfValues() != null) {
List<LovValue> vals = lovComp.getListOfValues().getValues();
int lovCnt = vals == null ? 0 : vals.size();
this.lov = new String[lovCnt];
this.displayLov = new String[lovCnt];
for (int i = 0; i < lovCnt; i++) {
LovValue lovValue = vals.get(i);
String realValue = lovValue.getValue() == null ? "" : lovValue.getValue().toString();
String disValue = lovValue.getDisplayValue();
lov[i] = realValue;
displayLov[i] = disValue;
}
}
}
}
if (!KUtil.isEmpty(propConfig)) {
this.propName = propConfig;
int ind = propConfig.indexOf('.');//only use name as suffix
if (ind > 0) {
propName = propConfig.substring(ind + 1);
}
if (!KUtil.isEmpty(propName)) {
this.chooseFromExcel = KUtil.getPrefVals(session, NewMeopDialogController.PREF_PREFIX_EXCEL + propName);
}
}
initPanel();
initComponent();
checkLovRelatedProp(session, prefComponents);
if(this.fromProcessValue!=null) {
setValue(this.fromProcessValue);
}
return true;
}
private void initComponent() throws Exception {
if (readonly) {
if (textField != null) {
textField.setEditable(false);
}
if (textArea != null) {
textArea.setEditable(false);
}
if (comboBox != null) {
comboBox.setEditable(false);
comboBox.setEnabled(false);
}
}
if (require) {
if (textField != null) {
textField.setRequired(true);
}
if (textArea != null) {
textArea.setRequired(true);
}
if (comboBox != null) {
comboBox.setMandatory(true);
}
}
}
private void checkLovRelatedProp(TCSession session, List<PrefComponent> prefComponents) throws Exception {
if(comboBox==null) {
return;
}
Map<String, Map<String, String>> relateValueMap = new HashMap<String, Map<String,String>>();
String prefName = NewMeopDialogController.PREF_REL_LOV+propName;
String[] prefs = KUtil.getPrefVals(session, prefName);
System.out.println(prefName+ " >> "+Arrays.toString(prefs));
int prefLen = KUtil.getLen(prefs);
for(int i=0;i<prefLen;i++) {
String pref = prefs[i];
int ind = pref.indexOf(':');
if(ind<0) {
continue;
}
String realValue = pref.substring(0, ind);
String[] relateValues = pref.substring(ind+1).split(";");
int relateLen = KUtil.getLen(relateValues);
for(int j=0 ;j<relateLen;j++) {
String relateValue = relateValues[j];
ind = relateValue.indexOf('=');
if(ind<=0) {
continue;
}
String relateProp = relateValue.substring(0, ind).trim();
if(this.propName.equals(relateProp)) {
continue;
}
relateValue = relateValue.substring(ind+1);
if(KUtil.isEmpty(relateProp)) {
continue;
}
Map<String, String> subMap;
if(relateValueMap.containsKey(realValue)) {
subMap = relateValueMap.get(realValue);
}else {
subMap = new HashMap<String, String>();
relateValueMap.put(realValue, subMap);
}
subMap.put(relateProp, relateValue);
}
}
if(relateValueMap.size()>0) {
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String item = getValue();
System.out.println("Select: "+item);
if(item==null) {
item = "";
}
if(relateValueMap.containsKey(item)) {
Map<String, String> subMap = relateValueMap.get(item);
for (PrefComponent comp : prefComponents) {
if(subMap.containsKey(comp.propName)) {
comp.setValue(subMap.get(comp.propName));
}
}
}
}
});
}
}
private void initPanel() {
// this.panel = new JPanel(new GridBagLayout());
// this.panel.setPreferredSize(new Dimension(260, 40));
// GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 0, 0,
// GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 0),
// 0, 0);
this.label = new JLabel(title, JLabel.RIGHT);
// KUtil.newRow(panel, label, s, 1);
int len = KUtil.getLen(displayLov);
if (len > 0) {
comboBox = new iComboBox();
for (int i = 0; i < len; i++) {
comboBox.addItem(displayLov[i]);
}
// KUtil.addCol(panel, comboBox, s, 1, 1);
} else {
if(isTextArea) {
textArea = new iTextArea(6, 12);
textArea.setLineWrap(true);
}else {
textField = new iTextField(12);
}
// KUtil.addCol(panel, textField, s, 1, 1);
}
}
// public Component getPanel() {
// return panel;
// }
public JComponent getValueComp() {
return textField == null ? (textArea==null?comboBox:textArea) : textField;
}
public JLabel getLabel() {
return this.label;
}
public void setValue(String value) {
if (textField != null) {
textField.setText(value);
}else if(textArea!=null) {
textArea.setText(value);
} else if (comboBox != null) {
if (value == null) {
comboBox.setSelectedItem(null);
} else {
int ind = KUtil.inArray(value, lov);
if (ind < 0) {
ind = KUtil.inArray(value, displayLov);
}
if (ind < 0) {
comboBox.setSelectedItem(null);
} else {
comboBox.setSelectedIndex(ind);
}
}
}
}
public void setValueAndSave(String value) {
this.savedValue = value;
if (textField != null) {
textField.setText(value);
}else if(textArea!=null) {
textArea.setText(value);
} else if (comboBox != null) {
if (value == null) {
this.savedValue="";
comboBox.setSelectedItem(null);
} else {
int ind = KUtil.inArray(value, lov);
if (ind < 0) {
ind = KUtil.inArray(value, displayLov);
}
if (ind < 0) {
this.savedValue="";
comboBox.setSelectedItem(null);
} else {
this.savedValue = lov[ind];
comboBox.setSelectedIndex(ind);
}
}
}
}
public boolean isModified() {
String val = getValue();
if(val==null) {
val = "";
}
if(savedValue==null) {
return !"".equals(val);
}else {
return !savedValue.equals(val);
}
}
public String getValue() {
String value = null;
if (textField != null) {
value = textField.getText();
} else if (textArea != null) {
value = textArea.getText();
} else if (comboBox != null) {
int ind = comboBox.getSelectedIndex();
if (ind >= 0 && ind < KUtil.getLen(lov)) {
value = lov[ind];
}
}
return value;
}
public String getAddtionalValue() {
String value = null;
if (textField != null) {
value = textField.getText();
} else if(textArea != null) {
value = textArea.getText();
} else if (comboBox != null) {
int ind = comboBox.getSelectedIndex();
if (ind >= 0 && ind < KUtil.getLen(lov)) {
value = additional[ind];
}
}
return value;
}
public boolean checkRequire() {
if (!require) {
return true;
}
String val = getValue();
return val != null && !"".equals(val);
}
public void performChoose(AbstractAIFDialog dialog, String type, AbstractAIFApplication app, List<PrefComponent> prefComponents) {
ChooseDialog chooseDialog = new ChooseDialog(dialog, new ChooseDialogController(app, type, this, prefComponents));
if (!chooseDialog.initDialog()) {
chooseDialog = null;
}
chooseDialog.showDialog();
// ChooseDialog chooseDialog = null;
// if (chooseDialogMap.containsKey(type)) {
// chooseDialog = chooseDialogMap.get(type);
// chooseDialog.showDialog();
// return;
// }
// if (chooseDialog == null) {
// chooseDialog = new ChooseDialog(dialog, new ChooseDialogController(app, type, this, prefComponents));
// if (!chooseDialog.initDialog()) {
// chooseDialog = null;
// }
// }
// if (chooseDialog != null) {
// chooseDialog.showDialog();
// chooseDialogMap.put(type, chooseDialog);
// }
}
/**
* /
* @param comp
*/
public void addAdditionalComp(JComponent comp) {
this.additionalComps.add(comp);
}
/**
* /
* @param visible
*/
public void setVisible(boolean visible) {
label.setVisible(visible);
getValueComp().setVisible(visible);
for (JComponent c : additionalComps) {
c.setVisible(visible);
}
}
public boolean hasDefault() {
System.out.println(getTitle()+" Default:"+fromProcessValue);
if(fromProcessValue==null || fromProcessValue.isEmpty())
return false;
return true;
}
public boolean isScyyj() {
return isScyyj;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save