master
洪丞进 1 year ago
parent a88711cae4
commit fc921c90b3

@ -1,2 +1,11 @@
xz=select xz=select
zjdx=Component object zjdx=Component object
yjmbcj=Create based on template
cpdh=Product code:
qd=determine
cpdhbnwk=Product code cannot be empty!
ts=prompt
mb=template
cjcg=Created successfully
cjsb=Creation failed
yczytc=Already exists in TC

@ -1,2 +1,11 @@
xz=\u9009\u62e9 xz=\u9009\u62e9
zjdx=\u7ec4\u4ef6\u5bf9\u8c61 zjdx=\u7ec4\u4ef6\u5bf9\u8c61
yjmbcj=\u4F9D\u636E\u6A21\u677F\u521B\u5EFA
cpdh=\u4EA7\u54C1\u4EE3\u53F7\uFF1A
qd=\u786E\u5B9A
cpdhbnwk=\u4EA7\u54C1\u4EE3\u53F7\u4E0D\u80FD\u4E3A\u7A7A\uFF01
ts=\u63D0\u793A
mb=\u6A21\u677F
cjcg=\u521B\u5EFA\u6210\u529F
cjsb=\u521B\u5EFA\u5931\u8D25
yczytc=\u5DF2\u5B58\u5728\u4E8ETC

@ -0,0 +1,221 @@
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 257949696 bytes for G1 virtual space
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
# placed in the first 32GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_windows.cpp:3541), pid=29588, tid=22644
#
# JRE version: (17.0.4.1+1) (build )
# Java VM: OpenJDK 64-Bit Server VM (17.0.4.1+1, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
--------------- S U M M A R Y ------------
Command Line: -Dfile.encoding=GBK -XX:+ShowCodeDetailsInExceptionMessages com.connor.kwc.createBom.test
Host: AMD Ryzen 5 4600H with Radeon Graphics , 12 cores, 15G, Windows 11 , 64 bit Build 23506 (10.0.23506.1000)
Time: Fri Jan 12 10:19:57 2024 Windows 11 , 64 bit Build 23506 (10.0.23506.1000) elapsed time: 0.011971 seconds (0d 0h 0m 0s)
--------------- T H R E A D ---------------
Current thread (0x0000022fdc886410): JavaThread "Unknown thread" [_thread_in_vm, id=22644, stack(0x000000ea04d00000,0x000000ea04e00000)]
Stack: [0x000000ea04d00000,0x000000ea04e00000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x67731a]
V [jvm.dll+0x832284]
V [jvm.dll+0x833a2e]
V [jvm.dll+0x834093]
V [jvm.dll+0x245775]
V [jvm.dll+0x674209]
V [jvm.dll+0x668a92]
V [jvm.dll+0x30471b]
V [jvm.dll+0x30bc66]
V [jvm.dll+0x35ba9e]
V [jvm.dll+0x35bccf]
V [jvm.dll+0x2db5b8]
V [jvm.dll+0x2dc524]
V [jvm.dll+0x803db1]
V [jvm.dll+0x3698f1]
V [jvm.dll+0x7e31bc]
V [jvm.dll+0x3ec25f]
V [jvm.dll+0x3edde1]
C [jli.dll+0x5277]
C [ucrtbase.dll+0x29363]
C [KERNEL32.DLL+0x126ad]
C [ntdll.dll+0x5aa08]
--------------- P R O C E S S ---------------
Threads class SMR info:
_java_thread_list=0x00007ff98b674e98, length=0, elements={
}
Java Threads: ( => current thread )
Other Threads:
0x0000022fdc8f1580 GCTaskThread "GC Thread#0" [stack: 0x000000ea04e00000,0x000000ea04f00000] [id=31264]
0x0000022fdc9032d0 ConcurrentGCThread "G1 Main Marker" [stack: 0x000000ea04f00000,0x000000ea05000000] [id=43564]
0x0000022fdc903be0 ConcurrentGCThread "G1 Conc#0" [stack: 0x000000ea05000000,0x000000ea05100000] [id=43708]
[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff98ae4c047]
VM state: not at safepoint (not fully initialized)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x0000022fdc881390] Heap_lock - owner thread: 0x0000022fdc886410
Heap address: 0x000000070a000000, size: 3936 MB, Compressed Oops mode: Zero based, Oop shift amount: 3
CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 0.
Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0
GC Precious Log:
<Empty>
Heap:
garbage-first heap total 0K, used 0K [0x000000070a000000, 0x0000000800000000)
region size 2048K, 0 young (0K), 0 survivors (0K)
[error occurred during error reporting (printing heap information), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff98b230699]
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Classes unloaded (0 events):
No events
Classes redefined (0 events):
No events
Internal exceptions (0 events):
No events
VM Operations (0 events):
No events
Events (1 events):
Event: 0.007 Loaded shared library C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\java.dll
Dynamic libraries:
0x00007ff73f360000 - 0x00007ff73f36e000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\javaw.exe
0x00007ffa24db0000 - 0x00007ffa24fc5000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x00007ffa23cb0000 - 0x00007ffa23d74000 C:\WINDOWS\System32\KERNEL32.DLL
0x00007ffa22160000 - 0x00007ffa22504000 C:\WINDOWS\System32\KERNELBASE.dll
0x00007ffa22670000 - 0x00007ffa22781000 C:\WINDOWS\System32\ucrtbase.dll
0x00007ffa1e0b0000 - 0x00007ffa1e0c8000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\jli.dll
0x00007ffa0f070000 - 0x00007ffa0f089000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\VCRUNTIME140.dll
0x00007ffa23620000 - 0x00007ffa237ce000 C:\WINDOWS\System32\USER32.dll
0x00007ffa10fe0000 - 0x00007ffa11273000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.23506.1000_none_f04aa4d392225b35\COMCTL32.dll
0x00007ffa22920000 - 0x00007ffa22946000 C:\WINDOWS\System32\win32u.dll
0x00007ffa24770000 - 0x00007ffa24817000 C:\WINDOWS\System32\msvcrt.dll
0x00007ffa22c30000 - 0x00007ffa22c59000 C:\WINDOWS\System32\GDI32.dll
0x00007ffa22800000 - 0x00007ffa22919000 C:\WINDOWS\System32\gdi32full.dll
0x00007ffa225d0000 - 0x00007ffa2266a000 C:\WINDOWS\System32\msvcp_win.dll
0x00007ffa22bf0000 - 0x00007ffa22c21000 C:\WINDOWS\System32\IMM32.DLL
0x00007ffa1a890000 - 0x00007ffa1a89c000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\vcruntime140_1.dll
0x00007ff9f3360000 - 0x00007ff9f33f1000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\msvcp140.dll
0x00007ff98ab60000 - 0x00007ff98b7a6000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\server\jvm.dll
0x00007ffa23d80000 - 0x00007ffa23e2e000 C:\WINDOWS\System32\ADVAPI32.dll
0x00007ffa22b40000 - 0x00007ffa22be4000 C:\WINDOWS\System32\sechost.dll
0x00007ffa24b70000 - 0x00007ffa24c87000 C:\WINDOWS\System32\RPCRT4.dll
0x00007ffa235a0000 - 0x00007ffa235a8000 C:\WINDOWS\System32\PSAPI.DLL
0x00007ff9f7800000 - 0x00007ff9f7809000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x00007ffa1e8a0000 - 0x00007ffa1e8d4000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x00007ffa17870000 - 0x00007ffa1787a000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x00007ffa24940000 - 0x00007ffa249b1000 C:\WINDOWS\System32\WS2_32.dll
0x00007ffa211a0000 - 0x00007ffa211b8000 C:\WINDOWS\SYSTEM32\kernel.appcore.dll
0x00007ff9ea2f0000 - 0x00007ff9ea2fa000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\jimage.dll
0x00007ffa1f810000 - 0x00007ffa1fa3e000 C:\WINDOWS\SYSTEM32\DBGHELP.DLL
0x00007ffa23010000 - 0x00007ffa2339a000 C:\WINDOWS\System32\combase.dll
0x00007ffa24c90000 - 0x00007ffa24d67000 C:\WINDOWS\System32\OLEAUT32.dll
0x00007ffa06fc0000 - 0x00007ffa06ff2000 C:\WINDOWS\SYSTEM32\dbgcore.DLL
0x00007ffa22ac0000 - 0x00007ffa22b3b000 C:\WINDOWS\System32\bcryptPrimitives.dll
0x00007ff9a4360000 - 0x00007ff9a4385000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\java.dll
dbghelp: loaded successfully - version: 4.0.5 - missing functions: none
symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin;C:\WINDOWS\SYSTEM32;C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.23506.1000_none_f04aa4d392225b35;C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\server
VM Arguments:
jvm_args: -Dfile.encoding=GBK -XX:+ShowCodeDetailsInExceptionMessages
java_command: com.connor.kwc.createBom.test
java_class_path (initial): D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\sapjco3.jar;D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\sqljdbc4.jar;D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\okhttp-2.7.4.jar;D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\okio-1.13.0.jar;C:\eclipse\eclipse\plugins\org.eclipse.fx.ide.css.jfx8_3.8.0.202204150904.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.ui_3.201.100.v20220826-1037.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.swt_3.121.0.v20220829-1402.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.swt.nl_14000.3.0.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.swt.win32.win32.x86_64_3.121.0.v20220829-1402.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.jface_3.27.0.v20220817-1444.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.commands_3.10.200.v20220512-0851.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.ui.workbench_3.126.0.v20220823-0718.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.e4.ui.workbench3_0.16.0.v20210619-0956.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.runtime_3.26.0.v20220813-0916.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi_3.18.100.v20220817-1601.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi.compatibility.state.nl_14000.3.0.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi.compatibility.state_1.2.700.v20220722-0431.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi.nl_14000.3.0.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.equinox.common_3.16.200.v20220817-1601.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.jobs_3.13.100.v20220817-1539.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.equinox.registry_3.11.200.v20220817-1601.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.equinox.preferences_3.10.100.v20220710-1223.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.osgi.service.prefs_1.1.2.202109301733.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.contenttype_3.8.200.v20220817-1539.jar;D:\WorkEnvironme
Launcher Type: SUN_STANDARD
[Global flags]
intx CICompilerCount = 4 {product} {ergonomic}
uint ConcGCThreads = 3 {product} {ergonomic}
uint G1ConcRefinementThreads = 10 {product} {ergonomic}
size_t G1HeapRegionSize = 2097152 {product} {ergonomic}
uintx GCDrainStackTargetSize = 64 {product} {ergonomic}
size_t InitialHeapSize = 257949696 {product} {ergonomic}
size_t MarkStackSize = 4194304 {product} {ergonomic}
size_t MaxHeapSize = 4127195136 {product} {ergonomic}
size_t MinHeapDeltaBytes = 2097152 {product} {ergonomic}
size_t MinHeapSize = 8388608 {product} {ergonomic}
uintx NonNMethodCodeHeapSize = 5839372 {pd product} {ergonomic}
uintx NonProfiledCodeHeapSize = 122909434 {pd product} {ergonomic}
uintx ProfiledCodeHeapSize = 122909434 {pd product} {ergonomic}
uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic}
bool SegmentedCodeCache = true {product} {ergonomic}
bool ShowCodeDetailsInExceptionMessages = true {manageable} {command line}
size_t SoftMaxHeapSize = 4127195136 {manageable} {ergonomic}
bool UseCompressedClassPointers = true {product lp64_product} {ergonomic}
bool UseCompressedOops = true {product lp64_product} {ergonomic}
bool UseG1GC = true {product} {ergonomic}
bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic}
Logging:
Log output configuration:
#0: stdout all=warning uptime,level,tags
#1: stderr all=off uptime,level,tags
Environment Variables:
JAVA_HOME=C:\Java\jdk1.8.0_121
CLASSPATH=.;C:\Java\jdk1.8.0_121\lib\dt.jar;C:\Java\jdk1.8.0_121\lib\tools.jar;
PATH=C:/eclipse/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038/jre/bin/server;C:/eclipse/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038/jre/bin;C:\Java\jdk1.8.0_121\bin;C:\Java\jdk1.8.0_121\jre\bin;C:\ProgramData\Oracle\Java\javapath;D:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;D:\Maven\apache-maven-3.9.1\bin;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;;D:\Program Files (x86)\Microsoft VS Code\bin;D:\Program Files\JetBrains\IntelliJ IDEA 2020.1\bin;;C:\eclipse\eclipse;
USERNAME=admin
OS=Windows_NT
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
TMP=C:\Users\admin\AppData\Local\Temp
TEMP=C:\Users\admin\AppData\Local\Temp
--------------- S Y S T E M ---------------
OS:
Windows 11 , 64 bit Build 23506 (10.0.23506.1000)
OS uptime: 3 days 0:30 hours
CPU: total 12 (initial active 12) (12 cores per cpu, 2 threads per core) family 23 model 96 stepping 1 microcode 0x0, cx8, cmov, fxsr, ht, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4a, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, clmul, bmi1, bmi2, adx, sha, fma, vzeroupper, clflush, clflushopt
Memory: 4k page, system-wide physical 15741M (2676M free)
TotalPageFile size 31086M (AvailPageFile size 105M)
current process WorkingSet (physical memory assigned to process): 11M, peak: 11M
current process commit charge ("private bytes"): 64M, peak: 310M
vm_info: OpenJDK 64-Bit Server VM (17.0.4.1+1) for windows-amd64 JRE (17.0.4.1+1), built on Aug 17 2022 07:42:43 by "temurin" with MS VC++ 16.7 (VS2019)
END.

@ -0,0 +1,221 @@
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 257949696 bytes for G1 virtual space
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
# placed in the first 32GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (os_windows.cpp:3541), pid=37884, tid=45512
#
# JRE version: (17.0.4.1+1) (build )
# Java VM: OpenJDK 64-Bit Server VM (17.0.4.1+1, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
--------------- S U M M A R Y ------------
Command Line: -Dfile.encoding=GBK -XX:+ShowCodeDetailsInExceptionMessages com.connor.kwc.createBom.test
Host: AMD Ryzen 5 4600H with Radeon Graphics , 12 cores, 15G, Windows 11 , 64 bit Build 23506 (10.0.23506.1000)
Time: Fri Jan 12 10:20:12 2024 Windows 11 , 64 bit Build 23506 (10.0.23506.1000) elapsed time: 0.010289 seconds (0d 0h 0m 0s)
--------------- T H R E A D ---------------
Current thread (0x0000022018735f70): JavaThread "Unknown thread" [_thread_in_vm, id=45512, stack(0x0000002feb300000,0x0000002feb400000)]
Stack: [0x0000002feb300000,0x0000002feb400000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x67731a]
V [jvm.dll+0x832284]
V [jvm.dll+0x833a2e]
V [jvm.dll+0x834093]
V [jvm.dll+0x245775]
V [jvm.dll+0x674209]
V [jvm.dll+0x668a92]
V [jvm.dll+0x30471b]
V [jvm.dll+0x30bc66]
V [jvm.dll+0x35ba9e]
V [jvm.dll+0x35bccf]
V [jvm.dll+0x2db5b8]
V [jvm.dll+0x2dc524]
V [jvm.dll+0x803db1]
V [jvm.dll+0x3698f1]
V [jvm.dll+0x7e31bc]
V [jvm.dll+0x3ec25f]
V [jvm.dll+0x3edde1]
C [jli.dll+0x5277]
C [ucrtbase.dll+0x29363]
C [KERNEL32.DLL+0x126ad]
C [ntdll.dll+0x5aa08]
--------------- P R O C E S S ---------------
Threads class SMR info:
_java_thread_list=0x00007ff98b674e98, length=0, elements={
}
Java Threads: ( => current thread )
Other Threads:
0x00000220187a1400 GCTaskThread "GC Thread#0" [stack: 0x0000002feb400000,0x0000002feb500000] [id=35212]
0x00000220187b29b0 ConcurrentGCThread "G1 Main Marker" [stack: 0x0000002feb500000,0x0000002feb600000] [id=32164]
0x00000220187b6920 ConcurrentGCThread "G1 Conc#0" [stack: 0x0000002feb600000,0x0000002feb700000] [id=38596]
[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff98ae4c047]
VM state: not at safepoint (not fully initialized)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x0000022018731600] Heap_lock - owner thread: 0x0000022018735f70
Heap address: 0x000000070a000000, size: 3936 MB, Compressed Oops mode: Zero based, Oop shift amount: 3
CDS archive(s) mapped at: [0x0000000000000000-0x0000000000000000-0x0000000000000000), size 0, SharedBaseAddress: 0x0000000800000000, ArchiveRelocationMode: 0.
Narrow klass base: 0x0000000000000000, Narrow klass shift: 0, Narrow klass range: 0x0
GC Precious Log:
<Empty>
Heap:
garbage-first heap total 0K, used 0K [0x000000070a000000, 0x0000000800000000)
region size 2048K, 0 young (0K), 0 survivors (0K)
[error occurred during error reporting (printing heap information), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff98b230699]
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Classes unloaded (0 events):
No events
Classes redefined (0 events):
No events
Internal exceptions (0 events):
No events
VM Operations (0 events):
No events
Events (1 events):
Event: 0.005 Loaded shared library C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\java.dll
Dynamic libraries:
0x00007ff73f360000 - 0x00007ff73f36e000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\javaw.exe
0x00007ffa24db0000 - 0x00007ffa24fc5000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x00007ffa23cb0000 - 0x00007ffa23d74000 C:\WINDOWS\System32\KERNEL32.DLL
0x00007ffa22160000 - 0x00007ffa22504000 C:\WINDOWS\System32\KERNELBASE.dll
0x00007ffa22670000 - 0x00007ffa22781000 C:\WINDOWS\System32\ucrtbase.dll
0x00007ffa1e0b0000 - 0x00007ffa1e0c8000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\jli.dll
0x00007ffa0f070000 - 0x00007ffa0f089000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\VCRUNTIME140.dll
0x00007ffa23620000 - 0x00007ffa237ce000 C:\WINDOWS\System32\USER32.dll
0x00007ffa22920000 - 0x00007ffa22946000 C:\WINDOWS\System32\win32u.dll
0x00007ffa10fe0000 - 0x00007ffa11273000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.23506.1000_none_f04aa4d392225b35\COMCTL32.dll
0x00007ffa22c30000 - 0x00007ffa22c59000 C:\WINDOWS\System32\GDI32.dll
0x00007ffa24770000 - 0x00007ffa24817000 C:\WINDOWS\System32\msvcrt.dll
0x00007ffa22800000 - 0x00007ffa22919000 C:\WINDOWS\System32\gdi32full.dll
0x00007ffa225d0000 - 0x00007ffa2266a000 C:\WINDOWS\System32\msvcp_win.dll
0x00007ffa22bf0000 - 0x00007ffa22c21000 C:\WINDOWS\System32\IMM32.DLL
0x00007ffa1a890000 - 0x00007ffa1a89c000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\vcruntime140_1.dll
0x00007ff9f3360000 - 0x00007ff9f33f1000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\msvcp140.dll
0x00007ff98ab60000 - 0x00007ff98b7a6000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\server\jvm.dll
0x00007ffa23d80000 - 0x00007ffa23e2e000 C:\WINDOWS\System32\ADVAPI32.dll
0x00007ffa22b40000 - 0x00007ffa22be4000 C:\WINDOWS\System32\sechost.dll
0x00007ffa24b70000 - 0x00007ffa24c87000 C:\WINDOWS\System32\RPCRT4.dll
0x00007ffa235a0000 - 0x00007ffa235a8000 C:\WINDOWS\System32\PSAPI.DLL
0x00007ff9f7800000 - 0x00007ff9f7809000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x00007ffa1e8a0000 - 0x00007ffa1e8d4000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x00007ffa17870000 - 0x00007ffa1787a000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x00007ffa24940000 - 0x00007ffa249b1000 C:\WINDOWS\System32\WS2_32.dll
0x00007ffa211a0000 - 0x00007ffa211b8000 C:\WINDOWS\SYSTEM32\kernel.appcore.dll
0x00007ff9ea2f0000 - 0x00007ff9ea2fa000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\jimage.dll
0x00007ffa1f810000 - 0x00007ffa1fa3e000 C:\WINDOWS\SYSTEM32\DBGHELP.DLL
0x00007ffa23010000 - 0x00007ffa2339a000 C:\WINDOWS\System32\combase.dll
0x00007ffa24c90000 - 0x00007ffa24d67000 C:\WINDOWS\System32\OLEAUT32.dll
0x00007ffa06fc0000 - 0x00007ffa06ff2000 C:\WINDOWS\SYSTEM32\dbgcore.DLL
0x00007ffa22ac0000 - 0x00007ffa22b3b000 C:\WINDOWS\System32\bcryptPrimitives.dll
0x00007ff9a4360000 - 0x00007ff9a4385000 C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\java.dll
dbghelp: loaded successfully - version: 4.0.5 - missing functions: none
symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin;C:\WINDOWS\SYSTEM32;C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.23506.1000_none_f04aa4d392225b35;C:\eclipse\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\server
VM Arguments:
jvm_args: -Dfile.encoding=GBK -XX:+ShowCodeDetailsInExceptionMessages
java_command: com.connor.kwc.createBom.test
java_class_path (initial): D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\sapjco3.jar;D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\sqljdbc4.jar;D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\okhttp-2.7.4.jar;D:\Project\Îýѹ\java\com.connor.kwc.plm\lib\okio-1.13.0.jar;C:\eclipse\eclipse\plugins\org.eclipse.fx.ide.css.jfx8_3.8.0.202204150904.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.ui_3.201.100.v20220826-1037.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.swt_3.121.0.v20220829-1402.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.swt.nl_14000.3.0.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.swt.win32.win32.x86_64_3.121.0.v20220829-1402.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.jface_3.27.0.v20220817-1444.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.commands_3.10.200.v20220512-0851.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.ui.workbench_3.126.0.v20220823-0718.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.e4.ui.workbench3_0.16.0.v20210619-0956.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.runtime_3.26.0.v20220813-0916.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi_3.18.100.v20220817-1601.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi.compatibility.state.nl_14000.3.0.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi.compatibility.state_1.2.700.v20220722-0431.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.osgi.nl_14000.3.0.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.equinox.common_3.16.200.v20220817-1601.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.jobs_3.13.100.v20220817-1539.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.equinox.registry_3.11.200.v20220817-1601.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.equinox.preferences_3.10.100.v20220710-1223.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.osgi.service.prefs_1.1.2.202109301733.jar;D:\WorkEnvironment\tc14JAVA\plugins\org.eclipse.core.contenttype_3.8.200.v20220817-1539.jar;D:\WorkEnvironme
Launcher Type: SUN_STANDARD
[Global flags]
intx CICompilerCount = 4 {product} {ergonomic}
uint ConcGCThreads = 3 {product} {ergonomic}
uint G1ConcRefinementThreads = 10 {product} {ergonomic}
size_t G1HeapRegionSize = 2097152 {product} {ergonomic}
uintx GCDrainStackTargetSize = 64 {product} {ergonomic}
size_t InitialHeapSize = 257949696 {product} {ergonomic}
size_t MarkStackSize = 4194304 {product} {ergonomic}
size_t MaxHeapSize = 4127195136 {product} {ergonomic}
size_t MinHeapDeltaBytes = 2097152 {product} {ergonomic}
size_t MinHeapSize = 8388608 {product} {ergonomic}
uintx NonNMethodCodeHeapSize = 5839372 {pd product} {ergonomic}
uintx NonProfiledCodeHeapSize = 122909434 {pd product} {ergonomic}
uintx ProfiledCodeHeapSize = 122909434 {pd product} {ergonomic}
uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic}
bool SegmentedCodeCache = true {product} {ergonomic}
bool ShowCodeDetailsInExceptionMessages = true {manageable} {command line}
size_t SoftMaxHeapSize = 4127195136 {manageable} {ergonomic}
bool UseCompressedClassPointers = true {product lp64_product} {ergonomic}
bool UseCompressedOops = true {product lp64_product} {ergonomic}
bool UseG1GC = true {product} {ergonomic}
bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic}
Logging:
Log output configuration:
#0: stdout all=warning uptime,level,tags
#1: stderr all=off uptime,level,tags
Environment Variables:
JAVA_HOME=C:\Java\jdk1.8.0_121
CLASSPATH=.;C:\Java\jdk1.8.0_121\lib\dt.jar;C:\Java\jdk1.8.0_121\lib\tools.jar;
PATH=C:/eclipse/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038/jre/bin/server;C:/eclipse/eclipse//plugins/org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038/jre/bin;C:\Java\jdk1.8.0_121\bin;C:\Java\jdk1.8.0_121\jre\bin;C:\ProgramData\Oracle\Java\javapath;D:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;D:\Maven\apache-maven-3.9.1\bin;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;;D:\Program Files (x86)\Microsoft VS Code\bin;D:\Program Files\JetBrains\IntelliJ IDEA 2020.1\bin;;C:\eclipse\eclipse;
USERNAME=admin
OS=Windows_NT
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
TMP=C:\Users\admin\AppData\Local\Temp
TEMP=C:\Users\admin\AppData\Local\Temp
--------------- S Y S T E M ---------------
OS:
Windows 11 , 64 bit Build 23506 (10.0.23506.1000)
OS uptime: 3 days 0:31 hours
CPU: total 12 (initial active 12) (12 cores per cpu, 2 threads per core) family 23 model 96 stepping 1 microcode 0x0, cx8, cmov, fxsr, ht, mmx, 3dnowpref, sse, sse2, sse3, ssse3, sse4a, sse4.1, sse4.2, popcnt, lzcnt, tsc, tscinvbit, avx, avx2, aes, clmul, bmi1, bmi2, adx, sha, fma, vzeroupper, clflush, clflushopt
Memory: 4k page, system-wide physical 15741M (2680M free)
TotalPageFile size 31086M (AvailPageFile size 116M)
current process WorkingSet (physical memory assigned to process): 11M, peak: 11M
current process commit charge ("private bytes"): 64M, peak: 310M
vm_info: OpenJDK 64-Bit Server VM (17.0.4.1+1) for windows-amd64 JRE (17.0.4.1+1), built on Aug 17 2022 07:42:43 by "temurin" with MS VC++ 16.7 (VS2019)
END.

@ -1,4 +1,4 @@
package com.connor.kwc.bombatchchange; package com.connor.kwc.bomBatchChange;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
@ -60,10 +60,10 @@ import com.teamcenter.rac.util.MessageBox;
/** /**
* *
* @ClassName: BomDialog * @ClassName: BomDialog
* @Description: LDBOM * @Description: LDBOM
* @author hcj * @author hcj
* @date 202415 * @date 202415
* *
*/ */
public class BomDialog extends AbstractAIFDialog { public class BomDialog extends AbstractAIFDialog {
@ -76,21 +76,20 @@ public class BomDialog extends AbstractAIFDialog {
private JPanel root; private JPanel root;
private BomDialog $this; private BomDialog $this;
private ResourceBundle rb; private ResourceBundle rb;
private String[] colDisplayNames2 = new String[] { "选择", "组件对象", "组件ID", "组件规格型号", "子件对象", "子件对象ID", "子件规格型号", private String[] colDisplayNames2 = new String[] { "选择", "组件对象", "组件ID", "组件规格型号", "子件对象", "子件对象ID", "子件规格型号", "用量",
"用量", "基础数量", "状态" }; "基础数量", "状态" };
private String[] colDisplayNames3 = new String[] { "选择", "组件对象", "组件ID", "组件规格型号", "状态" }; private String[] colDisplayNames3 = new String[] { "选择", "组件对象", "组件ID", "组件规格型号", "状态" };
private String[] colDisplayNames4 = new String[] { "序号 ", "修改用户", "更改时间", "更改内容" }; private String[] colDisplayNames4 = new String[] { "序号 ", "修改用户", "更改时间", "更改内容" };
private String[] colDisplayNames = new String[] { "选择", "组件对象", "组件ID", "组件规格型号", "子件对象", "子件对象ID", "子件规格型号", private String[] colDisplayNames = new String[] { "选择", "组件对象", "组件ID", "组件规格型号", "子件对象", "子件对象ID", "子件规格型号",
"状态" }; "状态" };
private Map<Integer, List<Object[]>> modelMap = new HashMap<Integer, List<Object[]>>(); private Map<Integer, List<Object[]>> modelMap = new HashMap<Integer, List<Object[]>>();
public BomDialog(AbstractAIFApplication app2) { public BomDialog(AbstractAIFApplication app2) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
super(); super();
this.app = app2; this.app = app2;
this.session = (TCSession) app.getSession(); this.session = (TCSession) app.getSession();
} }
@Override @Override
@ -102,10 +101,10 @@ public class BomDialog extends AbstractAIFDialog {
/** /**
* *
* @Title: initializationData * @Title: initializationData
* @Description: * @Description:
* @param * @param
* @return void * @return void
* @throws * @throws
*/ */
private void initializationData() { private void initializationData() {

@ -1,4 +1,4 @@
package com.connor.kwc.bombatchchange; package com.connor.kwc.bomBatchChange;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;

@ -1,4 +1,4 @@
package com.connor.kwc.bombatchchange; package com.connor.kwc.bomBatchChange;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -7,12 +7,13 @@ import org.eclipse.core.commands.ExecutionEvent;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.aifrcp.AIFUtility;
import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.AbstractHandler;
/** /**
* *
* @ClassName: bomBatchChangeHandler * @ClassName: bomBatchChangeHandler
* @Description: BOM * @Description: BOM
* @author hcj * @author hcj
* @date 202415 * @date 202415
* *
*/ */
public class bomBatchChangeHandler extends AbstractHandler { public class bomBatchChangeHandler extends AbstractHandler {

@ -64,6 +64,7 @@ public class CreateBOMHandler extends AbstractHandler {
if (!itemTypeList if (!itemTypeList
.contains(((TCComponentFolder) target).getStringProperty("object_type"))) { .contains(((TCComponentFolder) target).getStringProperty("object_type"))) {
MessageBox.post("选取的存储位置不正确", "提示", MessageBox.INFORMATION); MessageBox.post("选取的存储位置不正确", "提示", MessageBox.INFORMATION);
return;
} }
} catch (TCException e) { } catch (TCException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -86,6 +87,7 @@ public class CreateBOMHandler extends AbstractHandler {
dataMap.put("templateMap", templateMap); dataMap.put("templateMap", templateMap);
} else { } else {
MessageBox.post("首选项【" + preferencesName + "】长度配置有误", "提示", MessageBox.INFORMATION); MessageBox.post("首选项【" + preferencesName + "】长度配置有误", "提示", MessageBox.INFORMATION);
return;
} }
} else if (target instanceof TCComponentItemRevision) { } else if (target instanceof TCComponentItemRevision) {
@ -107,6 +109,7 @@ public class CreateBOMHandler extends AbstractHandler {
if (!itemTypeList.contains( if (!itemTypeList.contains(
((TCComponentItemRevision) target).getStringProperty("object_type"))) { ((TCComponentItemRevision) target).getStringProperty("object_type"))) {
MessageBox.post("选取的存储位置不正确", "提示", MessageBox.INFORMATION); MessageBox.post("选取的存储位置不正确", "提示", MessageBox.INFORMATION);
return;
} }
// 获取ID数组 // 获取ID数组
String[] ids = preferencesValues[1].split("=")[1].split(";"); String[] ids = preferencesValues[1].split("=")[1].split(";");

@ -75,11 +75,11 @@ public class CreateBOMOperation extends AbstractAIFOperation {
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
if ("folder".equals(type)) { if ("folder".equals(type)) {
NewJFrame2 newJFrame2 = new NewJFrame2(session, dataMap, (TCComponentFolder) target); CreateFolderFram createFolderFram = new CreateFolderFram(session, dataMap, (TCComponentFolder) target);
newJFrame2.setVisible(true); createFolderFram.setVisible(true);
} else if ("revision".equals(type)) { } else if ("revision".equals(type)) {
NewJFrame1 newJFrame2 = new NewJFrame1(session,dataMap, (TCComponentItemRevision) target); CreateItemFram createItemFram = new CreateItemFram(session, dataMap, (TCComponentItemRevision) target);
newJFrame2.setVisible(true); createItemFram.setVisible(true);
} }
} }

@ -27,8 +27,13 @@ import javax.swing.JTextField;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.LayoutStyle; import javax.swing.LayoutStyle;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeCellRenderer;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNode;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNodeSelectionListener;
import com.connor.kwc.util.Util; import com.connor.kwc.util.Util;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
@ -56,11 +61,10 @@ import com.teamcenter.soaictstubs.tagSeq_tHolder;
* @date 20231219 * @date 20231219
* *
*/ */
public class NewJFrame2 extends JFrame { public class CreateFolderFram extends JFrame {
private JButton jButton1; private JButton jButton1;
private JButton jButton2; private JButton jButton2;
private JComboBox<String> jComboBox1;
private JComboBox<String> jComboBox2; private JComboBox<String> jComboBox2;
private JComboBox<String> jComboBox3; private JComboBox<String> jComboBox3;
private JLabel jLabel1; private JLabel jLabel1;
@ -92,7 +96,7 @@ public class NewJFrame2 extends JFrame {
* @param session * @param session
* @param target * @param target
*/ */
public NewJFrame2(TCSession session, Map<String, Object> dataMap, TCComponentFolder target) { public CreateFolderFram(TCSession session, Map<String, Object> dataMap, TCComponentFolder target) {
this.session = session; this.session = session;
this.dataMap = dataMap; this.dataMap = dataMap;
this.target = target; this.target = target;
@ -147,7 +151,7 @@ public class NewJFrame2 extends JFrame {
jLabel3.setText("类型:"); jLabel3.setText("类型:");
ArrayList<String> typeList = (ArrayList<String>) dataMap.get("typeList"); ArrayList<String> typeList = (ArrayList<String>) dataMap.get("typeList");
//String[] typeArray = (String[]) typeList.toArray(); // String[] typeArray = (String[]) typeList.toArray();
String[] typeArray = typeList.stream().toArray(String[]::new); String[] typeArray = typeList.stream().toArray(String[]::new);
jComboBox2.setModel(new DefaultComboBoxModel<>(typeArray)); jComboBox2.setModel(new DefaultComboBoxModel<>(typeArray));
jComboBox2.setSelectedIndex(0); jComboBox2.setSelectedIndex(0);
@ -169,7 +173,7 @@ public class NewJFrame2 extends JFrame {
} }
} }
String[] array = tempList.stream().toArray(String[]::new); String[] array = tempList.stream().toArray(String[]::new);
// String[] array = (String[]) tempList.toArray(); // String[] array = (String[]) tempList.toArray();
jComboBox3.setModel(new DefaultComboBoxModel<>(array)); jComboBox3.setModel(new DefaultComboBoxModel<>(array));
jComboBox3.setSelectedIndex(0); jComboBox3.setSelectedIndex(0);
jLabel4.setText("模板:"); jLabel4.setText("模板:");
@ -188,6 +192,11 @@ public class NewJFrame2 extends JFrame {
jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener()); jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener());
jTree1.setModel(model); jTree1.setModel(model);
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer()); jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
// 展开所有节点并选中
for (int i = 0; i < jTree1.getRowCount(); i++) {
jTree1.expandRow(i);
}
rootNode.setSelected(true);
} }
} catch (TCException e1) { } catch (TCException e1) {
@ -320,7 +329,7 @@ public class NewJFrame2 extends JFrame {
int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标 int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标
this.setLocation(x, y); // 设置Frame的位置 this.setLocation(x, y); // 设置Frame的位置
this.setDefaultCloseOperation(2); this.setDefaultCloseOperation(2);
// 类型下拉框监听,更新模板下拉框 // 类型下拉框监听,更新模板下拉框
jComboBox2.addItemListener(new ItemListener() { jComboBox2.addItemListener(new ItemListener() {
@ -342,7 +351,7 @@ public class NewJFrame2 extends JFrame {
} }
} }
String[] array = tempList.stream().toArray(String[]::new); String[] array = tempList.stream().toArray(String[]::new);
//String[] array = (String[]) tempList.toArray(); // String[] array = (String[]) tempList.toArray();
jComboBox3.setModel(new DefaultComboBoxModel<>(array)); jComboBox3.setModel(new DefaultComboBoxModel<>(array));
} }
}); });
@ -368,6 +377,12 @@ public class NewJFrame2 extends JFrame {
jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener()); jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener());
jTree1.setModel(model); jTree1.setModel(model);
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer()); jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
jTree1.setRowHeight(0);
// 展开所有节点并选中
for (int i = 0; i < jTree1.getRowCount(); i++) {
jTree1.expandRow(i);
}
rootNode.setSelected(true);
} }
} catch (Exception e2) { } catch (Exception e2) {
// TODO: handle exception // TODO: handle exception
@ -377,10 +392,15 @@ public class NewJFrame2 extends JFrame {
} }
}); });
// 确定按钮更新 // 确定按钮更新
jButton1.addActionListener(new ActionListener() { jButton1.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
//开旁路
Util.setByPass(true);
// 必填判定 // 必填判定
String field1 = jTextField1.getText(); String field1 = jTextField1.getText();
String field2 = jTextField2.getText(); String field2 = jTextField2.getText();
@ -391,44 +411,57 @@ public class NewJFrame2 extends JFrame {
// 开始复制对象 // 开始复制对象
TCComponentItemRevision revision = (TCComponentItemRevision) component; TCComponentItemRevision revision = (TCComponentItemRevision) component;
try { try {
if (itemMapIsSel.get(revision.getStringProperty("object_string")).isSelected) { if (itemMapIsSel.get(revision.getStringProperty("object_name")).isSelected) {
TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A"); TCComponentItem newItem;
//TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A", jTextField2.getText(),"", true, null); try {
newItem = revision.saveAsItem(jTextField1.getText(), null);
} catch (Exception e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
MessageBox.post("创建失败ID【"+jTextField1.getText()+"】已存在于TC", "提示", MessageBox.INFORMATION);
return;
}
// TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A",
// jTextField2.getText(),"", true, null);
TCComponentItemRevision newRevision = newItem.getLatestItemRevision(); TCComponentItemRevision newRevision = newItem.getLatestItemRevision();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow"); .getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null); TCComponentBOMWindow view = winType.create(null);
TCComponentBOMLine line = view.setWindowTopLine(revision.getItem(), revision, null, null); TCComponentBOMLine line = view.setWindowTopLine(newItem, newRevision, null, null);
// 根据首选项的值复制对象属性 // 根据首选项的值复制对象属性
for (String attrStr : sxxdate) { for (String attrStr : sxxdate) {
if (attrStr.startsWith(line.getItemRevision().getItem().getStringProperty("object_type"))) { if (attrStr.startsWith(line.getItemRevision().getItem().getStringProperty("object_type"))) {
try { try {
//Util.replaceAttribute(line, newRevision, attrStr); // Util.replaceAttribute(line, newRevision, attrStr);
String[] replaces = attrStr.split("=")[1].split(";"); String[] replaces = attrStr.split("=")[1].split(";");
for(String replace : replaces) { for (String replace : replaces) {
String[] getValues = replace.split("\\."); String[] getValues = replace.split("\\.");
Object val = ""; Object val = "";
if(getValues[0].equals("item")) { if (getValues[0].equals("item")) {
val = Util.getTCPropertyValue(line.getItem(), getValues[1]); val = Util.getTCPropertyValue(revision, getValues[1]);
Util.setTCPropertyValue(newRevision.getItem(), getValues[1], val); Util.setTCPropertyValue(newRevision.getItem(), getValues[1], val);
//val = item.getProperty(getValues[1]); // val = item.getProperty(getValues[1]);
}else if(getValues[0].equals("rev")) { } else if (getValues[0].equals("rev")) {
val = Util.getTCPropertyValue(line.getItemRevision(), getValues[1]); val = Util.getTCPropertyValue(revision, getValues[1]);
Util.setTCPropertyValue(newRevision, getValues[1], val); Util.setTCPropertyValue(newRevision, getValues[1], val);
//val = rev.getProperty(getValues[1]); // val = rev.getProperty(getValues[1]);
}else if(getValues[0].equals("rm")) { } else if (getValues[0].equals("rm")) {
TCComponent[] oldreferenceListProperty = line.getItemRevision().getReferenceListProperty("IMAN_master_form_rev"); TCComponent[] oldreferenceListProperty = revision
.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0]; TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
val = Util.getTCPropertyValue(oldform, getValues[1]); val = Util.getTCPropertyValue(oldform, getValues[1]);
TCComponent[] newreferenceListProperty = newRevision.getReferenceListProperty("IMAN_master_form_rev"); TCComponent[] newreferenceListProperty = newRevision
.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0]; TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
Util.setTCPropertyValue(newform, getValues[1], val); Util.setTCPropertyValue(newform, getValues[1], val);
//val = form.getProperty(getValues[1]); // val = form.getProperty(getValues[1]);
}else if(getValues[0].equals("bom")) { } else if (getValues[0].equals("bom")) {
val = Util.getTCPropertyValue(line, getValues[1]); val = Util.getTCPropertyValue(line, getValues[1]);
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view1 = winType1.create(null); TCComponentBOMWindow view1 = winType1.create(null);
TCComponentBOMLine line1 = view1.setWindowTopLine(newRevision.getItem(), newRevision, null, null); TCComponentBOMLine line1 = view1.setWindowTopLine(revision.getItem(),
revision, null, null);
Util.setTCPropertyValue(line1, getValues[1], val); Util.setTCPropertyValue(line1, getValues[1], val);
} }
} }
@ -440,9 +473,9 @@ public class NewJFrame2 extends JFrame {
} }
} }
// 递归BOM结构删除未选中的对象 // 递归BOM结构删除未选中的对象
collectAllBomLine(line, jTextField1.getText(), winType, view, false); collectAllBomLine(line, jTextField1.getText(), winType, view, true);
TCComponentItemRevision itemRevision = line.getItemRevision(); TCComponentItem item = line.getItem();
target.add("contents", itemRevision); target.add("contents", item);
MessageBox.post("创建成功", "提示", MessageBox.INFORMATION); MessageBox.post("创建成功", "提示", MessageBox.INFORMATION);
return; return;
@ -453,6 +486,9 @@ public class NewJFrame2 extends JFrame {
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
}finally {
//关闭旁路
Util.setByPass(false);
} }
} }
}); });
@ -470,7 +506,7 @@ public class NewJFrame2 extends JFrame {
*/ */
public void collectAllBomLine(TCComponentBOMLine bomLine, String newId, TCComponentBOMWindowType winType, public void collectAllBomLine(TCComponentBOMLine bomLine, String newId, TCComponentBOMWindowType winType,
TCComponentBOMWindow newview, Boolean flag) throws TCException { TCComponentBOMWindow newview, Boolean flag) throws TCException {
String objectName = bomLine.getItemRevision().getStringProperty("object_string"); String objectName = bomLine.getItemRevision().getStringProperty("object_name");
boolean selected = itemMapIsSel.get(objectName).isSelected(); boolean selected = itemMapIsSel.get(objectName).isSelected();
// 判断界面是否选中 // 判断界面是否选中
if (selected) { if (selected) {
@ -488,41 +524,59 @@ public class NewJFrame2 extends JFrame {
} else { } else {
// 当不是第一次递归的时候每次递归另存一个对象把要同步的数据同步过去然后将对象替换到新的bomview上去 // 当不是第一次递归的时候每次递归另存一个对象把要同步的数据同步过去然后将对象替换到新的bomview上去
String itemId = bomLine.getItemRevision().getStringProperty("item_id"); String itemId = bomLine.getItemRevision().getStringProperty("item_id");
System.out.println("itemID:" + itemId);
System.out.println(bomLine.getItemRevision().getStringProperty("object_string"));
String newItemId = itemId.replaceFirst(itemId.split("-")[0], jTextField1.getText()); String newItemId = itemId.replaceFirst(itemId.split("-")[0], jTextField1.getText());
TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(newItemId, "A"); System.out.println("newItemId:"+newItemId);
//TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(jTextField1.getText(), "A", bomLine.getItemRevision().getStringProperty("object_name"), "", true, null); TCComponentItem saveAsItem;
try {
saveAsItem = bomLine.getItemRevision().saveAsItem(newItemId, null);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post("创建失败ID【"+newItemId+"】已存在于TC", "提示", MessageBox.INFORMATION);
return;
}
// TCComponentItem saveAsItem =
// bomLine.getItemRevision().saveAsItem(jTextField1.getText(), "A",
// bomLine.getItemRevision().getStringProperty("object_name"), "", true, null);
TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision(); TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision();
// 替换属性 // 替换属性
for (String attrStr : sxxdate) { for (String attrStr : sxxdate) {
if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) { if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) {
try { try {
//Util.replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision, attrStr); // Util.replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision,
String[] replaces = attrStr.split("=")[1].split(";"); // attrStr);
for(String replace : replaces) { String[] replaces = attrStr.split("=")[1].split(";");
for (String replace : replaces) {
String[] getValues = replace.split("\\."); String[] getValues = replace.split("\\.");
Object val = ""; Object val = "";
if(getValues[0].equals("item")) { if (getValues[0].equals("item")) {
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItem(), getValues[1]); val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItem(), getValues[1]);
Util.setTCPropertyValue(latestItemRevision.getItem(), getValues[1], val); Util.setTCPropertyValue(latestItemRevision.getItem(), getValues[1], val);
//val = item.getProperty(getValues[1]); // val = item.getProperty(getValues[1]);
}else if(getValues[0].equals("rev")) { } else if (getValues[0].equals("rev")) {
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItemRevision(), getValues[1]); val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItemRevision(),
getValues[1]);
Util.setTCPropertyValue(latestItemRevision, getValues[1], val); Util.setTCPropertyValue(latestItemRevision, getValues[1], val);
//val = rev.getProperty(getValues[1]); // val = rev.getProperty(getValues[1]);
}else if(getValues[0].equals("rm")) { } else if (getValues[0].equals("rm")) {
TCComponent[] oldreferenceListProperty = itemMapBoMap.get(objectName).getItemRevision().getReferenceListProperty("IMAN_master_form_rev"); TCComponent[] oldreferenceListProperty = itemMapBoMap.get(objectName)
.getItemRevision().getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0]; TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
val = Util.getTCPropertyValue(oldform, getValues[1]); val = Util.getTCPropertyValue(oldform, getValues[1]);
TCComponent[] newreferenceListProperty = latestItemRevision.getReferenceListProperty("IMAN_master_form_rev"); TCComponent[] newreferenceListProperty = latestItemRevision
.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0]; TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
Util.setTCPropertyValue(newform, getValues[1], val); Util.setTCPropertyValue(newform, getValues[1], val);
//val = form.getProperty(getValues[1]); // val = form.getProperty(getValues[1]);
}else if(getValues[0].equals("bom")) { } else if (getValues[0].equals("bom")) {
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName), getValues[1]); val = Util.getTCPropertyValue(itemMapBoMap.get(objectName), getValues[1]);
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view1 = winType1.create(null); TCComponentBOMWindow view1 = winType1.create(null);
TCComponentBOMLine line1 = view1.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null); TCComponentBOMLine line1 = view1.setWindowTopLine(latestItemRevision.getItem(),
latestItemRevision, null, null);
Util.setTCPropertyValue(line1, getValues[1], val); Util.setTCPropertyValue(line1, getValues[1], val);
} }
} }
@ -535,8 +589,10 @@ public class NewJFrame2 extends JFrame {
} }
// 替换分类属性 // 替换分类属性
//Ìí¼ÓÊôÐÔ // 添加属性
latestItemRevision.setStringProperty("kwc6_ProductID", jTextField1.getText()); TCComponent[] referenceListProperty = latestItemRevision.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm form = (TCComponentForm) referenceListProperty[0];
form.setStringProperty("XYProductID", jTextField1.getText());
// 替换bom行 // 替换bom行
bomLine.replace(saveAsItem, latestItemRevision, null); bomLine.replace(saveAsItem, latestItemRevision, null);
if (bomLine.hasChildren()) { if (bomLine.hasChildren()) {
@ -562,8 +618,8 @@ public class NewJFrame2 extends JFrame {
* @throws TCException * @throws TCException
*/ */
private void getTree(TCComponentBOMLine bomLine, CheckBoxTreeNode rootNode) throws TCException { private void getTree(TCComponentBOMLine bomLine, CheckBoxTreeNode rootNode) throws TCException {
itemMapIsSel.put(bomLine.getItemRevision().getStringProperty("object_string"), rootNode); itemMapIsSel.put(bomLine.getItemRevision().getStringProperty("object_name"), rootNode);
itemMapBoMap.put(bomLine.getItemRevision().getStringProperty("object_string"), bomLine); itemMapBoMap.put(bomLine.getItemRevision().getStringProperty("object_name"), bomLine);
if (bomLine.hasChildren()) { if (bomLine.hasChildren()) {
AIFComponentContext[] children = bomLine.getChildren(); AIFComponentContext[] children = bomLine.getChildren();
for (AIFComponentContext aifComponentContext : children) { for (AIFComponentContext aifComponentContext : children) {

@ -32,16 +32,24 @@ import javax.swing.JTextField;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.LayoutStyle; import javax.swing.LayoutStyle;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeCellRenderer;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNode;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNodeSelectionListener;
import com.connor.kwc.util.Util; import com.connor.kwc.util.Util;
import com.connor.kwc.util.UtilBean;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; 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.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMView; import com.teamcenter.rac.kernel.TCComponentBOMView;
import com.teamcenter.rac.kernel.TCComponentBOMWindow; import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType; import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentBomChange;
import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentForm; import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentGDE; import com.teamcenter.rac.kernel.TCComponentGDE;
@ -59,7 +67,7 @@ import com.teamcenter.rac.util.MessageBox;
* @date 20231219 * @date 20231219
* *
*/ */
public class NewJFrame1 extends JFrame { public class CreateItemFram extends JFrame {
private TCSession session; private TCSession session;
private Map<String, Object> dataMap; private Map<String, Object> dataMap;
@ -93,7 +101,7 @@ public class NewJFrame1 extends JFrame {
/** /**
* Creates new form NewJFrame2 * Creates new form NewJFrame2
*/ */
public NewJFrame1(TCSession session, Map<String, Object> dataMap, TCComponentItemRevision target) { public CreateItemFram(TCSession session, Map<String, Object> dataMap, TCComponentItemRevision target) {
this.session = session; this.session = session;
this.dataMap = dataMap; this.dataMap = dataMap;
this.target = target; this.target = target;
@ -155,8 +163,8 @@ public class NewJFrame1 extends JFrame {
jLabel3.setText("类型:"); jLabel3.setText("类型:");
ArrayList<String> typeList = (ArrayList<String>) dataMap.get("typeList"); ArrayList<String> typeList = (ArrayList<String>) dataMap.get("typeList");
for(String tyString : typeList) { for (String tyString : typeList) {
System.out.println("tyString:"+tyString); System.out.println("tyString:" + tyString);
} }
String[] typeArray = typeList.stream().toArray(String[]::new); String[] typeArray = typeList.stream().toArray(String[]::new);
jComboBox2.setModel(new DefaultComboBoxModel<>(typeArray)); jComboBox2.setModel(new DefaultComboBoxModel<>(typeArray));
@ -185,7 +193,7 @@ public class NewJFrame1 extends JFrame {
jLabel4.setText("模板:"); jLabel4.setText("模板:");
try { try {
// 根据模板创建树结构,给用户选择 // 根据模板创建树结构,给用户选择
System.out.println("tempId:"+tempIdList.get(0)); System.out.println("tempId:" + tempIdList.get(0));
component = session.stringToComponent(tempIdList.get(0)); component = session.stringToComponent(tempIdList.get(0));
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null); TCComponentBOMWindow view = winType.create(null);
@ -199,6 +207,11 @@ public class NewJFrame1 extends JFrame {
jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener()); jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener());
jTree1.setModel(model); jTree1.setModel(model);
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer()); jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
// 展开所有节点并选中
for (int i = 0; i < jTree1.getRowCount(); i++) {
jTree1.expandRow(i);
}
rootNode.setSelected(true);
} }
} catch (TCException e1) { } catch (TCException e1) {
@ -206,9 +219,6 @@ public class NewJFrame1 extends JFrame {
e1.printStackTrace(); e1.printStackTrace();
} }
jLabel5.setText("专业:"); jLabel5.setText("专业:");
jComboBox4.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBox4.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
@ -342,11 +352,19 @@ public class NewJFrame1 extends JFrame {
int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标 int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标
this.setLocation(x, y); // 设置Frame的位置 this.setLocation(x, y); // 设置Frame的位置
this.setDefaultCloseOperation(2); this.setDefaultCloseOperation(2);
int lastDashIndex = target.getStringProperty("item_id").lastIndexOf('-');
jTextField1.setText(target.getStringProperty("item_id")); if (lastDashIndex != -1) {
// 获取破折号之前的所有内容
String valueBeforeLastDash = target.getStringProperty("item_id").substring(0, lastDashIndex);
jTextField1.setText(valueBeforeLastDash);
} else {
jTextField1.setText(target.getStringProperty("item_id"));
}
// jTextField2.setText(target.getStringProperty("object_name")); // jTextField2.setText(target.getStringProperty("object_name"));
// jTextField1.setEditable(false); // jTextField1.setEditable(false);
jTextField2.setEditable(false); jTextField2.setEditable(false);
// 类型下拉框监听,更新模板下拉框 // 类型下拉框监听,更新模板下拉框
jComboBox2.addItemListener(new ItemListener() { jComboBox2.addItemListener(new ItemListener() {
@ -368,7 +386,7 @@ public class NewJFrame1 extends JFrame {
} }
} }
String[] array = tempList.stream().toArray(String[]::new); String[] array = tempList.stream().toArray(String[]::new);
//String[] array = (String[]) tempList.toArray(); // String[] array = (String[]) tempList.toArray();
jComboBox3.setModel(new DefaultComboBoxModel<>(array)); jComboBox3.setModel(new DefaultComboBoxModel<>(array));
} }
}); });
@ -394,6 +412,12 @@ public class NewJFrame1 extends JFrame {
jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener()); jTree1.addMouseListener(new CheckBoxTreeNodeSelectionListener());
jTree1.setModel(model); jTree1.setModel(model);
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer()); jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
jTree1.setRowHeight(0);
// 展开所有节点并选中
for (int i = 0; i < jTree1.getRowCount(); i++) {
jTree1.expandRow(i);
}
rootNode.setSelected(true);
} }
} catch (Exception e2) { } catch (Exception e2) {
// TODO: handle exception // TODO: handle exception
@ -416,80 +440,156 @@ public class NewJFrame1 extends JFrame {
// 开始复制对象 // 开始复制对象
TCComponentItemRevision revision = (TCComponentItemRevision) component; TCComponentItemRevision revision = (TCComponentItemRevision) component;
try { try {
if (itemMapIsSel.get(revision.getStringProperty("object_name")).isSelected) { // 开旁路
TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A"); Util.setByPass(true);
// TCComponentItem newItem = revision.saveAsItem(jTextField1.getText(), "A", revision.getStringProperty("object_name"),"", true, null); TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentItemRevision newRevision = newItem.getLatestItemRevision(); TCComponentBOMWindow view = winType.create(null);
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session // 获取顶层模板的itemID
.getTypeComponent("BOMWindow"); String itemId = revision.getItem().getStringProperty(UtilBean.ITEMID);
TCComponentBOMWindow view = winType.create(null); // 循环根节点判断下面的对象itemID是否包含根节点id如果包含则另存不包含则直接引用
TCComponentBOMLine line = view.setWindowTopLine(newItem, newRevision, null, null); TCComponentBOMLine line = view.setWindowTopLine(revision.getItem(), revision, null, null);
// 根据首选项的值复制对象属性 List<TCComponentItem> itemList = new ArrayList<TCComponentItem>();
for (String attrStr : sxxdate) { eachAllBomLine(line, itemId, jTextField1.getText(), itemList);
if (attrStr.startsWith(line.getItemRevision().getItem().getStringProperty("object_type"))) {
try { /*
String[] replaces = attrStr.split("=")[1].split(";"); * if (itemMapIsSel.get(revision.getStringProperty("object_name")).isSelected) {
for(String replace : replaces) { * TCComponentItem newItem; try { newItem =
String[] getValues = replace.split("\\."); * revision.saveAsItem(jTextField1.getText(), null); } catch (Exception e2) { //
Object val = ""; * TODO Auto-generated catch block e2.printStackTrace();
if(getValues[0].equals("item")) { * MessageBox.post("创建失败ID【"+jTextField1.getText()+"】已存在于TC", "提示",
val = Util.getTCPropertyValue(revision.getItem(), getValues[1]); * MessageBox.INFORMATION); return; } TCComponentItem newItem =
Util.setTCPropertyValue(newRevision.getItem(), getValues[1], val); * revision.saveAsItem(jTextField1.getText(), "A",
//val = item.getProperty(getValues[1]); * revision.getStringProperty("object_name"),"", true, null);
}else if(getValues[0].equals("rev")) { * TCComponentItemRevision newRevision = newItem.getLatestItemRevision();
val = Util.getTCPropertyValue(revision, getValues[1]); *
Util.setTCPropertyValue(newRevision, getValues[1], val); * TCComponentBOMLine line = view.setWindowTopLine(newItem, newRevision, null,
//val = rev.getProperty(getValues[1]); * null);
}else if(getValues[0].equals("rm")) { *
TCComponent[] oldreferenceListProperty = revision.getReferenceListProperty("IMAN_master_form_rev"); * // 递归BOM结构删除未选中的对象 collectAllBomLine(line, jTextField1.getText(), winType,
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0]; * line.getBOMView(), true); AIFComponentContext[] children =
val = Util.getTCPropertyValue(oldform, getValues[1]); * line.getChildren();
TCComponent[] newreferenceListProperty = newRevision.getReferenceListProperty("IMAN_master_form_rev"); */
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
Util.setTCPropertyValue(newform, getValues[1], val); TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session
//val = form.getProperty(getValues[1]); .getTypeComponent("BOMWindow");
}else if(getValues[0].equals("bom")) { TCComponentBOMWindow view1 = winType1.create(null);
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMLine revLine = view1.setWindowTopLine(target.getItem(), target, null, null);
TCComponentBOMWindow view1 = winType1.create(null); for (TCComponentItem line2 : itemList) {
TCComponentBOMLine line1 = view1.setWindowTopLine(revision.getItem(), revision, null, null); revLine.add(line2, line2.getLatestItemRevision(), null, false, "");
val = Util.getTCPropertyValue(line1, getValues[1]); view1.save();
Util.setTCPropertyValue(line, getValues[1], val);
}
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
break;
}
}
// 递归BOM结构删除未选中的对象
collectAllBomLine(line, jTextField1.getText(), winType, line.getBOMView(), true);
AIFComponentContext[] children = line.getChildren();
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow view1 = winType1.create(null);
TCComponentBOMLine revLine = view1.setWindowTopLine(target.getItem(), target, null, null);
for(AIFComponentContext line2 : children) {
TCComponentBOMLine bomLine = (TCComponentBOMLine)line2.getComponent();
revLine.add(bomLine.getItem(), bomLine.getItemRevision(), null, false, "");
view1.save();
}
MessageBox.post("创建成功", "提示", MessageBox.INFORMATION);
return;
} else {
return;
} }
dispose();
MessageBox.post("创建成功", "提示", MessageBox.INFORMATION);
return;
} catch (TCException e1) { } catch (TCException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
dispose();
MessageBox.post("创建失败", "提示", MessageBox.INFORMATION);
e1.printStackTrace(); e1.printStackTrace();
} finally {
// 关闭旁路
Util.setByPass(false);
} }
} }
}); });
} }
/**
* BOM
*
* @param view
* @param topBomLine
* @param newId
* @param itemList
* @param string
* @param winType
* @param newview
* @throws TCException
*/
public void eachAllBomLine(TCComponentBOMLine bomLine, String isHasId, String newId, List<TCComponentItem> itemList)
throws TCException {
AIFComponentContext[] children = bomLine.getChildren();
for (AIFComponentContext componentContext : children) {
TCComponentBOMLine line = (TCComponentBOMLine) componentContext.getComponent();
// 判断是否选中
String objectName = line.getItemRevision().getStringProperty(UtilBean.OBJECTNAMR);
boolean selected = itemMapIsSel.get(objectName).isSelected();
System.out.println(selected);
if (selected) {
String itemId = line.getItem().getStringProperty(UtilBean.ITEMID);
System.out.println(itemId+"=========="+isHasId);
if (itemId.contains(isHasId)) {
// 另存
char separator = '-';
// 替换并组合新的字符串
String newString = newId + itemId.substring(itemId.indexOf(separator));
System.out.println(newString);
TCComponentItem saveAsItem;
try {
saveAsItem = line.getItemRevision().saveAsItem(newString, null);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post("创建失败ID【" + newString + "】已存在于TC", "提示", MessageBox.INFORMATION);
return;
}
TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision();
// 替换属性
for (String attrStr : sxxdate) {
if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) {
try {
// Util.replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision,
// attrStr);
String[] replaces = attrStr.split("=")[1].split(";");
for (String replace : replaces) {
String[] getValues = replace.split("\\.");
Object val = "";
if (getValues[0].equals("item")) {
val = Util.getTCPropertyValue(line.getItem(), getValues[1]);
Util.setTCPropertyValue(latestItemRevision.getItem(), getValues[1], val);
// val = item.getProperty(getValues[1]);
} else if (getValues[0].equals("rev")) {
val = Util.getTCPropertyValue(line.getItemRevision(), getValues[1]);
Util.setTCPropertyValue(latestItemRevision, getValues[1], val);
// val = rev.getProperty(getValues[1]);
} else if (getValues[0].equals("rm")) {
TCComponent[] oldreferenceListProperty = line.getItemRevision()
.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
val = Util.getTCPropertyValue(oldform, getValues[1]);
TCComponent[] newreferenceListProperty = latestItemRevision
.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
Util.setTCPropertyValue(newform, getValues[1], val);
// val = form.getProperty(getValues[1]);
} else if (getValues[0].equals("bom")) {
val = Util.getTCPropertyValue(line, getValues[1]);
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view1 = winType1.create(null);
TCComponentBOMLine line1 = view1.setWindowTopLine(latestItemRevision.getItem(),
latestItemRevision, null, null);
Util.setTCPropertyValue(line1, getValues[1], val);
}
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
break;
}
}
itemList.add(saveAsItem);
} else {
// 引用
itemList.add(line.getItem());
}
}
}
}
/** /**
* BOM * BOM
* *
@ -520,43 +620,60 @@ public class NewJFrame1 extends JFrame {
} else { } else {
// 当不是第一次递归的时候每次递归另存一个对象把要同步的数据同步过去然后将对象替换到新的bomview上去 // 当不是第一次递归的时候每次递归另存一个对象把要同步的数据同步过去然后将对象替换到新的bomview上去
String itemId = bomLine.getItemRevision().getStringProperty("item_id"); String itemId = bomLine.getItemRevision().getStringProperty("item_id");
System.out.println("itemID:"+itemId); System.out.println("itemID:" + itemId);
System.out.println(bomLine.getItemRevision().getStringProperty("object_string")); System.out.println(bomLine.getItemRevision().getStringProperty("object_string"));
String newItemId = itemId.replaceFirst(itemId.split("-")[0], jTextField1.getText()); String newItemId = itemId.replaceFirst(itemId.split("-")[0], jTextField1.getText());
System.out.println("newItemId:"+newItemId); System.out.println("newItemId:" + newItemId);
TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(newItemId, "A"); TCComponentItem saveAsItem;
//TCComponentItem saveAsItem = bomLine.getItemRevision().saveAsItem(jTextField1.getText(), "A",bomLine.getItemRevision().getStringProperty("object_name"), "", true, null); try {
saveAsItem = bomLine.getItemRevision().saveAsItem(newItemId, null);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post("创建失败ID【" + newItemId + "】已存在于TC", "提示", MessageBox.INFORMATION);
return;
}
// TCComponentItem saveAsItem =
// bomLine.getItemRevision().saveAsItem(jTextField1.getText(),
// "A",bomLine.getItemRevision().getStringProperty("object_name"), "", true,
// null);
TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision(); TCComponentItemRevision latestItemRevision = saveAsItem.getLatestItemRevision();
// 替换属性 // 替换属性
for (String attrStr : sxxdate) { for (String attrStr : sxxdate) {
if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) { if (attrStr.startsWith(bomLine.getItemRevision().getItem().getStringProperty("object_type"))) {
try { try {
//Util.replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision, attrStr); // Util.replaceAttribute(itemMapBoMap.get(objectName), latestItemRevision,
String[] replaces = attrStr.split("=")[1].split(";"); // attrStr);
for(String replace : replaces) { String[] replaces = attrStr.split("=")[1].split(";");
for (String replace : replaces) {
String[] getValues = replace.split("\\."); String[] getValues = replace.split("\\.");
Object val = ""; Object val = "";
if(getValues[0].equals("item")) { if (getValues[0].equals("item")) {
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItem(), getValues[1]); val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItem(), getValues[1]);
Util.setTCPropertyValue(latestItemRevision.getItem(), getValues[1], val); Util.setTCPropertyValue(latestItemRevision.getItem(), getValues[1], val);
//val = item.getProperty(getValues[1]); // val = item.getProperty(getValues[1]);
}else if(getValues[0].equals("rev")) { } else if (getValues[0].equals("rev")) {
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItemRevision(), getValues[1]); val = Util.getTCPropertyValue(itemMapBoMap.get(objectName).getItemRevision(),
getValues[1]);
Util.setTCPropertyValue(latestItemRevision, getValues[1], val); Util.setTCPropertyValue(latestItemRevision, getValues[1], val);
//val = rev.getProperty(getValues[1]); // val = rev.getProperty(getValues[1]);
}else if(getValues[0].equals("rm")) { } else if (getValues[0].equals("rm")) {
TCComponent[] oldreferenceListProperty = itemMapBoMap.get(objectName).getItemRevision().getReferenceListProperty("IMAN_master_form_rev"); TCComponent[] oldreferenceListProperty = itemMapBoMap.get(objectName)
.getItemRevision().getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0]; TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
val = Util.getTCPropertyValue(oldform, getValues[1]); val = Util.getTCPropertyValue(oldform, getValues[1]);
TCComponent[] newreferenceListProperty = latestItemRevision.getReferenceListProperty("IMAN_master_form_rev"); TCComponent[] newreferenceListProperty = latestItemRevision
.getReferenceListProperty("IMAN_master_form_rev");
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0]; TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
Util.setTCPropertyValue(newform, getValues[1], val); Util.setTCPropertyValue(newform, getValues[1], val);
//val = form.getProperty(getValues[1]); // val = form.getProperty(getValues[1]);
}else if(getValues[0].equals("bom")) { } else if (getValues[0].equals("bom")) {
val = Util.getTCPropertyValue(itemMapBoMap.get(objectName), getValues[1]); val = Util.getTCPropertyValue(itemMapBoMap.get(objectName), getValues[1]);
TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); TCComponentBOMWindowType winType1 = (TCComponentBOMWindowType) session
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view1 = winType1.create(null); TCComponentBOMWindow view1 = winType1.create(null);
TCComponentBOMLine line1 = view1.setWindowTopLine(latestItemRevision.getItem(), latestItemRevision, null, null); TCComponentBOMLine line1 = view1.setWindowTopLine(latestItemRevision.getItem(),
latestItemRevision, null, null);
Util.setTCPropertyValue(line1, getValues[1], val); Util.setTCPropertyValue(line1, getValues[1], val);
} }
} }
@ -568,14 +685,14 @@ public class NewJFrame1 extends JFrame {
} }
} }
// 替换分类属性 // 替换分类属性
//添加属性 // 添加属性
latestItemRevision.setStringProperty("kwc6_ProductID", jTextField1.getText()); latestItemRevision.setStringProperty("kwc6_ProductID", jTextField1.getText());
// 添加bom行 // 添加bom行
String stringProperty = bomLine.getItemRevision().getStringProperty("object_string"); String stringProperty = bomLine.getItemRevision().getStringProperty("object_string");
System.out.println("要替换的老行:"+stringProperty); System.out.println("要替换的老行:" + stringProperty);
String stringProperty2 = latestItemRevision.getStringProperty("object_string"); String stringProperty2 = latestItemRevision.getStringProperty("object_string");
System.out.println("要替换的新行:"+stringProperty2); System.out.println("要替换的新行:" + stringProperty2);
bomLine.replace(saveAsItem, latestItemRevision, null); bomLine.replace(saveAsItem, latestItemRevision, null);
if (bomLine.hasChildren()) { if (bomLine.hasChildren()) {
for (AIFComponentContext aifComponentContext : bomLine.getChildren()) { for (AIFComponentContext aifComponentContext : bomLine.getChildren()) {
@ -613,6 +730,5 @@ public class NewJFrame1 extends JFrame {
} }
} }
} }
} }

@ -6,17 +6,13 @@
*/ */
package com.connor.kwc.createBom; package com.connor.kwc.createBom;
import java.awt.EventQueue;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode; import com.connor.kwc.jtreeUtilClass.CheckBoxTreeCellRenderer;
import javax.swing.tree.TreePath; import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNode;
import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNodeSelectionListener;
/** /**
* @ClassName: test * @ClassName: test
@ -27,46 +23,14 @@ import javax.swing.tree.TreePath;
*/ */
public class test { public class test {
public static void main(String[] args) { public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("CheckBoxTreeDemo");
frame.setBounds(200, 200, 400, 400);
JTree tree = new JTree();
CheckBoxTreeNode rootNode = new CheckBoxTreeNode("root");
CheckBoxTreeNode node1 = new CheckBoxTreeNode("node_1");
CheckBoxTreeNode node1_1 = new CheckBoxTreeNode("node_1_1");
CheckBoxTreeNode node1_2 = new CheckBoxTreeNode("node_1_2");
CheckBoxTreeNode node1_3 = new CheckBoxTreeNode("node_1_3");
node1.add(node1_1);
node1.add(node1_2);
node1.add(node1_3);
CheckBoxTreeNode node2 = new CheckBoxTreeNode("node_2");
boolean selected = node2.isSelected();
CheckBoxTreeNode node2_1 = new CheckBoxTreeNode("node_2_1");
CheckBoxTreeNode node2_2 = new CheckBoxTreeNode("node_2_2");
node2.add(node2_1);
node2.add(node2_2);
rootNode.add(node1);
rootNode.add(node2);
DefaultTreeModel model = new DefaultTreeModel(rootNode);
tree.addMouseListener(new CheckBoxTreeNodeSelectionListener());
tree.setModel(model);
tree.setCellRenderer(new CheckBoxTreeCellRenderer());
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
String string = tree.getSelectionPath().toString();
System.out.println(string);
}
});
JScrollPane scroll = new JScrollPane(tree);
scroll.setBounds(0, 0, 300, 320);
frame.getContentPane().add(scroll);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String originalString = "prefix-suffix";
char separator = '-';
String replacement = "newPrefix";
// 替换并组合新的字符串
String newString = replacement + originalString.substring(originalString.indexOf(separator));
frame.setVisible(true); System.out.println(newString);
}
});
} }
} }

@ -88,15 +88,16 @@ public class CreateDWGHandler extends AbstractHandler {
} }
return null; return null;
} }
/** /**
* *
* @Title: createdataSetForUID * @Title: createdataSetForUID
* @Description: uid * @Description: uid
* @param @param revision * @param @param revision
* @param @param templateMap * @param @param templateMap
* @param @param key * @param @param key
* @param @throws TCException * @param @throws TCException
* @return void * @return void
* @throws * @throws
*/ */
public void createdataSetForUID(TCComponentItemRevision revision, Map<String, String> templateMap, String key) public void createdataSetForUID(TCComponentItemRevision revision, Map<String, String> templateMap, String key)

@ -4,52 +4,45 @@ import java.util.Arrays;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
/** /**
* *
* @ClassName: CompontByNode * @ClassName: CompontByNode
* @Description: Ê÷½ÚµãÔÏó * @Description: Ê÷½ÚµãÔÏó
* @author hcj * @author hcj
* @date 202418 * @date 202418
* *
*/ */
public class CompontByNode { public class CompontByNode {
//父对象 // 父对象
private TCComponent component; private TCComponent component;
//子对象 // 子对象
private TCComponent[] components; private TCComponent[] components;
public CompontByNode() { public CompontByNode() {
super(); super();
} }
public CompontByNode(TCComponent component, TCComponent[] components) { public CompontByNode(TCComponent component, TCComponent[] components) {
super(); super();
this.component = component; this.component = component;
this.components = components; this.components = components;
} }
public TCComponent getComponent() { public TCComponent getComponent() {
return component; return component;
} }
public void setComponent(TCComponent component) { public void setComponent(TCComponent component) {
this.component = component; this.component = component;
} }
public TCComponent[] getComponents() { public TCComponent[] getComponents() {
return components; return components;
} }
public void setComponents(TCComponent[] components) { public void setComponents(TCComponent[] components) {
this.components = components; this.components = components;
} }
} }

@ -4,48 +4,36 @@ import java.awt.Dimension;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.text.ParseException; import java.time.Year;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import com.connor.kwc.createBom.CheckBoxTreeCellRenderer; import com.connor.kwc.jtreeUtilClass.CheckBoxTreeCellRenderer;
import com.connor.kwc.createBom.CheckBoxTreeNode; import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNode;
import com.connor.kwc.createBom.CheckBoxTreeNodeSelectionListener; import com.connor.kwc.jtreeUtilClass.CheckBoxTreeNodeSelectionListener;
import com.connor.kwc.util.Util; import com.connor.kwc.util.Util;
import com.teamcenter.rac.aif.AIFPortal; import com.connor.kwc.util.UtilBean;
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.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentFolder; import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
import com.teamcenter.rac.kernel.TCComponentForm; import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
@ -59,8 +47,29 @@ import com.teamcenter.rac.util.MessageBox;
*/ */
public class CreateTemplateDialg extends JFrame { public class CreateTemplateDialg extends JFrame {
private static final long serialVersionUID = 1L;
//依据模板创建
private final static String YJMBCJ = "yjmbcj";
//产品代号
private final static String CPDH = "cpdh";
//确定
private final static String QD = "qd";
//产品代号不能为空!
private final static String CPDHBNWK = "cpdhbnwk";
//提示
private final static String TS = "ts";
//创建失败
private final static String CJSB = "cjsb";
//创建成功
private final static String CJCG = "cjcg";
//已存在于TC
private final static String YCZYTC = "yczytc";
//模板
private final static String MB = "mb";
private TCSession session; private TCSession session;
private TCComponent target; private TCComponent target;
private ResourceBundle resource;
private JButton jButton3; private JButton jButton3;
private JLabel jLabel3; private JLabel jLabel3;
private JPanel jPanel1; private JPanel jPanel1;
@ -69,15 +78,15 @@ public class CreateTemplateDialg extends JFrame {
private JScrollPane jScrollPane1; private JScrollPane jScrollPane1;
private JTextField jTextField3; private JTextField jTextField3;
private JTree jTree1; private JTree jTree1;
private String[] sxxdate; private String[] createDOCtemplate;
private String[] sxxAttrDate; private String[] createDOCAttribute;
private Map<String, Map<String, List<Map<TCComponent, CheckBoxTreeNode>>>> folderByNodeMap = new HashMap<String, Map<String, List<Map<TCComponent, CheckBoxTreeNode>>>>(); private Map<String, Map<String, List<Map<TCComponent, CheckBoxTreeNode>>>> folderByNodeMap = new HashMap<String, Map<String, List<Map<TCComponent, CheckBoxTreeNode>>>>();
private Map<CheckBoxTreeNode,List<Map<TCComponent, CheckBoxTreeNode>>> isSavaAsMap = new HashMap<CheckBoxTreeNode,List<Map<TCComponent, CheckBoxTreeNode>>>(); private Map<CheckBoxTreeNode, List<Map<TCComponent, CheckBoxTreeNode>>> isSavaAsMap = new HashMap<CheckBoxTreeNode, List<Map<TCComponent, CheckBoxTreeNode>>>();
private Map<String, CheckBoxTreeNode> nodeIsSelectMap = new HashMap<String, CheckBoxTreeNode>(); private Map<String, CheckBoxTreeNode> nodeIsSelectMap = new HashMap<String, CheckBoxTreeNode>();
private Map<String, Map<TCComponent, CheckBoxTreeNode>> isSelectByNodeMap = new HashMap<String, Map<TCComponent, CheckBoxTreeNode>>(); private Map<String, Map<TCComponent, CheckBoxTreeNode>> isSelectByNodeMap = new HashMap<String, Map<TCComponent, CheckBoxTreeNode>>();
/** /**
* Creates new form NewJFrame2 * Creates new form CreateTemplateDialg
*/ */
public CreateTemplateDialg(TCSession session, TCComponent folder) { public CreateTemplateDialg(TCSession session, TCComponent folder) {
this.session = session; this.session = session;
@ -94,24 +103,24 @@ public class CreateTemplateDialg extends JFrame {
/** /**
* *
* @Title: getData * @Title: getData
* @Description: * @Description:
* @param * @param
* @return void * @return void
* @throws * @throws
*/ */
private void getData() { private void getData() {
//清理数据 // 清理数据
System.out.println("清理数据......."); System.out.println("清理数据.......");
folderByNodeMap.clear(); folderByNodeMap.clear();
isSavaAsMap.clear(); isSavaAsMap.clear();
nodeIsSelectMap.clear(); nodeIsSelectMap.clear();
isSelectByNodeMap.clear(); isSelectByNodeMap.clear();
System.out.println("数据清理完毕......."); System.out.println("数据清理完毕.......");
//读取配置文件
resource = ResourceBundle.getBundle("com.connor.kwc.message.Message", Locale.getDefault());
// TODO Auto-generated method stub //读取首选项
sxxdate = Util.getSXX(session, "KWC_CreateDOCtemplate"); createDOCtemplate = Util.getSXX(session, UtilBean.CREATRDOCTEMPLATE);
sxxAttrDate = Util.getSXX(session, "KWC_CreateDOC_attribute"); createDOCAttribute = Util.getSXX(session, UtilBean.CRWATEDOCATTRIBUTE);
} }
@ -124,9 +133,9 @@ public class CreateTemplateDialg extends JFrame {
* @throws * @throws
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() throws TCException { private void initComponents() throws TCException {
this.setTitle("依据模板创建"); //依据模板创建
this.setTitle(resource.getString(YJMBCJ));
jPanel1 = new JPanel(); jPanel1 = new JPanel();
jPanel2 = new JPanel(); jPanel2 = new JPanel();
jLabel3 = new JLabel(); jLabel3 = new JLabel();
@ -137,7 +146,7 @@ public class CreateTemplateDialg extends JFrame {
jTree1.setCellRenderer(new CheckBoxTreeCellRenderer()); jTree1.setCellRenderer(new CheckBoxTreeCellRenderer());
jButton3 = new JButton(); jButton3 = new JButton();
jTextField3 = new JTextField(); jTextField3 = new JTextField();
jTextField3.setText(target.getStringProperty("item_id")); jTextField3.setText(target.getStringProperty(UtilBean.ITEMID));
jPanel4 = new JPanel(); jPanel4 = new JPanel();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
@ -146,12 +155,12 @@ public class CreateTemplateDialg extends JFrame {
jPanel1.setBackground(new java.awt.Color(240, 240, 240)); jPanel1.setBackground(new java.awt.Color(240, 240, 240));
jPanel2.setBackground(new java.awt.Color(240, 240, 240)); jPanel2.setBackground(new java.awt.Color(240, 240, 240));
//产品代号
jLabel3.setText("产品代号:"); jLabel3.setText(resource.getString(CPDH));
jScrollPane1.setViewportView(jTree1); jScrollPane1.setViewportView(jTree1);
//确定
jButton3.setText("确定"); jButton3.setText(resource.getString(QD));
GroupLayout jPanel2Layout = new GroupLayout(jPanel2); GroupLayout jPanel2Layout = new GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout); jPanel2.setLayout(jPanel2Layout);
@ -214,60 +223,97 @@ public class CreateTemplateDialg extends JFrame {
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack(); pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
int screenWidth = screenSize.width; // 获取屏幕宽度 //设置窗口居中
int screenHeight = screenSize.height; // 获取屏幕高度 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screenWidth - this.getWidth()) / 2; // 计算Frame的左上角x坐标 int screenWidth = screenSize.width;
int y = (screenHeight - this.getHeight()) / 2; // 计算Frame的左上角y坐标 int screenHeight = screenSize.height;
this.setLocation(x, y); // 设置Frame的位置 int x = (screenWidth - this.getWidth()) / 2;
int y = (screenHeight - this.getHeight()) / 2;
this.setLocation(x, y); //
this.setDefaultCloseOperation(2); this.setDefaultCloseOperation(2);
// 确定按钮监听
this.jButton3.addActionListener(new ActionListener() { this.jButton3.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
String name = jTextField3.getText(); String name = jTextField3.getText();
if (name.isEmpty()) { if (name.isEmpty()) {
MessageBox.post("产品代号不能为空!", "提示 ", MessageBox.INFORMATION); //产品代号不能为空! 提示
MessageBox.post(resource.getString(CPDHBNWK), resource.getString(TS), MessageBox.INFORMATION);
} else { } else {
try { try {
// 开旁路
Util.setByPass(true);
// 根据当前文件夹下的关系匹配树节点的选中状态创建对象 // 根据当前文件夹下的关系匹配树节点的选中状态创建对象
for(Entry<String, CheckBoxTreeNode> nodeIsSelect : nodeIsSelectMap.entrySet()) { for (Entry<String, CheckBoxTreeNode> nodeIsSelect : nodeIsSelectMap.entrySet()) {
if(nodeIsSelect.getValue().isSelected()) { if (nodeIsSelect.getValue().isSelected()) {
List<Map<TCComponent, CheckBoxTreeNode>> list = isSavaAsMap.get(nodeIsSelect.getValue()); List<Map<TCComponent, CheckBoxTreeNode>> list = isSavaAsMap
for(Map<TCComponent, CheckBoxTreeNode> childMap : list) { .get(nodeIsSelect.getValue());
// 判断是否选中 for (Map<TCComponent, CheckBoxTreeNode> childMap : list) {
// 判断是否选中
for (Map.Entry<TCComponent, CheckBoxTreeNode> entry1 : childMap.entrySet()) { for (Map.Entry<TCComponent, CheckBoxTreeNode> entry1 : childMap.entrySet()) {
if (entry1.getValue().isSelected()) { if (entry1.getValue().isSelected()) {
// 创建对象 // 创建对象
TCComponent oldObj = entry1.getKey(); TCComponent oldObj = entry1.getKey();
if(oldObj instanceof TCComponentFolder) { if (oldObj instanceof TCComponentFolder) {
TCComponentFolder oldFolder = (TCComponentFolder)oldObj; TCComponentFolder oldFolder = (TCComponentFolder) oldObj;
TCComponentFolder saveAs = oldFolder.saveAs(jTextField3.getText() + oldFolder.getStringProperty("object_string").replaceAll("\\[.*?\\]", "")); TCComponentFolder saveAs = oldFolder.saveAs(jTextField3.getText()
TCComponent[] referenceListProperty = saveAs.getReferenceListProperty("contents"); + oldFolder.getStringProperty(UtilBean.OBJECTSTRING)
.replaceFirst("\\[.*?\\]", ""));
TCComponent[] referenceListProperty = saveAs
.getReferenceListProperty(UtilBean.CONTENTS);
saveAs.remove("contents", referenceListProperty); saveAs.remove("contents", referenceListProperty);
System.out.println("开始添加文件夹"+saveAs.getStringProperty("object_string")+"对象到"+nodeIsSelect.getKey()+"关系下"); target.add(nodeIsSelect.getKey(), saveAs);
target.add(nodeIsSelect.getKey(),saveAs);
// 挂载新的对象 // 挂载新的对象
isLoadNewCompint(oldObj, saveAs); isLoadNewCompint(oldObj, saveAs);
}else if(oldObj instanceof TCComponentItem) { } else if (oldObj instanceof TCComponentItem) {
TCComponentItem oldItem = (TCComponentItem)oldObj; TCComponentItem oldItem = (TCComponentItem) oldObj;
TCComponentItem saveAsItem = oldItem.getLatestItemRevision().saveAsItem(jTextField3.getText()+oldItem.getStringProperty("object_string").replaceAll("\\[.*?\\]", ""), "A"); TCComponentItem saveAsItem;
System.out.println("开始添加item"+saveAsItem.getStringProperty("object_string")+"对象到"+nodeIsSelect.getKey()+"关系下"); String replaceName = jTextField3.getText()
target.add(nodeIsSelect.getKey(),saveAsItem); + oldItem.getStringProperty(UtilBean.OBJECTSTRING)
} .replaceFirst("\\[.*?\\]", "");
String replace = replaceName.replace("[Y]",
String.valueOf(Year.now().getValue()));
try {
saveAsItem = oldItem.getLatestItemRevision().saveAsItem(replace,
null);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
MessageBox.post(
//创建失败 已存在于TC
resource.getString(CJSB) + "ID【" + replaceName + "】"
+ resource.getString(YCZYTC),
resource.getString(TS), MessageBox.INFORMATION);
return;
}
target.add(nodeIsSelect.getKey(), saveAsItem);
}
} }
} }
} }
} }
} }
dispose(); dispose();
//创建成功
MessageBox.post(resource.getString(CJCG), resource.getString(TS), MessageBox.INFORMATION);
return;
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
dispose();
//创建失败
MessageBox.post(resource.getString(CJSB), resource.getString(TS), MessageBox.INFORMATION);
return;
} finally {
// 关闭旁路
Util.setByPass(false);
} }
} }
} }
@ -286,43 +332,96 @@ public class CreateTemplateDialg extends JFrame {
* @throws * @throws
*/ */
private void isLoadNewCompint(TCComponent oldObj, TCComponent newObj) throws TCException { private void isLoadNewCompint(TCComponent oldObj, TCComponent newObj) throws TCException {
if (isSelectByNodeMap.containsKey(oldObj.getStringProperty("object_string"))) { if (isSelectByNodeMap.containsKey(oldObj.getStringProperty(UtilBean.OBJECTSTRING))) {
// 创建文件夹挂载新创建的对象 // 创建文件夹挂载新创建的对象
Map<TCComponent, CheckBoxTreeNode> map = isSelectByNodeMap.get(oldObj.getStringProperty("object_string")); Map<TCComponent, CheckBoxTreeNode> map = isSelectByNodeMap.get(oldObj.getStringProperty(UtilBean.OBJECTSTRING));
System.out.println("另存对象长度"+map.size()); System.out.println("saveAs length:" + map.size());
for (Map.Entry<TCComponent, CheckBoxTreeNode> entry : map.entrySet()) { for (Map.Entry<TCComponent, CheckBoxTreeNode> entry : map.entrySet()) {
if (entry.getValue().isSelected()) { if (entry.getValue().isSelected()) {
// 另存文件,复制属性规则 // 另存文件,复制属性规则
TCComponentItem item = (TCComponentItem) entry.getKey(); TCComponentItem item = (TCComponentItem) entry.getKey();
System.out.println("开始另存对象"+item.getStringProperty("object_string")); System.out.println("start saveAs:" + item.getStringProperty(UtilBean.OBJECTSTRING));
TCComponentItem saveAsItem = item.getLatestItemRevision().saveAsItem(jTextField3.getText()+item.getStringProperty("object_string").replaceAll("\\[.*?\\]", ""), "A"); String itemId = item.getStringProperty(UtilBean.ITEMID);
String newId = itemId.replace(UtilBean.ITEMIDHEAD, jTextField3.getText());
String replace = newId.replace(UtilBean.YEAR, String.valueOf(Year.now().getValue()));
System.out.println("replace:" + replace);
TCComponentItem saveAsItem;
try {
saveAsItem = item.getLatestItemRevision().saveAsItem(replace, null);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//创建失败 已存在于TC
MessageBox.post(resource.getString(CJSB) + "ID【" + replace + "】" + resource.getString(YCZYTC),
resource.getString(TS), MessageBox.INFORMATION);
return;
}
// 判断版本下面是否有数据集,有的话需要改变数据集的名字
TCComponent[] spectficationObj = saveAsItem.getLatestItemRevision()
.getReferenceListProperty(UtilBean.IMANSPECIFICATION);
if (spectficationObj != null && spectficationObj.length > 0) {
for (TCComponent tcComponent : spectficationObj) {
if (tcComponent instanceof TCComponentDataset) {
TCComponentDataset dataset = (TCComponentDataset) tcComponent;
String datasettName = dataset.getStringProperty(UtilBean.OBJECTNAMR);
String[] splitName = datasettName.split("-");
TCComponentDataset newDataset = dataset
.saveAs(replace + splitName[splitName.length - 1]);
saveAsItem.getLatestItemRevision().remove(UtilBean.IMANSPECIFICATION, spectficationObj);
saveAsItem.getLatestItemRevision().add(UtilBean.IMANSPECIFICATION, newDataset);
// 改变内置文件名
String oldFileName = dataset.getRelatedComponent(UtilBean.REFLIST)
.getProperty(UtilBean.ORIGINALFILENAME);
// 分离文件名和扩展名
int dotIndex = oldFileName.lastIndexOf('.');
String extension = "";
if (dotIndex != -1) {
extension = oldFileName.substring(dotIndex);
oldFileName = oldFileName.substring(0, dotIndex);
// 替换文件名前缀并添加原来的扩展名
String newFileName = replace + splitName[splitName.length - 1] + extension;
newDataset.getRelatedComponent(UtilBean.REFLIST).setProperty(UtilBean.ORIGINALFILENAME,
newFileName);
} else {
newDataset.getRelatedComponent(UtilBean.REFLIST).setProperty(UtilBean.ORIGINALFILENAME,
replace + splitName[splitName.length - 1]);
}
break;
}
}
}
// 替换属性 // 替换属性
for (String attrStr : sxxAttrDate) { for (String attrStr : createDOCAttribute) {
if (attrStr.startsWith(saveAsItem.getStringProperty("object_type"))) { if (attrStr.startsWith(saveAsItem.getStringProperty(UtilBean.OBJECTTYPE))) {
try { try {
String[] replaces = attrStr.split("=")[1].split(";"); String[] replaces = attrStr.split("=")[1].split(";");
for (String replace : replaces) { for (String replace1 : replaces) {
String[] getValues = replace.split("\\."); String[] getValues = replace1.split("\\.");
Object val = ""; Object val = "";
if (getValues[0].equals("item")) { if (getValues[0].equals(UtilBean.ITEM)) {
//替换item属性
val = Util.getTCPropertyValue(item, getValues[1]); val = Util.getTCPropertyValue(item, getValues[1]);
Util.setTCPropertyValue(saveAsItem, getValues[1], val); Util.setTCPropertyValue(saveAsItem, getValues[1], val);
// val = item.getProperty(getValues[1]); } else if (getValues[0].equals(UtilBean.REV)) {
} else if (getValues[0].equals("rev")) { //替换版本属性
val = Util.getTCPropertyValue(item.getLatestItemRevision(), getValues[1]); val = Util.getTCPropertyValue(item.getLatestItemRevision(), getValues[1]);
Util.setTCPropertyValue(saveAsItem.getLatestItemRevision(), getValues[1], val); Util.setTCPropertyValue(saveAsItem.getLatestItemRevision(), getValues[1], val);
// val = rev.getProperty(getValues[1]); } else if (getValues[0].equals(UtilBean.RM)) {
} else if (getValues[0].equals("rm")) { //替换版本表单属性
TCComponent[] oldreferenceListProperty = item.getLatestItemRevision() TCComponent[] oldreferenceListProperty = item.getLatestItemRevision()
.getReferenceListProperty("IMAN_master_form_rev"); .getReferenceListProperty(UtilBean.IMANMASTERFORMREV);
TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0]; TCComponentForm oldform = (TCComponentForm) oldreferenceListProperty[0];
val = Util.getTCPropertyValue(oldform, getValues[1]); val = Util.getTCPropertyValue(oldform, getValues[1]);
TCComponent[] newreferenceListProperty = saveAsItem.getLatestItemRevision() TCComponent[] newreferenceListProperty = saveAsItem.getLatestItemRevision()
.getReferenceListProperty("IMAN_master_form_rev"); .getReferenceListProperty(UtilBean.IMANMASTERFORMREV);
TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0]; TCComponentForm newform = (TCComponentForm) newreferenceListProperty[0];
Util.setTCPropertyValue(newform, getValues[1], val); Util.setTCPropertyValue(newform, getValues[1], val);
// val = form.getProperty(getValues[1]);
} }
} }
} catch (Exception e1) { } catch (Exception e1) {
@ -340,51 +439,58 @@ public class CreateTemplateDialg extends JFrame {
} }
/** /**
* *
* * @Title: initTree
* @param tree * @Description:
*/ * @param @param tree
* @return void
* @throws
*/
private void initTree(JTree tree) { private void initTree(JTree tree) {
String puids = sxxdate[0].split("=")[1]; String puids = createDOCtemplate[0].split("=")[1];
System.out.println(puids); System.out.println(puids);
String releaseNames = sxxdate[1].split("=")[1]; String releaseNames = createDOCtemplate[1].split("=")[1];
System.out.println(releaseNames); System.out.println(releaseNames);
try { try {
CheckBoxTreeNode rootNode = new CheckBoxTreeNode("模板"); //模板
CheckBoxTreeNode rootNode = new CheckBoxTreeNode(resource.getString(MB));
TCComponent tcComponent = session.stringToComponent(puids); TCComponent tcComponent = session.stringToComponent(puids);
String[] releaseName = releaseNames.split(";"); String[] releaseName = releaseNames.split(";");
System.out.println(tcComponent.getStringProperty("object_string")); System.out.println(tcComponent.getStringProperty(UtilBean.OBJECTSTRING));
// Map<String, List<Map<TCComponent, CheckBoxTreeNode>>> foMap = new HashMap<String, List<Map<TCComponent, CheckBoxTreeNode>>>();
//根据分号分割,获取关系名称,循环创建关系下的对象
for (String release : releaseName) { for (String release : releaseName) {
System.out.println("release:" + release); System.out.println("release:" + release);
String[] attr = release.split("-"); String[] attr = release.split("-");
CheckBoxTreeNode childNode = new CheckBoxTreeNode(attr[1]); CheckBoxTreeNode childNode = new CheckBoxTreeNode(attr[1]);
rootNode.add(childNode); rootNode.add(childNode);
nodeIsSelectMap.put(attr[0], childNode); nodeIsSelectMap.put(attr[0], childNode);
TCComponent[] pseudoFolders = tcComponent.getReferenceListProperty(attr[0]); TCComponent[] pseudoFolders = tcComponent.getReferenceListProperty(attr[0]);
if(pseudoFolders!=null) { if (pseudoFolders != null) {
List<Map<TCComponent, CheckBoxTreeNode>> components = new ArrayList<Map<TCComponent, CheckBoxTreeNode>>(); List<Map<TCComponent, CheckBoxTreeNode>> components = new ArrayList<Map<TCComponent, CheckBoxTreeNode>>();
for (TCComponent reCompont : pseudoFolders) { for (TCComponent reCompont : pseudoFolders) {
Map<TCComponent, CheckBoxTreeNode> map = new HashMap<TCComponent, CheckBoxTreeNode>(); Map<TCComponent, CheckBoxTreeNode> map = new HashMap<TCComponent, CheckBoxTreeNode>();
CheckBoxTreeNode topNode = new CheckBoxTreeNode(reCompont.getStringProperty("object_string")); CheckBoxTreeNode topNode = new CheckBoxTreeNode(reCompont.getStringProperty(UtilBean.OBJECTSTRING));
childNode.add(topNode); childNode.add(topNode);
map.put(reCompont, topNode); map.put(reCompont, topNode);
components.add(map); components.add(map);
//循环创建子节点
buildTree(reCompont, topNode); buildTree(reCompont, topNode);
} }
// 将List集合放入Map中与伪文件夹关系对象 // 将List集合放入Map中与伪文件夹关系对象
isSavaAsMap.put(childNode, components); isSavaAsMap.put(childNode, components);
} }
} }
//渲染Jtree复选框
DefaultTreeModel model = new DefaultTreeModel(rootNode); DefaultTreeModel model = new DefaultTreeModel(rootNode);
tree.addMouseListener(new CheckBoxTreeNodeSelectionListener()); tree.addMouseListener(new CheckBoxTreeNodeSelectionListener());
tree.setModel(model); tree.setModel(model);
tree.setCellRenderer(new CheckBoxTreeCellRenderer()); tree.setCellRenderer(new CheckBoxTreeCellRenderer());
tree.setRowHeight(0);
// 展开所有节点并选中 // 展开所有节点并选中
for (int i = 0; i < tree.getRowCount(); i++) { for (int i = 0; i < tree.getRowCount(); i++) {
tree.expandRow(i); tree.expandRow(i);
@ -403,16 +509,16 @@ public class CreateTemplateDialg extends JFrame {
* @throws TCException * @throws TCException
*/ */
private void buildTree(TCComponent component, CheckBoxTreeNode topNode) throws TCException { private void buildTree(TCComponent component, CheckBoxTreeNode topNode) throws TCException {
TCComponent[] relatedComponent = component.getReferenceListProperty("contents"); TCComponent[] relatedComponent = component.getReferenceListProperty(UtilBean.CONTENTS);
if (relatedComponent != null && relatedComponent.length > 0) { if (relatedComponent != null && relatedComponent.length > 0) {
System.out.println("存储的长度"+relatedComponent.length); System.out.println("length:" + relatedComponent.length);
Map<TCComponent, CheckBoxTreeNode> isSelectMap = new HashMap<TCComponent, CheckBoxTreeNode>(); Map<TCComponent, CheckBoxTreeNode> isSelectMap = new HashMap<TCComponent, CheckBoxTreeNode>();
for (TCComponent child : relatedComponent) { for (TCComponent child : relatedComponent) {
CheckBoxTreeNode childNode = new CheckBoxTreeNode(child.getStringProperty("object_string")); CheckBoxTreeNode childNode = new CheckBoxTreeNode(child.getStringProperty(UtilBean.OBJECTSTRING));
isSelectMap.put(child, childNode); isSelectMap.put(child, childNode);
topNode.add(childNode); topNode.add(childNode);
} }
isSelectByNodeMap.put(component.getStringProperty("object_string"), isSelectMap); isSelectByNodeMap.put(component.getStringProperty(UtilBean.OBJECTSTRING), isSelectMap);
} }
} }

@ -4,7 +4,7 @@
* @author admin * @date 20231220 * @author admin * @date 20231220
* @version V1.0 * @version V1.0
*/ */
package com.connor.kwc.createBom; package com.connor.kwc.jtreeUtilClass;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;

@ -4,7 +4,7 @@
* @author admin * @date 20231220 * @author admin * @date 20231220
* @version V1.0 * @version V1.0
*/ */
package com.connor.kwc.createBom; package com.connor.kwc.jtreeUtilClass;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;

@ -4,9 +4,16 @@
* @author admin * @date 2023Äê12ÔÂ20ÈÕ * @author admin * @date 2023Äê12ÔÂ20ÈÕ
* @version V1.0 * @version V1.0
*/ */
package com.connor.kwc.createBom; package com.connor.kwc.jtreeUtilClass;
import java.awt.Component;
import java.util.Enumeration;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
/** /**
* @ClassName: CheckBoxTreeNode * @ClassName: CheckBoxTreeNode
@ -17,7 +24,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
*/ */
public class CheckBoxTreeNode extends DefaultMutableTreeNode { public class CheckBoxTreeNode extends DefaultMutableTreeNode {
protected boolean isSelected; public boolean isSelected;
public CheckBoxTreeNode() { public CheckBoxTreeNode() {
this(null); this(null);
@ -94,4 +101,7 @@ public class CheckBoxTreeNode extends DefaultMutableTreeNode {
// pNode.setSelected(_isSelected); // pNode.setSelected(_isSelected);
} }
} }
} }

@ -4,13 +4,17 @@
* @author admin * @date 2023Äê12ÔÂ20ÈÕ * @author admin * @date 2023Äê12ÔÂ20ÈÕ
* @version V1.0 * @version V1.0
*/ */
package com.connor.kwc.createBom; package com.connor.kwc.jtreeUtilClass;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import com.connor.kwc.util.Util;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
/** /**
@ -25,6 +29,7 @@ public class CheckBoxTreeNodeSelectionListener extends MouseAdapter {
@Override @Override
public void mouseClicked(MouseEvent event) { public void mouseClicked(MouseEvent event) {
JTree tree = (JTree) event.getSource(); JTree tree = (JTree) event.getSource();
int x = event.getX(); int x = event.getX();
int y = event.getY(); int y = event.getY();
int row = tree.getRowForLocation(x, y); int row = tree.getRowForLocation(x, y);
@ -35,6 +40,10 @@ public class CheckBoxTreeNodeSelectionListener extends MouseAdapter {
boolean isSelected = !node.isSelected(); boolean isSelected = !node.isSelected();
node.setSelected(isSelected); node.setSelected(isSelected);
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node);
// 展开所有节点并选中
for (int i = 0; i < tree.getRowCount(); i++) {
tree.expandRow(i);
}
} }
} }
} }

@ -1,2 +1,11 @@
xz=select xz=select
zjdx=Component object zjdx=Component object
yjmbcj=Create based on template
cpdh=Product code:
qd=determine
cpdhbnwk=Product code cannot be empty!
ts=prompt
mb=template
cjcg=Created successfully
cjsb=Creation failed
yczytc=Already exists in TC

@ -1,2 +1,11 @@
xz=\u9009\u62e9 xz=\u9009\u62e9
zjdx=\u7ec4\u4ef6\u5bf9\u8c61 zjdx=\u7ec4\u4ef6\u5bf9\u8c61
yjmbcj=\u4F9D\u636E\u6A21\u677F\u521B\u5EFA
cpdh=\u4EA7\u54C1\u4EE3\u53F7\uFF1A
qd=\u786E\u5B9A
cpdhbnwk=\u4EA7\u54C1\u4EE3\u53F7\u4E0D\u80FD\u4E3A\u7A7A\uFF01
ts=\u63D0\u793A
mb=\u6A21\u677F
cjcg=\u521B\u5EFA\u6210\u529F
cjsb=\u521B\u5EFA\u5931\u8D25
yczytc=\u5DF2\u5B58\u5728\u4E8ETC

@ -10,10 +10,15 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.JTree;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aifrcp.AIFUtility; import com.teamcenter.rac.aifrcp.AIFUtility;
@ -61,14 +66,38 @@ public class Util {
textService = session.getTextService(); textService = session.getTextService();
} }
/** /**
* *
* @Title: getRevisionPseudoFolder * @Title: expandAll
* @Description:
* @param @param tree
* @param @param parent
* @param @param expand
* @return void
* @throws
*/
public static void expandAll(JTree tree, TreePath parent, boolean expand) {
TreeNode node = (TreeNode) parent.getLastPathComponent();
if (node.getChildCount() >= 0) {
for (Enumeration<?> e = node.children(); e.hasMoreElements();) {
TreeNode n = (TreeNode) e.nextElement();
TreePath path = parent.pathByAddingChild(n);
tree.expandPath(path); // 展开路径
expandAll(tree, path, expand); // 递归展开其子节点
}
}
}
/**
*
* @Title: getRevisionPseudoFolder
* @Description: * @Description:
* @param @param itemRev * @param @param itemRev
* @param @param relation * @param @param relation
* @param @return * @param @return
* @return TCComponentPseudoFolder * @return TCComponentPseudoFolder
* @throws * @throws
*/ */
public static TCComponentPseudoFolder getRevisionPseudoFolder(TCComponent tcComponent, String relation) { public static TCComponentPseudoFolder getRevisionPseudoFolder(TCComponent tcComponent, String relation) {
@ -94,17 +123,16 @@ public class Util {
} }
return realtionFolder; return realtionFolder;
} }
/** /**
* *
* @Title: queryObject * @Title: queryObject
* @Description: * @Description:
* @param @param queryName * @param @param queryName
* @param @param keys * @param @param keys
* @param @param values * @param @param values
* @param @return * @param @return
* @return List<TCComponent> * @return List<TCComponent>
* @throws * @throws
*/ */
public static List<TCComponent> queryObject(String queryName, String[] keys, String[] values) { public static List<TCComponent> queryObject(String queryName, String[] keys, String[] values) {
@ -133,12 +161,12 @@ public class Util {
/** /**
* *
* @Title: getTCPropertyValue * @Title: getTCPropertyValue
* @Description: * @Description:
* @param @param item * @param @param item
* @param @param propertyName * @param @param propertyName
* @param @return * @param @return
* @return Object * @return Object
* @throws * @throws
*/ */
public static Object getTCPropertyValue(TCComponent item, String propertyName) { public static Object getTCPropertyValue(TCComponent item, String propertyName) {
@ -177,12 +205,12 @@ public class Util {
/** /**
* *
* @Title: setTCPropertyValue * @Title: setTCPropertyValue
* @Description: * @Description:
* @param @param item * @param @param item
* @param @param propertyName * @param @param propertyName
* @param @param value * @param @param value
* @return void * @return void
* @throws * @throws
*/ */
public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) { public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) {
@ -224,8 +252,6 @@ public class Util {
} }
} }
/** /**
* *
* @Title: getSXX * @Title: getSXX
@ -283,7 +309,7 @@ public class Util {
userservice.call("Connor_open_bypass", new Object[] { val }); userservice.call("Connor_open_bypass", new Object[] { val });
System.out.println(val ? "Open Bypass" : "Close Bypass"); System.out.println(val ? "Open Bypass" : "Close Bypass");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); System.out.println("【Connor_open_bypass】命名的方法未注册有用户服务");
} }
} }

@ -0,0 +1,21 @@
package com.connor.kwc.util;
public class UtilBean {
public static final long serialVersionUID = 1L;
public final static String CREATRDOCTEMPLATE = "KWC_CreateDOCtemplate";
public final static String CRWATEDOCATTRIBUTE = "KWC_CreateDOC_attribute";
public final static String ITEMID = "item_id";
public final static String OBJECTSTRING = "object_string";
public final static String OBJECTNAMR = "object_name";
public final static String OBJECTTYPE = "object_type";
public final static String CONTENTS = "contents";
public final static String REFLIST = "ref_list";
public final static String ORIGINALFILENAME = "original_file_name";
public final static String ITEM = "item";
public final static String REV = "rev";
public final static String RM = "rm";
public final static String IMANMASTERFORMREV = "IMAN_master_form_rev";
public final static String IMANSPECIFICATION = "IMAN_specification";
public final static String ITEMIDHEAD = "[CPDH]";
public final static String YEAR = "[Y]";
}
Loading…
Cancel
Save