commit
f124be2196
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry exported="true" kind="lib" path="lib/aspose-cells-18.9.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="lib" path="lib/commons-codec-1.13.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-collections4-4.4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-compress-1.19.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-lang3-3.9.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/commons-math3-3.6.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/datepicker.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/fastjson-1.2.9.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/hutool-all-5.0.7.jar" sourcepath="C:/Users/5RKB5B~1/AppData/Local/Temp/.org.sf.feeling.decompiler1604022865349/source/hutool-all-5.0.7-sources-1604023924461.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jaxb-api-2.3.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jaxb-core-2.3.0.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jaxb-impl-2.3.2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jfxrt.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/ojdbc6.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/poi-4.1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/poi-examples-4.1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/poi-excelant-4.1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/poi-ooxml-4.1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/poi-ooxml-schemas-4.1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/poi-scratchpad-4.1.1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/xmlbeans-3.1.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/sqljdbc4.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
/bin/
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>com.connor.lyBOMManagement</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,3 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/com/connor/jd/plm/handlers/Wf001ScheduleHandler.java=UTF-8
|
||||||
|
encoding//src/com/connor/jd/plm/utils/JDMethodUtil.java=UTF-8
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: JDProject
|
||||||
|
Bundle-SymbolicName: com.connor.lyBOMManagement;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0
|
||||||
|
Require-Bundle: org.eclipse.ui;bundle-version="3.108.0",
|
||||||
|
com.teamcenter.rac.common;bundle-version="12000.1.0",
|
||||||
|
com.teamcenter.rac.tcapps;bundle-version="12000.1.0",
|
||||||
|
com.teamcenter.rac.util;bundle-version="12000.1.0",
|
||||||
|
com.teamcenter.rac.aifrcp;bundle-version="12000.1.0",
|
||||||
|
com.teamcenter.rac.ui.commands;bundle-version="12000.1.0",
|
||||||
|
com.teamcenter.rac.kernel;bundle-version="12000.1.0",
|
||||||
|
org.eclipse.ui.views;bundle-version="3.8.100",
|
||||||
|
org.eclipse.core.runtime;bundle-version="3.12.0",
|
||||||
|
org.eclipse.ui.forms;bundle-version="3.7.0",
|
||||||
|
com.teamcenter.rac.schedule;bundle-version="12000.1.0",
|
||||||
|
TcSoaCommon;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.workflow.processviewer;bundle-version="12000.2.0",
|
||||||
|
com.teamcenter.rac.workflow.processdesigner;bundle-version="12000.2.0"
|
||||||
|
Automatic-Module-Name: JDProject
|
||||||
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||||
|
Export-Package: com.connor.jd.operations,
|
||||||
|
com.connor.jd.plm.action,
|
||||||
|
com.connor.jd.plm.beans,
|
||||||
|
com.connor.jd.plm.dialog,
|
||||||
|
com.connor.jd.plm.dialogs,
|
||||||
|
com.connor.jd.plm.form,
|
||||||
|
com.connor.jd.plm.handlers,
|
||||||
|
com.connor.jd.plm.table,
|
||||||
|
com.connor.jd.plm.util,
|
||||||
|
com.connor.jd.plm.utils,
|
||||||
|
com.teamcenter.rac.stylesheet
|
||||||
|
Import-Package: com.connor.jd.plm.beans,
|
||||||
|
com.connor.jd.plm.table,
|
||||||
|
com.teamcenter.services,
|
||||||
|
com.teamcenter.services.rac,
|
||||||
|
com.teamcenter.services.rac.core,
|
||||||
|
com.teamcenter.services.rac.core._2008_06,
|
||||||
|
org.apache.http.client,
|
||||||
|
org.apache.http.client.methods,
|
||||||
|
org.apache.http.client.params,
|
||||||
|
org.apache.http.client.protocol,
|
||||||
|
org.apache.log4j
|
||||||
|
Bundle-ClassPath: .,
|
||||||
|
lib/fastjson-1.2.9.jar,
|
||||||
|
lib/hutool-all-5.0.7.jar,
|
||||||
|
lib/commons-codec-1.13.jar,
|
||||||
|
lib/commons-collections4-4.4.jar,
|
||||||
|
lib/commons-compress-1.19.jar,
|
||||||
|
lib/commons-logging-1.2.jar,
|
||||||
|
lib/commons-math3-3.6.1.jar,
|
||||||
|
lib/jaxb-api-2.3.1.jar,
|
||||||
|
lib/jaxb-core-2.3.0.1.jar,
|
||||||
|
lib/jaxb-impl-2.3.2.jar,
|
||||||
|
lib/jfxrt.jar,
|
||||||
|
lib/poi-4.1.1.jar,
|
||||||
|
lib/poi-examples-4.1.1.jar,
|
||||||
|
lib/poi-excelant-4.1.1.jar,
|
||||||
|
lib/poi-ooxml-4.1.1.jar,
|
||||||
|
lib/poi-ooxml-schemas-4.1.1.jar,
|
||||||
|
lib/poi-scratchpad-4.1.1.jar,
|
||||||
|
lib/xmlbeans-3.1.0.jar,
|
||||||
|
lib/commons-lang3-3.9.jar,
|
||||||
|
lib/ojdbc6.jar,
|
||||||
|
config/,
|
||||||
|
lib/datepicker.jar,
|
||||||
|
lib/aspose-cells-18.9.jar,
|
||||||
|
lib/sqljdbc4.jar
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
source.. = src/
|
||||||
|
output.. = bin/
|
||||||
|
bin.includes = plugin.xml,\
|
||||||
|
META-INF/,\
|
||||||
|
.,\
|
||||||
|
icons/,\
|
||||||
|
lib/fastjson-1.2.9.jar,\
|
||||||
|
lib/hutool-all-5.0.7.jar,\
|
||||||
|
lib/commons-codec-1.13.jar,\
|
||||||
|
lib/commons-collections4-4.4.jar,\
|
||||||
|
lib/commons-compress-1.19.jar,\
|
||||||
|
lib/commons-logging-1.2.jar,\
|
||||||
|
lib/commons-math3-3.6.1.jar,\
|
||||||
|
lib/jaxb-api-2.3.1.jar,\
|
||||||
|
lib/jaxb-core-2.3.0.1.jar,\
|
||||||
|
lib/jaxb-impl-2.3.2.jar,\
|
||||||
|
lib/jfxrt.jar,\
|
||||||
|
lib/poi-4.1.1.jar,\
|
||||||
|
lib/poi-examples-4.1.1.jar,\
|
||||||
|
lib/poi-excelant-4.1.1.jar,\
|
||||||
|
lib/poi-ooxml-4.1.1.jar,\
|
||||||
|
lib/poi-ooxml-schemas-4.1.1.jar,\
|
||||||
|
lib/poi-scratchpad-4.1.1.jar,\
|
||||||
|
lib/xmlbeans-3.1.0.jar,\
|
||||||
|
lib/ojdbc6.jar,\
|
||||||
|
lib/commons-lang3-3.9.jar,\
|
||||||
|
src/config/,\
|
||||||
|
lib/datepicker.jar,\
|
||||||
|
lib/aspose-cells-18.9.jar,\
|
||||||
|
lib/sqljdbc4.jar
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 526 B |
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.
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.
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,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?eclipse version="3.4"?>
|
||||||
|
<plugin>
|
||||||
|
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.commands">
|
||||||
|
<category
|
||||||
|
id="JDProject.commands.category"
|
||||||
|
name="Sample Category">
|
||||||
|
</category>
|
||||||
|
|
||||||
|
|
||||||
|
<command categoryId="JDProject.commands.category" name="BOM批量管理" id="BOMManagement"></command>
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.handlers">
|
||||||
|
|
||||||
|
<handler commandId="BOMManagement" class="com.connor.jd.plm.handlers.BOMManagementHandler"></handler>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.bindings">
|
||||||
|
<key
|
||||||
|
commandId="Item"
|
||||||
|
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="BOMManagement"
|
||||||
|
label="BOM管理"
|
||||||
|
mnemonic="M">
|
||||||
|
<command commandId="BOMManagement" id="JDProject.menus.BOMManagement" mnemonic="S"></command>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</menu>
|
||||||
|
|
||||||
|
</menuContribution>
|
||||||
|
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
</plugin>
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String[] arr = new String[] { "0,1", "1,10", "0,100", "xx", "1,2" };
|
||||||
|
Arrays.sort(arr, new Comparator<String>() {
|
||||||
|
@Override
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
if (o1.indexOf(",") == -1 || o2.indexOf(",") == -1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
String[] temp1 = o1.split(",");
|
||||||
|
String[] temp2 = o2.split(",");
|
||||||
|
if (temp1[0].equals(temp2[0])) {
|
||||||
|
return Integer.parseInt(temp1[1]) - Integer.parseInt(temp2[1]);
|
||||||
|
} else {
|
||||||
|
return Integer.parseInt(temp1[0]) - Integer.parseInt(temp2[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
System.out.println(Arrays.toString(arr));
|
||||||
|
List<String> list1 = new ArrayList<String>();
|
||||||
|
List<String> list2 = new ArrayList<String>();
|
||||||
|
List<String> list3 = new ArrayList<String>();
|
||||||
|
for (int i = 0; i < arr.length; i++) {
|
||||||
|
if (arr[i].indexOf(",") == -1 || "0".equals(arr[i].split(",")[0])) {
|
||||||
|
list1.add(arr[i]);
|
||||||
|
} else {
|
||||||
|
list2.add(arr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int maxLength = Math.max(list1.size(), list2.size());
|
||||||
|
for (int i = 0; i < maxLength; i++) {
|
||||||
|
if (i > list1.size() - 1) {
|
||||||
|
list3.add("");
|
||||||
|
list3.add(list2.get(i));
|
||||||
|
} else if (i > list2.size() - 1) {
|
||||||
|
list3.add(list1.get(i));
|
||||||
|
list3.add("");
|
||||||
|
} else {
|
||||||
|
list3.add(list1.get(i));
|
||||||
|
list3.add(list2.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(Arrays.toString(list3.toArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.connor.jd.operations;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.utils.DBConnectionUtil;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
public class CreateTableOperation {
|
||||||
|
private static Connection con = null;
|
||||||
|
private static Statement ps = null;
|
||||||
|
private static ResultSet rs = null;
|
||||||
|
private static TCSession session;
|
||||||
|
|
||||||
|
public static void create() {
|
||||||
|
session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
||||||
|
String createTable1 = "CREATE TABLE JD2_Component (test_type VARCHAR(255),test_project VARCHAR(255),test_time VARCHAR(255),test_num NUMBER,test_cost FLOAT, test_id NUMBER primary key)";
|
||||||
|
String createSeq1 = "CREATE sequence component_id_seq minvalue 1 nomaxvalue INCREMENT BY 1 START WITH 1 nocache";
|
||||||
|
String createTRG1 = "CREATE or REPLACE TRIGGER component_id_ins_trg before INSERT ON JD2_COMPONENT for each ROW BEGIN SELECT component_id_seq.Nextval into : new.TEST_ID from dual; END;";
|
||||||
|
|
||||||
|
String createTable2 = "CREATE TABLE JD2_Machine (test_type VARCHAR(255),test_project VARCHAR(255),test_cost FLOAT, test_id NUMBER primary key)";
|
||||||
|
String createSeq2 = "CREATE sequence machine_id_seq minvalue 1 nomaxvalue INCREMENT BY 1 START WITH 1 nocache";
|
||||||
|
String createTRG2 = "CREATE or REPLACE TRIGGER machine_id_ins_trg before INSERT ON JD2_MACHINE for each ROW BEGIN SELECT machine_id_seq.Nextval into : new.TEST_ID from dual; END;";
|
||||||
|
String[] sqls = { createTable1, createSeq1, createTRG1, createTable2, createSeq2, createTRG2 };
|
||||||
|
try {
|
||||||
|
con = DBConnectionUtil.dbConn(session);
|
||||||
|
String sqlString = "SELECT count(*) from user_tables WHERE table_name='JD2_COMPONENT'";
|
||||||
|
if (con == null) {
|
||||||
|
System.out.print("Á¬½Óʧ°Ü");
|
||||||
|
} else {
|
||||||
|
ps = con.createStatement();
|
||||||
|
rs = ps.executeQuery(sqlString);
|
||||||
|
while (rs.next()) {
|
||||||
|
System.out.println(rs.getInt(1));
|
||||||
|
if (rs.getInt(1) == 0) {
|
||||||
|
for (int i = 0; i < sqls.length; i++) {
|
||||||
|
ps = con.createStatement();
|
||||||
|
ps.execute(sqls[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ps != null) {
|
||||||
|
try {
|
||||||
|
ps.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (con != null) {
|
||||||
|
try {
|
||||||
|
con.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,264 @@
|
|||||||
|
package com.connor.jd.operations;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
|
||||||
|
public class ExcelOperation {
|
||||||
|
private static final String XLS = "xls";
|
||||||
|
private static final String XLSX = "xlsx";
|
||||||
|
|
||||||
|
public static void writeExcel(File file, String outpath, Map<String, List<TCComponent>> jfw) {
|
||||||
|
if (jfw.size() == 1) {
|
||||||
|
writeoneExcel(file, outpath, jfw);
|
||||||
|
} else {
|
||||||
|
writeallExcel(file, outpath, jfw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeallExcel(File file, String outpath, Map<String, List<TCComponent>> jfw) {
|
||||||
|
Workbook workbook;
|
||||||
|
try {
|
||||||
|
workbook = getworkbook(file);
|
||||||
|
System.out.println("已有文件");
|
||||||
|
Workbook newwb = getWorkbook(outpath);
|
||||||
|
Sheet newsheet = newwb.createSheet();
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
CellStyle style = workbook.createCellStyle();
|
||||||
|
Row row = sheet.getRow(0);
|
||||||
|
row.setRowStyle(style);
|
||||||
|
Row newrow0 = newsheet.createRow(0);
|
||||||
|
for (int i = 0; i < row.getLastCellNum(); i++) {
|
||||||
|
Cell newCell = newrow0.createCell(i);
|
||||||
|
newCell.setCellValue(row.getCell(i).getStringCellValue());
|
||||||
|
}
|
||||||
|
List<CellRangeAddress> cellRangeList = getCombineCell(sheet);
|
||||||
|
for (Entry<String, List<TCComponent>> ever : jfw.entrySet()) {
|
||||||
|
List<TCComponent> itemList = ever.getValue();
|
||||||
|
String sfname = ever.getKey();
|
||||||
|
System.out.println("itemList长度" + itemList.size());
|
||||||
|
for (int i = 0; i < cellRangeList.size(); i++) {
|
||||||
|
CellRangeAddress ca = cellRangeList.get(i);
|
||||||
|
int firstColumn = 0;
|
||||||
|
int firstRow = ca.getFirstRow();
|
||||||
|
int lastRow = ca.getLastRow();
|
||||||
|
Row fRow = sheet.getRow(firstRow);
|
||||||
|
Cell fCell = fRow.getCell(firstColumn);
|
||||||
|
String cellVelue = fCell.getStringCellValue();
|
||||||
|
System.out.println("合并单元格的内容" + cellVelue);
|
||||||
|
System.out.println("起始行" + firstRow + "最后行" + lastRow);
|
||||||
|
if (sfname.equals(cellVelue)) {
|
||||||
|
for (int z = firstRow; z <= lastRow; z++) {
|
||||||
|
Row newRow = sheet.getRow(z);
|
||||||
|
String value = newRow.getCell(1).getStringCellValue();
|
||||||
|
System.out.println("表格内容" + value);
|
||||||
|
for (int p = 0; p < itemList.size(); p++) {
|
||||||
|
if (itemList.get(p).getTCProperty("object_type").getDisplayableValue().equals(value)) {
|
||||||
|
TCComponent[] revlist = itemList.get(p).getTCProperty("revision_list")
|
||||||
|
.getReferenceValueArray();
|
||||||
|
TCComponent component = null;
|
||||||
|
for (int revlength = 0; revlength < revlist.length; revlength++) {
|
||||||
|
String status = revlist[revlength].getProperty("release_status_list");
|
||||||
|
if (!status.equals("")) {
|
||||||
|
component = revlist[revlength];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] info = new String[4];
|
||||||
|
if (component != null) {
|
||||||
|
info[0] = component.getProperty("owning_group");
|
||||||
|
info[1] = component.getProperty("owning_user");
|
||||||
|
info[2] = component.getProperty("creation_date");
|
||||||
|
info[3] = component.getProperty("item_id");
|
||||||
|
} else {
|
||||||
|
info[0] = "";
|
||||||
|
info[1] = "";
|
||||||
|
info[2] = "";
|
||||||
|
info[3] = "";
|
||||||
|
}
|
||||||
|
for (int v = 0; v < info.length; v++) {
|
||||||
|
Cell cellvalue = newRow.createCell(v + 2);
|
||||||
|
cellvalue.setCellValue(info[v]);
|
||||||
|
System.out.println("内容是" + info[v]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileOutputStream fos = new FileOutputStream(outpath);
|
||||||
|
workbook.write(fos);
|
||||||
|
workbook.close();
|
||||||
|
fos.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeoneExcel(File file, String outpath, Map<String, List<TCComponent>> jfw) {
|
||||||
|
Workbook workbook;
|
||||||
|
try {
|
||||||
|
workbook = getworkbook(file);
|
||||||
|
System.out.println("已有文件");
|
||||||
|
Workbook newwb = getWorkbook(outpath);
|
||||||
|
Sheet newsheet = newwb.createSheet();
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
CellStyle style = newwb.createCellStyle();
|
||||||
|
Row row = sheet.getRow(0);
|
||||||
|
Row newrow0 = newsheet.createRow(0);
|
||||||
|
for (int i = 0; i < row.getLastCellNum(); i++) {
|
||||||
|
Cell oldCell = row.getCell(i);
|
||||||
|
style.cloneStyleFrom(oldCell.getCellStyle());
|
||||||
|
|
||||||
|
Cell newCell = newrow0.createCell(i);
|
||||||
|
newCell.setCellStyle(style);
|
||||||
|
newCell.setCellValue(oldCell.getStringCellValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
List<CellRangeAddress> cellRangeList = getCombineCell(sheet);
|
||||||
|
for (Entry<String, List<TCComponent>> ever : jfw.entrySet()) {
|
||||||
|
List<TCComponent> itemList = ever.getValue();
|
||||||
|
String sfname = ever.getKey();
|
||||||
|
System.out.println("itemList长度" + itemList.size());
|
||||||
|
for (int i = 0; i < cellRangeList.size(); i++) {
|
||||||
|
CellRangeAddress ca = cellRangeList.get(i);
|
||||||
|
int firstColumn = 0;
|
||||||
|
int firstRow = ca.getFirstRow();
|
||||||
|
int lastRow = ca.getLastRow();
|
||||||
|
Row fRow = sheet.getRow(firstRow);
|
||||||
|
Cell fCell = fRow.getCell(firstColumn);
|
||||||
|
String cellVelue = fCell.getStringCellValue();
|
||||||
|
System.out.println("合并单元格的内容" + cellVelue);
|
||||||
|
System.out.println("起始行" + firstRow + "最后行" + lastRow);
|
||||||
|
|
||||||
|
if (sfname.equals(cellVelue)) {
|
||||||
|
List<String> valueList = new ArrayList<String>();
|
||||||
|
for (int z = firstRow; z <= lastRow; z++) {
|
||||||
|
Row oldRow = sheet.getRow(z);
|
||||||
|
String value = oldRow.getCell(1).getStringCellValue();
|
||||||
|
|
||||||
|
valueList.add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 1; j <= lastRow - firstRow + 1; j++) {
|
||||||
|
Row newRow = newsheet.createRow(j);
|
||||||
|
Cell cell = newRow.createCell(0);
|
||||||
|
cell.setCellValue(cellVelue);
|
||||||
|
Cell cell2 = newRow.createCell(1);
|
||||||
|
cell2.setCellValue(valueList.get(j - 1));
|
||||||
|
System.out.println("特殊表格内容" + valueList.get(j - 1));
|
||||||
|
for (int p = 0; p < itemList.size(); p++) {
|
||||||
|
if (itemList.get(p).getTCProperty("object_type").getDisplayableValue()
|
||||||
|
.equals(valueList.get(j - 1))) {
|
||||||
|
System.out.println(
|
||||||
|
"类型:" + itemList.get(p).getTCProperty("object_type").getDisplayableValue());
|
||||||
|
TCComponent[] revlist = itemList.get(p).getTCProperty("revision_list")
|
||||||
|
.getReferenceValueArray();
|
||||||
|
TCComponent component = null;
|
||||||
|
for (int revlength = 0; revlength < revlist.length; revlength++) {
|
||||||
|
String status = revlist[revlength].getProperty("release_status_list");
|
||||||
|
if (!status.equals("")) {
|
||||||
|
component = revlist[revlength];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] info = new String[4];
|
||||||
|
if (component != null) {
|
||||||
|
info[0] = component.getProperty("owning_group");
|
||||||
|
info[1] = component.getProperty("owning_user");
|
||||||
|
info[2] = component.getProperty("creation_date");
|
||||||
|
info[3] = component.getProperty("item_id");
|
||||||
|
} else {
|
||||||
|
info[0] = "";
|
||||||
|
info[1] = "";
|
||||||
|
info[2] = "";
|
||||||
|
info[3] = "";
|
||||||
|
}
|
||||||
|
for (int v = 0; v < info.length; v++) {
|
||||||
|
System.out.println("开始创建内容");
|
||||||
|
Cell cellvalue = newRow.createCell(v + 2);
|
||||||
|
cellvalue.setCellValue(info[v]);
|
||||||
|
System.out.println("内容是" + info[v]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CellRangeAddress region = new CellRangeAddress(1, lastRow - firstRow + 1, 0, 0);
|
||||||
|
newsheet.addMergedRegion(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileOutputStream fos = new FileOutputStream(outpath);
|
||||||
|
newwb.write(fos);
|
||||||
|
newwb.close();
|
||||||
|
fos.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并单元格处理,获取合并行
|
||||||
|
*
|
||||||
|
* @param sheet
|
||||||
|
* @return List<CellRangeAddress>
|
||||||
|
*/
|
||||||
|
public static List<CellRangeAddress> getCombineCell(Sheet sheet) {
|
||||||
|
List<CellRangeAddress> list = new ArrayList<>();
|
||||||
|
// 获得一个 sheet 中合并单元格的数量
|
||||||
|
int sheetmergerCount = sheet.getNumMergedRegions();
|
||||||
|
// 遍历所有的合并单元格
|
||||||
|
for (int i = 0; i < sheetmergerCount; i++) {
|
||||||
|
// 获得合并单元格保存进list中
|
||||||
|
CellRangeAddress ca = sheet.getMergedRegion(i);
|
||||||
|
list.add(ca);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Workbook getWorkbook(String file) throws IOException {
|
||||||
|
Workbook workbook = null;
|
||||||
|
// FileInputStream in = new FileInputStream(file);
|
||||||
|
if (file.endsWith(XLS)) {
|
||||||
|
System.out.println("xls");
|
||||||
|
workbook = new HSSFWorkbook();
|
||||||
|
} else if (file.endsWith(XLSX)) {
|
||||||
|
System.out.println("xlsx");
|
||||||
|
workbook = new XSSFWorkbook();
|
||||||
|
} else {
|
||||||
|
System.out.println("格式错误");
|
||||||
|
}
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Workbook getworkbook(File file) throws IOException {
|
||||||
|
Workbook workbook = null;
|
||||||
|
FileInputStream in = new FileInputStream(file);
|
||||||
|
if (file.getName().endsWith(XLS)) {
|
||||||
|
System.out.println("xls");
|
||||||
|
workbook = new HSSFWorkbook(in);
|
||||||
|
} else if (file.getName().endsWith(XLSX)) {
|
||||||
|
System.out.println("xlsx");
|
||||||
|
workbook = new XSSFWorkbook(in);
|
||||||
|
} else {
|
||||||
|
System.out.println("格式错误");
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
public class AddHLBOMAction extends AbstractAIFAction {
|
||||||
|
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
private TCSession session;
|
||||||
|
|
||||||
|
public AddHLBOMAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
this.app = arg0;
|
||||||
|
this.session = (TCSession) app.getSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
TCComponent target = (TCComponent) app.getTargetComponent();
|
||||||
|
TCComponentItemRevision rev = null;
|
||||||
|
if (target instanceof TCComponentItemRevision) {
|
||||||
|
rev = (TCComponentItemRevision) target;
|
||||||
|
} else if (target instanceof TCComponentItem) {
|
||||||
|
try {
|
||||||
|
rev = ((TCComponentItem) target).getLatestItemRevision();
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TCComponent[] revs = rev.getRelatedComponents("JD2_HLBOM");
|
||||||
|
String itemId = rev.getProperty("item_id");
|
||||||
|
String itemName = rev.getProperty("object_name");
|
||||||
|
TCComponentItem newItem = null;
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { true });
|
||||||
|
if (revs.length == 0) {
|
||||||
|
newItem = rev.saveAsItem(itemId + "-1", null);
|
||||||
|
} else {
|
||||||
|
Arrays.sort(revs, new Comparator<TCComponent>() {
|
||||||
|
@Override
|
||||||
|
public int compare(TCComponent o1, TCComponent o2) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
try {
|
||||||
|
return o1.getProperty("item_id").compareTo(o2.getProperty("item_id"));
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
String str = revs[revs.length - 1].getProperty("item_id");
|
||||||
|
str = str.split("-")[1];
|
||||||
|
newItem = rev.saveAsItem(itemId + "-" + (Integer.parseInt(str) + 1), null);
|
||||||
|
}
|
||||||
|
rev.add("JD2_HLBOM", newItem);
|
||||||
|
TCComponentItemRevision newRev = newItem.getLatestItemRevision();
|
||||||
|
TCComponent[] comps = newRev.getRelatedComponents("JD2_HLBOM");
|
||||||
|
System.out.println(Arrays.toString(comps));
|
||||||
|
newRev.cutOperation("JD2_HLBOM", comps);
|
||||||
|
newRev.lock();
|
||||||
|
newRev.setProperty("jd2_ishl", "1");
|
||||||
|
newRev.save();
|
||||||
|
newRev.unlock();
|
||||||
|
|
||||||
|
rev.refresh();
|
||||||
|
MessageBox.post("´´½¨³É¹¦", "Ìáʾ", MessageBox.WARNING);
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
JOptionPane.showMessageDialog(null, e.getMessage(), "´íÎó", JOptionPane.ERROR_MESSAGE);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { false });
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.dialogs.BOMManagementFrame;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
|
||||||
|
public class BOMManagementAction extends AbstractAIFAction {
|
||||||
|
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
|
||||||
|
public BOMManagementAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
this.app = arg0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
new BOMManagementFrame(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.utils.DialogUtil;
|
||||||
|
import com.connor.jd.plm.utils.DialogUtil.TableMsg;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
public class BatchReviseAction extends AbstractAIFAction {
|
||||||
|
private TCSession session;
|
||||||
|
private TCComponentFolder folder;
|
||||||
|
|
||||||
|
public BatchReviseAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
this.session = (TCSession) arg0.getSession();
|
||||||
|
TCComponent target = (TCComponent) arg0.getTargetComponent();
|
||||||
|
System.out.println("类型===>" + target.getType());
|
||||||
|
if (target instanceof TCComponentFolder) {
|
||||||
|
this.folder = (TCComponentFolder) target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (folder == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TCComponent[] comps = folder.getRelatedComponents("contents");
|
||||||
|
List<String[]> unpublished = new ArrayList<String[]>();
|
||||||
|
check(comps, unpublished);
|
||||||
|
if (unpublished.size() > 0) {
|
||||||
|
TableMsg msg = DialogUtil.createTableMsg(new String[] { "序号", "名称", "原因" }, unpublished);
|
||||||
|
JPanel content = new JPanel(new BorderLayout());
|
||||||
|
content.setSize(new Dimension(msg.panel.getWidth(), msg.panel.getHeight() + 50));
|
||||||
|
JLabel text = new JLabel("操作已取消,下列目标未满足要求:");
|
||||||
|
content.add(text, BorderLayout.NORTH);
|
||||||
|
content.add(msg.panel, BorderLayout.CENTER);
|
||||||
|
JOptionPane.showMessageDialog(null, content, "信息", JOptionPane.PLAIN_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<TCComponentItemRevision> newRevs = new ArrayList<>();
|
||||||
|
for (TCComponent comp : comps) {
|
||||||
|
if (!(comp instanceof TCComponentItemRevision)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TCComponentItemRevision rev = (TCComponentItemRevision) comp;
|
||||||
|
newRevs.add(rev.saveAs(rev.getItem().getNewRev()));
|
||||||
|
}
|
||||||
|
if (comps.length > 0) {
|
||||||
|
folder.cutOperation("contents", comps);
|
||||||
|
folder.add("contents", newRevs);
|
||||||
|
folder.refresh();
|
||||||
|
JOptionPane.showMessageDialog(null, "升版成功", "信息", JOptionPane.WARNING_MESSAGE);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(TCComponent[] comps, List<String[]> unpublished) throws Exception {
|
||||||
|
for (TCComponent comp : comps) {
|
||||||
|
if (!(comp instanceof TCComponentItemRevision)) {
|
||||||
|
unpublished.add(
|
||||||
|
new String[] { unpublished.size() + 1 + "", comp.getProperty("object_string"), "目标类型错误,请放版本" });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
boolean isAccess = session.getTCAccessControlService()
|
||||||
|
.checkPrivilege(((TCComponentItemRevision) comp).getItem(), "WRITE");
|
||||||
|
if (!isAccess) {
|
||||||
|
unpublished.add(new String[] { unpublished.size() + 1 + "", comp.getProperty("object_string"), "无权限" });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TCComponent[] status = comp.getRelatedComponents("release_status_list");
|
||||||
|
if (status.length == 0) {
|
||||||
|
unpublished.add(new String[] { unpublished.size() + 1 + "", comp.getProperty("object_string"), "未发布" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,126 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.utils.JDMethodUtil;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
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.TCComponentItem;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCProperty;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
public class DeleteItemRevisionAction extends AbstractAIFAction {
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
|
||||||
|
public DeleteItemRevisionAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
this.app = arg0;
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent[] targets = app.getTargetComponents();
|
||||||
|
String[] allow = JDMethodUtil.getPrefStrArray("connor_wl_type", session);
|
||||||
|
String[] allow2 = JDMethodUtil.getPrefStrArray("connor_tz_type", session);
|
||||||
|
String[] allow3 = JDMethodUtil.getPrefStrArray("jd2_wltz_Revise_allow", session);
|
||||||
|
System.out.println("connor_wl_type===>" + Arrays.toString(allow));
|
||||||
|
System.out.println("connor_tz_type===>" + Arrays.toString(allow2));
|
||||||
|
System.out.println("jd2_wltz_Revise_allow===>" + Arrays.toString(allow3));
|
||||||
|
List<String> pref = Arrays.asList(allow);
|
||||||
|
List<String> pref2 = Arrays.asList(allow2);
|
||||||
|
List<String> pref3 = Arrays.asList(allow3);
|
||||||
|
for (InterfaceAIFComponent target : targets) {
|
||||||
|
System.out.println(target.getType());
|
||||||
|
if (target instanceof TCComponentItemRevision) {
|
||||||
|
if (!pref.contains(target.getType()) && !pref2.contains(target.getType())
|
||||||
|
&& !pref3.contains(target.getType())) {
|
||||||
|
try {
|
||||||
|
MessageBox.post(target.getProperty("object_string") + "既不是物料也不是图纸,不执行删除", "提示",
|
||||||
|
MessageBox.WARNING);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TCComponentItemRevision rev = (TCComponentItemRevision) target;
|
||||||
|
try {
|
||||||
|
String loginUser = session.getUser().getProperty("object_string");
|
||||||
|
// String owningUser = rev.getProperty("owning_user");
|
||||||
|
// System.out.println("loginUser===>" + loginUser);
|
||||||
|
// System.out.println("owningUser===>" + owningUser);
|
||||||
|
boolean[] isAccess = session.getTCAccessControlService().checkPrivileges(rev.getItem(),
|
||||||
|
new String[] { "WRITE", "DELETE" });
|
||||||
|
if (isAccess[0] && isAccess[1]) {
|
||||||
|
TCComponentItem item = rev.getItem();
|
||||||
|
TCComponent[] released = item.getReleasedItemRevisions();
|
||||||
|
for (TCComponent comp : released) {
|
||||||
|
if (comp.getUid().equals(rev.getUid())) {
|
||||||
|
MessageBox.post(target.getProperty("object_string") + "无法删除,物料已经发布", "提示",
|
||||||
|
MessageBox.WARNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { true });
|
||||||
|
System.out.println("rev uid===>" + rev.getUid());
|
||||||
|
AIFComponentContext[] aifs = rev.whereReferenced();
|
||||||
|
for (AIFComponentContext aif : aifs) {
|
||||||
|
if (aif.getComponent() instanceof TCComponent) {
|
||||||
|
TCComponent temp = (TCComponent) aif.getComponent();
|
||||||
|
if (temp.getUid().equals(rev.getItem().getUid())) {
|
||||||
|
System.out.println("跳过对象");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
System.out.println("引用者===>" + temp.getProperty("onject_string"));
|
||||||
|
TCProperty[] tcProps = temp.getAllTCProperties();
|
||||||
|
for (TCProperty tcProp : tcProps) {
|
||||||
|
if (tcProp.isReferenceType()) {
|
||||||
|
if (tcProp.isNotArray()) {
|
||||||
|
if (tcProp.getReferenceValue() != null
|
||||||
|
&& tcProp.getReferenceValue().getUid().equals(rev.getUid())) {
|
||||||
|
System.out.println("关系===>" + tcProp.getPropertyName());
|
||||||
|
temp.cutOperation(tcProp.getPropertyName(), new TCComponent[] { rev });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TCComponent[] comps = tcProp.getReferenceValueArray();
|
||||||
|
for (TCComponent comp : comps) {
|
||||||
|
if (comp.getUid().equals(rev.getUid())) {
|
||||||
|
System.out.println("关系===>" + tcProp.getPropertyName());
|
||||||
|
temp.cutOperation(tcProp.getPropertyName(),
|
||||||
|
new TCComponent[] { rev });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (pref.contains(target.getType())) {
|
||||||
|
// rev.cutOperation("TC_Is_Represented_By", rev.getRelatedComponents("TC_Is_Represented_By"));
|
||||||
|
// } else {
|
||||||
|
// rev.cutOperation("representation_for", rev.getRelatedComponents("representation_for"));
|
||||||
|
// }
|
||||||
|
rev.delete();
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { false });
|
||||||
|
MessageBox.post("删除成功", "提示", MessageBox.WARNING);
|
||||||
|
} else {
|
||||||
|
MessageBox.post(target.getProperty("object_string") + "无修改和删除权限", "提示", MessageBox.WARNING);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.dialog.EditClassificationDialog;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
|
||||||
|
public class EditClassificationAction extends AbstractAIFAction {
|
||||||
|
private final AbstractAIFApplication app;
|
||||||
|
|
||||||
|
public EditClassificationAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
this.app = arg0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
try {
|
||||||
|
new EditClassificationDialog(app);
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
public class ExportBOMAction extends AbstractAIFAction {
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
private TCSession session;
|
||||||
|
|
||||||
|
public ExportBOMAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
this.app = arg0;
|
||||||
|
this.session = (TCSession) app.getSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TCComponent target = (TCComponent) app.getTargetComponent();
|
||||||
|
TCComponentItemRevision rev;
|
||||||
|
if (target instanceof TCComponentItemRevision) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,278 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.connor.jd.plm.utils.JDMethodUtil;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.common.Activator;
|
||||||
|
import com.teamcenter.rac.kernel.TCAccessControlService;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentICO;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.kernel.ics.ICSProperty;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
public class WLTZReviseAction extends AbstractAIFAction {
|
||||||
|
private AbstractAIFApplication app;
|
||||||
|
private TCSession session;
|
||||||
|
|
||||||
|
public WLTZReviseAction(AbstractAIFApplication arg0, String arg1) {
|
||||||
|
super(arg0, arg1);
|
||||||
|
this.app = arg0;
|
||||||
|
this.session = (TCSession) app.getSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
String server = JDMethodUtil.getPrefStr("jd2_server_ip", session);
|
||||||
|
if (server == null || "".equals(server)) {
|
||||||
|
MessageBox.post("未配置jd2_server_ip首选项", "错误", MessageBox.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCComponent target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent();
|
||||||
|
String[] allow = getPrefStrArray("jd2_wltz_Revise_allow");
|
||||||
|
List<String> list = Arrays.asList(allow);
|
||||||
|
for (String s : list) {
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
TCAccessControlService aclService = session.getTCAccessControlService();
|
||||||
|
TCComponentItemRevision rev;
|
||||||
|
if (target instanceof TCComponentItemRevision) {
|
||||||
|
rev = (TCComponentItemRevision) target;
|
||||||
|
} else if (target instanceof TCComponentBOMLine) {
|
||||||
|
try {
|
||||||
|
rev = ((TCComponentBOMLine) target).getItemRevision();
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
MessageBox.post(e.getMessage(), "错误", MessageBox.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessageBox.post("当前对象类型不允许修订并发送分类!", "错误", MessageBox.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String type = rev.getType();
|
||||||
|
System.out.println("uid===>" + rev.getItem().getUid());
|
||||||
|
System.out.println("user===>" + session.getUser().getUid());
|
||||||
|
System.out.println(type);
|
||||||
|
if (!list.contains(type)) {
|
||||||
|
MessageBox.post("当前对象类型不允许修订并发送分类!", "错误", MessageBox.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rev.refresh();
|
||||||
|
// String url = "http://" + server + ":8880/api/grantPrivilege";
|
||||||
|
// TCComponentItem item = rev.getItem();
|
||||||
|
// TCComponent[] comps = rev.getRelatedComponents("fnd0ActuatedInteractiveTsks");
|
||||||
|
// TCComponent[] bomViews = item.getRelatedComponents("bom_view_tags");
|
||||||
|
// String uids = "";
|
||||||
|
// for (TCComponent bomView : bomViews) {
|
||||||
|
// uids += "," + bomView.getUid();
|
||||||
|
// }
|
||||||
|
// AIFComponentContext[] referenced = rev.whereReferenced();
|
||||||
|
// for (AIFComponentContext aif : referenced) {
|
||||||
|
// if (aif.getComponent() instanceof TCComponentItem
|
||||||
|
// || aif.getComponent() instanceof TCComponentItemRevision) {
|
||||||
|
// uids += aif.getComponent().getUid() + ",";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// uids = uids.substring(0, uids.length() - 1);
|
||||||
|
// Map<String, Object> privilegeMap = new HashMap<String, Object>();
|
||||||
|
// privilegeMap.put("uid", uids);
|
||||||
|
// privilegeMap.put("user", session.getUser().getUid());
|
||||||
|
// privilegeMap.put("privilege", "WRITE,DELETE");
|
||||||
|
// privilegeMap.put("pass", true);
|
||||||
|
// List<String> allow2 = Arrays.asList(JDMethodUtil.getPrefStrArray("jd_wltz_revise_workflow", session));
|
||||||
|
// System.out.println("allow workflow:" + Arrays.toString(allow2.toArray()));
|
||||||
|
// TCComponentItemRevision newRev = null;
|
||||||
|
// boolean getPrivilege = false;
|
||||||
|
// for (TCComponent comp : comps) {
|
||||||
|
// if (comp.getProperty("object_name").contains("编制") && allow2.contains(comp.getProperty("parent_name"))
|
||||||
|
// && comp.getProperty("task_state").equals("已开始")) {
|
||||||
|
// System.out.println("开始授权");
|
||||||
|
// privilegeMap.put("pass", true);
|
||||||
|
// String res = HttpUtil.post(url, privilegeMap);
|
||||||
|
// System.out.println("res===>" + res);
|
||||||
|
// if (!res.contains("success")) {
|
||||||
|
// MessageBox.post("授权异常,失败", "错误", MessageBox.ERROR);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// item.refresh();
|
||||||
|
// for (TCComponent bomView : bomViews) {
|
||||||
|
// bomView.refresh();
|
||||||
|
// }
|
||||||
|
// getPrivilege = true;
|
||||||
|
// System.out.println("已授权读写删除");
|
||||||
|
// session.getUserService().call("bs_bypass", new Object[] { true });
|
||||||
|
// newRev = rev.saveAs(item.getNewRev());
|
||||||
|
// session.getUserService().call("bs_bypass", new Object[] { false });
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev.getItem(), "WRITE");
|
||||||
|
// if (!isAccess) {
|
||||||
|
// MessageBox.post("无权限", "提示", MessageBox.WARNING);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
String loginUser = session.getUser().getProperty("object_string");
|
||||||
|
String owningUser = rev.getProperty("owning_user");
|
||||||
|
System.out.println("loginUser===>" + loginUser);
|
||||||
|
System.out.println("owningUser===>" + owningUser);
|
||||||
|
TCComponentItemRevision newRev = null;
|
||||||
|
if (!loginUser.equals(owningUser)) {
|
||||||
|
System.out.println("非所有者请走升版审批流程!");
|
||||||
|
MessageBox.post("非所有者请走升版审批流程!", "提示", MessageBox.WARNING);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { true });
|
||||||
|
newRev = rev.saveAs(rev.getItem().getNewRev());
|
||||||
|
if (target instanceof TCComponentBOMLine) {
|
||||||
|
TCComponentBOMLine bomLine = (TCComponentBOMLine) target;
|
||||||
|
if (bomLine.parent() != null) {
|
||||||
|
bomLine.window().refresh();
|
||||||
|
} else {
|
||||||
|
System.out.println("topLine");
|
||||||
|
Activator.getDefault().openPerspective("com.teamcenter.rac.pse.PSEPerspective");
|
||||||
|
Activator.getDefault().openComponents("com.teamcenter.rac.pse.PSEPerspective",
|
||||||
|
new InterfaceAIFComponent[] { newRev });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.getUserService().call("bs_bypass", new Object[] { false });
|
||||||
|
}
|
||||||
|
if (rev.getClassificationClass() == null || "".equals(rev.getClassificationClass())) {
|
||||||
|
MessageBox.post("升版成功", "提示", MessageBox.WARNING);
|
||||||
|
// if (getPrivilege) {
|
||||||
|
// privilegeMap.put("pass", false);
|
||||||
|
// String res = HttpUtil.post(url, privilegeMap);
|
||||||
|
// System.out.println("res===>" + res);
|
||||||
|
// if (res.contains("error")) {
|
||||||
|
// MessageBox.post("撤销权限异常,失败", "错误", MessageBox.ERROR);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// item.refresh();
|
||||||
|
// for (TCComponent bomView : bomViews) {
|
||||||
|
// bomView.refresh();
|
||||||
|
// }
|
||||||
|
// System.out.println("已撤销读写删除权限");
|
||||||
|
// }
|
||||||
|
System.out.println("success");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newRev == null) {
|
||||||
|
MessageBox.post("未知异常", "错误", MessageBox.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TCComponentICO ico = rev.getClassificationObjects()[0];
|
||||||
|
ICSProperty[] oldICSProps = ico.getICSProperties(true);
|
||||||
|
int[] ids = new int[oldICSProps.length];
|
||||||
|
String[] values = new String[oldICSProps.length];
|
||||||
|
for (int i = 0; i < oldICSProps.length; i++) {
|
||||||
|
System.out.println(oldICSProps[i].getId() + "=====>" + oldICSProps[i].getValue());
|
||||||
|
ids[i] = oldICSProps[i].getId();
|
||||||
|
values[i] = oldICSProps[i].getValue();
|
||||||
|
}
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("ids", ids);
|
||||||
|
json.put("values", values);
|
||||||
|
String prop = json.toString();
|
||||||
|
// prop = prop.replace("\"", "\\\"");
|
||||||
|
System.out.println("prop:" + prop);
|
||||||
|
String uid = newRev.getUid();
|
||||||
|
System.out.println("uid:" + uid);
|
||||||
|
String cid = rev.getClassificationClass();
|
||||||
|
System.out.println("cid:" + cid);
|
||||||
|
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||||
|
paramMap.put("uid", uid);
|
||||||
|
paramMap.put("cid", cid);
|
||||||
|
paramMap.put("prop", prop);
|
||||||
|
final String URL = "http://" + server + ":8880/api/sendClassification";
|
||||||
|
// final String URL2 = url;
|
||||||
|
final Map<String, Object> PARAMMAP = paramMap;
|
||||||
|
// final Map<String, Object> PRIVILEGEMAP = privilegeMap;
|
||||||
|
// final TCComponent[] BOMVIEWS = bomViews;
|
||||||
|
// final boolean GetPrivilege = getPrivilege;
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
cn.hutool.http.HttpUtil.post(URL, PARAMMAP);
|
||||||
|
MessageBox.post("升版成功", "提示", MessageBox.WARNING);
|
||||||
|
|
||||||
|
// if (GetPrivilege) {
|
||||||
|
// PRIVILEGEMAP.put("pass", false);
|
||||||
|
// String res = HttpUtil.post(URL2, PRIVILEGEMAP);
|
||||||
|
// System.out.println("res===>" + res);
|
||||||
|
// if (!res.contains("success")) {
|
||||||
|
// MessageBox.post("撤销权限异常,失败", "错误", MessageBox.ERROR);
|
||||||
|
// } else {
|
||||||
|
// try {
|
||||||
|
// item.refresh();
|
||||||
|
// for (TCComponent bomView : BOMVIEWS) {
|
||||||
|
// bomView.refresh();
|
||||||
|
// }
|
||||||
|
// } catch (TCException e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// System.out.println("已撤销写删除权限");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
System.out.println("success");
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
MessageBox.post(e.getMessage(), "错误", MessageBox.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单值得首选项
|
||||||
|
*
|
||||||
|
* @param prefName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getPrefStr(String prefName) {
|
||||||
|
TCPreferenceService service = session.getPreferenceService();
|
||||||
|
String str = service.getString(TCPreferenceService.TC_preference_site, prefName);
|
||||||
|
if (str == null) {
|
||||||
|
str = new String("");
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多值得首选项
|
||||||
|
*
|
||||||
|
* @param prefName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String[] getPrefStrArray(String prefName) {
|
||||||
|
TCPreferenceService service = session.getPreferenceService();
|
||||||
|
String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName);
|
||||||
|
service.getStringValues(prefName);
|
||||||
|
service.getStringValue(prefName);
|
||||||
|
if (strs == null) {
|
||||||
|
strs = new String[] { "" };
|
||||||
|
}
|
||||||
|
return strs;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
package com.connor.jd.plm.action;
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
public class BOMExportBean {
|
||||||
|
private String pid;// 父id
|
||||||
|
private String prev;// 父版本
|
||||||
|
private String cid;// 子id
|
||||||
|
private String crev;// 子版本
|
||||||
|
private String childCount;// 子数量
|
||||||
|
private String childUnit;// 子单位
|
||||||
|
private String HLCount;// 回料数量
|
||||||
|
private String SN;// 编号
|
||||||
|
|
||||||
|
public BOMExportBean(String pid, String prev, String cid, String crev, String childCount, String childUnit,
|
||||||
|
String HLCount, String SN) {
|
||||||
|
super();
|
||||||
|
this.pid = pid;
|
||||||
|
this.prev = prev;
|
||||||
|
this.cid = cid;
|
||||||
|
this.crev = crev;
|
||||||
|
this.childCount = childCount;
|
||||||
|
this.childUnit = childUnit;
|
||||||
|
this.HLCount = HLCount;
|
||||||
|
this.SN = SN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPid(String pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrev() {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrev(String prev) {
|
||||||
|
this.prev = prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCid() {
|
||||||
|
return cid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCid(String cid) {
|
||||||
|
this.cid = cid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCrev() {
|
||||||
|
return crev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCrev(String crev) {
|
||||||
|
this.crev = crev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChildCount() {
|
||||||
|
return childCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildCount(String childCount) {
|
||||||
|
this.childCount = childCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChildUnit() {
|
||||||
|
return childUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildUnit(String childUnit) {
|
||||||
|
this.childUnit = childUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHLCount() {
|
||||||
|
return HLCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHLCount(String HLCount) {
|
||||||
|
this.HLCount = HLCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSN() {
|
||||||
|
return SN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSN(String SN) {
|
||||||
|
this.SN = SN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int isNegative() {
|
||||||
|
return StrUtil.isBlank(HLCount) ? 0 : Integer.parseInt(HLCount) < 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
public class BOMLogBean {
|
||||||
|
private String target1;
|
||||||
|
private String target2;
|
||||||
|
private String parent;
|
||||||
|
private String operation;
|
||||||
|
private String unit;
|
||||||
|
private String oldNum;
|
||||||
|
private String num;
|
||||||
|
|
||||||
|
public BOMLogBean(String target1, String target2, String parent, String operation, String unit, String oldNum,
|
||||||
|
String num) {
|
||||||
|
super();
|
||||||
|
this.target1 = target1;
|
||||||
|
this.target2 = target2;
|
||||||
|
this.parent = parent;
|
||||||
|
this.operation = operation;
|
||||||
|
this.unit = unit;
|
||||||
|
this.oldNum = oldNum;
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTarget1() {
|
||||||
|
return target1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget1(String target1) {
|
||||||
|
this.target1 = target1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTarget2() {
|
||||||
|
return target2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget2(String target2) {
|
||||||
|
this.target2 = target2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(String parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperation() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperation(String operation) {
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOldNum() {
|
||||||
|
return oldNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOldNum(String oldNum) {
|
||||||
|
this.oldNum = oldNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNum(String num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
|
||||||
|
public class BOMManageTableBean {
|
||||||
|
|
||||||
|
private String parentString;
|
||||||
|
private String childString;
|
||||||
|
private TCComponentItemRevision parentRev;
|
||||||
|
private TCComponentItemRevision childRev;
|
||||||
|
private TCComponentBOMLine parentLine;
|
||||||
|
private TCComponentBOMLine childLine;
|
||||||
|
|
||||||
|
public BOMManageTableBean(String parentString, String childString, TCComponentItemRevision parentRev,
|
||||||
|
TCComponentItemRevision childRev, TCComponentBOMLine parentLine, TCComponentBOMLine childLine) {
|
||||||
|
super();
|
||||||
|
this.parentString = parentString;
|
||||||
|
this.childString = childString;
|
||||||
|
this.parentRev = parentRev;
|
||||||
|
this.childRev = childRev;
|
||||||
|
this.parentLine = parentLine;
|
||||||
|
this.childLine = childLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentString() {
|
||||||
|
return parentString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentString(String parentString) {
|
||||||
|
this.parentString = parentString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChildString() {
|
||||||
|
return childString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildString(String childString) {
|
||||||
|
this.childString = childString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TCComponentItemRevision getParentRev() {
|
||||||
|
return parentRev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentRev(TCComponentItemRevision parentRev) {
|
||||||
|
this.parentRev = parentRev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TCComponentItemRevision getChildRev() {
|
||||||
|
return childRev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildRev(TCComponentItemRevision childRev) {
|
||||||
|
this.childRev = childRev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TCComponentBOMLine getParentLine() {
|
||||||
|
return parentLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentLine(TCComponentBOMLine parentLine) {
|
||||||
|
this.parentLine = parentLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TCComponentBOMLine getChildLine() {
|
||||||
|
return childLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChildLine(TCComponentBOMLine childLine) {
|
||||||
|
this.childLine = childLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
public class CheckBoxPo {
|
||||||
|
public Object value = null;
|
||||||
|
public String text = null;
|
||||||
|
|
||||||
|
public CheckBoxPo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckBoxPo(String text, Object value) {
|
||||||
|
this.value = value;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
public class ClassPropBean {
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public ClassPropBean(int id, String name, String value) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CustomLovBean {
|
||||||
|
private List<CustomLovBean> sub = new ArrayList<CustomLovBean>();
|
||||||
|
public String displayName = "";
|
||||||
|
|
||||||
|
public CustomLovBean(String displayName) {
|
||||||
|
super();
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomLovBean(String displayName, String[] subArray) {
|
||||||
|
super();
|
||||||
|
this.displayName = displayName;
|
||||||
|
translateArrayToSub(subArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void translateArrayToSub(String[] subArray) {
|
||||||
|
for (int i = 0; i < subArray.length; i++) {
|
||||||
|
sub.add(new CustomLovBean(subArray[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CustomLovBean> getSub() {
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChild() {
|
||||||
|
return sub.size() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSub(CustomLovBean clb) {
|
||||||
|
sub.add(clb);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
public class JG {
|
||||||
|
int row;
|
||||||
|
int times;
|
||||||
|
String jg;
|
||||||
|
|
||||||
|
public JG(int row, int times, String jg) {
|
||||||
|
super();
|
||||||
|
this.row = row;
|
||||||
|
this.times = times;
|
||||||
|
this.jg = jg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTimes() {
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimes(int times) {
|
||||||
|
this.times = times;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJg() {
|
||||||
|
return jg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJg(String jg) {
|
||||||
|
this.jg = jg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRow() {
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRow(int row) {
|
||||||
|
this.row = row;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
public class ResultData {
|
||||||
|
private boolean res;
|
||||||
|
private String Message;
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
public ResultData(boolean res, String message, Object data) {
|
||||||
|
super();
|
||||||
|
this.res = res;
|
||||||
|
Message = message;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRes() {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRes(boolean res) {
|
||||||
|
this.res = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
Message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Object data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.connor.jd.plm.beans;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.Icon;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
|
||||||
|
public class TransformBomBean {
|
||||||
|
public String displayName;
|
||||||
|
public TCComponentBOMLine line;
|
||||||
|
public TCComponentItemRevision selectRev;
|
||||||
|
public Map<String, TCComponentItemRevision> map=new HashMap<>();
|
||||||
|
|
||||||
|
public TransformBomBean(TCComponentBOMLine line) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
try {
|
||||||
|
this.line = line;
|
||||||
|
this.displayName=line.getProperty("object_string");
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch blocks
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.connor.jd.plm.dialog;
|
||||||
|
|
||||||
|
public class DocumentTemplate {
|
||||||
|
private String type;// 模板类型
|
||||||
|
private String[] relation;// 数据集关系
|
||||||
|
private String uid;// 模板uid
|
||||||
|
|
||||||
|
public DocumentTemplate(String type, String uid, String[] relation) {
|
||||||
|
super();
|
||||||
|
this.type = type;
|
||||||
|
this.relation = relation;
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getRelation() {
|
||||||
|
return relation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelation(String[] relation) {
|
||||||
|
this.relation = relation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(String uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
package com.connor.jd.plm.dialog;
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,66 @@
|
|||||||
|
package com.connor.jd.plm.dialogs;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.plaf.ColorUIResource;
|
||||||
|
|
||||||
|
public class CheckBoxTreeLabel extends JLabel {
|
||||||
|
private boolean isSelected;
|
||||||
|
private boolean hasFocus;
|
||||||
|
|
||||||
|
public CheckBoxTreeLabel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackground(Color color) {
|
||||||
|
if (color instanceof ColorUIResource)
|
||||||
|
color = null;
|
||||||
|
super.setBackground(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
String str;
|
||||||
|
if ((str = getText()) != null) {
|
||||||
|
if (0 < str.length()) {
|
||||||
|
if (isSelected)
|
||||||
|
g.setColor(UIManager.getColor("Tree.selectionBackground"));
|
||||||
|
else
|
||||||
|
g.setColor(UIManager.getColor("Tree.textBackground"));
|
||||||
|
Dimension d = getPreferredSize();
|
||||||
|
int imageOffset = 0;
|
||||||
|
Icon currentIcon = getIcon();
|
||||||
|
if (currentIcon != null)
|
||||||
|
imageOffset = currentIcon.getIconWidth() + Math.max(0, getIconTextGap() - 1);
|
||||||
|
g.fillRect(imageOffset, 0, d.width - 1 - imageOffset, d.height);
|
||||||
|
if (hasFocus) {
|
||||||
|
g.setColor(UIManager.getColor("Tree.selectionBorderColor"));
|
||||||
|
g.drawRect(imageOffset, 0, d.width - 1 - imageOffset, d.height - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.paint(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
Dimension retDimension = super.getPreferredSize();
|
||||||
|
if (retDimension != null)
|
||||||
|
retDimension = new Dimension(retDimension.width + 3, retDimension.height);
|
||||||
|
return retDimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(boolean isSelected) {
|
||||||
|
this.isSelected = isSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocus(boolean hasFocus) {
|
||||||
|
this.hasFocus = hasFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.connor.jd.plm.dialogs;
|
||||||
|
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class CheckBoxTreeNodeSelectionListener extends MouseAdapter {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent event) {
|
||||||
|
|
||||||
|
JTree tree = (JTree) event.getSource();
|
||||||
|
int x = event.getX();
|
||||||
|
int y = event.getY();
|
||||||
|
int row = tree.getRowForLocation(x, y);
|
||||||
|
TreePath path = tree.getPathForRow(row);
|
||||||
|
if (path != null) {
|
||||||
|
CheckBoxTreeNode node = (CheckBoxTreeNode) path.getLastPathComponent();
|
||||||
|
if (node != null&&node.isSelectable) {
|
||||||
|
boolean isSelected = !node.isSelected();
|
||||||
|
node.setSelected(isSelected);
|
||||||
|
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.connor.jd.plm.dialogs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
|
||||||
|
public class ColorMaterialBean {
|
||||||
|
public List<String[]> colorMaterial = new ArrayList<String[]>();
|
||||||
|
public Map<TCComponentItemRevision, Object[]> data = new HashMap<TCComponentItemRevision, Object[]>();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.connor.jd.plm.dialogs;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
|
||||||
|
public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
|
||||||
|
private TCSession session;
|
||||||
|
|
||||||
|
public MyTreeCellRenderer(TCSession session) {
|
||||||
|
this.session = session;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf,
|
||||||
|
int row, boolean hasFocus) {
|
||||||
|
|
||||||
|
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
|
||||||
|
|
||||||
|
setText(value.toString());
|
||||||
|
|
||||||
|
if (sel) {
|
||||||
|
setForeground(getTextSelectionColor());
|
||||||
|
} else {
|
||||||
|
setForeground(getTextNonSelectionColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
|
||||||
|
String str = node.toString();
|
||||||
|
if (!"".equals(str)) {
|
||||||
|
// session.search(arg0, arg1, arg2)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,295 @@
|
|||||||
|
package com.connor.jd.plm.dialogs;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.connor.jd.operations.ExcelOperation;
|
||||||
|
import com.connor.jd.plm.utils.JDMethodUtil;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentProjectSmartFolder;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentTcFile;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
import javafx.stage.FileChooser.ExtensionFilter;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class QTXJCDialog extends Application {
|
||||||
|
|
||||||
|
private TCSession session;
|
||||||
|
private TextField road = null;
|
||||||
|
private ComboBox<String> pjsName = null;
|
||||||
|
private List<String> sfList = new ArrayList<String>();
|
||||||
|
private TCComponent[] com;
|
||||||
|
private String type;
|
||||||
|
private Stage primaryStage = null;
|
||||||
|
|
||||||
|
public QTXJCDialog(List<String> sfList, TCComponent[] com, TCSession session, String type) throws TCException {
|
||||||
|
|
||||||
|
this.sfList = sfList;
|
||||||
|
this.com = com;
|
||||||
|
this.session = session;
|
||||||
|
this.type = type;
|
||||||
|
// initUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage arg0) throws Exception {
|
||||||
|
primaryStage = new Stage();
|
||||||
|
Pane root = new Pane();
|
||||||
|
Label pjStage = new Label("项目阶段");
|
||||||
|
pjStage.setLayoutX(37.0);
|
||||||
|
pjStage.setLayoutY(51.0);
|
||||||
|
pjsName = new ComboBox<String>();
|
||||||
|
pjsName.setLayoutX(89.0);
|
||||||
|
pjsName.setLayoutY(47.0);
|
||||||
|
pjsName.setPrefSize(161.0, 23.0);
|
||||||
|
pjsName.setValue("");
|
||||||
|
pjsName.getItems().add("");
|
||||||
|
for (int i = 0; i < sfList.size(); i++) {
|
||||||
|
pjsName.getItems().add(sfList.get(i));
|
||||||
|
}
|
||||||
|
Label roadLabel = new Label("路径");
|
||||||
|
roadLabel.setLayoutX(37.0);
|
||||||
|
roadLabel.setLayoutY(107.0);
|
||||||
|
road = new TextField();
|
||||||
|
road.setLayoutX(89.0);
|
||||||
|
road.setLayoutY(103.0);
|
||||||
|
road.setDisable(true);
|
||||||
|
Button open = new Button("选择");
|
||||||
|
open.setLayoutX(263.0);
|
||||||
|
open.setLayoutY(103.0);
|
||||||
|
open.setOnAction((arg) -> {
|
||||||
|
openBtn(primaryStage);
|
||||||
|
});
|
||||||
|
Button export = new Button("导出");
|
||||||
|
export.setLayoutX(89.0);
|
||||||
|
export.setLayoutY(158.0);
|
||||||
|
export.setPrefSize(48.0, 23.0);
|
||||||
|
export.setOnAction((arg) -> {
|
||||||
|
exportBtn();
|
||||||
|
});
|
||||||
|
Button out = new Button("取消");
|
||||||
|
out.setLayoutX(208.0);
|
||||||
|
out.setLayoutY(158.0);
|
||||||
|
out.setPrefSize(48.0, 23.0);
|
||||||
|
out.setOnAction((arg) -> {
|
||||||
|
primaryStage.close();
|
||||||
|
});
|
||||||
|
root.getChildren().add(pjStage);
|
||||||
|
root.getChildren().add(pjsName);
|
||||||
|
root.getChildren().add(roadLabel);
|
||||||
|
root.getChildren().add(road);
|
||||||
|
root.getChildren().add(open);
|
||||||
|
root.getChildren().add(export);
|
||||||
|
root.getChildren().add(out);
|
||||||
|
|
||||||
|
Scene scene = new Scene(root, 338.0, 207);
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.setResizable(false);
|
||||||
|
primaryStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void initUI() {
|
||||||
|
// this.setAutoRequestFocus(true);
|
||||||
|
// this.setPreferredSize(new Dimension(360, 150));
|
||||||
|
// this.setResizable(false);
|
||||||
|
//
|
||||||
|
// JLabel pjStage = new JLabel("项目阶段");
|
||||||
|
// pjsName.addItem("");
|
||||||
|
// for (int i = 0; i < sfList.size(); i++) {
|
||||||
|
// pjsName.addItem(sfList.get(i));
|
||||||
|
// }
|
||||||
|
// JLabel roadLabel = new JLabel("路径");
|
||||||
|
//
|
||||||
|
// JButton open = new JButton("...");
|
||||||
|
// open.addActionListener(new ActionListener() {
|
||||||
|
// @Override
|
||||||
|
// public void actionPerformed(ActionEvent e) {
|
||||||
|
// openBtn();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// JButton export = new JButton("导出");
|
||||||
|
// export.addActionListener(new ActionListener() {
|
||||||
|
// @Override
|
||||||
|
// public void actionPerformed(ActionEvent e) {
|
||||||
|
// exportBtn();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// JButton out = new JButton("取消");
|
||||||
|
// out.addActionListener(new ActionListener() {
|
||||||
|
// @Override
|
||||||
|
// public void actionPerformed(ActionEvent e) {
|
||||||
|
// dispose();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// JPanel flow1 = new JPanel();
|
||||||
|
// Box b1 = Box.createHorizontalBox();
|
||||||
|
// flow1.add(b1);
|
||||||
|
// // b1.add(Box.createHorizontalStrut(20));
|
||||||
|
// b1.add(pjStage);
|
||||||
|
// b1.add(Box.createHorizontalStrut(50));
|
||||||
|
// b1.add(pjsName);
|
||||||
|
// JPanel flow2 = new JPanel();
|
||||||
|
// Box b2 = Box.createHorizontalBox();
|
||||||
|
// flow2.add(b2);
|
||||||
|
// b2.add(Box.createHorizontalStrut(20));
|
||||||
|
// b2.add(roadLabel);
|
||||||
|
// b2.add(Box.createHorizontalStrut(20));
|
||||||
|
// b2.add(road);
|
||||||
|
// b2.add(Box.createHorizontalStrut(80));
|
||||||
|
// b2.add(open);
|
||||||
|
// JPanel btn = new JPanel(new ButtonLayout());
|
||||||
|
// btn.add(export);
|
||||||
|
// btn.add(out);
|
||||||
|
// JPanel center = new JPanel(new BorderLayout());
|
||||||
|
// center.add(flow1, BorderLayout.NORTH);
|
||||||
|
// center.add(flow2, BorderLayout.CENTER);
|
||||||
|
// center.add(btn, BorderLayout.SOUTH);
|
||||||
|
// this.add(center, "Center");
|
||||||
|
//
|
||||||
|
// this.pack();
|
||||||
|
// this.centerToScreen();
|
||||||
|
// this.showDialog();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
String roadName = null;
|
||||||
|
|
||||||
|
private void openBtn(Stage primaryStage) {
|
||||||
|
FileChooser chooser = new FileChooser();
|
||||||
|
chooser.setTitle("请选择要保存的文件夹");
|
||||||
|
chooser.getExtensionFilters().addAll(new ExtensionFilter("Excel工作簿(*.xlsx)", "xlsx"));
|
||||||
|
File getfile = chooser.showSaveDialog(primaryStage);
|
||||||
|
try {
|
||||||
|
if (getfile.getAbsolutePath() != null) {
|
||||||
|
String filePath = getfile.getAbsolutePath() + ".xlsx";
|
||||||
|
roadName = filePath;
|
||||||
|
if (filePath.length() > 25) {
|
||||||
|
road.setText(filePath.substring(0, 25) + "...");
|
||||||
|
} else {
|
||||||
|
road.setText(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportBtn() {
|
||||||
|
String jdname = "JDJFW";
|
||||||
|
if (roadName.equals("")) {
|
||||||
|
MessageBox.post("没有选择保存路径", "错误", MessageBox.ERROR);
|
||||||
|
} else {
|
||||||
|
System.out.println(road.getText());
|
||||||
|
String outpath = roadName;
|
||||||
|
|
||||||
|
System.out.println(outpath);
|
||||||
|
// System.out.println("type是" + type);
|
||||||
|
File file = getExcle(jdname, type);
|
||||||
|
String sel = pjsName.getSelectionModel().getSelectedItem();
|
||||||
|
Map<String, List<TCComponent>> jfw = new HashMap<String, List<TCComponent>>();
|
||||||
|
if (sel.equals("")) {
|
||||||
|
for (int i = 0; i < sfList.size(); i++) {
|
||||||
|
TCComponentProjectSmartFolder sf = (TCComponentProjectSmartFolder) com[i];
|
||||||
|
try {
|
||||||
|
TCComponent[] psf = sf.getTCProperty("project_data").getReferenceValueArray();
|
||||||
|
|
||||||
|
List<TCComponent> jfList = new ArrayList<TCComponent>();
|
||||||
|
for (int j = 0; j < psf.length; j++) {
|
||||||
|
// TCComponentItem jf = (TCComponentItem) psf[j];
|
||||||
|
jfList.add(psf[j]);
|
||||||
|
}
|
||||||
|
jfw.put(sf.getProperty("object_string"), jfList);
|
||||||
|
} catch (TCException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < sfList.size(); i++) {
|
||||||
|
TCComponentProjectSmartFolder sf = (TCComponentProjectSmartFolder) com[i];
|
||||||
|
try {
|
||||||
|
if (sel.equals(sf.getProperty("object_string"))) {
|
||||||
|
TCComponent[] psf = sf.getTCProperty("project_data").getReferenceValueArray();
|
||||||
|
List<TCComponent> jfList = new ArrayList<TCComponent>();
|
||||||
|
for (int j = 0; j < psf.length; j++) {
|
||||||
|
// TCComponentItem jf = (TCComponentItem) psf[j];
|
||||||
|
jfList.add(psf[j]);
|
||||||
|
}
|
||||||
|
jfw.put(sel, jfList);
|
||||||
|
}
|
||||||
|
} catch (TCException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExcelOperation.writeExcel(file, outpath, jfw);
|
||||||
|
System.out.println("导出成功");
|
||||||
|
primaryStage.close();
|
||||||
|
MessageBox.post("导出成功", "信息", MessageBox.INFORMATION);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getExcle(String ssx, String type) {
|
||||||
|
File fmsFile = null;
|
||||||
|
String allpuid = JDMethodUtil.getPrefStr(ssx, session);
|
||||||
|
String[] relpuid = allpuid.split(";");
|
||||||
|
if (relpuid.length != 3) {
|
||||||
|
MessageBox.post("请联系管理员检查首选项", "错误", MessageBox.ERROR);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String puid = null;
|
||||||
|
switch (type) {
|
||||||
|
case "GT":
|
||||||
|
puid = relpuid[2];
|
||||||
|
break;
|
||||||
|
case "BL":
|
||||||
|
puid = relpuid[1];
|
||||||
|
break;
|
||||||
|
case "BX":
|
||||||
|
puid = relpuid[0];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (puid == null) {
|
||||||
|
MessageBox.post("请联系管理员检查首选项", "错误", MessageBox.ERROR);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
TCComponentDataset dateset = null;
|
||||||
|
try {
|
||||||
|
dateset = (TCComponentDataset) session.stringToComponent(puid);
|
||||||
|
} catch (TCException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (dateset == null) {
|
||||||
|
MessageBox.post("未找到数据集,请联系管理员检查首选项", "错误", MessageBox.ERROR);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
TCComponentTcFile[] file = dateset.getTcFiles();
|
||||||
|
if (file.length == 0 || file.length != 1) {
|
||||||
|
MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!", "警告", MessageBox.WARNING);
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
fmsFile = file[0].getFmsFile();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return fmsFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,351 @@
|
|||||||
|
package com.connor.jd.plm.form;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.ScrollPane;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.table.CTMap;
|
||||||
|
import com.connor.jd.plm.table.CTable;
|
||||||
|
import com.connor.jd.plm.table.MyCellEditor4;
|
||||||
|
import com.connor.jd.plm.table.TCTableUtil;
|
||||||
|
import com.connor.jd.plm.utils.DBUtil;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
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.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.db.Db;
|
||||||
|
import cn.hutool.db.Entity;
|
||||||
|
|
||||||
|
public class ComponentTestFrame extends JFrame {
|
||||||
|
private CTMap model;
|
||||||
|
private CTable table;
|
||||||
|
private int bottom;
|
||||||
|
private Container container;
|
||||||
|
private TCComponentForm form;
|
||||||
|
private TCSession session;
|
||||||
|
private MyCallBack callBack;
|
||||||
|
private String itemId;
|
||||||
|
private String[] colNames = new String[] { "jd2_no", "jd2_wtry", "jd2_syxm", "jd2_syzq", "jd2_syts", "jd2_syfy",
|
||||||
|
"jd2_sycs" };
|
||||||
|
private TCComponentForm testForm;
|
||||||
|
|
||||||
|
public ComponentTestFrame(Object itemId, TCComponentForm form, MyCallBack callBack) {
|
||||||
|
this.itemId = StrUtil.toString(itemId);
|
||||||
|
this.callBack = callBack;
|
||||||
|
this.form = form;
|
||||||
|
this.session = (TCSession) AIFUtility.getCurrentApplication().getSession();
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
this.setTitle("部件测试项目");
|
||||||
|
this.setSize(560, 400);
|
||||||
|
this.setResizable(true);
|
||||||
|
this.setAlwaysOnTop(true);
|
||||||
|
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
container = this.getContentPane();
|
||||||
|
container.setLayout(new BorderLayout());
|
||||||
|
container.setPreferredSize(new Dimension(600, 400));
|
||||||
|
|
||||||
|
model = new CTMap(10, 7);
|
||||||
|
model.setValueAt("编号", 0, 0);
|
||||||
|
model.setValueAt("部品类型", 0, 1);
|
||||||
|
model.setValueAt("试验项目", 0, 2);
|
||||||
|
model.setValueAt("试验时间", 0, 3);
|
||||||
|
model.setValueAt("样品数量", 0, 4);
|
||||||
|
model.setValueAt("试验费用", 0, 5);
|
||||||
|
model.setValueAt("是否选择", 0, 6);
|
||||||
|
|
||||||
|
table = new CTable(model) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int col) {
|
||||||
|
if (row == 0 || col == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
table.setRowHeight(25);
|
||||||
|
table.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||||
|
for (int i = 0; i < model.getColumnCount(); i++) {
|
||||||
|
table.getColumnModel().getColumn(i).setPreferredWidth(80);
|
||||||
|
}
|
||||||
|
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
|
||||||
|
// 重写方法
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||||
|
boolean hasFocus, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
if (value instanceof JCheckBox) {
|
||||||
|
return (JCheckBox) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxPreferredHeight = 0;
|
||||||
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||||
|
setText("" + table.getValueAt(row, i));
|
||||||
|
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
||||||
|
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
||||||
|
}
|
||||||
|
setBackground(Color.white);
|
||||||
|
// if(points1.contains(new Point(row,column)))
|
||||||
|
// setForeground(new Color(0,0,255));
|
||||||
|
// else
|
||||||
|
setForeground(Color.black);
|
||||||
|
if (isSelected) {
|
||||||
|
setBackground(new Color(0, 120, 215));
|
||||||
|
setForeground(Color.white);
|
||||||
|
}
|
||||||
|
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
||||||
|
table.setRowHeight(row, maxPreferredHeight);
|
||||||
|
|
||||||
|
setText(value == null ? "" : value.toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tcr1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
table.setDefaultRenderer(Object.class, tcr1);
|
||||||
|
table.getColumnModel().getColumn(6).setCellEditor(new MyCellEditor4(new JTextField()));
|
||||||
|
|
||||||
|
// 填写数据
|
||||||
|
Map<String, String[]> dataMap = new LinkedHashMap<>();
|
||||||
|
try {
|
||||||
|
List<Entity> list = Db.use(DBUtil.getDataSource(session)).findAll("JD2_COMPONENT");
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
String[] rowData = new String[6];
|
||||||
|
rowData[0] = list.get(i).getStr("TEST_ID");
|
||||||
|
rowData[1] = list.get(i).getStr("TEST_TYPE");
|
||||||
|
rowData[2] = list.get(i).getStr("TEST_PROJECT");
|
||||||
|
rowData[3] = list.get(i).getStr("TEST_TIME");
|
||||||
|
rowData[4] = list.get(i).getInt("TEST_NUM") + "";
|
||||||
|
rowData[5] = list.get(i).getInt("TEST_COST") == null ? "0" : list.get(i).getInt("TEST_COST") + "";
|
||||||
|
dataMap.put(rowData[0], rowData);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
MessageBox.post("数据库配置错误", "错误", MessageBox.ERROR);
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> checkedId = new ArrayList<>();
|
||||||
|
if (StrUtil.isNotBlank(itemId)) {
|
||||||
|
try {
|
||||||
|
TCComponent[] res = session.search("Item ID", new String[] { "零组件 ID" }, new String[] { itemId });
|
||||||
|
if (ArrayUtil.isNotEmpty(res) && "JD2_GTCSJH".equals(res[0].getType())) {
|
||||||
|
TCComponentItemRevision resRev = ((TCComponentItem) res[0]).getLatestItemRevision();
|
||||||
|
TCComponent[] forms = resRev.getRelatedComponents("IMAN_master_form_rev");
|
||||||
|
testForm = (TCComponentForm) forms[0];
|
||||||
|
String[][] rowDatas = TCTableUtil.getTableRows(testForm, "jd2_csjh", colNames);
|
||||||
|
for (int i = 0; i < rowDatas.length; i++) {
|
||||||
|
checkedId.add(rowDatas[i][0]);
|
||||||
|
String[] rowData = new String[6];
|
||||||
|
rowData[0] = rowDatas[i][0];
|
||||||
|
rowData[1] = "自定义测试项";
|
||||||
|
rowData[2] = rowDatas[i][2];
|
||||||
|
rowData[3] = rowDatas[i][3];
|
||||||
|
rowData[4] = rowDatas[i][4];
|
||||||
|
rowData[5] = rowDatas[i][5];
|
||||||
|
dataMap.put(rowDatas[i][0], rowData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bottom = dataMap.size();
|
||||||
|
int row = 1;
|
||||||
|
for (Entry<String, String[]> entry : dataMap.entrySet()) {
|
||||||
|
if (row > model.getRowCount() - 1) {
|
||||||
|
model.addRow();
|
||||||
|
}
|
||||||
|
model.setValueAt(entry.getValue()[0], row, 0);
|
||||||
|
model.setValueAt(entry.getValue()[1], row, 1);
|
||||||
|
model.setValueAt(entry.getValue()[2], row, 2);
|
||||||
|
model.setValueAt(entry.getValue()[3], row, 3);
|
||||||
|
model.setValueAt(entry.getValue()[4], row, 4);
|
||||||
|
model.setValueAt(entry.getValue()[5], row, 5);
|
||||||
|
if (checkedId.contains(entry.getValue()[0])) {
|
||||||
|
JCheckBox tempCheck = new JCheckBox();
|
||||||
|
tempCheck.setSelected(true);
|
||||||
|
model.setValueAt(tempCheck, row, 6);
|
||||||
|
} else {
|
||||||
|
model.setValueAt(new JCheckBox(), row, 6);
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮
|
||||||
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||||
|
JButton createTest = new JButton("创建/更新测试计划");
|
||||||
|
createTest.addActionListener(createTest());
|
||||||
|
JButton addTestItem = new JButton("新增测试项");
|
||||||
|
addTestItem.addActionListener(addTestItem());
|
||||||
|
JButton cancel = new JButton("取消");
|
||||||
|
cancel.addActionListener(cancel());
|
||||||
|
buttonPanel.add(createTest);
|
||||||
|
buttonPanel.add(addTestItem);
|
||||||
|
buttonPanel.add(cancel);
|
||||||
|
|
||||||
|
ScrollPane scrollPane = new ScrollPane();
|
||||||
|
scrollPane.add(table);
|
||||||
|
|
||||||
|
container.add(scrollPane, BorderLayout.CENTER);
|
||||||
|
container.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionListener createTest() {
|
||||||
|
return new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
try {
|
||||||
|
if (testForm != null) {// 更新
|
||||||
|
String[] propNames = new String[] { "jd2_no", "jd2_syxh", "jd2_symd", "jd2_wtry", "jd2_syxm",
|
||||||
|
"jd2_syts", "jd2_syzq", "jd2_syfy", "jd2_jhrc", "jd2_jhrc1", "jd2_sjrc", "jd2_sjrc1",
|
||||||
|
"jd2_syzt", "jd2_syjg", "jd2_sycs", "jd2_syry", "jd2_csbg", "jd2_bz" };
|
||||||
|
List<Map<String, String>> oldRowData = TCTableUtil.getTableMapList(testForm, "jd2_csjh",
|
||||||
|
propNames);
|
||||||
|
List<String> selectedNo = new ArrayList<>();
|
||||||
|
for (int i = 1; i <= bottom; i++) {
|
||||||
|
JCheckBox jb = (JCheckBox) model.getValueAt(i, 6);
|
||||||
|
if (jb.isSelected()) {
|
||||||
|
String no = model.getValueAt(i, 0).toString();
|
||||||
|
selectedNo.add(no);
|
||||||
|
boolean isInclude = false;
|
||||||
|
for (int ii = 0; ii < oldRowData.size(); ii++) {// 修改
|
||||||
|
if (no.equals(oldRowData.get(ii).get("jd2_no"))) {
|
||||||
|
isInclude = true;
|
||||||
|
oldRowData.get(ii).put("jd2_syxm", model.getValueAt(i, 2).toString());
|
||||||
|
oldRowData.get(ii).put("jd2_syzq", model.getValueAt(i, 3).toString());
|
||||||
|
oldRowData.get(ii).put("jd2_syts", model.getValueAt(i, 4).toString());
|
||||||
|
oldRowData.get(ii).put("jd2_syfy", model.getValueAt(i, 5).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isInclude) {// 新增
|
||||||
|
Map<String, String> tempMap = new HashMap<String, String>();
|
||||||
|
tempMap.put("jd2_no", no);
|
||||||
|
tempMap.put("jd2_wtry", form.getTCProperty("owning_user").getUIFValue());
|
||||||
|
tempMap.put("jd2_syxm", model.getValueAt(i, 2).toString());
|
||||||
|
tempMap.put("jd2_syzq", model.getValueAt(i, 3).toString());
|
||||||
|
tempMap.put("jd2_syts", model.getValueAt(i, 4).toString());
|
||||||
|
tempMap.put("jd2_syfy", model.getValueAt(i, 5).toString());
|
||||||
|
oldRowData.add(tempMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < oldRowData.size(); i++) {// 删除
|
||||||
|
if (!selectedNo.contains(oldRowData.get(i).get("jd2_no"))) {
|
||||||
|
oldRowData.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TCTableUtil.setTableMapList(testForm, "jd2_csjh", "JD2_CSJHTABLE", oldRowData);
|
||||||
|
callBack.execute(itemId);
|
||||||
|
} else {// 创建
|
||||||
|
TCComponentItemRevision rev = (TCComponentItemRevision) form.whereReferenced()[0]
|
||||||
|
.getComponent();
|
||||||
|
|
||||||
|
TCComponentItemType type = (TCComponentItemType) session.getTypeComponent("Item");
|
||||||
|
TCComponentItem item = type.create(null, null, "JD2_GTCSJH", "测试计划", "", null);
|
||||||
|
rev.add("JD2_CSJH", item);
|
||||||
|
TCComponentItemRevision rev1 = item.getLatestItemRevision();
|
||||||
|
TCComponentForm form1 = (TCComponentForm) rev1.getRelatedComponents("IMAN_master_form_rev")[0];
|
||||||
|
|
||||||
|
List<String[]> list = new ArrayList<String[]>();
|
||||||
|
String[] row = new String[7];
|
||||||
|
for (int i = 1; i <= bottom; i++) {
|
||||||
|
JCheckBox jb = (JCheckBox) model.getValueAt(i, 6);
|
||||||
|
if (jb.isSelected()) {
|
||||||
|
for (int ii = 2; ii < 6; ii++) {
|
||||||
|
row[ii - 2] = model.getValueAt(i, ii) == null ? ""
|
||||||
|
: model.getValueAt(i, ii).toString();
|
||||||
|
}
|
||||||
|
// TCComponentPerson p = (TCComponentPerson) session.getUser().getUserInformation().get(0);
|
||||||
|
list.add(new String[] { model.getValueAt(i, 0).toString(),
|
||||||
|
form.getTCProperty("owning_user").getUIFValue(), row[0], row[1], row[2], row[3],
|
||||||
|
"1" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[][] data = list.toArray(new String[list.size()][7]);
|
||||||
|
TCTableUtil.setTableRows(form1, "jd2_csjh", "JD2_CSJHTABLE", colNames, data);
|
||||||
|
callBack.execute(item.getProperty("item_id"));
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
} catch (TCException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionListener addTestItem() {
|
||||||
|
return new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (bottom > model.getRowCount() - 2) {
|
||||||
|
model.addRow();
|
||||||
|
}
|
||||||
|
int num = Math.max(Integer.parseInt(model.getValueAt(bottom, 0).toString()), 10000);
|
||||||
|
model.setValueAt(num + 1, ++bottom, 0);
|
||||||
|
model.setValueAt(new JCheckBox(), bottom, 6);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
container.removeAll();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionListener cancel() {
|
||||||
|
return new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,583 @@
|
|||||||
|
package com.connor.jd.plm.form;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.table.CTMap;
|
||||||
|
import com.connor.jd.plm.table.CTable;
|
||||||
|
import com.connor.jd.plm.table.JCheckPanel;
|
||||||
|
import com.connor.jd.plm.table.MyCellEditor3;
|
||||||
|
import com.connor.jd.plm.table.TCTableUtil;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.stylesheet.AbstractRendering;
|
||||||
|
|
||||||
|
public class ExperimentalPowerOfAttorneyForm extends AbstractRendering implements MyCallBack {
|
||||||
|
private TCComponentForm form;
|
||||||
|
private CTMap model;
|
||||||
|
private CTable table;
|
||||||
|
private int top = 10;
|
||||||
|
private int end = 1;
|
||||||
|
private int bottom;
|
||||||
|
private CTMap model2;
|
||||||
|
private CTable table2;
|
||||||
|
private Map<String, String> prop;
|
||||||
|
private List<String> disableEdit;
|
||||||
|
private List<String> disableEdit2;
|
||||||
|
private Map<String, int[]> general;
|
||||||
|
private Map<String, int[]> general2;
|
||||||
|
private JCheckPanel bgqf;
|
||||||
|
private JPopupMenu menu = new JPopupMenu();
|
||||||
|
private JMenuItem addR;
|
||||||
|
private JMenuItem delR;
|
||||||
|
private JMenuItem test;
|
||||||
|
private String[] colNames = new String[] { "jd2_no", "jd2_name", "jd2_bgq", "jd2_bgh", "jd2_risk", "jd2_csjh",
|
||||||
|
"jd2_bz" };
|
||||||
|
private String[][] rows;
|
||||||
|
private ExperimentalPowerOfAttorneyForm $this;
|
||||||
|
|
||||||
|
public ExperimentalPowerOfAttorneyForm(TCComponent arg0) throws Exception {
|
||||||
|
super(arg0);
|
||||||
|
if (arg0 instanceof TCComponentForm) {
|
||||||
|
this.form = (TCComponentForm) arg0;
|
||||||
|
TCSession session = arg0.getSession();
|
||||||
|
loadRendering();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadRendering() throws TCException {
|
||||||
|
$this = this;
|
||||||
|
|
||||||
|
this.setLayout(new BorderLayout());
|
||||||
|
JPanel root = new JPanel(new BorderLayout());
|
||||||
|
root.setPreferredSize(new Dimension(800, 500));
|
||||||
|
|
||||||
|
// 内容
|
||||||
|
prop = form.getProperties();
|
||||||
|
model = new CTMap(20, 11);
|
||||||
|
bottom = model.getRowCount() - end;
|
||||||
|
|
||||||
|
model2 = new CTMap(3, 11);
|
||||||
|
|
||||||
|
initModel();
|
||||||
|
|
||||||
|
table = new CTable(model) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int col) {
|
||||||
|
if (isEditorDisable(disableEdit, row, col)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
table.setRowHeight(25);
|
||||||
|
table.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||||
|
table.getColumnModel().getColumn(0).setPreferredWidth(40);
|
||||||
|
table.getColumnModel().getColumn(1).setPreferredWidth(100);
|
||||||
|
table.getColumnModel().getColumn(2).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(3).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(4).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(5).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(6).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(7).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(8).setPreferredWidth(80);
|
||||||
|
table.getColumnModel().getColumn(9).setPreferredWidth(150);
|
||||||
|
table.getColumnModel().getColumn(10).setPreferredWidth(60);
|
||||||
|
table.putClientProperty("terminateEditOnFocusLost", true);
|
||||||
|
|
||||||
|
DefaultTableCellRenderer tcr1 = new DefaultTableCellRenderer() {
|
||||||
|
// 重写方法
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||||
|
boolean hasFocus, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
if (value instanceof JPanel) {
|
||||||
|
return (JPanel) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxPreferredHeight = 0;
|
||||||
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||||
|
setText("" + table.getValueAt(row, i));
|
||||||
|
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
||||||
|
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
||||||
|
}
|
||||||
|
setBackground(Color.white);
|
||||||
|
// if(points1.contains(new Point(row,column)))
|
||||||
|
// setForeground(new Color(0,0,255));
|
||||||
|
// else
|
||||||
|
setForeground(Color.black);
|
||||||
|
if (isSelected) {
|
||||||
|
setBackground(new Color(0, 120, 215));
|
||||||
|
setForeground(Color.white);
|
||||||
|
}
|
||||||
|
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
||||||
|
table.setRowHeight(row, maxPreferredHeight);
|
||||||
|
|
||||||
|
setText(value == null ? "" : value.toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tcr1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
table.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN);
|
||||||
|
table.setDefaultRenderer(Object.class, tcr1);
|
||||||
|
table.getColumnModel().getColumn(2).setCellEditor(new MyCellEditor3(new JTextField()));
|
||||||
|
table.addMouseListener(rightClick());
|
||||||
|
|
||||||
|
initModel2();
|
||||||
|
|
||||||
|
table2 = new CTable(model2) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int col) {
|
||||||
|
if (isEditorDisable(disableEdit2, row, col)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
table2.setRowHeight(25);
|
||||||
|
table2.setBorder(BorderFactory.createLineBorder(Color.black));
|
||||||
|
table2.getColumnModel().getColumn(0).setPreferredWidth(40);
|
||||||
|
table2.getColumnModel().getColumn(1).setPreferredWidth(100);
|
||||||
|
table2.getColumnModel().getColumn(2).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(3).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(4).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(5).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(6).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(7).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(8).setPreferredWidth(80);
|
||||||
|
table2.getColumnModel().getColumn(9).setPreferredWidth(150);
|
||||||
|
table2.getColumnModel().getColumn(10).setPreferredWidth(60);
|
||||||
|
table2.putClientProperty("terminateEditOnFocusLost", true);
|
||||||
|
|
||||||
|
DefaultTableCellRenderer tcr2 = new DefaultTableCellRenderer() {
|
||||||
|
// 重写方法
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||||
|
boolean hasFocus, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
if (value instanceof JPanel) {
|
||||||
|
return (JPanel) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxPreferredHeight = 0;
|
||||||
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||||
|
setText("" + table.getValueAt(row, i));
|
||||||
|
setSize(table.getColumnModel().getColumn(column).getWidth(), 0);
|
||||||
|
maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height);
|
||||||
|
}
|
||||||
|
setBackground(Color.white);
|
||||||
|
// if(points1.contains(new Point(row,column)))
|
||||||
|
// setForeground(new Color(0,0,255));
|
||||||
|
// else
|
||||||
|
setForeground(Color.black);
|
||||||
|
if (isSelected) {
|
||||||
|
setBackground(new Color(0, 120, 215));
|
||||||
|
setForeground(Color.white);
|
||||||
|
}
|
||||||
|
if (table.getRowHeight(row) != maxPreferredHeight) // 少了这行则处理器瞎忙
|
||||||
|
table.setRowHeight(row, maxPreferredHeight);
|
||||||
|
|
||||||
|
setText(value == null ? "" : value.toString());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tcr2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
table2.setAutoResizeMode(CTable.AUTO_RESIZE_NEXT_COLUMN);
|
||||||
|
table2.setDefaultRenderer(Object.class, tcr2);
|
||||||
|
|
||||||
|
// 右键菜单
|
||||||
|
menu.setVisible(false);
|
||||||
|
addR = new JMenuItem("新增行");
|
||||||
|
addR.setEnabled(false);
|
||||||
|
menu.add(addR);
|
||||||
|
addR.addActionListener(addRow());
|
||||||
|
delR = new JMenuItem("删除行");
|
||||||
|
delR.setEnabled(false);
|
||||||
|
menu.add(delR);
|
||||||
|
delR.addActionListener(delRow());
|
||||||
|
test = new JMenuItem("测试项");
|
||||||
|
test.setEnabled(false);
|
||||||
|
menu.add(test);
|
||||||
|
test.addActionListener(test());
|
||||||
|
|
||||||
|
// 填写数据
|
||||||
|
for (Entry<String, int[]> entry : general.entrySet()) {
|
||||||
|
if (prop.containsKey(entry.getKey())) {
|
||||||
|
model.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
|
||||||
|
} else {
|
||||||
|
System.out.println("未找到属性 " + entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Entry<String, int[]> entry : general2.entrySet()) {
|
||||||
|
if (prop.containsKey(entry.getKey())) {
|
||||||
|
model2.setValueAt(prop.get(entry.getKey()), entry.getValue()[0], entry.getValue()[1]);
|
||||||
|
} else {
|
||||||
|
System.out.println("未找到属性 " + entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prop.containsKey("jd2_bgqf")) {
|
||||||
|
bgqf.setSelected(prop.get("jd2_bgqf"));
|
||||||
|
} else {
|
||||||
|
System.out.println("未找到属性 jd2_bgqf");
|
||||||
|
}
|
||||||
|
rows = TCTableUtil.getTableRows(form, "jd2_sywts", colNames);
|
||||||
|
for (int i = 0; i < rows.length; i++) {
|
||||||
|
if (top + i + 1 > bottom) {
|
||||||
|
this.addRow();
|
||||||
|
}
|
||||||
|
for (int ii = 0; ii < rows[0].length; ii++) {
|
||||||
|
model.setValueAt(rows[i][ii], top + i + 1, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 属性映射
|
||||||
|
try {
|
||||||
|
AIFComponentContext[] refs = form.whereReferenced();
|
||||||
|
for (AIFComponentContext aif : refs) {
|
||||||
|
if (aif.getComponent().getType().equals("JD2_GTSYWTSRevision")) {
|
||||||
|
model.setValueAt(aif.getComponent().getProperty("item_id"), 0, 9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.setValueAt(form.getProperty("creation_date"), 1, 9);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel inner = new JPanel(new BorderLayout());
|
||||||
|
inner.add(table, BorderLayout.CENTER);
|
||||||
|
inner.add(table2, BorderLayout.SOUTH);
|
||||||
|
JScrollPane jsp = new JScrollPane(inner);
|
||||||
|
root.add(jsp, BorderLayout.CENTER);
|
||||||
|
this.add(menu);
|
||||||
|
this.add(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initModel() {
|
||||||
|
disableEdit = new ArrayList<>();// 不允许编辑
|
||||||
|
general = new HashMap<String, int[]>();// 要填写的一般属性
|
||||||
|
model.setValueAt("吉德", 0, 0);
|
||||||
|
disableEdit.add("0,0");
|
||||||
|
model.setValueAt("试验委托书", 0, 3);
|
||||||
|
disableEdit.add("0,3");
|
||||||
|
model.setValueAt("表号", 0, 8);
|
||||||
|
disableEdit.add("0,8");
|
||||||
|
model.setValueAt("生效期", 1, 8);
|
||||||
|
disableEdit.add("1,8");
|
||||||
|
general.put("jd2_bh", new int[] { 0, 9 });
|
||||||
|
general.put("jd2_sxr", new int[] { 1, 9 });
|
||||||
|
model.setValueAt("委托项目:", 3, 0);
|
||||||
|
disableEdit.add("3,0");
|
||||||
|
model.setValueAt("委托部门:", 4, 0);
|
||||||
|
disableEdit.add("4,0");
|
||||||
|
general.put("jd2_wtxm", new int[] { 3, 3 });
|
||||||
|
general.put("jd2_wtbm", new int[] { 4, 3 });
|
||||||
|
model.setValueAt("供货厂家:", 3, 6);
|
||||||
|
disableEdit.add("3,6");
|
||||||
|
model.setValueAt("接受部门:", 4, 6);
|
||||||
|
disableEdit.add("4,6");
|
||||||
|
general.put("jd2_ghcj", new int[] { 3, 8 });
|
||||||
|
general.put("jd2_jsbm", new int[] { 4, 8 });
|
||||||
|
model.setValueAt("变更区分:", 5, 0);
|
||||||
|
bgqf = new JCheckPanel(new String[] { "复制模", "降本", "二元化", "改善优化", "新规部品" });
|
||||||
|
model.setValueAt(bgqf, 5, 2);
|
||||||
|
model.setValueAt("部品型号:", 7, 0);
|
||||||
|
disableEdit.add("7,0");
|
||||||
|
general.put("jd2_bpxh", new int[] { 7, 2 });
|
||||||
|
model.setValueAt("适用型号:", 7, 6);
|
||||||
|
disableEdit.add("7,6");
|
||||||
|
general.put("jd2_syxh", new int[] { 7, 7 });
|
||||||
|
model.setValueAt("变更内容", 8, 0);
|
||||||
|
disableEdit.add("8,0");
|
||||||
|
|
||||||
|
model.setValueAt("NO", top, 0);
|
||||||
|
disableEdit.add(top + ",0");
|
||||||
|
model.setValueAt("名称", top, 1);
|
||||||
|
disableEdit.add(top + ",1");
|
||||||
|
model.setValueAt("变更前", top, 2);
|
||||||
|
disableEdit.add(top + ",2");
|
||||||
|
model.setValueAt("变更后", top, 5);
|
||||||
|
disableEdit.add(top + ",5");
|
||||||
|
model.setValueAt("Risk", top, 8);
|
||||||
|
disableEdit.add(top + ",8");
|
||||||
|
model.setValueAt("测试计划", top, 9);
|
||||||
|
disableEdit.add(top + ",9");
|
||||||
|
model.setValueAt("备注", top, 10);
|
||||||
|
disableEdit.add(top + ",10");
|
||||||
|
|
||||||
|
model.combine(new int[] { 0, 1, 2 }, new int[] { 0, 1, 2 });
|
||||||
|
model.combine(new int[] { 0, 1, 2 }, new int[] { 3, 4, 5, 6, 7 });
|
||||||
|
model.combine(new int[] { 0 }, new int[] { 9, 10 });
|
||||||
|
model.combine(new int[] { 1 }, new int[] { 9, 10 });
|
||||||
|
model.combine(new int[] { 2 }, new int[] { 8, 9, 10 });
|
||||||
|
model.combine(new int[] { 3 }, new int[] { 0, 1, 2 });
|
||||||
|
model.combine(new int[] { 3 }, new int[] { 3, 4, 5 });
|
||||||
|
model.combine(new int[] { 3 }, new int[] { 6, 7 });
|
||||||
|
model.combine(new int[] { 3 }, new int[] { 8, 9, 10 });
|
||||||
|
model.combine(new int[] { 4 }, new int[] { 0, 1, 2 });
|
||||||
|
model.combine(new int[] { 4 }, new int[] { 3, 4, 5 });
|
||||||
|
model.combine(new int[] { 4 }, new int[] { 6, 7 });
|
||||||
|
model.combine(new int[] { 4 }, new int[] { 8, 9, 10 });
|
||||||
|
model.combine(new int[] { 5 }, new int[] { 0, 1 });
|
||||||
|
model.combine(new int[] { 5 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||||
|
model.combine(new int[] { 6 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||||
|
model.combine(new int[] { 7 }, new int[] { 0, 1 });
|
||||||
|
model.combine(new int[] { 7 }, new int[] { 2, 3, 4, 5 });
|
||||||
|
model.combine(new int[] { 7 }, new int[] { 7, 8, 9, 10 });
|
||||||
|
model.combine(new int[] { 8, 9 }, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||||
|
model.combine(new int[] { top }, new int[] { 2, 3, 4 });
|
||||||
|
model.combine(new int[] { top }, new int[] { 5, 6, 7 });
|
||||||
|
for (int i = top + 1; i <= bottom; i++) {
|
||||||
|
model.combine(new int[] { i }, new int[] { 2, 3, 4 });
|
||||||
|
model.combine(new int[] { i }, new int[] { 5, 6, 7 });
|
||||||
|
model.setValueAt(i - top, i, 0);
|
||||||
|
disableEdit.add(i + ",0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initModel2() {
|
||||||
|
disableEdit2 = new ArrayList<String>();
|
||||||
|
general2 = new HashMap<String, int[]>();
|
||||||
|
model2.setValueAt("预计完成日期:", 0, 0);
|
||||||
|
disableEdit2.add("0,0");
|
||||||
|
general2.put("jd2_yjwcrq", new int[] { 0, 2 });
|
||||||
|
model2.setValueAt("编制签名:", 1, 0);
|
||||||
|
disableEdit2.add("1,0");
|
||||||
|
model2.setValueAt("批准签名:", 2, 0);
|
||||||
|
disableEdit2.add("2,0");
|
||||||
|
general2.put("jd2_bz", new int[] { 1, 2 });
|
||||||
|
general2.put("jd2_pz", new int[] { 2, 2 });
|
||||||
|
model2.setValueAt("编制时间:", 1, 5);
|
||||||
|
disableEdit2.add("1,5");
|
||||||
|
model2.setValueAt("批准时间:", 2, 5);
|
||||||
|
disableEdit2.add("2,5");
|
||||||
|
general2.put("jd2_bzrq", new int[] { 1, 8 });
|
||||||
|
general2.put("jd2_pzrq", new int[] { 2, 8 });
|
||||||
|
|
||||||
|
model2.combine(new int[] { 0 }, new int[] { 0, 1 });
|
||||||
|
model2.combine(new int[] { 0 }, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 });
|
||||||
|
model2.combine(new int[] { 1 }, new int[] { 0, 1 });
|
||||||
|
model2.combine(new int[] { 1 }, new int[] { 2, 3, 4 });
|
||||||
|
model2.combine(new int[] { 1 }, new int[] { 5, 6, 7 });
|
||||||
|
model2.combine(new int[] { 1 }, new int[] { 8, 9, 10 });
|
||||||
|
model2.combine(new int[] { 2 }, new int[] { 0, 1 });
|
||||||
|
model2.combine(new int[] { 2 }, new int[] { 2, 3, 4 });
|
||||||
|
model2.combine(new int[] { 2 }, new int[] { 5, 6, 7 });
|
||||||
|
model2.combine(new int[] { 2 }, new int[] { 8, 9, 10 });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveRendering() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
for (Entry<String, int[]> entry : general.entrySet()) {
|
||||||
|
if (prop.containsKey(entry.getKey())) {
|
||||||
|
String value = model.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString();
|
||||||
|
try {
|
||||||
|
if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) {
|
||||||
|
value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues()
|
||||||
|
.getRealValue(value);
|
||||||
|
}
|
||||||
|
System.out.println(entry.getKey() + ":" + value);
|
||||||
|
form.setProperty(entry.getKey(), value);
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
for (Entry<String, int[]> entry : general2.entrySet()) {
|
||||||
|
if (prop.containsKey(entry.getKey())) {
|
||||||
|
String value = model2.getValueAt(entry.getValue()[0], entry.getValue()[1]).toString();
|
||||||
|
try {
|
||||||
|
if (form.getTCProperty(entry.getKey()).getLOV() != null && !"".equals(value)) {
|
||||||
|
value = (String) form.getTCProperty(entry.getKey()).getLOV().getListOfValues()
|
||||||
|
.getRealValue(value);
|
||||||
|
}
|
||||||
|
System.out.println(entry.getKey() + ":" + value);
|
||||||
|
form.setProperty(entry.getKey(), value);
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (prop.containsKey("jd2_bgqf")) {
|
||||||
|
String value = bgqf.getSelectedText() == null ? "" : bgqf.getSelectedText();
|
||||||
|
try {
|
||||||
|
if (form.getTCProperty("jd2_bgqf").getLOV() != null && !"".equals(value)) {
|
||||||
|
value = (String) form.getTCProperty("jd2_bgqf").getLOV().getListOfValues().getRealValue(value);
|
||||||
|
}
|
||||||
|
System.out.println("jd2_bgqf:" + value);
|
||||||
|
form.setProperty("jd2_bgqf", value);
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop.containsKey("jd2_sywts")) {
|
||||||
|
List<String[]> data = new ArrayList<String[]>();
|
||||||
|
int num = 0;
|
||||||
|
while (true) {
|
||||||
|
boolean isNotEmpty = false;
|
||||||
|
String[] row = new String[7];
|
||||||
|
for (int ii = 0; ii < row.length; ii++) {
|
||||||
|
Object object = model.getValueAt(top + 1 + num, ii > 2 ? ii > 3 ? ii + 4 : ii + 2 : ii);
|
||||||
|
row[ii] = object == null ? "" : object.toString();
|
||||||
|
if (!isNotEmpty && ii > 0 && ii < 4) {
|
||||||
|
isNotEmpty = !"".equals(row[ii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isNotEmpty) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data.add(row);
|
||||||
|
num++;
|
||||||
|
if (top + 1 + num > bottom) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[][] dataArr = data.toArray(new String[data.size()][]);
|
||||||
|
System.out.println(Arrays.deepToString(dataArr));
|
||||||
|
TCTableUtil.setTableRows(form, "jd2_sywts", "JD2_SYWTS", colNames, dataArr);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
form.refresh();
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEditorDisable(List<String> list, int row, int col) {
|
||||||
|
return list.contains(row + "," + col);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MouseAdapter rightClick() {
|
||||||
|
return new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if (e.getButton() == MouseEvent.BUTTON3 && form.isCheckedOut() && table.getSelectedRow() != -1) {
|
||||||
|
int row = table.getSelectedRow();
|
||||||
|
boolean flag = (row > top && row <= bottom);
|
||||||
|
addR.setEnabled(flag);
|
||||||
|
delR.setEnabled(flag);
|
||||||
|
test.setEnabled(flag);
|
||||||
|
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionListener addRow() {
|
||||||
|
return new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
int num = Integer.parseInt(model.getValueAt(bottom, 0).toString());
|
||||||
|
model.insertRow(++bottom);
|
||||||
|
// model.setValueAt(num + 1, bottom, 0);
|
||||||
|
// model.combine(new int[] { bottom }, new int[] { 2, 3, 4 });
|
||||||
|
// model.combine(new int[] { bottom }, new int[] { 5, 6, 7 });
|
||||||
|
|
||||||
|
System.out.println(bottom);
|
||||||
|
initModel();
|
||||||
|
table.revalidate();
|
||||||
|
table.repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionListener delRow() {
|
||||||
|
return new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
int row = table.getSelectedRow();
|
||||||
|
int num = Integer.parseInt(model.getValueAt(row, 0).toString());
|
||||||
|
model.removeRow(row);
|
||||||
|
bottom--;
|
||||||
|
// if (row <= bottom) {
|
||||||
|
// for (int i = row; i <= bottom; i++) {
|
||||||
|
// model.setValueAt(num + i - row, i, 0);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
System.out.println(bottom);
|
||||||
|
initModel();
|
||||||
|
table.revalidate();
|
||||||
|
table.repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionListener test() {
|
||||||
|
return new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
new ComponentTestFrame(model.getValueAt(table.getSelectedRow(), 9), form, $this);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String itemId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
int row = table.getSelectedRow();
|
||||||
|
System.out.println(itemId + " " + row);
|
||||||
|
model.setValueAt(itemId, row, 9);
|
||||||
|
table.revalidate();
|
||||||
|
table.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRenderingModified() {
|
||||||
|
return form.isCheckedOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.connor.jd.plm.form;
|
||||||
|
|
||||||
|
public interface MyCallBack {
|
||||||
|
|
||||||
|
public void execute(String itemId);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@
|
|||||||
|
package com.connor.jd.plm.form;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
public class PhotoFrame extends JFrame {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2216276219179107707L;
|
||||||
|
private Container con;
|
||||||
|
|
||||||
|
private ZPanel zPanel;
|
||||||
|
private JScrollPane imgSp;
|
||||||
|
private static PhotoFrame instance;
|
||||||
|
|
||||||
|
public static PhotoFrame getInstance(String imgPath) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new PhotoFrame(imgPath);
|
||||||
|
} else {
|
||||||
|
instance.zPanel.setImagePath(imgPath);
|
||||||
|
instance.setVisible(true);
|
||||||
|
instance.zPanel.setPreferredSize(
|
||||||
|
new Dimension(instance.zPanel.getImgWidth(),
|
||||||
|
instance.zPanel.getImgHeight()));
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PhotoFrame(String imgPath) {
|
||||||
|
init(imgPath);
|
||||||
|
finalSetting();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(String imgPath) {
|
||||||
|
con = getContentPane();
|
||||||
|
|
||||||
|
zPanel = new ZPanel();
|
||||||
|
zPanel.setImagePath(imgPath);
|
||||||
|
zPanel.setPreferredSize(
|
||||||
|
new Dimension(zPanel.getImgWidth(), zPanel.getImgHeight()));
|
||||||
|
|
||||||
|
imgSp = new JScrollPane();
|
||||||
|
imgSp.setViewportView(zPanel);
|
||||||
|
imgSp.setHorizontalScrollBarPolicy(
|
||||||
|
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||||
|
imgSp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
|
|
||||||
|
con.add(imgSp, BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finalSetting() {
|
||||||
|
setTitle("Ô¤ÀÀ");
|
||||||
|
|
||||||
|
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||||
|
Dimension screenSize = kit.getScreenSize();
|
||||||
|
int screenHeight = screenSize.height;
|
||||||
|
int screenWidth = screenSize.width;
|
||||||
|
int frameH = getHeight();
|
||||||
|
int frameW = getWidth();
|
||||||
|
setLocation((screenWidth - frameW) / 2 - 250,
|
||||||
|
(screenHeight - frameH) / 2 - 250);
|
||||||
|
setSize(screenWidth / 2, screenHeight / 2);
|
||||||
|
setVisible(true);
|
||||||
|
setResizable(true);
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.dispose();
|
||||||
|
System.out.println("Ô¤ÀÀ¹Ø±Õ");
|
||||||
|
zPanel.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.AddHLBOMAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class AddHLBOMHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
AddHLBOMAction action = new AddHLBOMAction(app, "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.BOMManagementAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class BOMManagementHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
BOMManagementAction action = new BOMManagementAction(app, "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.BatchReviseAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class BatchReviseHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
new Thread(new BatchReviseAction(app, "")).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.DeleteItemRevisionAction;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class DeleteItemRevisionHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
DeleteItemRevisionAction action = new DeleteItemRevisionAction(AIFUtility.getCurrentApplication(), "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.EditClassificationAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class EditClassificationHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
EditClassificationAction action = new EditClassificationAction(app, "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.ExportBOMAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class ExportBOMHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
ExportBOMAction action = new ExportBOMAction(app, "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.dialogs.QTXJCDialog;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponent;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentProject;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentProjectSmartFolder;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.util.MessageBox;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.embed.swing.JFXPanel;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class QTXJCHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
private TCComponent[] com;
|
||||||
|
private String type = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
List<String> sfList = new ArrayList<String>();
|
||||||
|
String name = arg0.getCommand().getId();
|
||||||
|
// System.out.println("name:" + name);
|
||||||
|
try {
|
||||||
|
AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
if (app.getTargetComponent() != null && app.getTargetComponent() instanceof TCComponentProject) {
|
||||||
|
TCComponentProject project = (TCComponentProject) app.getTargetComponent();
|
||||||
|
com = project.getTCProperty("project_data").getReferenceValueArray();
|
||||||
|
for (int i = 0; i < com.length; i++) {
|
||||||
|
TCComponentProjectSmartFolder sf = (TCComponentProjectSmartFolder) com[i];
|
||||||
|
sfList.add(sf.getProperty("object_string"));
|
||||||
|
}
|
||||||
|
TCSession session = (TCSession) app.getSession();
|
||||||
|
|
||||||
|
switch (name) {
|
||||||
|
case "JD2_GTQTXJC":
|
||||||
|
type = "GT";
|
||||||
|
break;
|
||||||
|
case "JD2_BLQTXJC":
|
||||||
|
type = "BL";
|
||||||
|
break;
|
||||||
|
case "JD2_BXQTXJC":
|
||||||
|
type = "BX";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
new Thread(() -> {
|
||||||
|
new JFXPanel();
|
||||||
|
Platform.setImplicitExit(false);
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
// System.out.println("typeÄÚÈÝ" + type);
|
||||||
|
QTXJCDialog qtxjc = new QTXJCDialog(sfList, com, session, type);
|
||||||
|
qtxjc.start(new Stage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
} else {
|
||||||
|
MessageBox.post("ÇëÑ¡ÔñÏîÄ¿", "Ìáʾ", MessageBox.INFORMATION);
|
||||||
|
}
|
||||||
|
} catch (TCException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,148 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Label;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.dialogs.TransformDesignToPartDialog;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||||
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||||
|
import com.teamcenter.rac.kernel.TCException;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.kernel.TCTypeService;
|
||||||
|
import com.teamcenter.rac.util.ButtonLayout;
|
||||||
|
|
||||||
|
public class TransformDesignToPartHandler extends AbstractHandler {
|
||||||
|
private StringBuffer errorMsgSb;
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
try {
|
||||||
|
errorMsgSb=new StringBuffer();
|
||||||
|
System.out.println("111");
|
||||||
|
final AbstractAIFApplication app= AIFUtility.getCurrentApplication();
|
||||||
|
TCSession session=(TCSession) app.getSession();
|
||||||
|
final String[] types=session.getPreferenceService().getStringValues("connor_wl_type");
|
||||||
|
TCComponentItemRevision rev = (TCComponentItemRevision) app.getTargetComponent();
|
||||||
|
TCTypeService service = session.getTypeService();
|
||||||
|
TCComponentBOMWindowType bomwindow = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
|
||||||
|
TCComponentBOMWindow window = bomwindow.create(null);
|
||||||
|
final TCComponentBOMLine topBomline = window.setWindowTopLine(rev.getItem(), rev, null, null);
|
||||||
|
checkBomRef(topBomline,types);
|
||||||
|
checkBomLine(topBomline,types);
|
||||||
|
System.out.println("step:-2------------------");
|
||||||
|
if (!errorMsgSb.toString().equals("")) {
|
||||||
|
final JFrame sFrame = new JFrame("确认对话框");
|
||||||
|
sFrame.setSize(350, 200);
|
||||||
|
JLabel title = new JLabel(" 警 告 ");
|
||||||
|
JTextArea area = new JTextArea(4, 30);
|
||||||
|
area.setText("" + errorMsgSb.append("无关联物料,若不需关联则点确定,若需要关联则点退出!"));
|
||||||
|
area.setWrapStyleWord(true);
|
||||||
|
area.setLineWrap(true);
|
||||||
|
area.setEditable(false);
|
||||||
|
JButton okButton = new JButton("确定");
|
||||||
|
okButton.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
try {
|
||||||
|
sFrame.dispose();
|
||||||
|
new TransformDesignToPartDialog(app, topBomline,types);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JButton celButton = new JButton("退出");
|
||||||
|
celButton.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
sFrame.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
panel.add(area, BorderLayout.CENTER);
|
||||||
|
panel.add(title, BorderLayout.NORTH);
|
||||||
|
JPanel buttonPanel = new JPanel(new ButtonLayout());
|
||||||
|
buttonPanel.add("1.1.left,top", okButton);
|
||||||
|
buttonPanel.add("1.2.left,top", new Label(" "));
|
||||||
|
buttonPanel.add("1.3.left,top", celButton);
|
||||||
|
JPanel rootPanel = new JPanel(new BorderLayout());
|
||||||
|
rootPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
rootPanel.add(panel, BorderLayout.CENTER);
|
||||||
|
sFrame.setLayout(new BorderLayout());
|
||||||
|
sFrame.add(rootPanel);
|
||||||
|
sFrame.setLocationRelativeTo(null);
|
||||||
|
sFrame.setVisible(true);
|
||||||
|
sFrame.setResizable(false);
|
||||||
|
} else {
|
||||||
|
new Thread(new TransformDesignToPartDialog(app, topBomline,types)).start();;
|
||||||
|
}
|
||||||
|
} catch (TCException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查bom和其子bom
|
||||||
|
* @param line
|
||||||
|
* @throws TCException
|
||||||
|
*/
|
||||||
|
public void checkBomLine(TCComponentBOMLine line,String[] types) throws TCException {
|
||||||
|
if (line == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AIFComponentContext[] children = line.getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
TCComponentBOMLine childLine = (TCComponentBOMLine) children[i].getComponent();
|
||||||
|
checkBomRef(childLine,types);
|
||||||
|
checkBomLine(childLine,types);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查有没有关联物料
|
||||||
|
public void checkBomRef(TCComponentBOMLine line,String[] types) {
|
||||||
|
try {
|
||||||
|
if (line == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (line.getItemRevision().isTypeOf("PartRevision")) {
|
||||||
|
//#物料 不操作
|
||||||
|
} else {
|
||||||
|
System.out.println("check");
|
||||||
|
AIFComponentContext[] aifContext = line.getItemRevision().whereReferencedByTypeRelation(
|
||||||
|
types, new String[] { "TC_Is_Represented_By" });
|
||||||
|
if (aifContext == null || aifContext.length == 0) {
|
||||||
|
this.errorMsgSb.append(line.getProperty("object_string") + ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (
|
||||||
|
|
||||||
|
TCException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.action.WLTZReviseAction;
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
|
||||||
|
public class WLTZReviseHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
WLTZReviseAction action = new WLTZReviseAction(app, "");
|
||||||
|
new Thread(action).start();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
package com.connor.jd.plm.handlers;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||||
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||||
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||||
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
||||||
|
import com.teamcenter.rac.kernel.TCSession;
|
||||||
|
import com.teamcenter.rac.schedule.commands.newschedule.NewScheduleHandler;
|
||||||
|
import com.teamcenter.rac.schedule.plugin.Activator;
|
||||||
|
import com.teamcenter.rac.schedule.project.sharedUtils.TimeZoneCalUtil;
|
||||||
|
import com.teamcenter.rac.schedule.wizardpages.SchedulePageModel;
|
||||||
|
import com.teamcenter.rac.ui.commands.handlers.NewBOHandler;
|
||||||
|
import com.teamcenter.rac.util.Registry;
|
||||||
|
|
||||||
|
public class Wf001ScheduleHandler extends NewBOHandler {
|
||||||
|
|
||||||
|
private TCSession session;
|
||||||
|
|
||||||
|
public Wf001ScheduleHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SchedulePageModel getScheduleModel() {
|
||||||
|
if (scheduleModel == null)
|
||||||
|
scheduleModel = new SchedulePageModel();
|
||||||
|
return scheduleModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent executionevent) throws ExecutionException {
|
||||||
|
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||||
|
session = (TCSession) app.getSession();
|
||||||
|
InterfaceAIFComponent targetComp = app.getTargetComponent();
|
||||||
|
if (targetComp == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduleModel = null;
|
||||||
|
wizardId = "com.teamcenter.rac.schedule.commands.newschedule.GenericScheduleWizard";
|
||||||
|
TCSession tcsession = (TCSession) Activator.getDefault().getSessionService().getDefaultSession();
|
||||||
|
TCPreferenceService tcpreferenceservice = tcsession.getPreferenceService();
|
||||||
|
String s = tcpreferenceservice.getString(4, "SiteTimeZone", "null");
|
||||||
|
IWorkbench iworkbench = PlatformUI.getWorkbench();
|
||||||
|
IWorkbenchWindow iworkbenchwindow = iworkbench.getActiveWorkbenchWindow();
|
||||||
|
Shell shell = iworkbenchwindow.getShell();
|
||||||
|
if ("null".equals(s) || s == null) {
|
||||||
|
MessageDialog.openInformation(shell, textRegistry.getString("tzNotSet.TITLE"),
|
||||||
|
textRegistry.getString("tzNotSet.MSG"));
|
||||||
|
return Boolean.valueOf(false);
|
||||||
|
}
|
||||||
|
if (!TimeZoneCalUtil.testTimeZoneID(s)) {
|
||||||
|
String s1 = textRegistry.getString("tzInvalid.MSG");
|
||||||
|
s1 = MessageFormat.format(s1, new Object[] { s });
|
||||||
|
MessageDialog.openInformation(shell, textRegistry.getString("tzInvalid.TITLE"), s1);
|
||||||
|
return Boolean.valueOf(false);
|
||||||
|
} else {
|
||||||
|
return super.execute(executionevent);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// } else
|
||||||
|
//
|
||||||
|
|
||||||
|
// if (targetComp.getType().equals("TC_Project")) {
|
||||||
|
//
|
||||||
|
// CreateScheduleOperation operation = new CreateScheduleOperation(targetComp,session);
|
||||||
|
// session.queueOperation(operation);
|
||||||
|
//
|
||||||
|
// return null;
|
||||||
|
// } else {
|
||||||
|
// MessageBox.post("ÇëÑ¡ÖÐÏîĿִÐд´½¨!!", "´íÎó", MessageBox.ERROR);
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWizardTitle() {
|
||||||
|
Registry registry = Registry.getRegistry(NewScheduleHandler.class);
|
||||||
|
return registry.getString("dialog.TITLE");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SchedulePageModel scheduleModel = null;
|
||||||
|
private final Registry textRegistry = Registry.getRegistry("com.teamcenter.rac.schedule.schedule");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DECOMPILATION REPORT
|
||||||
|
*
|
||||||
|
* Decompiled from:
|
||||||
|
* D:\Teamcenter_4Sh\OTW11\rac\plugins\com.teamcenter.rac.schedule_11000.2.0.jar
|
||||||
|
* Total time: 1083 ms Jad reported messages/errors: Exit status: 0 Caught
|
||||||
|
* exceptions:
|
||||||
|
*/
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.swing.DefaultCellEditor;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.util.DateButton;
|
||||||
|
|
||||||
|
public class ButtonEditor extends DefaultCellEditor {
|
||||||
|
protected DateButton button;
|
||||||
|
private String label;
|
||||||
|
private boolean isPushed;
|
||||||
|
|
||||||
|
public ButtonEditor(JCheckBox checkBox) {
|
||||||
|
super(checkBox);
|
||||||
|
button = new DateButton();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||||
|
boolean isSelected, int row, int column) {
|
||||||
|
if (isSelected) {
|
||||||
|
button.setForeground(table.getSelectionForeground());
|
||||||
|
button.setBackground(table.getSelectionBackground());
|
||||||
|
} else {
|
||||||
|
button.setForeground(table.getForeground());
|
||||||
|
button.setBackground(table.getBackground());
|
||||||
|
}
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getCellEditorValue() {
|
||||||
|
//yyyyÄêMMÔÂddÈÕ
|
||||||
|
SimpleDateFormat format=new SimpleDateFormat("yyyyÄêMMÔÂddÈÕ");
|
||||||
|
SimpleDateFormat format2=new SimpleDateFormat("MMÔÂ");
|
||||||
|
SimpleDateFormat format3=new SimpleDateFormat("ddÈÕ");
|
||||||
|
Date data = new Date();
|
||||||
|
System.out.println("aaa===>"+format2.format(data));
|
||||||
|
System.out.println("bbb===>"+format3.format(data));
|
||||||
|
System.out.println("ccc===>"+format.format(data));
|
||||||
|
|
||||||
|
return format.format(button.getDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.swing.DefaultCellEditor;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
|
||||||
|
import com.teamcenter.rac.util.DateButton;
|
||||||
|
|
||||||
|
public class ButtonEditor2 extends DefaultCellEditor {
|
||||||
|
|
||||||
|
protected DateButton button;
|
||||||
|
private String label;
|
||||||
|
private boolean isPushed;
|
||||||
|
|
||||||
|
public ButtonEditor2(JCheckBox checkBox) {
|
||||||
|
super(checkBox);
|
||||||
|
button = new DateButton();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||||
|
boolean isSelected, int row, int column) {
|
||||||
|
if (isSelected) {
|
||||||
|
button.setForeground(table.getSelectionForeground());
|
||||||
|
button.setBackground(table.getSelectionBackground());
|
||||||
|
} else {
|
||||||
|
button.setForeground(table.getForeground());
|
||||||
|
button.setBackground(table.getBackground());
|
||||||
|
}
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getCellEditorValue() {
|
||||||
|
//yyyyÄêMMÔÂddÈÕ HH:mm
|
||||||
|
SimpleDateFormat format=new SimpleDateFormat("HH:mm");
|
||||||
|
Date data = new Date();
|
||||||
|
System.out.println("ccc===>"+format.format(data));
|
||||||
|
|
||||||
|
return format.format(button.getDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,207 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
public class CTMap extends DefaultTableModel implements CellSpan {
|
||||||
|
protected int rowSize;
|
||||||
|
protected int columnSize;
|
||||||
|
protected int[][][] span; // CellSpan
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getSpan(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isOutOfBounds(row, column)) {
|
||||||
|
int[] ret_code = { 1, 1 };
|
||||||
|
return ret_code;
|
||||||
|
}
|
||||||
|
return span[row][column];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSpan(int[] span, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isOutOfBounds(row, column))
|
||||||
|
return;
|
||||||
|
this.span[row][column] = span;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isOutOfBounds(row, column))
|
||||||
|
return false;
|
||||||
|
if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void combine(int[] rows, int[] columns) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
int rowSpan = rows.length;
|
||||||
|
int columnSpan = columns.length;
|
||||||
|
int startRow = rows[0];
|
||||||
|
int startColumn = columns[0];
|
||||||
|
for (int i = 0; i < rowSpan; i++) {
|
||||||
|
for (int j = 0; j < columnSpan; j++) {
|
||||||
|
if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1)
|
||||||
|
|| (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) {
|
||||||
|
// System.out.println("can't combine");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0, ii = 0; i < rowSpan; i++, ii--) {
|
||||||
|
for (int j = 0, jj = 0; j < columnSpan; j++, jj--) {
|
||||||
|
span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj;
|
||||||
|
span[startRow + i][startColumn + j][CellSpan.ROW] = ii;
|
||||||
|
// System.out.println("r " +ii +" c " +jj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
span[startRow][startColumn][CellSpan.COLUMN] = columnSpan;
|
||||||
|
span[startRow][startColumn][CellSpan.ROW] = rowSpan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(Dimension size) {
|
||||||
|
columnSize = size.width;
|
||||||
|
rowSize = size.height;
|
||||||
|
span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW
|
||||||
|
initValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isOutOfBounds(int row, int column) {
|
||||||
|
if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void addRow() {
|
||||||
|
|
||||||
|
Vector newData = new Vector(getColumnCount());
|
||||||
|
dataVector.add(newData);
|
||||||
|
|
||||||
|
//
|
||||||
|
newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS,
|
||||||
|
TableModelEvent.INSERT));
|
||||||
|
int[][][] oldSpan = span;
|
||||||
|
int numRows = oldSpan.length;
|
||||||
|
int numColumns = oldSpan[0].length;
|
||||||
|
span = new int[numRows + 1][numColumns][2];
|
||||||
|
System.arraycopy(oldSpan, 0, span, 0, numRows);
|
||||||
|
for (int i = 0; i < numColumns; i++) {
|
||||||
|
span[numRows][i][CellSpan.COLUMN] = 1;
|
||||||
|
span[numRows][i][CellSpan.ROW] = 1;
|
||||||
|
}
|
||||||
|
rowSize = span.length;
|
||||||
|
}
|
||||||
|
public void addColumn(Object columnName) {
|
||||||
|
|
||||||
|
int[][][] oldSpan = span;
|
||||||
|
int numRows = oldSpan.length;
|
||||||
|
int numColumns = oldSpan[0].length;
|
||||||
|
span = new int[numRows][numColumns + 1][2];
|
||||||
|
for (int i = 0; i < span.length; i++) {
|
||||||
|
for (int j = 0; j < span[0].length; j++) {
|
||||||
|
span[i][j][CellSpan.COLUMN] = 1;
|
||||||
|
span[i][j][CellSpan.ROW] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
columnSize = span[0].length;
|
||||||
|
addColumn(columnName, (Vector) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void insertRow(int row) {
|
||||||
|
Vector rowData = new Vector(getColumnCount());
|
||||||
|
|
||||||
|
dataVector.insertElementAt(rowData, row);
|
||||||
|
System.out.println("size:" + dataVector.size());
|
||||||
|
|
||||||
|
//
|
||||||
|
newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
|
||||||
|
int[][][] newSpan = new int[span.length + 1][span[0].length][2];
|
||||||
|
|
||||||
|
int numRows = span.length;
|
||||||
|
int numColumns = span[0].length;
|
||||||
|
for (int i = 0; i < newSpan.length; i++) {
|
||||||
|
if (i < row) {
|
||||||
|
for (int j = 0; j < numColumns; j++) {
|
||||||
|
newSpan[i][j][0] = span[i][j][0];
|
||||||
|
newSpan[i][j][1] = span[i][j][1];
|
||||||
|
}
|
||||||
|
} else if (i == row) {
|
||||||
|
for (int j = 0; j < numColumns; j++) {
|
||||||
|
newSpan[i][j][0] = 1;
|
||||||
|
newSpan[i][j][1] = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int j = 0; j < numColumns; j++) {
|
||||||
|
newSpan[i][j][0] = span[i - 1][j][0];
|
||||||
|
newSpan[i][j][1] = span[i - 1][j][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
span = newSpan;
|
||||||
|
rowSize = span.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CTMap(int numRows, int numColumns) {
|
||||||
|
Vector names = new Vector(numColumns);
|
||||||
|
names.setSize(numColumns);
|
||||||
|
setColumnIdentifiers(names);
|
||||||
|
dataVector = new Vector();
|
||||||
|
setNumRows(numRows);
|
||||||
|
setSize(new Dimension(numColumns, numRows));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initValue() {
|
||||||
|
System.out.println(span.length);
|
||||||
|
for (int i = 0; i < span.length; i++) {
|
||||||
|
for (int j = 0; j < span[i].length; j++) {
|
||||||
|
span[i][j][CellSpan.COLUMN] = 1;
|
||||||
|
span[i][j][CellSpan.ROW] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void split(int row, int column) {
|
||||||
|
if (isOutOfBounds(row, column))
|
||||||
|
return;
|
||||||
|
int columnSpan = span[row][column][CellSpan.COLUMN];
|
||||||
|
int rowSpan = span[row][column][CellSpan.ROW];
|
||||||
|
for (int i = 0; i < rowSpan; i++) {
|
||||||
|
for (int j = 0; j < columnSpan; j++) {
|
||||||
|
span[row + i][column + j][CellSpan.COLUMN] = 1;
|
||||||
|
span[row + i][column + j][CellSpan.ROW] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCol() {
|
||||||
|
|
||||||
|
columnIdentifiers.removeElementAt(columnIdentifiers.size()-1);
|
||||||
|
dataVector.setSize(getRowCount());
|
||||||
|
|
||||||
|
for (int i = 0; i < getRowCount()-1; i++) {
|
||||||
|
|
||||||
|
((Vector)dataVector.elementAt(i)).setSize(getColumnCount());
|
||||||
|
}
|
||||||
|
fireTableStructureChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.plaf.basic.BasicTableUI;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
|
public class CTUI extends BasicTableUI {
|
||||||
|
|
||||||
|
public void paint(Graphics g, JComponent c){
|
||||||
|
Rectangle oldClipBounds = g.getClipBounds();
|
||||||
|
Rectangle clipBounds = new Rectangle(oldClipBounds);
|
||||||
|
int tableWidth = table.getColumnModel().getTotalColumnWidth();
|
||||||
|
clipBounds.width = Math.min(clipBounds.width, tableWidth);
|
||||||
|
g.setClip(clipBounds);
|
||||||
|
|
||||||
|
int firstIndex = table.rowAtPoint(new Point(0, clipBounds.y));
|
||||||
|
int lastIndex = table.getRowCount() - 1;
|
||||||
|
Rectangle rowRect = new Rectangle(0, 0, tableWidth, table.getRowHeight() + table.getRowMargin());
|
||||||
|
rowRect.y = firstIndex * rowRect.height;
|
||||||
|
for (int index = firstIndex; index <= lastIndex; index++) {
|
||||||
|
if (rowRect.intersects(clipBounds)) {
|
||||||
|
// System.out.println(); // debug
|
||||||
|
// System.out.print("" + index +": "); // row
|
||||||
|
paintRow(g, index);
|
||||||
|
}
|
||||||
|
rowRect.y += rowRect.height;
|
||||||
|
}
|
||||||
|
g.setClip(oldClipBounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paintRow(Graphics g, int row) {
|
||||||
|
Rectangle rect = g.getClipBounds();
|
||||||
|
boolean drawn = false;
|
||||||
|
CellSpan cellAtt = (CellSpan) table.getModel();
|
||||||
|
int numColumns = table.getColumnCount();
|
||||||
|
|
||||||
|
for (int column = 0; column < numColumns; column++) {
|
||||||
|
Rectangle cellRect = table.getCellRect(row, column, true);
|
||||||
|
|
||||||
|
int cellRow, cellColumn;
|
||||||
|
if (cellAtt.isVisible(row, column)) {
|
||||||
|
cellRow = row;
|
||||||
|
cellColumn = column;
|
||||||
|
// System.out.print(" "+column+" "); // debug
|
||||||
|
} else {
|
||||||
|
cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW];
|
||||||
|
cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN];
|
||||||
|
// System.out.print(" ("+column+")"); // debug
|
||||||
|
}
|
||||||
|
if (cellRect.intersects(rect)) {
|
||||||
|
drawn = true;
|
||||||
|
paintCell(g, cellRect, cellRow, cellColumn);
|
||||||
|
} else {
|
||||||
|
if (drawn)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paintCell(Graphics g, Rectangle cellRect, int row, int column) {
|
||||||
|
int spacingHeight = table.getRowMargin();
|
||||||
|
int spacingWidth = table.getColumnModel().getColumnMargin();
|
||||||
|
|
||||||
|
Color c = g.getColor();
|
||||||
|
g.setColor(table.getGridColor());
|
||||||
|
g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1);
|
||||||
|
g.setColor(c);
|
||||||
|
|
||||||
|
cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth,
|
||||||
|
cellRect.height - spacingHeight);
|
||||||
|
|
||||||
|
if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) {
|
||||||
|
Component component = table.getEditorComponent();
|
||||||
|
component.setBounds(cellRect);
|
||||||
|
component.validate();
|
||||||
|
} else {
|
||||||
|
TableCellRenderer renderer = table.getCellRenderer(row, column);
|
||||||
|
Component component = table.prepareRenderer(renderer, row, column);
|
||||||
|
|
||||||
|
if (component.getParent() == null) {
|
||||||
|
rendererPane.add(component);
|
||||||
|
}
|
||||||
|
rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,145 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
public class CTable extends JTable {
|
||||||
|
Map<Point,TableCellEditor> map;
|
||||||
|
public CTable(TableModel model) {
|
||||||
|
super(model);
|
||||||
|
setUI(new CTUI());
|
||||||
|
getTableHeader().setReorderingAllowed(false);
|
||||||
|
setCellSelectionEnabled(true);
|
||||||
|
setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||||
|
map=new HashMap();
|
||||||
|
}
|
||||||
|
public String getToolTipText(MouseEvent e) {
|
||||||
|
int row=this.rowAtPoint(e.getPoint());
|
||||||
|
int col=this.columnAtPoint(e.getPoint());
|
||||||
|
String tiptextString=null;
|
||||||
|
if(row>-1 && col>-1){
|
||||||
|
Object value=this.getValueAt(row, col);
|
||||||
|
if(null!=value && !"".equals(value))
|
||||||
|
tiptextString=value.toString();//Ðü¸¡ÏÔʾµ¥Ôª¸ñÄÚÈÝ
|
||||||
|
}
|
||||||
|
return tiptextString;
|
||||||
|
}
|
||||||
|
public Rectangle getCellRect(int row, int column, boolean includeSpacing) {
|
||||||
|
Rectangle sRect = super.getCellRect(row, column, includeSpacing);
|
||||||
|
if ((row < 0) || (column < 0) || (getRowCount() <= row) || (getColumnCount() <= column)) {
|
||||||
|
return sRect;
|
||||||
|
}
|
||||||
|
CellSpan cellAtt = (CellSpan) getModel();
|
||||||
|
if (!cellAtt.isVisible(row, column)) {
|
||||||
|
int temp_row = row;
|
||||||
|
int temp_column = column;
|
||||||
|
row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW];
|
||||||
|
column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN];
|
||||||
|
}
|
||||||
|
int[] n = cellAtt.getSpan(row, column);
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
int columnMargin = getColumnModel().getColumnMargin();
|
||||||
|
Rectangle cellFrame = new Rectangle();
|
||||||
|
int aCellHeight = rowHeight + rowMargin;
|
||||||
|
cellFrame.y = row * aCellHeight;
|
||||||
|
cellFrame.height = n[CellSpan.ROW] * aCellHeight;
|
||||||
|
|
||||||
|
Enumeration eeration = getColumnModel().getColumns();
|
||||||
|
while (eeration.hasMoreElements()) {
|
||||||
|
TableColumn aColumn = (TableColumn) eeration.nextElement();
|
||||||
|
cellFrame.width = aColumn.getWidth() + columnMargin;
|
||||||
|
if (index == column)
|
||||||
|
break;
|
||||||
|
cellFrame.x += cellFrame.width;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) {
|
||||||
|
TableColumn aColumn = (TableColumn) eeration.nextElement();
|
||||||
|
cellFrame.width += aColumn.getWidth() + columnMargin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!includeSpacing) {
|
||||||
|
Dimension spacing = getIntercellSpacing();
|
||||||
|
cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + spacing.height / 2,
|
||||||
|
cellFrame.width - spacing.width, cellFrame.height - spacing.height);
|
||||||
|
}
|
||||||
|
return cellFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] rowColumnAtPoint(Point point) {
|
||||||
|
int[] retValue = { -1, -1 };
|
||||||
|
int row = point.y / (rowHeight + rowMargin);
|
||||||
|
if ((row < 0) || (getRowCount() <= row))
|
||||||
|
return retValue;
|
||||||
|
int column = getColumnModel().getColumnIndexAtX(point.x);
|
||||||
|
|
||||||
|
CellSpan cellAtt = (CellSpan) getModel();
|
||||||
|
|
||||||
|
if (cellAtt.isVisible(row, column)) {
|
||||||
|
retValue[CellSpan.COLUMN] = column;
|
||||||
|
retValue[CellSpan.ROW] = row;
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN];
|
||||||
|
retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW];
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int rowAtPoint(Point point) {
|
||||||
|
return rowColumnAtPoint(point)[CellSpan.ROW];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int columnAtPoint(Point point) {
|
||||||
|
return rowColumnAtPoint(point)[CellSpan.COLUMN];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void columnSelectionChanged(ListSelectionEvent e) {
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
|
int firstIndex = e.getFirstIndex();
|
||||||
|
int lastIndex = e.getLastIndex();
|
||||||
|
if (firstIndex == -1 && lastIndex == -1) { // Selection cleared.
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
Rectangle dirtyRegion = getCellRect(firstIndex, 0, false);
|
||||||
|
int numCoumns = getColumnCount();
|
||||||
|
int index = firstIndex;
|
||||||
|
for (int i = 0; i < numCoumns; i++) {
|
||||||
|
dirtyRegion.add(getCellRect(index, i, false));
|
||||||
|
}
|
||||||
|
index = lastIndex;
|
||||||
|
for (int i = 0; i < numCoumns; i++) {
|
||||||
|
dirtyRegion.add(getCellRect(index, i, false));
|
||||||
|
}
|
||||||
|
repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height);
|
||||||
|
}
|
||||||
|
public void setCombo(int row,int col,TableCellEditor ce){
|
||||||
|
map.put(new Point(row,col), ce);
|
||||||
|
}
|
||||||
|
public TableCellEditor getCellEditor(int row, int column){
|
||||||
|
Point point = new Point(row,column);
|
||||||
|
if(map.containsKey(point)){
|
||||||
|
return map.get(point);
|
||||||
|
}else{
|
||||||
|
return super.getCellEditor(row, column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void setRowHeight(int row, int rowHeight) {
|
||||||
|
super.setRowHeight(row, rowHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
|
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
public class CTest {
|
||||||
|
static int[] rows;
|
||||||
|
static JScrollPane pane;
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
final CTMap map = new CTMap(5, 5);
|
||||||
|
final CTable table = new CTable(map);
|
||||||
|
table.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer());
|
||||||
|
pane = new JScrollPane(table);
|
||||||
|
JButton button = new JButton("add");
|
||||||
|
table.setShowGrid(false);
|
||||||
|
final JDialog dialog = new JDialog();
|
||||||
|
dialog.setLayout(new BorderLayout());
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
table.setRowHeight(2, 50);
|
||||||
|
table.revalidate();
|
||||||
|
table.repaint();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.add(pane, BorderLayout.CENTER);
|
||||||
|
dialog.add(button, BorderLayout.SOUTH);
|
||||||
|
dialog.setPreferredSize(new Dimension(500, 500));
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
interface CellSpan {
|
||||||
|
public final int ROW = 0;
|
||||||
|
public final int COLUMN = 1;
|
||||||
|
|
||||||
|
public int[] getSpan(int row, int column);
|
||||||
|
public void setSpan(int[] span, int row, int column);
|
||||||
|
|
||||||
|
public boolean isVisible(int row, int column);
|
||||||
|
|
||||||
|
public void combine(int[] rows, int[] columns);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
|
||||||
|
import javax.swing.DefaultCellEditor;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
|
import com.connor.jd.plm.utils.DatePickerUtil;
|
||||||
|
import com.eltima.components.ui.DatePicker;
|
||||||
|
|
||||||
|
public class DatePickerCellEditor extends DefaultCellEditor {
|
||||||
|
|
||||||
|
private DatePicker datePicker;
|
||||||
|
|
||||||
|
public DatePickerCellEditor(JTextField arg0) {
|
||||||
|
super(arg0);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
datePicker = DatePickerUtil.getDatePicker(null);
|
||||||
|
return datePicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getCellEditorValue() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return datePicker.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
package com.connor.jd.plm.table;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
public class DefaultModel extends DefaultTableModel implements CellSpan {
|
||||||
|
protected int rowSize;
|
||||||
|
protected int columnSize;
|
||||||
|
protected int[][][] span; // CellSpan
|
||||||
|
@Override
|
||||||
|
public int[] getSpan(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isOutOfBounds(row, column)) {
|
||||||
|
int[] ret_code = { 1, 1 };
|
||||||
|
return ret_code;
|
||||||
|
}
|
||||||
|
return span[row][column];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSpan(int[] span, int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isOutOfBounds(row, column))
|
||||||
|
return;
|
||||||
|
this.span[row][column] = span;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(int row, int column) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (isOutOfBounds(row, column))
|
||||||
|
return false;
|
||||||
|
if ((span[row][column][CellSpan.COLUMN] < 1) || (span[row][column][CellSpan.ROW] < 1))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void combine(int[] rows, int[] columns) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
int rowSpan = rows.length;
|
||||||
|
int columnSpan = columns.length;
|
||||||
|
int startRow = rows[0];
|
||||||
|
int startColumn = columns[0];
|
||||||
|
for (int i = 0; i < rowSpan; i++) {
|
||||||
|
for (int j = 0; j < columnSpan; j++) {
|
||||||
|
if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1)
|
||||||
|
|| (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) {
|
||||||
|
// System.out.println("can't combine");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0, ii = 0; i < rowSpan; i++, ii--) {
|
||||||
|
for (int j = 0, jj = 0; j < columnSpan; j++, jj--) {
|
||||||
|
span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj;
|
||||||
|
span[startRow + i][startColumn + j][CellSpan.ROW] = ii;
|
||||||
|
// System.out.println("r " +ii +" c " +jj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
span[startRow][startColumn][CellSpan.COLUMN] = columnSpan;
|
||||||
|
span[startRow][startColumn][CellSpan.ROW] = rowSpan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(Dimension size) {
|
||||||
|
columnSize = size.width;
|
||||||
|
rowSize = size.height;
|
||||||
|
span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW
|
||||||
|
initValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initValue() {
|
||||||
|
System.out.println(span.length);
|
||||||
|
for (int i = 0; i < span.length; i++) {
|
||||||
|
for (int j = 0; j < span[i].length; j++) {
|
||||||
|
span[i][j][CellSpan.COLUMN] = 1;
|
||||||
|
span[i][j][CellSpan.ROW] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isOutOfBounds(int row, int column) {
|
||||||
|
if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultModel(int numRows, int numColumns) {
|
||||||
|
Vector names = new Vector(numColumns);
|
||||||
|
names.setSize(numColumns);
|
||||||
|
setColumnIdentifiers(names);
|
||||||
|
dataVector = new Vector();
|
||||||
|
setNumRows(numRows);
|
||||||
|
setSize(new Dimension(numColumns, numRows));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue