项目来源:20250521WC

项目备份
main
熊朝柱 4 weeks ago
commit 7435655f67

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="poi_lib/commons-io-1.4.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/antlr-2.7.7.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/axis2-ant-plugin-1.6.2.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/aspose-words-17.4.0-jdk16.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/commons-collections4-4.1.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/poi-3.17.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/poi-examples-3.17.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/poi-excelant-3.17.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/poi-ooxml-3.17.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/poi-ooxml-schemas-3.17.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/poi-scratchpad-3.17.jar"/>
<classpathentry exported="true" kind="lib" path="poi_lib/xmlbeans-2.6.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

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

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,38 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Plm
Bundle-SymbolicName: com.connor.plm;singleton:=true
Bundle-Version: 1.0.0
Bundle-Vendor: CONNOR
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp,
com.teamcenter.rac.kernel,
com.teamcenter.rac.util,
com.teamcenter.rac.common,
com.teamcenter.rac.tcapps,
TcSoaCoreRac;bundle-version="12000.3.0",
com.teamcenter.rac.ui;bundle-version="12000.3.0",
org.eclipse.osgi.services;bundle-version="3.7.100",
org.eclipse.osgi.util;bundle-version="3.5.100",
com.teamcenter.rac.pca.kernel;bundle-version="12000.3.0",
com.teamcenter.rac.workflow.processdesigner;bundle-version="12000.3.0",
TcSoaWorkflowRac;bundle-version="12000.3.0",
com.teamcenter.rac.workflow;bundle-version="12000.3.0",
com.teamcenter.rac.workflow.processviewer;bundle-version="12000.3.0",
TcSoaWorkflowLoose;bundle-version="12000.3.0"
Automatic-Module-Name: com.connor.plm
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: poi_lib/aspose-words-17.4.0-jdk16.jar,
poi_lib/commons-collections4-4.1.jar,
poi_lib/poi-3.17.jar,
poi_lib/poi-examples-3.17.jar,
poi_lib/poi-excelant-3.17.jar,
poi_lib/poi-ooxml-3.17.jar,
poi_lib/poi-ooxml-schemas-3.17.jar,
poi_lib/poi-scratchpad-3.17.jar,
poi_lib/xmlbeans-2.6.0.jar,
.,
poi_lib/axis2-ant-plugin-1.6.2.jar,
poi_lib/antlr-2.7.7.jar,
poi_lib/commons-io-1.4.jar

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,58 @@
#
#Thu Jan 21 10:28:16 CST 2021
createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25
project=Project
dsuidinpref.ERROR1=Error dataset uid set in preference\: %s
valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s
writedata=Write Data
querynotexist.ERROR1=Query not exist\: %s
dialoginit.ERROR=Init Error
preferror.ERROR1=Preference error\: %s
norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file.
cancel=Cancel
exeop.STATUS=Execute...
initop.STATUS=Checking Data...
noflowkey.ERROR=Missing key for flow number.
wordfield_pagecount.NAME=\u9875\u6570
nopropintype.ERROR2=Property is not defined in type "%s"\: %s.
getflowno.ERROR1=Error getting new flow number for key\: %s
formsave.ERRORTITLE=Error Saving Data
wordfield_pageno.NAME=\u9875\u7801
wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00
wordfield_totalpagecount.NAME=\u603B\u9875\u6570
exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info.
selectProject=Select Project
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
excelnotitle.ERROR=Can't find title row in excel sheet.
loadCompFromUid.Error2=Error loading component "%s", UID \= "%s".
uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed.
wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00
nodatainfile.ERROR1=No Data in File\: %s
noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA
notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C
error=Error
mergefile=Merge File...
index=Index
forminit.ERRORTITLE=Error Loading Rendering
ok=OK
wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570
requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s
functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD
multiuserbyid.ERROR1=Find multiple users by id\: %s
preparedata=Prepare Data
dbconn.ERROR=Connect to database failed.
typenotfound.ERROR1=Type not found\: %s
filenotexist.ERROR1=File not exist\: %s
wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00
readdata=Read Data
clearcache=Clear Cache
exportsuccess.INFO=Export Complete.
uploadfile=Upload File
propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s
foldernotexist.ERROR1=Folder not exist\: %s
info=Info
wordfield_totalpageno.NAME=\u603B\u9875\u7801
multiuserbyname.ERROR1=Find multiple users by name\: %s
exportopenfile.INFO=Export complete. Open file?
prefnotconfiged.ERROR1=Prefernce not found\: %s
export=Export

@ -0,0 +1,58 @@
#
#Thu Jan 21 10:28:16 CST 2021
createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25
project=\u9879\u76EE
dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6
valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s
writedata=\u5199\u5165\u6570\u636E
querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s
dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38
preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s
norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002
cancel=\u53D6\u6D88
exeop.STATUS=\u6B63\u5728\u6267\u884C...
initop.STATUS=\u68C0\u67E5\u6570\u636E...
noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A
wordfield_pagecount.NAME=\u9875\u6570
nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s
getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s
formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519
wordfield_pageno.NAME=\u9875\u7801
wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00
wordfield_totalpagecount.NAME=\u603B\u9875\u6570
exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9
selectProject=\u9009\u62E9\u9879\u76EE
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C
loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002
uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002
wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00
nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s
noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA
notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C
error=\u9519\u8BEF
mergefile=\u5408\u5E76\u6587\u4EF6
index=\u5E8F\u53F7
forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38
ok=\u786E\u5B9A
wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570
requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s
functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD
multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s
preparedata=\u51C6\u5907\u6570\u636E
dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002
typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s
filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s
wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00
readdata=\u8BFB\u53D6\u6570\u636E
clearcache=\u6E05\u7406\u7F13\u5B58
exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210
uploadfile=\u4E0A\u4F20\u6587\u4EF6
propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s
foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s
info=\u63D0\u793A
wordfield_totalpageno.NAME=\u603B\u9875\u7801
multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s
exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F
prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s
export=\u5BFC\u51FA

@ -0,0 +1,7 @@
selectDataset=Please select a dataset
warn=warn
ok=ok
err=err
revisedSuccessful=save successfully
revisionFailed=save failed
cel=cancel

@ -0,0 +1,7 @@
selectDataset=\u8BF7\u9009\u4E2D\u6570\u636E\u96C6
warn=\u63D0\u9192
ok=\u786E\u8BA4
err=\u9519\u8BEF
revisedSuccessful=\u5907\u4EFD\u5B8C\u6210
revisionFailed=\u5907\u4EFD\u5931\u8D25
cel=\u53D6\u6D88

@ -0,0 +1,86 @@
package com.net.connor.ld.plm.ld06;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.RowSorter;
import javax.swing.RowSorter.SortKey;
import javax.swing.SortOrder;
import javax.swing.table.TableRowSorter;
import antlr.collections.List;
public class ArrowIcon implements Icon {
private final SortOrder sortOrder;
private final int size;
private final boolean ascending;
public ArrowIcon(TableRowSorter<?> sorter, int column, boolean ascending) {
this.ascending = ascending;
this.size = 12;
java.util.List<? extends SortKey> sortKeys = sorter.getSortKeys();
if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) {
this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder();
} else {
this.sortOrder = SortOrder.ASCENDING;
}
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(x, y);
if (ascending) {
g2.rotate(Math.PI, size / 2.0, size / 2.0);
}
if (sortOrder == SortOrder.ASCENDING) {
g2.draw(createUpTriangle(size));
} else {
g2.draw(createDownTriangle(size));
}
g2.dispose();
}
public int getIconWidth() {
return size;
}
public int getIconHeight() {
return size;
}
private Polygon createUpTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, size);
triangle.addPoint(size / 2, 0);
triangle.addPoint(size, size);
return triangle;
}
private Polygon createDownTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, 0);
triangle.addPoint(size, 0);
triangle.addPoint(size / 2, size);
return triangle;
}
}
//表格列排序类
class ColumnSorter implements Comparator<Object> {
private final int col;
private final boolean ascending;
public ColumnSorter(int col, boolean ascending) {
this.col = col;
this.ascending = ascending;
}
@Override
public int compare(Object a, Object b) {
if (a instanceof Comparable && b instanceof Comparable) {
if (ascending) {
return ((Comparable) a).compareTo((Comparable) b);
} else {
return ((Comparable) b).compareTo((Comparable) a);
}
} else {
return 0;
}
}
}

Binary file not shown.

@ -0,0 +1,18 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
poi_lib/aspose-words-17.4.0-jdk16.jar,\
poi_lib/commons-collections4-4.1.jar,\
poi_lib/poi-3.17.jar,\
poi_lib/poi-examples-3.17.jar,\
poi_lib/poi-excelant-3.17.jar,\
poi_lib/poi-ooxml-3.17.jar,\
poi_lib/poi-ooxml-schemas-3.17.jar,\
poi_lib/poi-scratchpad-3.17.jar,\
poi_lib/xmlbeans-2.6.0.jar,\
poi_lib/axis2-ant-plugin-1.6.2.jar,\
poi_lib/antlr-2.7.7.jar,\
poi_lib/commons-io-1.4.jar

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<!--菜单名称定义-->
<extension point="org.eclipse.ui.commands">
<command name="备份实施计划" id="com.connor.plm.sample.DatasetSaveAsHandler"> </command>
<command name="提取属性到Word/Excel" id="com.connor.plm.sb01.PropertyToWordOrExcelCommand"/>
<command name="派生更改请求ECR" id="com.connor.plm.sb02.DerivedChangeRequestCommand"/>
<command name="派生更改通知ECN" id="com.connor.plm.sb02.DerivedChangeNoticeCommand"/>
</extension>
<!--菜单跳转到对应程序-->
<extension point="org.eclipse.ui.handlers">
<handler
class="com.connor.plm.sample.DatasetSaveAsHandler"
commandId="com.connor.plm.sample.DatasetSaveAsHandler">
</handler>
<handler commandId="com.connor.plm.sb01.PropertyToWordOrExcelCommand" class="com.connor.plm.KHandler"/>
<handler commandId="com.connor.plm.sb02.DerivedChangeRequestCommand" class="com.connor.plm.KHandler"/>
<handler commandId="com.connor.plm.sb02.DerivedChangeNoticeCommand" class="com.connor.plm.KHandler"/>
</extension>
<!--菜单快捷键设置-->
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.connor.plm.sample.DatasetSaveAsHandler"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6">
</key>
</extension>
<!--菜单显示位置设置-->
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="com.connor.plm.menus.sampleMenu"
label="世宝二开"
mnemonic="M">
<command
commandId="com.connor.plm.sample.DatasetSaveAsHandler"
id="com.connor.plm.sample.menus.DatasetSaveAsHandler"
mnemonic="S">
</command>
</menu>
</menuContribution>
<!-- 右键菜单 -->
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="com.connor.plm.sample.DatasetSaveAsHandler"
id="com.connor.plm.sample.menus.DatasetSaveAsHandler"
mnemonic="S">
</command>
<command id="com.connor.plm.sb01.menus.PropertyToWordOrExcelCommand" commandId="com.connor.plm.sb01.PropertyToWordOrExcelCommand">
<visibleWhen checkEnabled="true">
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="com.connor.plm.sb01.PropertyToWordOrExcelCommand" />
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command id="com.connor.plm.sb02.menus.DerivedChangeRequestCommand" commandId="com.connor.plm.sb02.DerivedChangeRequestCommand">
<visibleWhen checkEnabled="true">
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="com.connor.plm.sb02.DerivedChangeRequestCommand" />
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
<command id="com.connor.plm.sb02.menus.DerivedChangeNoticeCommand" commandId="com.connor.plm.sb02.DerivedChangeNoticeCommand">
<visibleWhen checkEnabled="true">
<and>
<iterate ifEmpty="false">
<adapt type="com.teamcenter.rac.kernel.TCComponent">
<or>
<test property="com.teamcenter.rac.kernel.TCComponent.typeClass"
value="ItemRevision">
</test>
</or>
</adapt>
</iterate>
<with variable="rac_command_suppression">
<not>
<iterate operator="or">
<equals value="com.connor.plm.sb02.DerivedChangeNoticeCommand" />
</iterate>
</not>
</with>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,44 @@
package com.connor.plm;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "cn.net.connor.ml.plm"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

@ -0,0 +1,603 @@
package com.connor.plm;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class DateUtil {
private static final String HYPHEN = "-";
private static final String COLON = ":";
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间格式 DateTimeFormatter (Java8) ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
enum FormatEnum {
/**
* DateTimeFormatter "yyyy-MM-dd HH:mm:ss"
*/
FORMAT_DATA_TIME(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)),
/**
* DateTimeFormatter "yyyyMMddHHmmss"
*/
FORMAT_DATA_TIME_NO_SYMBOL(DateTimeFormatter.ofPattern(DATETIME_FORMAT)),
/**
* DateTimeFormatter "yyyy-MM-dd"
*/
FORMAT_DATE(DateTimeFormatter.ofPattern(DATE_FORMAT)),
/**
* DateTimeFormatter "HH:mm:ss"
*/
FORMAT_TIME(DateTimeFormatter.ofPattern(TIME_FORMAT));
private DateTimeFormatter value;
FormatEnum(DateTimeFormatter format) {
this.value = format;
}
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间格式 DateTimeFormatter (Java8) ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间格式 字符串 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
*
* <br/>
* "yyyy"
*/
public static final String YEAR_FORMAT = "yyyy";
/**
*
* <br/>
* "MM"
*/
public static final String MONTH_FORMAT = "MM";
/**
*
* <br/>
* "dd"
*/
public static final String DAY_FORMAT = "dd";
/**
*
* <br/>
* "HH"
*/
public static final String HOUR_FORMAT = "HH";
/**
*
* <br/>
* "mm"
*/
public static final String MINUTE_FORMAT = "mm";
/**
*
* <br/>
* "ss"
*/
public static final String SECOND_FORMAT = "ss";
/**
* <span color='red'>--</span>
* <br/>
* "yyyy-MM-dd"
*/
public static final String DATE_FORMAT = YEAR_FORMAT + HYPHEN + MONTH_FORMAT + HYPHEN + DAY_FORMAT;
/**
* <span color='red'>::</span>
* <br/>
* "HH:mm:ss"
*/
public static final String TIME_FORMAT = HOUR_FORMAT + COLON + MINUTE_FORMAT + COLON + SECOND_FORMAT;
/**
* <span color='red'>-- ::</span>
* <br/>
* "yyyy-MM-dd HH:mm:ss"
*/
public static final String DATE_TIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
/**
* <span color='red'></span>
* <br/>
* "yyyyMMddHHmmss"
*/
public static final String DATETIME_FORMAT = YEAR_FORMAT + MONTH_FORMAT + DAY_FORMAT + HOUR_FORMAT + MINUTE_FORMAT + SECOND_FORMAT;
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间格式 字符串 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间戳 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
*
*/
public static Long epochSecond() {
return localDateTime().toEpochSecond(ZoneOffset.of("+8"));
}
/**
*
*/
public static Long epochMilli() {
return localDateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli();
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间戳 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 当前时间相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* like 2018-08-27 17:20:06
*/
public static String dateTime() {
return localDateTime().format(FormatEnum.FORMAT_DATA_TIME.value);
}
/**
* like 20180827172006
*/
public static String dateTimeNoSymbol() {
return localDateTime().format(FormatEnum.FORMAT_DATA_TIME_NO_SYMBOL.value);
}
/**
* like 2018-08-27
*/
public static String date() {
return localDate() + "";
}
/**
* like 17:20:06
*/
public static String time() {
return localTime().format(FormatEnum.FORMAT_TIME.value);
}
/**
*
*/
public static Integer year() {
return localDate().getYear();
}
/**
*
*/
public static int month() {
return localDate().getMonthValue();
}
/**
*
*/
public static Integer dayOfYear() {
return localDate().getDayOfYear();
}
/**
*
*/
public static Integer dayOfMonth() {
return localDate().getDayOfMonth();
}
/**
*
*/
public static Integer dayOfWeek() {
return localDate().getDayOfWeek().getValue();
}
/**
*
*/
public static Integer hour() {
return localTime().getHour();
}
/**
*
*/
public static Integer minute() {
return localTime().getMinute();
}
/**
*
*/
public static Integer second() {
return localTime().getSecond();
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 当前时间相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 未来、历史时间相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
*
* <p>
*
* @param years
* @param formatEnum
* @return
*/
public static String minusYears(Long years, FormatEnum formatEnum) {
return minusOrPlusYears(-years, formatEnum);
}
/**
*
* <p>
*
* @param years
* @param formatEnum
* @return
*/
public static String plusYears(Long years, FormatEnum formatEnum) {
return minusOrPlusYears(years, formatEnum);
}
/**
*
*
* @param months
* @param formatEnum
* @return
*/
public static String minusMonths(Long months, FormatEnum formatEnum) {
return minusOrPlusMonths(-months, formatEnum);
}
/**
*
*
* @param months
* @param formatEnum
* @return
*/
public static String plusMonths(Long months, FormatEnum formatEnum) {
return minusOrPlusMonths(months, formatEnum);
}
/**
*
*
* @param days
* @param formatEnum
* @return
*/
public static String minusDays(Long days, FormatEnum formatEnum) {
return minusOrPlusDays(-days, formatEnum);
}
/**
*
*
* @param days
* @param formatEnum
* @return
*/
public static String plusDays(Long days, FormatEnum formatEnum) {
return minusOrPlusDays(days, formatEnum);
}
/**
*
*
* @param weeks
* @param formatEnum
* @return
*/
public static String minusWeeks(Long weeks, FormatEnum formatEnum) {
return minusOrPlusWeeks(-weeks, formatEnum);
}
/**
*
*
* @param weeks
* @param formatEnum
* @return
*/
public static String plusWeeks(Long weeks, FormatEnum formatEnum) {
return minusOrPlusWeeks(weeks, formatEnum);
}
/**
*
*
* @param hours
* @param formatEnum
* @return
*/
public static String minusHours(Long hours, FormatEnum formatEnum) {
return minusOrPlusHours(-hours, formatEnum);
}
/**
*
*
* @param hours
* @param formatEnum
* @return
*/
public static String plusHours(Long hours, FormatEnum formatEnum) {
return minusOrPlusHours(hours, formatEnum);
}
/**
*
*
* @param minutes
* @param formatEnum
* @return
*/
public static String minusMinutes(Long minutes, FormatEnum formatEnum) {
return minusOrPlusMinutes(-minutes, formatEnum);
}
/**
*
*
* @param minutes
* @param formatEnum
* @return
*/
public static String plusMinutes(Long minutes, FormatEnum formatEnum) {
return minusOrPlusMinutes(minutes, formatEnum);
}
/**
*
*
* @param seconds
* @param formatEnum
* @return
*/
public static String minusSeconds(Long seconds, FormatEnum formatEnum) {
return minusOrPlusSeconds(-seconds, formatEnum);
}
/**
* /
*
* @param seconds
* @param formatEnum
* @return
*/
public static String plusSeconds(Long seconds, FormatEnum formatEnum) {
return minusOrPlusSeconds(seconds, formatEnum);
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 未来、历史时间相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间转换相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* DateLocalDateTime
* <p>
*
* @param date date
* @return LocalDateTime
*/
public static LocalDateTime toLocalDateTime(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
/**
* DateLocalDate
* <p>
*
* @param date date
* @return LocalDate
*/
public static LocalDate toLocalDate(Date date) {
return toLocalDateTime(date).toLocalDate();
}
/**
* DateLocalTime
* <p>
*
* @param date date
* @return LocalTime
*/
public static LocalTime toLocalTime(Date date) {
return toLocalDateTime(date).toLocalTime();
}
/**
* LocalDateTime Date
*
* @param localDateTime localDateTime
* @return Date
*/
public static Date toDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
/**
* LocalDateDate
*
* @param localDate localDate
* @return Date
*/
public static Date toDate(LocalDate localDate) {
return toDate(localDate.atStartOfDay());
}
/**
* LocalTimeDate
*
* @param localTime localTime
* @return Date
*/
public static Date toDate(LocalTime localTime) {
return toDate(LocalDateTime.of(localDate(), localTime));
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间转换相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 时间间隔相关 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* endDate-startDate
* <br> leigq
* <br> 2018-11-07 09:55
* <br>
*
* @param startDate
* @param endDate
* @return
*/
public static Long daysInterval(LocalDate startDate, LocalDate endDate) {
return endDate.toEpochDay() - startDate.toEpochDay();
}
/**
* endDate-startDate
* <br> leigq
* <br> 2018-11-07 09:55
* <br>
*
* @param startDate
* @param endDate
* @return
*/
public static Long daysInterval(String startDate, String endDate) {
return daysInterval(LocalDateTime.parse(endDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate(),
LocalDateTime.parse(startDate, FormatEnum.FORMAT_DATA_TIME.value).toLocalDate());
}
/**
* endDate-startDate
* <br> leigq
* <br> 2018-11-07 09:55
* <br>
*
* @param startDate
* @param endDate
* @return
*/
public static Long daysInterval(LocalDateTime startDate, LocalDateTime endDate) {
return daysInterval(startDate.toLocalDate(), endDate.toLocalDate());
}
/*↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 时间间隔相关 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
/*↓↓↓只允许此类调用↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
/**
* /
* <p>
*
* @param yearsToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusYears(Long yearsToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusYears(yearsToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param monthsToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusMonths(Long monthsToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusMonths(monthsToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param daysToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusDays(Long daysToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusDays(daysToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param weeksToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusWeeks(Long weeksToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusWeeks(weeksToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param hoursToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusHours(Long hoursToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusHours(hoursToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param minutesToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusMinutes(Long minutesToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusMinutes(minutesToAddOrSubtract).format(formatEnum.value);
}
/**
* /
*
* @param secondsToAddOrSubtract
* @param formatEnum
* @return /
*/
private static String minusOrPlusSeconds(Long secondsToAddOrSubtract, FormatEnum formatEnum) {
return localDateTime().plusSeconds(secondsToAddOrSubtract).format(formatEnum.value);
}
/**
* LocalDate
*/
private static LocalDate localDate() {
return localDateTime().toLocalDate();
}
/**
* LocalTime
*/
private static LocalTime localTime() {
return localDateTime().toLocalTime();
}
/**
* LocalDateTime
*/
private static LocalDateTime localDateTime() {
return LocalDateTime.now();
}
}

@ -0,0 +1,37 @@
package com.connor.plm;
import java.lang.reflect.Constructor;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.util.MessageBox;
public class KAction extends AbstractAIFAction {
KAction(AbstractAIFUIApplication app, String string) {
super(app,string);
}
@Override
public void run() {
try {
int ind = actionName.indexOf('#');
String action=actionName;
String actionData="";
if(ind>0) {
action=actionName.substring(0,ind);
actionData=actionName.substring(ind+1);
}
Class<?> c = Class.forName(action);
Constructor<?> constructor = c.getConstructor(AbstractAIFApplication.class, String.class,String.class);
KCommand command = (KCommand) constructor.newInstance(this.application, action, actionData);
command.executeModal();
} catch (Exception e) {
e.printStackTrace();
MessageBox.post(e.toString(),KLocale.getString("error"),MessageBox.ERROR);
}
}
}

@ -0,0 +1,16 @@
package com.connor.plm;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFCommand;
public abstract class KCommand extends AbstractAIFCommand {
protected AbstractAIFApplication app;
protected String actionInfo;
public KCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
this.app = app;
this.actionInfo = actionInfo;
}
}

@ -0,0 +1,24 @@
package com.connor.plm;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
/**
* Add following config to MANIFEST.MF
* Eclipse-RegisterBuddy: k.util
* @author Administrator
*
*/
public class KHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) {
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
new Thread(new KAction(app,arg0.getCommand().getId())).start();
return null;
}
}

@ -0,0 +1,22 @@
package com.connor.plm;
import com.teamcenter.rac.util.Registry;
public class KLocale {
public static final Registry reg = Registry.getRegistry(KLocale.class);
public static String getString(String title) {
if (isEmpty(title)) {
return "";
} else {
String res = reg.getString(title);
return isEmpty(res) ? title : res;
}
}
private static boolean isEmpty(String title) {
return title == null || "".equals(title.trim());
}
}

@ -0,0 +1,52 @@
package com.connor.plm;
import java.awt.Dimension;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCSession;
/*
* do not call executeOperation yourself
* use session.performOperation
*/
public abstract class KOperation extends AbstractAIFOperation {
protected AbstractAIFApplication app;
protected TCSession session;
public String messageLabel;
public KOperation(AbstractAIFApplication app, String opName, String messageLabel) {
super(opName, true);
this.app = app;
this.session = (TCSession) app.getSession();
this.messageLabel = messageLabel;// ½ø¶ÈÌõÐÅÏ¢
setSession(session);
}
public abstract boolean init() throws Exception;
public abstract void execute() throws Exception;
@Override
public void executeOperation() {
ProgressBar pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true);
try {
pb.showDialog();
pb.setText(messageLabel);
setStatus("Checking Data...");
if (!init()) {
pb.disposeDialog();
return;
}
setStatus("Execute...");
pb.setText(messageLabel);
execute();
pb.disposeDialog();
} catch (Exception e) {
pb.disposeDialog();
KUtil.error(getCurrentDesktop(), "·¢ÉúÒì³££º\n" + e.getMessage());
e.printStackTrace();
}
}
}

@ -0,0 +1,51 @@
package com.connor.plm;
import java.awt.Dimension;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCSession;
/*
* do not call executeOperation yourself
* use session.performOperation
*/
public abstract class KOperation2 extends AbstractAIFOperation {
protected AbstractAIFApplication app;
protected TCSession session;
protected ProgressBar pb;
public KOperation2(AbstractAIFApplication app, String opName) {
super(opName, true);
this.app = app;
this.session = (TCSession) app.getSession();
setSession(session);
}
public abstract boolean init() throws Exception;
public abstract void execute() throws Exception;
@Override
public void executeOperation() {
pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true);
try {
pb.showDialog();
setStatus(KLocale.getString("initop.STATUS"));
if (!init()) {
pb.disposeDialog();
return;
}
setStatus(KLocale.getString("exeop.STATUS"));
execute();
KUtil.setByPass(false);
pb.disposeDialog();
} catch (Exception e) {
pb.disposeDialog();
KUtil.setByPass(false);
KUtil.error(getCurrentDesktop(), "·¢ÉúÒì³££º\n" + e);
e.printStackTrace();
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,130 @@
package com.connor.plm;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.KeyStroke;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aif.AbstractAIFDialog;
@SuppressWarnings("serial")
public class ProgressBar extends AbstractAIFDialog {
private JLabel messageLabel;
private JProgressBar progressBar;
private boolean showBar = false;
public ProgressBar(AIFDesktop aifDesktop, Dimension dim, boolean showBar) {
super(aifDesktop, false);
this.showBar = showBar;
initUI(dim);
}
public ProgressBar(AbstractAIFDialog pd, Dimension dimension) {
super(pd, false);
initUI(dimension);
}
public ProgressBar(Dimension dim, boolean showBar) {
super(false);
this.showBar = showBar;
initUI(dim);
}
public ProgressBar(AbstractAIFDialog pd, Dimension dimension, boolean showBar) {
super(pd, false);
this.showBar = showBar;
initUI(dimension);
}
private void initUI(Dimension dim) {
this.setLayout(new BorderLayout(0, 0));
this.setUndecorated(true);
JPanel main = new JPanel(new GridBagLayout());
GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0);
main.setBackground(new Color(53, 53, 53));
if (dim != null) {
this.setPreferredSize(dim);
} else {
this.setPreferredSize(new Dimension(200, 40));
}
messageLabel = new JLabel(" ");
messageLabel.setForeground(Color.white);
progressBar = new JProgressBar();
progressBar.setForeground(Color.black);
main.add(messageLabel, s);
s.gridy++;
s.insets = new Insets(0, 5, 2, 5);
if (showBar) {
main.add(progressBar, s);
}
this.add(BorderLayout.CENTER, main);
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
this.getRootPane().registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
MouseAdapter ma = new MouseAdapter() {
private Point pressPoint = new Point();
@Override
public void mousePressed(MouseEvent e) {
pressPoint = e.getPoint();
}
@Override
public void mouseReleased(MouseEvent e) {
pressPoint = new Point();
}
@Override
public void mouseDragged(MouseEvent e) {
Rectangle r = ProgressBar.this.getBounds();
setLocation(r.x + (e.getX() - pressPoint.x), r.y + (e.getY() - pressPoint.y));
}
};
this.addMouseListener(ma);
this.addMouseMotionListener(ma);
}
public void setText(String message) {
// System.out.println(message);
messageLabel.setText(message);
}
public void setText(String txt, int percent) {
setText(txt);
if (percent > progressBar.getMaximum()) {
percent = progressBar.getMaximum();
}
progressBar.setValue(percent);
}
public void cancel() {
disposeDialog();
}
public void startProgress() {
showDialog();
}
}

@ -0,0 +1,58 @@
#
#Thu Jan 21 10:28:16 CST 2021
createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25
project=Project
dsuidinpref.ERROR1=Error dataset uid set in preference\: %s
valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s
writedata=Write Data
querynotexist.ERROR1=Query not exist\: %s
dialoginit.ERROR=Init Error
preferror.ERROR1=Preference error\: %s
norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file.
cancel=Cancel
exeop.STATUS=Execute...
initop.STATUS=Checking Data...
noflowkey.ERROR=Missing key for flow number.
wordfield_pagecount.NAME=\u9875\u6570
nopropintype.ERROR2=Property is not defined in type "%s"\: %s.
getflowno.ERROR1=Error getting new flow number for key\: %s
formsave.ERRORTITLE=Error Saving Data
wordfield_pageno.NAME=\u9875\u7801
wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00
wordfield_totalpagecount.NAME=\u603B\u9875\u6570
exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info.
selectProject=Select Project
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
excelnotitle.ERROR=Can't find title row in excel sheet.
loadCompFromUid.Error2=Error loading component "%s", UID \= "%s".
uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed.
wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00
nodatainfile.ERROR1=No Data in File\: %s
noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA
notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C
error=Error
mergefile=Merge File...
index=Index
forminit.ERRORTITLE=Error Loading Rendering
ok=OK
wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570
requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s
functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD
multiuserbyid.ERROR1=Find multiple users by id\: %s
preparedata=Prepare Data
dbconn.ERROR=Connect to database failed.
typenotfound.ERROR1=Type not found\: %s
filenotexist.ERROR1=File not exist\: %s
wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00
readdata=Read Data
clearcache=Clear Cache
exportsuccess.INFO=Export Complete.
uploadfile=Upload File
propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s
foldernotexist.ERROR1=Folder not exist\: %s
info=Info
wordfield_totalpageno.NAME=\u603B\u9875\u7801
multiuserbyname.ERROR1=Find multiple users by name\: %s
exportopenfile.INFO=Export complete. Open file?
prefnotconfiged.ERROR1=Prefernce not found\: %s
export=Export

@ -0,0 +1,58 @@
#
#Thu Jan 21 10:28:16 CST 2021
createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25
project=\u9879\u76EE
dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6
valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s
writedata=\u5199\u5165\u6570\u636E
querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s
dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38
preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s
norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002
cancel=\u53D6\u6D88
exeop.STATUS=\u6B63\u5728\u6267\u884C...
initop.STATUS=\u68C0\u67E5\u6570\u636E...
noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A
wordfield_pagecount.NAME=\u9875\u6570
nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s
getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s
formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519
wordfield_pageno.NAME=\u9875\u7801
wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00
wordfield_totalpagecount.NAME=\u603B\u9875\u6570
exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9
selectProject=\u9009\u62E9\u9879\u76EE
proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E
excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C
loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002
uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002
wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00
nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s
noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA
notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C
error=\u9519\u8BEF
mergefile=\u5408\u5E76\u6587\u4EF6
index=\u5E8F\u53F7
forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38
ok=\u786E\u5B9A
wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570
requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s
functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD
multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s
preparedata=\u51C6\u5907\u6570\u636E
dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002
typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s
filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s
wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00
readdata=\u8BFB\u53D6\u6570\u636E
clearcache=\u6E05\u7406\u7F13\u5B58
exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210
uploadfile=\u4E0A\u4F20\u6587\u4EF6
propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s
foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s
info=\u63D0\u793A
wordfield_totalpageno.NAME=\u603B\u9875\u7801
multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s
exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F
prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s
export=\u5BFC\u51FA

@ -0,0 +1,47 @@
package com.connor.plm.sample;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* :
* :2024-08-04
* @author
*
*
*
*/
public class DatasetSaveAsHandler extends AbstractHandler{
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
InterfaceAIFComponent targetComp = app.getTargetComponent();
TCSession session = (TCSession) app.getSession();
if(targetComp != null){
if(targetComp instanceof TCComponentDataset){
TCComponentDataset targetDataset = (TCComponentDataset)targetComp;
DatasetSaveAsOperation operation = new DatasetSaveAsOperation(app,targetDataset);
session.queueOperation(operation);
return null;
}else{
MessageBox.post(PlmLocale.getString("selectDataset"),
PlmLocale.getString("warn"),
MessageBox.INFORMATION);
return null;
}
}else{
MessageBox.post(PlmLocale.getString("selectDataset"),
PlmLocale.getString("warn"),
MessageBox.INFORMATION);
}
return null;
}
}

@ -0,0 +1,170 @@
package com.connor.plm.sample;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.workflow.WorkflowService;
import com.teamcenter.services.rac.workflow._2008_06.Workflow.ContextData;
import com.teamcenter.services.rac.workflow._2008_06.Workflow.InstanceInfo;
/**
* :
* :2019-02-26
* @author
*
*
* 2019-01-24 XXXX
*/
public class DatasetSaveAsOperation extends AbstractAIFOperation{
private AbstractAIFUIApplication app;
private TCComponentDataset targetComp;
private static final String SPEC_RELATION_TYPE = "IMAN_specification";
private static final String preName = "Connor_dataset_ref";
private TCSession session;
public DatasetSaveAsOperation(AbstractAIFUIApplication app,
TCComponentDataset targetComp) {
this.app = app;
this.targetComp = targetComp;
session = (TCSession) app.getSession();
}
/**
*
*
* @return
*/
private TCComponentDataset createDataset() {
TCComponentDataset newDataset = null;
String[] path = new String[1];
String[] refType = new String[1];
try {
String type = targetComp.getType();
Map<String, String> refMap = new HashMap<String, String>();
String[] prefVals = KUtil.getPrefVals(session, preName);
for (int i = 0; i < prefVals.length; i++) {
if(prefVals[i].contains("=")) {
String[] split = prefVals[i].split("=");
refMap.put(split[0], split[1]);
}
}
if(refMap.containsKey(type)) {
refType[0] = refMap.get(type);
}else {
MessageBox.post("未找到对应数据集类型"+type+"的引用,请联系管理员检查",
PlmLocale.getString("err"),
MessageBox.INFORMATION);
return null;
}
String datasetName = targetComp.getStringProperty("object_name");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String timestamp = sdf.format(new Date());
String objectName = "";
if(datasetName.contains(".")) {
String[] split = datasetName.split("\\.");
objectName = split[0] + timestamp + "." + split[1];
}else {
objectName = datasetName + timestamp;
}
File[] files = targetComp.getFiles("");
TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset");
//创建数据集
newDataset = datasetType.create(objectName, "", type);
//上传物理文件
if(newDataset != null) {
String oldPath = files[0].getAbsolutePath();
if(oldPath.contains(".")) {
String[] split = oldPath.split("\\.");
String newPath = split[0] + timestamp + "." + split[1];
FileUtils.copyFile(new File(oldPath), new File(newPath));
path[0] = newPath;
newDataset.setFiles(path, refType);
}
}else {
return newDataset;
}
} catch (Exception e) {
e.printStackTrace();
}
return newDataset;
}
@Override
public void executeOperation() throws Exception {
try {
//获取关联目标数据集的版本对象
AIFComponentContext[] whereReferenced = targetComp.whereReferenced();
InterfaceAIFComponent comp = whereReferenced[0].getComponent();
if(comp instanceof TCComponentItemRevision) {
TCComponentItemRevision rev = (TCComponentItemRevision) comp;
TCComponentDataset tempDataset = createDataset();
if(tempDataset != null) {
//给新数据集打上发布状态
workflow(new String[] {tempDataset.getUid()},"快速发布","TCM Release Process");
//添加关系
rev.add(SPEC_RELATION_TYPE,tempDataset);
MessageBox.post(PlmLocale.getString("revisedSuccessful"),
PlmLocale.getString("ok"),
MessageBox.INFORMATION);
}else {
MessageBox.post(PlmLocale.getString("revisionFailed"),
PlmLocale.getString("err"),
MessageBox.ERROR);
}
}
} catch (TCException e) {
e.printStackTrace();
MessageBox.post(PlmLocale.getString("revisionFailed"),
PlmLocale.getString("err"),
MessageBox.ERROR);
}
}
/**
*
*
*/
public void workflow(String[] uid,String workFlowName,String templateName) {
// String uid = rev.getUid();
//创建流程
WorkflowService wfService = WorkflowService.getService(session);
ContextData contextData = new ContextData();
String observerKey = "";
String name = workFlowName;
String subject = "";
String description = "";
contextData.processTemplate = templateName; // update with your own ProcessTemplate.
contextData.subscribeToEvents = false;
contextData.subscriptionEventCount = 0;
contextData.attachmentCount = uid.length;
contextData.attachments = uid ;
int [] types = new int[uid.length];
for(int i = 0;i <uid.length;i++) {
types[i] = 1;
}
contextData.attachmentTypes = types;
//创建流程
InstanceInfo instanceInfo = wfService.createInstance(true, observerKey, name, subject, description, contextData);
}
}

@ -0,0 +1,29 @@
package com.connor.plm.sample;
import com.teamcenter.rac.util.Registry;
/**
* :
* :2019-02-26
* @author
*
*
* 2019-01-24 XXXX
*/
public class PlmLocale {
public static final Registry reg = Registry.getRegistry(PlmLocale.class);
public static String getString(String title) {
if (isEmpty(title)) {
return "";
} else {
String res = reg.getString(title);
return isEmpty(res) ? title : res;
}
}
private static boolean isEmpty(String title) {
return title == null || "".equals(title.trim());
}
}

@ -0,0 +1,7 @@
selectDataset=Please select a dataset
warn=warn
ok=ok
err=err
revisedSuccessful=save successfully
revisionFailed=save failed
cel=cancel

@ -0,0 +1,7 @@
selectDataset=\u8BF7\u9009\u4E2D\u6570\u636E\u96C6
warn=\u63D0\u9192
ok=\u786E\u8BA4
err=\u9519\u8BEF
revisedSuccessful=\u5907\u4EFD\u5B8C\u6210
revisionFailed=\u5907\u4EFD\u5931\u8D25
cel=\u53D6\u6D88

@ -0,0 +1,66 @@
package com.connor.plm.sb01;
import java.io.File;
import com.connor.plm.KCommand;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
public class PropertyToWordOrExcelCommand extends KCommand{
final String preName = "Connor_WordExcel_Report_ItemType";
public PropertyToWordOrExcelCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
this.setRunnable(new PropertyToWordOrExcelOperation(app, "提取对象版本属性到Word Excel"));
// InterfaceAIFComponent targetComponent = app.getTargetComponent();
// TCComponentItemRevision revision = (TCComponentItemRevision) targetComponent;
// try {
// String[] prefVals = KUtil.getPrefVals(session, preName);
// if(prefVals == null || prefVals.length == 0) {
// KUtil.info(AIFDesktop.getActiveDesktop(), preName + "该首选项未配置,请联系管理员!");
// return ;
// }
// String relatioin = prefVals[0];
// TCComponent[] relatedComponents = revision.getRelatedComponents(relatioin);
// if(relatedComponents == null || relatedComponents.length == 0) {
// KUtil.info(AIFDesktop.getActiveDesktop(), "选中对象的 " + relatioin + " 关系下没有数据集");
// return ;
// }
// for (TCComponent tcComponent : relatedComponents) {
// if (tcComponent instanceof TCComponentDataset) {
// TCComponentDataset dataset = (TCComponentDataset) tcComponent;
// File datasetFile = KUtil.getDatasetFile(dataset);
// System.out.println();
// String type = tcComponent.getType();
// switch (type) {
// case "MSExcel":
//
// break;
// case "MSExcelX":
//
// break;
// case "MSWord":
//
// break;
// case "MSWordX":
//
// break;
// }
// }
// }
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
}

@ -0,0 +1,345 @@
package com.connor.plm.sb01;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFName;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFName;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.aspose.words.Bookmark;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
import com.connor.plm.KOperation;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AIFDesktop;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.util.FileUtility;
public class PropertyToWordOrExcelOperation extends KOperation {
public PropertyToWordOrExcelOperation(AbstractAIFApplication app, String opName) {
super(app, opName, "正在执行。。。");
}
final String preName = "Connor_WordExcel_Report_ItemType";
@Override
public boolean init() throws Exception {
new Thread().sleep(1000);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
TCComponentItemRevision revision = (TCComponentItemRevision) targetComponent;
String[] prefVals = KUtil.getPrefVals(session, preName);
if(prefVals == null || prefVals.length == 0) {
KUtil.info(AIFDesktop.getActiveDesktop(), preName + "该首选项未配置,请联系管理员!");
return false;
}
String relatioin = prefVals[0];
TCComponent[] relatedComponents = revision.getRelatedComponents(relatioin);
if(relatedComponents == null || relatedComponents.length == 0) {
KUtil.info(AIFDesktop.getActiveDesktop(), "选中对象的 " + relatioin + " 关系下没有数据集");
return false;
}
String revType = revision.getType();
//处理首选项
HashMap<String, String> nameMap = new HashMap<String, String>();//数据集里面的名称和对象(item,rev,revMaster)集合
if(prefVals.length >= 2) {
for (int i = 1; i < prefVals.length; i++) {
//Item.object_name=object_name
String[] split = prefVals[i].split("\\|");
if(!split[0].equals(revType)) {
continue;
}
String[] split1 = split[1].split("=");
nameMap.put(split1[1],split1[0]);
}
}
for (TCComponent tcComponent : relatedComponents) {
if (tcComponent instanceof TCComponentDataset) {
TCComponentDataset dataset = (TCComponentDataset) tcComponent;
TCComponent[] comps = dataset.getRelatedComponents("release_status_list");
if(comps != null && comps.length > 0) {
continue;
}
File datasetFile = KUtil.getDatasetFile(dataset);
String type = tcComponent.getType();
String datasetType = "";
String newPath = "";
if("MSExcel".equals(type) || "MSExcelX".equals(type) || "MSWord".equals(type) || "MSWordX".equals(type)) {
switch (type) {
case "MSExcel":
datasetType = "excel";
newPath = dealExcel(datasetFile,revision,nameMap);
break;
case "MSExcelX":
datasetType = "excel";
newPath = dealExcelX(datasetFile,revision,nameMap);
break;
case "MSWord":
datasetType = "word";
newPath = dealWord2(datasetFile,revision,nameMap,"doc");
break;
case "MSWordX":
datasetType = "word";
newPath = dealWord2(datasetFile,revision,nameMap,"docx");
break;
}
//给数据集设置新的命名的引用
dataset.setFiles(new String[] {newPath}, new String[] {datasetType});
}
}
}
KUtil.info(AIFDesktop.getActiveDesktop(), "提取对象版本属性到Word Excel执行完成");
return true;
}
@Override
public void execute() throws Exception {
}
private String dealExcel(File datasetFile, TCComponentItemRevision revision, HashMap<String, String> nameMap) throws IOException, TCException {
FileInputStream is = new FileInputStream(datasetFile);
HSSFWorkbook workbook = new HSSFWorkbook(is);
List<HSSFName> allNames = workbook.getAllNames();
for (HSSFName hssfName : allNames) {
String name = hssfName.getNameName();
//名称管理器存在首选项的名称
if (nameMap.containsKey(name)) {
CellReference cellReference = new CellReference(hssfName.getRefersToFormula());
HSSFSheet sheet = workbook.getSheet(cellReference.getSheetName());
HSSFRow row = sheet.getRow(cellReference.getRow());
HSSFCell cell = row.getCell(cellReference.getCol());
String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(name));
if(preConfigValue.endsWith("00:00")) {
System.out.println("时间格式特殊处理");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = dateFormat.parse(preConfigValue);
preConfigValue = dateFormat2.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
System.out.println("行为:" + cellReference.getRow() + "====" + "列为:" + cellReference.getCol() + "===="
+ "值为: " + preConfigValue);
if(cell == null) {
cell = row.createCell(cellReference.getCol());
}
cell.setCellValue(preConfigValue);
}
}
is.close();
FileOutputStream os = new FileOutputStream(datasetFile);
workbook.write(os);
workbook.close();
return datasetFile.getAbsolutePath();
}
private String dealExcelX(File datasetFile, TCComponentItemRevision revision, HashMap<String, String> nameMap) throws IOException, TCException {
FileInputStream is = new FileInputStream(datasetFile);
XSSFWorkbook workbook = new XSSFWorkbook(is);
List<XSSFName> allNames = workbook.getAllNames();
for (XSSFName xssfName : allNames) {
String name = xssfName.getNameName();
//名称管理器存在首选项的名称
if (nameMap.containsKey(name)) {
CellReference cellReference = new CellReference(xssfName.getRefersToFormula());
XSSFSheet sheet = workbook.getSheet(cellReference.getSheetName());
XSSFRow row = sheet.getRow(cellReference.getRow());
XSSFCell cell = row.getCell(cellReference.getCol());
String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(name));
if(preConfigValue.endsWith("00:00")) {
System.out.println("时间格式特殊处理");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = dateFormat.parse(preConfigValue);
preConfigValue = dateFormat2.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
System.out.println("行为:" + cellReference.getRow() + "====" + "列为:" + cellReference.getCol() + "===="
+ "值为: " + preConfigValue);
if(cell == null) {
cell = row.createCell(cellReference.getCol());
cell.setCellValue(preConfigValue);
}
else {
cell.setCellValue(preConfigValue);
}
}
}
is.close();
FileOutputStream os = new FileOutputStream(datasetFile);
workbook.write(os);
workbook.close();
return datasetFile.getAbsolutePath();
}
private String dealWord(File datasetFile, TCComponentItemRevision revision, HashMap<String, String> nameMap,String type) throws IOException, TCException {
String path = datasetFile.getAbsolutePath();
InputStream inputStream = Files.newInputStream(Paths.get(path));
Map<String, String> dataMap = new HashMap<>();
for(String key : nameMap.keySet()) {
String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(key));
if(preConfigValue.endsWith("00:00")) {
System.out.println("时间格式特殊处理");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = dateFormat.parse(preConfigValue);
preConfigValue = dateFormat2.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
dataMap.put(key, preConfigValue);
}
String newPath = "";
if(type.equals("doc")) {
newPath = path.replace(".doc", "temp.doc");
WordUtils.replaceBookmarksByDoc(inputStream, Files.newOutputStream(Paths.get(newPath)), dataMap);
}
else if(type.equals("docx")) {
newPath = path.replace(".docx", "temp.docx");
WordUtils.replaceBookmarksByDocx(inputStream, Files.newOutputStream(Paths.get(newPath)), dataMap);
}
return newPath;
}
private String dealWord2(File datasetFile, TCComponentItemRevision revision, HashMap<String, String> nameMap,String type) throws FileNotFoundException, Exception {
String path = datasetFile.getAbsolutePath();
Document document2 = new Document(new FileInputStream(path));
OutputStream outputStream = null;
String newPath = path.replace(".doc", "temp.doc");
outputStream = new FileOutputStream(newPath);
Map<String, String> dataMap = new HashMap<>();
for(String key : nameMap.keySet()) {
String preConfigValue = getPreConfigValue(revision,nameMap,nameMap.get(key));
if(preConfigValue.endsWith("00:00")) {
System.out.println("时间格式特殊处理");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = dateFormat.parse(preConfigValue);
preConfigValue = dateFormat2.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
dataMap.put(key, preConfigValue);
}
for (Bookmark bookmark : document2.getRange().getBookmarks()) {
String bookmarkName = bookmark.getName();
System.out.println("书签名:"+bookmarkName);
if(dataMap.containsKey(bookmarkName))
{
System.out.println("添加内容");
bookmark.setText(dataMap.get(bookmarkName));
}
}
if(type.equals("doc")) {
document2.save(outputStream, SaveFormat.DOC);
}else if(type.equals("docx")) {
document2.save(outputStream, SaveFormat.DOCX);
}
return newPath;
}
/**
* =
* @param revision
* @param nameMap
* @param value
* @return
* @throws TCException
*/
private String getPreConfigValue(TCComponentItemRevision revision, HashMap<String, String> nameMap,String value) throws TCException {
String[] split = value.split("\\.");
String cellValue = "";
TCProperty property = null;
if(split.length == 2) {
switch (split[0]) {
case "Item":
property = revision.getItem().getTCProperty(split[1]);
break;
case "Rev":
property = revision.getTCProperty(split[1]);
break;
case "RevMaster":
property = revision.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[1]);
break;
default:
break;
}
}
//取关系文件夹下的属性
else if(split.length == 3) {
String relation = split[0];
TCComponent relatedComponent = revision.getRelatedComponent(relation);
TCComponentItemRevision centerRev = null;
if(relatedComponent instanceof TCComponentItemRevision) {
centerRev = (TCComponentItemRevision) relatedComponent;
}else if(relatedComponent instanceof TCComponentItem) {
centerRev = ((TCComponentItem) relatedComponent).getLatestItemRevision();
}
if(centerRev != null) {
switch (split[1]) {
case "Item":
property = centerRev.getItem().getTCProperty(split[2]);
break;
case "Rev":
property = centerRev.getTCProperty(split[2]);
break;
case "RevMaster":
property = centerRev.getRelatedComponent("IMAN_master_form_rev").getTCProperty(split[2]);
break;
default:
break;
}
}
}
if(property == null) {
return "";
}
else {
cellValue = property.getDisplayValue();
return cellValue;
}
}
}

@ -0,0 +1,68 @@
package com.connor.plm.sb01;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.usermodel.HSSFName;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.usermodel.XSSFName;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.aspose.words.Bookmark;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
public class Test {
public static void main(String[] args) {
try {
// FileInputStream is = new FileInputStream("C:\\Users\\Administrator\\Desktop\\测试文件夹\\2.xls");
// // 读取文件进来
// HSSFWorkbook workbook = new HSSFWorkbook(is);
// List<HSSFName> allNames = workbook.getAllNames();
// System.out.println("allNames = " + allNames);
// String cellReference = allNames.get(0).getRefersToFormula();
// workbook.close();
// is.close();
// FileInputStream is2 = new FileInputStream("C:\\Users\\Administrator\\Desktop\\测试文件夹\\1.xlsx");
// // 读取文件进来
// XSSFWorkbook workbook2 = new XSSFWorkbook(is2);
// List<XSSFName> allNames2 = workbook2.getAllNames();
//
// workbook2.close();
// is2.close();
FileInputStream is = new FileInputStream("C:\\Users\\Administrator\\Desktop\\work。excel\\1.docx");
// 读取文件进来
XSSFWorkbook workbook = new XSSFWorkbook(is);
File datasetFile = new File("C:\\Users\\Administrator\\Desktop\\work。excel\\1.docx");
String path = datasetFile.getAbsolutePath();
Document document2 = new Document(new FileInputStream(path));
OutputStream outputStream = null;
String newPath = path.replace(".doc", "temp.doc");
outputStream = new FileOutputStream(newPath);
Map<String, String> dataMap = new HashMap<>();
dataMap.put("one", "one");
dataMap.put("two", "two");
for (Bookmark bookmark : document2.getRange().getBookmarks()) {
String bookmarkName = bookmark.getName();
System.out.println("书签名:"+bookmarkName);
if(dataMap.containsKey(bookmarkName))
{
System.out.println("添加内容");
bookmark.setText(dataMap.get(bookmarkName));
}
}
document2.save(outputStream, SaveFormat.DOC);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,168 @@
package com.connor.plm.sb01;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.Bookmark;
import org.apache.poi.hwpf.usermodel.Bookmarks;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.w3c.dom.Node;
public class WordUtils {
public static final String RUN_NODE_NAME = "w:r";
public static final String TEXT_NODE_NAME = "w:t";
public static final String BOOKMARK_START_TAG = "w:bookmarkStart";
public static final String BOOKMARK_END_TAG = "w:bookmarkEnd";
public static final String BOOKMARK_ID_ATTR_NAME = "w:id";
public static final String STYLE_NODE_NAME = "w:rPr";
public static void main(String[] args) throws IOException {
// 替换文件中的 bookmark 内容
InputStream inputStream3 = Files.newInputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\测试文件夹\\22.doc"));
Map<String, String> dataMap = new HashMap<>();
dataMap.put("one", "oneoneoneoneone");
dataMap.put("two", "twotwotwotwo");
dataMap.put("three", "ceshi");
replaceBookmarksByDoc(inputStream3, Files.newOutputStream(Paths.get("C:\\Users\\Administrator\\Desktop\\测试文件夹\\33.doc")), dataMap);
}
/**
* doc
*
* @param inputStream
* @throws IOException
*/
public static void getBookmarksByDoc(InputStream inputStream) throws IOException {
HWPFDocument wordDoc = new HWPFDocument(inputStream);
Bookmarks bookmarks = wordDoc.getBookmarks();
for (int b = 0; b < bookmarks.getBookmarksCount(); b++) {
Bookmark bookmark = bookmarks.getBookmark(b);
String bookMarkText = new Range(bookmark.getStart(), bookmark.getEnd(), wordDoc).text();
System.out.println("[" + bookmark.getStart() + "; "
+ bookmark.getEnd() + "]: " + bookmark.getName() + " = " + bookMarkText);
}
}
/**
* docx
*
* @param inputStream
* @throws IOException
*/
public static void getBookmarksByDocx(InputStream inputStream) throws IOException {
XWPFDocument docx = new XWPFDocument(inputStream);
List<XWPFParagraph> paragraphList = docx.getParagraphs();
for (XWPFParagraph xwpfParagraph : paragraphList) {
CTP ctp = xwpfParagraph.getCTP();
for (int dwI = 0; dwI < ctp.sizeOfBookmarkStartArray(); dwI++) {
CTBookmark bookmark = ctp.getBookmarkStartArray(dwI);
String bookmarkName = bookmark.getName();
// 因为 docx 的结构是xml格式它不像 doc 文档那样有具体的start和end值来定位一个bookmark的值范围
// 所有如果你想要读取 docx 文档中bookmark的内容你需要从 bookmarkStart 节点开始逐级逐层依次解析xml文
// 件的 nodeValue 值并进行拼接,直至读取到下一个名为 bookmarkEnd 的节点为止。
// 下面这个方法 getBookmarkTextContent() 是一个没有实现的方法,如有需要请自行实现
// String bookmarkTextContent = getBookmarkTextContent(bookmark);
System.out.println(bookmarkName);
}
}
}
/**
* docx
*
* @param inputStream
* @param outputStream
* @param dataMap
* @throws IOException
*/
public static void replaceBookmarksByDocx(InputStream inputStream, OutputStream outputStream, Map<String, String> dataMap) throws IOException {
XWPFDocument document = new XWPFDocument(inputStream).getXWPFDocument();
List<XWPFParagraph> paragraphList = document.getParagraphs();
for (XWPFParagraph xwpfParagraph : paragraphList) {
CTP ctp = xwpfParagraph.getCTP();
for (int dwI = 0; dwI < ctp.sizeOfBookmarkStartArray(); dwI++) {
CTBookmark bookmark = ctp.getBookmarkStartArray(dwI);
if (dataMap.containsKey(bookmark.getName())) {
XWPFRun run = xwpfParagraph.createRun();
run.setText(dataMap.get(bookmark.getName()));
Node firstNode = bookmark.getDomNode();
Node nextNode = firstNode.getNextSibling();
while (nextNode != null) {
// 循环查找结束符
String nodeName = nextNode.getNodeName();
if (nodeName.equals(BOOKMARK_END_TAG)) {
break;
}
// 删除中间的非结束节点,即删除原书签内容
Node delNode = nextNode;
nextNode = nextNode.getNextSibling();
ctp.getDomNode().removeChild(delNode);
}
if (nextNode == null) {
// 始终找不到结束标识的,就在书签前面添加
ctp.getDomNode().insertBefore(run.getCTR().getDomNode(), firstNode);
} else {
// 找到结束符将新内容添加到结束符之前即内容写入bookmark中间
ctp.getDomNode().insertBefore(run.getCTR().getDomNode(), nextNode);
}
}
}
}
document.write(outputStream);
document.close();
}
/**
* doc
*
* @param inputStream
* @param outputStream
* @param dataMap
* @throws IOException
*/
public static void replaceBookmarksByDoc(InputStream inputStream, OutputStream outputStream,
Map<String, String> dataMap) throws IOException {
HWPFDocument document = new HWPFDocument(inputStream);
Bookmarks bookmarks = document.getBookmarks();
for (int dwI = 0; dwI < bookmarks.getBookmarksCount(); dwI++) {
Bookmark bookmark = bookmarks.getBookmark(dwI);
if (dataMap.containsKey(bookmark.getName())) {
Range range = new Range(bookmark.getStart(), bookmark.getEnd(), document);
range.replaceText(dataMap.get(bookmark.getName()), false);
}
}
document.write(outputStream);
}
}

@ -0,0 +1,86 @@
package com.connor.plm.sb02;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.RowSorter;
import javax.swing.RowSorter.SortKey;
import javax.swing.SortOrder;
import javax.swing.table.TableRowSorter;
import antlr.collections.List;
public class ArrowIcon implements Icon {
private final SortOrder sortOrder;
private final int size;
private final boolean ascending;
public ArrowIcon(TableRowSorter<?> sorter, int column, boolean ascending) {
this.ascending = ascending;
this.size = 12;
java.util.List<? extends SortKey> sortKeys = sorter.getSortKeys();
if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) {
this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder();
} else {
this.sortOrder = SortOrder.ASCENDING;
}
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(x, y);
if (ascending) {
g2.rotate(Math.PI, size / 2.0, size / 2.0);
}
if (sortOrder == SortOrder.ASCENDING) {
g2.draw(createUpTriangle(size));
} else {
g2.draw(createDownTriangle(size));
}
g2.dispose();
}
public int getIconWidth() {
return size;
}
public int getIconHeight() {
return size;
}
private Polygon createUpTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, size);
triangle.addPoint(size / 2, 0);
triangle.addPoint(size, size);
return triangle;
}
private Polygon createDownTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, 0);
triangle.addPoint(size, 0);
triangle.addPoint(size / 2, size);
return triangle;
}
}
//±í¸ñÁÐÅÅÐòÀà
class ColumnSorter implements Comparator<Object> {
private final int col;
private final boolean ascending;
public ColumnSorter(int col, boolean ascending) {
this.col = col;
this.ascending = ascending;
}
@Override
public int compare(Object a, Object b) {
if (a instanceof Comparable && b instanceof Comparable) {
if (ascending) {
return ((Comparable) a).compareTo((Comparable) b);
} else {
return ((Comparable) b).compareTo((Comparable) a);
}
} else {
return 0;
}
}
}

@ -0,0 +1,97 @@
package com.connor.plm.sb02;
import java.util.HashMap;
import javax.swing.JComboBox;
import com.teamcenter.rac.common.lov.view.components.LOVDisplayer;
public class ControlBean {
private String propName;
private String propRelName;
private String defaultValue = "";
private String propType;
private HashMap<String, String> lovMap;
private String propTo; // ÊôÐÔдÔÚItem/Rev/Form
private JComboBox<String> combox;
private boolean ifMust = false;
// private LOVDisplayer combox;
// public LOVDisplayer getCombox() {
// return combox;
// }
//
// public void setCombox(LOVDisplayer combox) {
// this.combox = combox;
// }
public boolean isIfMust() {
return ifMust;
}
public void setIfMust(boolean ifMust) {
this.ifMust = ifMust;
}
public JComboBox<String> getCombox() {
return combox;
}
public void setCombox(JComboBox<String> combox) {
this.combox = combox;
}
public String getPropTo() {
return propTo;
}
public void setPropTo(String propTo) {
this.propTo = propTo;
}
public HashMap<String, String> getLovMap() {
return lovMap;
}
public void setLovMap(HashMap<String, String> lovMap) {
this.lovMap = lovMap;
}
public String getPropName() {
return propName;
}
public void setPropName(String propName) {
this.propName = propName;
}
public String getPropRelName() {
return propRelName;
}
public void setPropRelName(String propRelName) {
this.propRelName = propRelName;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getPropType() {
return propType;
}
public void setPropType(String propType) {
this.propType = propType;
}
@Override
public String toString() {
return "ControlBean [propName=" + propName + ", propRelName=" + propRelName + ", defaultValue=" + defaultValue
+ ", propType=" + propType + ", lovMap=" + lovMap + ", propTo=" + propTo + ", ifMust=" + ifMust
+ ", combox=" + combox + "]";
}
}

@ -0,0 +1,18 @@
package com.connor.plm.sb02;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class DateTest {
public static void main(String[] args) {
String ssString = "sss.sss";
String[] split = ssString.split("\\.");
System.out.println(split.length);
String takeeffect = "";
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-M-dd HH:mm");
//LocalDateTime createDate = LocalDateTime.parse(create, fmt);
LocalDateTime takeeffectDate = LocalDateTime.parse(takeeffect, fmt);
}
}

@ -0,0 +1,54 @@
package com.connor.plm.sb02;
import java.util.ArrayList;
import com.connor.plm.KCommand;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DerivedChangeNoticeCommand extends KCommand {
public DerivedChangeNoticeCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
String preName = "Connor_Derive_CN";
try {
String[] prefVals = KUtil.getPrefVals(session, preName);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
StringBuffer newType = new StringBuffer();
if (prefVals == null) {
MessageBox.post(preName + "首选项未配置", "提示", MessageBox.INFORMATION);
return;
}
ArrayList<ControlBean> beanList = new ArrayList<ControlBean>();
KUtil.dealPref(prefVals, targetComponent, beanList, newType);
for (ControlBean bean : beanList) {
System.out.println("beanList" + bean.toString());
}
if (newType.toString().isEmpty()) {
MessageBox.post(preName + "首选项配置有误,不存在新建的对象类型", "提示", MessageBox.INFORMATION);
return;
}
if (beanList.size() == 0) {
MessageBox.post(preName + "首选项配置有误,不存在选中对象类型的配置", "提示", MessageBox.INFORMATION);
return;
}
// 问题报告
// if (targetComponent.getType().equals("ProblemReportRevision")) {
this.setRunnable(new DerivedChangeRequestDialog(app, beanList, newType,
(TCComponentItemRevision) targetComponent));
// }
// new
// DerivedChangeRequestDialog(app,beanList,newType,(TCComponentItemRevision)targetComponent);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,46 @@
package com.connor.plm.sb02;
import java.util.ArrayList;
import com.connor.plm.KCommand;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DerivedChangeRequestCommand extends KCommand {
public DerivedChangeRequestCommand(AbstractAIFApplication app, String commandId, String actionInfo) {
super(app, commandId, actionInfo);
TCSession session = (TCSession) app.getSession();
String preName = "Connor_Derive_CR";
try {
String[] prefVals = KUtil.getPrefVals(session, preName);
InterfaceAIFComponent targetComponent = app.getTargetComponent();
StringBuffer newType = new StringBuffer();
if (prefVals == null) {
MessageBox.post(preName + "首选项未配置", "提示", MessageBox.INFORMATION);
return;
}
ArrayList<ControlBean> beanList = new ArrayList<ControlBean>();
KUtil.dealPref(prefVals, targetComponent, beanList, newType);
System.out.println("newType:" + newType);
if (newType.toString().isEmpty()) {
MessageBox.post(preName + "首选项配置有误,不存在新建的对象类型", "提示", MessageBox.INFORMATION);
return;
}
if (beanList.size() == 0) {
MessageBox.post(preName + "首选项配置有误,不存在选中对象类型的配置", "提示", MessageBox.INFORMATION);
return;
}
this.setRunnable(
new DerivedChangeRequestDialog(app, beanList, newType, (TCComponentItemRevision) targetComponent));
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,623 @@
package com.connor.plm.sb02;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
import com.aspose.words.FieldAutoNumLgl;
import com.aspose.words.Revision;
import com.connor.plm.KUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.common.lov.view.components.LOVDisplayer;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.DateButton;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.schemas.soa._2006_03.exceptions.ServiceException;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
import com.teamcenter.services.rac.workflow.WorkflowService;
import com.teamcenter.services.rac.workflow._2008_06.Workflow.ContextData;
import com.teamcenter.services.rac.workflow._2008_06.Workflow.InstanceInfo;
@SuppressWarnings("serial")
public class DerivedChangeRequestDialog extends AbstractAIFDialog implements ActionListener {
protected TCSession session;
private ArrayList<ControlBean> beanList;
private String newType;
private JPanel centerPanel;
private JButton okButton;
private JButton celButton;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm");
private TCComponentItemRevision tarRev;
private JTextField idField = null;
private static final Pattern ECN_PATTERN = Pattern.compile("ECN-[0-9]{8}");
private static final Pattern ECR_PATTERN = Pattern.compile("ECR-[0-9]{8}");
// 属性类型真实值和类型
private HashMap<String, ControlBean> beanMap = new HashMap<String, ControlBean>();
// 选中的物料集合
private ArrayList<TCComponentItemRevision> partList = new ArrayList<TCComponentItemRevision>();
public DerivedChangeRequestDialog(AbstractAIFApplication app, ArrayList<ControlBean> beanList, StringBuffer newType,
TCComponentItemRevision tarRev) {
super(false);
this.session = (TCSession) app.getSession();
this.beanList = beanList;
this.newType = newType.toString();
this.tarRev = tarRev;
}
public DerivedChangeRequestDialog(AbstractAIFApplication app, ArrayList<ControlBean> beanList, StringBuffer newType,
TCComponentItemRevision tarRev, ArrayList<TCComponentItemRevision> partList) {
super(false);
this.session = (TCSession) app.getSession();
this.beanList = beanList;
this.newType = newType.toString();
this.tarRev = tarRev;
this.partList = partList;
run();
}
@Override
public void run() {
initUI();
}
private void initUI() {
this.setPreferredSize(new Dimension(555, 888));
centerPanel = new JPanel(new PropertyLayout());
JLabel label1 = new JLabel(" ");
centerPanel.add("1.1.center", label1);
for (int i = 0; i < beanList.size(); i++) {
int row = i + 2;
ControlBean bean = beanList.get(i);
beanMap.put(bean.getPropRelName(), bean);
String labelValue = bean.getPropName();
if (bean.isIfMust()) {
labelValue = bean.getPropName() + "(必填)";
}
JLabel oneLabel = new JLabel(" ");
centerPanel.add(row + ".1.center", oneLabel);
JLabel label = new JLabel(labelValue);
label.setPreferredSize(new Dimension(120, 40));
centerPanel.add(row + ".2.center", label);
if (bean.getPropType().equals("lov")) {
JComboBox<String> combox = bean.getCombox();
combox.setName(bean.getPropRelName());
combox.setPreferredSize(new Dimension(350, 25));
System.out.println("默认值为:" + bean.getDefaultValue());
combox.setSelectedItem(bean.getDefaultValue());
System.out.println("bean==>" + bean.toString());
centerPanel.add(row + ".3.center", combox);
} else if (bean.getPropType().equals("string")) {
if ("object_name".equals(bean.getPropRelName()) || "object_desc".equals(bean.getPropRelName())) {
JTextArea area = new JTextArea(bean.getDefaultValue());
area.setName(bean.getPropRelName());
area.setPreferredSize(new Dimension(350, 50));
area.setBorder(new LineBorder(new java.awt.Color(127, 157, 185), 1, false));
centerPanel.add(row + ".3.center", area);
} else {
if("item_id".equals(bean.getPropRelName())) {
idField = new JTextField(bean.getDefaultValue());
idField.setName(bean.getPropRelName());
idField.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", idField);
}else {
JTextField field = new JTextField(bean.getDefaultValue());
field.setName(bean.getPropRelName());
field.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", field);
}
}
} else if (bean.getPropType().equals("boolean")) {
JComboBox<String> combox = new JComboBox<String>();
combox.addItem("是");
combox.addItem("否");
combox.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", combox);
} else if (bean.getPropType().equals("date")) {
DateButton dateButton = new DateButton(sdf);
dateButton.setName(bean.getPropRelName());
dateButton.setText(bean.getDefaultValue());
dateButton.setPreferredSize(new Dimension(350, 25));
centerPanel.add(row + ".3.center", dateButton);
}
}
// LOVDisplayer year_categoryCombo = null;
// TCProperty prop;
// try {
// prop = tarRev.getTCProperty("ld6_emergencyLevel");
// TCPropertyDescriptor descriptor = prop.getPropertyDescriptor();
// year_categoryCombo = new LOVDisplayer(descriptor);
// //String projectYear = Utilities.getStringForArray(Utilities.getArray(year_categoryCombo.getSelectedValue()),"");
// } catch (TCException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// JLabel oneLabel = new JLabel(" ");
// centerPanel.add(beanList.size() + 2 + ".1.center",oneLabel);
// JLabel label = new JLabel("测试数据:");
// label.setPreferredSize(new Dimension(120,40));
// centerPanel.add(beanList.size() + 2 + ".2.center",label);
// centerPanel.add(beanList.size() + 2 + ".3.center",year_categoryCombo);
JScrollPane jsp = new JScrollPane(centerPanel);
okButton = new JButton("创建");
okButton.addActionListener(this);
celButton = new JButton("取消");
celButton.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.add(okButton);
buttonPanel.add(celButton);
this.setLayout(new BorderLayout());
this.add(BorderLayout.CENTER, jsp);
this.add(BorderLayout.SOUTH, buttonPanel);
showDialog();
}
@Override
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == this.celButton) {
this.dispose();
} else if (arg0.getSource() == this.okButton) {
new Thread() {
@Override
public void run() {
try {
long time1 = System.nanoTime();
// KUtil.setByPass(true);
if(idField != null) {
String itemId = idField.getText();
String type = tarRev.getType();
if("ProblemReportRevision".equals(type)) {
if(!ECR_PATTERN.matcher(itemId).matches()) {
MessageBox.post("值为" + itemId + "不符合系统命名规则【ECR-'nnnnnnnn'】,请确认后重新填写",
"提示", MessageBox.INFORMATION);
return;
}
}else {
if(!ECN_PATTERN.matcher(itemId).matches()) {
MessageBox.post("值为" + itemId + "不符合系统命名规则【ECN-'nnnnnnnn'】,请确认后重新填写",
"提示", MessageBox.INFORMATION);
return;
}
}
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(newType);
TCComponentItem findItem = itemType.find(itemId);
if(findItem != null) {
MessageBox.post("系统中已经存在id为" + itemId + "的对象,请检查后重新填写ID",
"提示", MessageBox.INFORMATION);
return;
}
}
TCComponentItemRevision rev = createItem("");
// KUtil.setByPass(false);
long time2 = System.nanoTime();
System.out.println("创建总用时(ms) " + (time2 - time1) / 1000000);
if(rev != null) {
MessageBox.post("创建成功,新对象在newstuff文件夹下", "提示", MessageBox.INFORMATION);
}
disposeDialog();
} catch (Exception e) {
MessageBox.post(e.getMessage(), "提示", MessageBox.INFORMATION);
e.printStackTrace();
}
}
}.start();
}
}
/**
*
*
* @param errorBuffer
* @param valueMap
* @param objectDesc
* @param itemId
*/
private void judgeMust(StringBuffer errorBuffer, HashMap<String, String> valueMap) {
for (Entry<String, ControlBean> entry : beanMap.entrySet()) {
String name = entry.getKey();
ControlBean bean = entry.getValue();
System.out.println("当前字段为:" + name + "======当前是否必填为:" + bean.isIfMust());
if (bean.isIfMust()) {
String propValue = valueMap.get(name);
System.out.println("当前字段为:" + name + "======当前字段的值为:" + propValue);
if (propValue == null || propValue.isEmpty() || "未设置日期。".equals(propValue)) {
errorBuffer.append(bean.getPropName() + ",");
}
}
}
valueMap.remove("item_id");
valueMap.remove("object_desc");
}
/**
*
*
* @throws TCException
* @throws ServiceException
* @throws ParseException
* @throws NotLoadedException
*/
private TCComponentItemRevision createItem(String partNum)
throws TCException, ServiceException, ParseException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(newType);
HashMap<String, String> valueMap = new HashMap<String, String>();
int componentCount = centerPanel.getComponentCount();
// String itemId = null;
String objectDesc = "派生创建";
String objectName = "";
for (int i = 0; i < componentCount; i++) {
Component component = centerPanel.getComponent(i);
if (component instanceof JTextField) {
JTextField filed = (JTextField) component;
valueMap.put(filed.getName(), filed.getText());
} else if (component instanceof JComboBox) {
JComboBox<String> combox = (JComboBox<String>) component;
String select = (String)combox.getSelectedItem();
valueMap.put(combox.getName(), select);
} else if (component instanceof DateButton) {
DateButton date = (DateButton) component;
valueMap.put(date.getName(), date.getText());
} else if (component instanceof JTextArea) {
JTextArea area = (JTextArea) component;
if (area.getName().equals("object_desc")) {
objectDesc = area.getText();
} else {
objectName = area.getText();
valueMap.put(area.getName(), area.getText());
}
}
}
StringBuffer errorBuffer = new StringBuffer();
if(idField != null && idField.getText() != null && !"".equals(idField.getText().trim())) {
valueMap.put("item_id", idField.getText());
}else {
String itemId = itemType.getNewID();
valueMap.put("item_id", itemId);
}
valueMap.put("object_desc", objectDesc);
judgeMust(errorBuffer, valueMap);
if (!errorBuffer.toString().isEmpty()) {
MessageBox.post(errorBuffer.toString() + " 这些必填项未填", "提示", MessageBox.INFORMATION);
return null;
}
Map<String, String> itemMaps = new HashMap<String, String>();
Map<String, String> revMaps = new HashMap<String, String>();
if(idField != null && idField.getText() != null && !"".equals(idField.getText().trim())) {
itemMaps.put("item_id", idField.getText());
}else {
itemMaps.put("item_id", valueMap.get("item_id"));
}
itemMaps.put("object_desc", objectDesc);
// revMaps.put("object_name", partNum + objectName);
// 修改3.7
revMaps.put("object_name", objectName);
//object_name ld6_partName
System.out.println("newType:" + newType);
TCComponent createMaterialBySOA = createMaterialBySOA(newType, itemMaps, revMaps,valueMap);
if (createMaterialBySOA == null) {
MessageBox.post("创建失败", "提示", MessageBox.INFORMATION);
return null;
}
TCComponentItem newItem = (TCComponentItem) createMaterialBySOA;
TCComponentItemRevision latestItemRevision = newItem.getLatestItemRevision();
// 放到newstuff
TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder();
newStuffFolder.add("contents", newItem);
try {
KUtil.setByPass(true);
tarRev.add("CMImplementedBy", latestItemRevision);
KUtil.setByPass(false);
} catch (TCException e) {
// TODO Auto-generated catch blocke
e.printStackTrace();
}finally {
KUtil.setByPass(false);
}
// id版本类型名称描述
// TCComponentItem newItem = itemType.create(itemId,"",newType ,"", "niuma",
// null);
// TCComponentItemRevision latestItemRevision = newItem.getLatestItemRevision();
// tarRev.add("CMImplementedBy", latestItemRevision);
// 设置属性
for (Entry<String, String> entry : valueMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ControlBean controlBean = beanMap.get(key);
TCComponent center = null;
if ("Item".equals(controlBean.getPropTo())) {
center = newItem;
} else if ("Rev".equals(controlBean.getPropTo())) {
center = latestItemRevision;
} else if ("Form".equals(controlBean.getPropTo())) {
center = latestItemRevision.getRelatedComponent("IMAN_master_form_rev");
}
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
center.setLogicalProperty(key, true);
} else if ("否".equals(value)) {
center.setLogicalProperty(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
center.setDateProperty(key, sdf.parse(value));
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
center.setStringProperty(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
center.setStringProperty(key, controlBean.getLovMap().get(value));
}
}
System.out.println("开始转移关系文件夹下的对象");
TCComponent[] re1 = tarRev.getRelatedComponents("CMHasProblemItem");
if (re1 != null && re1.length > 0) {
latestItemRevision.add("CMHasProblemItem", re1);
}
TCComponent[] re2 = tarRev.getRelatedComponents("CMReferences");
if (re2 != null && re2.length > 0) {
latestItemRevision.add("CMReferences", re2);
}
String type = tarRev.getType();
if (!"ProblemReportRevision".equals(type)) {
TCComponent[] re4 = tarRev.getRelatedComponents("CMHasImpactedItem");
if (re4 != null && re4.length > 0) {
latestItemRevision.add("CMHasImpactedItem", re4);
}
}
if("ChangeRequestRevision".equals(type)) {
TCComponent[] re5 = tarRev.getRelatedComponents("IMAN_specification");
if(re5 != null && re5.length > 0) {
for (int i = 0; i < re5.length; i++) {
TCComponent dataset = re5[i];
if(dataset instanceof TCComponentDataset) {
TCComponentDataset newDataset = ((TCComponentDataset) dataset).saveAs(dataset.getStringProperty("object_name"));
if(newDataset != null) {
workflow(new String[] {newDataset.getUid()},"快速发布","TCM Release Process");
latestItemRevision.add("IMAN_specification", newDataset);
}
}
}
}
}
return latestItemRevision;
}
/**
*
* @param itemTypeCom
* @param itemPropMaps
* @param revMaps
* @return
* @throws TCException
* @throws ServiceException
* @throws ParseException
*/
private TCComponent createMaterialBySOA(String itemTypeCom, Map<String, String> itemPropMaps,
Map<String, String> revMaps,HashMap<String, String> valueMap) throws TCException, ServiceException, ParseException {
System.out.println(itemTypeCom);
Map<String, Boolean> itemboole = new HashMap<String, Boolean>();
Map<String,Calendar> itemdate = new HashMap<String, Calendar>();
Map<String, Boolean> revboole = new HashMap<String, Boolean>();
Map<String,Calendar> revdate = new HashMap<String, Calendar>();
Map<String, String> formMaps = new HashMap<String,String>();
Map<String, Boolean> formboole = new HashMap<String, Boolean>();
Map<String,Calendar> formdate = new HashMap<String, Calendar>();
for (Entry<String, String> entry : valueMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ControlBean controlBean = beanMap.get(key);
if ("Item".equals(controlBean.getPropTo())) {
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
itemboole.put(key, true);
} else if ("否".equals(value)) {
itemboole.put(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
Date parse = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
itemdate.put(key, cal);
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
itemPropMaps.put(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
String string = controlBean.getLovMap().get(value);
if(!"".equals(string.trim())) {
itemPropMaps.put(key, string);
}
}
} else if ("Rev".equals(controlBean.getPropTo())) {
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
revboole.put(key, true);
} else if ("否".equals(value)) {
revboole.put(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
Date parse = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
revdate.put(key, cal);
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
revMaps.put(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
String string = controlBean.getLovMap().get(value);
if(!"".equals(string.trim())) {
revMaps.put(key, string);
}
}
}else if("Form".equals(controlBean.getPropTo())) {
if ("boolean".equals(controlBean.getPropType())) {
if ("是".equals(value)) {
formboole.put(key, true);
} else if ("否".equals(value)) {
formboole.put(key, false);
}
} else if ("date".equals(controlBean.getPropType())) {
if (!value.isEmpty() && !"未设置日期。".equals(value)) {
Date parse = sdf.parse(value);
Calendar cal = Calendar.getInstance();
cal.setTime(parse);
formdate.put(key, cal);
}
} else if ("string".equals(controlBean.getPropType())) {
if (!value.isEmpty()) {
formMaps.put(key, value);
}
} else if ("lov".equals(controlBean.getPropType())) {
String string = controlBean.getLovMap().get(value);
if(!"".equals(string.trim())) {
formMaps.put(key, string);
}
}
}
}
for (Map.Entry<String, String> entry : itemPropMaps.entrySet()) {
System.out.println("itemPropMaps: key = " + entry.getKey() + ", value = " + entry.getValue());
}
for (Map.Entry<String, String> entry : revMaps.entrySet()) {
System.out.println("revMaps: key = " + entry.getKey() + ", value = " + entry.getValue());
}
DataManagementService dmService = DataManagementService.getService(session);
CreateInput revInput = new CreateInput();
revInput.boName = itemTypeCom + "Revision";
revInput.stringProps = revMaps;
revInput.dateProps = revdate;
revInput.boolProps = revboole;
CreateInput[] formCompInputS = new CreateInput[1];
formCompInputS[0] = new CreateInput();
formCompInputS[0].boName = itemTypeCom + "Revision Master";
formCompInputS[0].stringProps = formMaps;
formCompInputS[0].dateProps = formdate;
formCompInputS[0].boolProps = formboole;
Map<String, CreateInput[]> formCompMap = new HashMap();
formCompMap.put("IMAN_master_form_rev", formCompInputS);
revInput.compoundCreateInput = formCompMap;
CreateInput itemInput = new CreateInput();
itemInput.boName = itemTypeCom;
itemInput.stringProps = itemPropMaps;
itemInput.dateProps = itemdate;
itemInput.boolProps = itemboole;
HashMap<String, CreateInput[]> revInfoMap = new HashMap<String, CreateInput[]>();
revInfoMap.put("revision", new CreateInput[] { revInput });
itemInput.compoundCreateInput = revInfoMap;
CreateIn createin = new CreateIn();
createin.clientId = "CreateItem";
createin.data = itemInput;
com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse createresponse;
createresponse = dmService.createObjects(new CreateIn[] { createin });
if (createresponse.serviceData.sizeOfPartialErrors() > 0) {
System.out.println("create item failed");
for (int i = 0; i < createresponse.serviceData.sizeOfPartialErrors(); i++) {
String[] messages = createresponse.serviceData.getPartialError(0).getMessages();
for(int j=0;j<messages.length;j++) {
System.out.println(createresponse.serviceData.getPartialError(0).getErrorValues()[j].getMessage());
}
System.out.println(createresponse.serviceData.getPartialError(0).getMessages());
System.out.println(createresponse.serviceData.getPartialError(0).getErrorValues()[0].getMessage());
}
return null;
}
TCComponent comp = null;
CreateOut cOs[] = createresponse.output;
if (cOs.length > 0) {
comp = cOs[0].objects[0];
System.out.println("创建的对象:" + comp);
return comp;
}
return null;
}
/**
*
*
*/
public void workflow(String[] uid,String workFlowName,String templateName) {
// String uid = rev.getUid();
//创建流程
WorkflowService wfService = WorkflowService.getService(session);
ContextData contextData = new ContextData();
String observerKey = "";
String name = workFlowName;
String subject = "";
String description = "";
contextData.processTemplate = templateName; // update with your own ProcessTemplate.
contextData.subscribeToEvents = false;
contextData.subscriptionEventCount = 0;
contextData.attachmentCount = uid.length;
contextData.attachments = uid ;
int [] types = new int[uid.length];
for(int i = 0;i <uid.length;i++) {
types[i] = 1;
}
contextData.attachmentTypes = types;
//创建流程
InstanceInfo instanceInfo = wfService.createInstance(true, observerKey, name, subject, description, contextData);
}
}

@ -0,0 +1,87 @@
package com.connor.plm.sb02;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javafx.scene.control.TableColumn;
public class TableDemo extends JFrame{
static JTable table;
public TableDemo() {
setSize(600, 600);
setLocationRelativeTo(null);
/*创建表格*/
DefaultTableModel model = new DefaultTableModel();
model.addColumn("编号",new Vector<Integer>());
model.addColumn("书名", new Vector<String>());
model.addColumn("作者", new Vector<String>());
model.addColumn("是否选中", new Vector<String>());
table = new JTable(model);
JScrollPane jp = new JScrollPane(table);
for(int i = 0;i < 20 ;i ++) {
model.addRow(new Vector<String>());
}
JTableHeader head = table.getTableHeader();
//设置表头的大小
head.setPreferredSize(new Dimension(head.getWidth(),30));
//设置表头字体大小
head.setFont(new Font("宋体",Font.BOLD,16));
//设置表格的行宽
table.setRowHeight(30);
//设置表格行中字体大小
table.setFont(new Font("宋体",Font.ROMAN_BASELINE,13));
/*设置表格中的内容居中*/
DefaultTableCellRenderer renderer=new DefaultTableCellRenderer();
renderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
table.setDefaultRenderer(Object.class, renderer);
/*定义复选框*/
JCheckBox box = new JCheckBox();
/*getColumn()中数字填对应的第几行添加复选框*/
table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,int row, int column) {
/*设置当复选框被选中整行被渲染*/
box.setSelected(isSelected);
/*设置复选框在单元格中居中*/
box.setHorizontalAlignment((int) 0.5f);
return box;
}
});
this.add(jp);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
TableDemo t = new TableDemo();
}
}

@ -0,0 +1,86 @@
package com.net.connor.ld.plm.ld06;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.RowSorter;
import javax.swing.RowSorter.SortKey;
import javax.swing.SortOrder;
import javax.swing.table.TableRowSorter;
import antlr.collections.List;
public class ArrowIcon implements Icon {
private final SortOrder sortOrder;
private final int size;
private final boolean ascending;
public ArrowIcon(TableRowSorter<?> sorter, int column, boolean ascending) {
this.ascending = ascending;
this.size = 12;
java.util.List<? extends SortKey> sortKeys = sorter.getSortKeys();
if (sortKeys.size() > 0 && ((RowSorter.SortKey) sortKeys.get(0)).getColumn() == column) {
this.sortOrder = ((RowSorter.SortKey) sortKeys.get(0)).getSortOrder();
} else {
this.sortOrder = SortOrder.ASCENDING;
}
}
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(x, y);
if (ascending) {
g2.rotate(Math.PI, size / 2.0, size / 2.0);
}
if (sortOrder == SortOrder.ASCENDING) {
g2.draw(createUpTriangle(size));
} else {
g2.draw(createDownTriangle(size));
}
g2.dispose();
}
public int getIconWidth() {
return size;
}
public int getIconHeight() {
return size;
}
private Polygon createUpTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, size);
triangle.addPoint(size / 2, 0);
triangle.addPoint(size, size);
return triangle;
}
private Polygon createDownTriangle(int size) {
Polygon triangle = new Polygon();
triangle.addPoint(0, 0);
triangle.addPoint(size, 0);
triangle.addPoint(size / 2, size);
return triangle;
}
}
//表格列排序类
class ColumnSorter implements Comparator<Object> {
private final int col;
private final boolean ascending;
public ColumnSorter(int col, boolean ascending) {
this.col = col;
this.ascending = ascending;
}
@Override
public int compare(Object a, Object b) {
if (a instanceof Comparable && b instanceof Comparable) {
if (ascending) {
return ((Comparable) a).compareTo((Comparable) b);
} else {
return ((Comparable) b).compareTo((Comparable) a);
}
} else {
return 0;
}
}
}

@ -0,0 +1,15 @@
package com.connor.plm;
import java.text.SimpleDateFormat;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String value = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm");
value = sdf.format("");
System.out.println(value);
}
}
Loading…
Cancel
Save