1.自动匹配工具初始化

main
xuezhou 2 months ago
commit 7a9a6378ae

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.sq.customization</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,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

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

@ -0,0 +1,26 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Customization
Bundle-SymbolicName: com.sq.customization;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.sq.customization.Activator
Bundle-Vendor: SQ
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp;bundle-version="13000.3.0",
com.teamcenter.rac.common;bundle-version="13000.3.0",
com.teamcenter.rac.external;bundle-version="13000.3.0",
com.teamcenter.rac.kernel;bundle-version="13000.3.0",
com.teamcenter.rac.pca;bundle-version="13000.3.0",
com.teamcenter.rac.pse;bundle-version="13000.3.0",
com.teamcenter.rac.tcapps;bundle-version="13000.3.0",
com.teamcenter.rac.ui;bundle-version="13000.3.0",
com.teamcenter.rac.ui.views;bundle-version="13000.3.0",
com.teamcenter.rac.util;bundle-version="13000.3.0",
com.teamcenter.rac.pca.kernel;bundle-version="13000.3.0",
com.teamcenter.rac.pse.pca;bundle-version="13000.3.0",
com.teamcenter.rac.cme.kernel;bundle-version="13000.3.0",
org.apache.poi.39;bundle-version="3.9.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Automatic-Module-Name: com.sq.customization
Bundle-ActivationPolicy: lazy

@ -0,0 +1,5 @@
RuleInheritanceDialog.sourcelabel=Source configuration object:
RuleInheritanceDialog.targetlabel=The target configuration object:
RuleInheritanceDialog.handoffbutton=Toggle the source and target
RuleInheritanceDialog.okbutton=OK
RuleInheritanceDialog.cancelbutton=Cancel

@ -0,0 +1,5 @@
RuleInheritanceDialog.sourcelabel=\u6E90\u914D\u7F6E\u5BF9\u8C61\uFF1A
RuleInheritanceDialog.targetlabel=\u76EE\u6807\u914D\u7F6E\u5BF9\u8C61\uFF1A
RuleInheritanceDialog.handoffbutton=\u5207\u6362\u6E90\u4E0E\u76EE\u6807
RuleInheritanceDialog.okbutton=\u786E\u5B9A
RuleInheritanceDialog.cancelbutton=\u53D6\u6D88

@ -0,0 +1,2 @@
BOPInitHandler.selecterror=Please select a Mfg0MEPlantBOPRevision\Mfg0MEProcLineRevision\Mfg0MEProcStatnRevision object

@ -0,0 +1,2 @@
BOPInitHandler.selecterror=\u8BF7\u9009\u62E9\u5BF9\u8C61\u4E3A\u6574\u8F66\uFF0C\u4EA7\u7EBF\uFF0C\u5DE5\u4F4D\uFF0C

@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
javacDefaultEncoding.. = UTF-8
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
categoryId="com.sq.customization.commands.category"
name="【自动匹配替换工具】"
id="com.sq.customization.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.sq.customization.handlers.SampleHandler"
commandId="com.sq.customization.commands.sampleCommand">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
id="com.sq.customization.menus.sampleMenu"
label="【上汽TCM定制开发】"
mnemonic="M">
<command
commandId="com.sq.customization.commands.sampleCommand"
id="com.sq.customization.menus.sampleCommand"
mnemonic="S">
</command>
</menu>
</menuContribution>
</extension>
</plugin>

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

@ -0,0 +1,410 @@
package com.sq.customization.dialogs;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
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.xssf.usermodel.XSSFWorkbook;
import com.sq.customization.util.ExcelUtil;
import com.sq.customization.util.ProgressCustomDialog;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrOperation;
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPart;
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPlantBOP;
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrProcessLine;
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrProcessStation;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.stylesheet.PropertyTextField;
import com.teamcenter.rac.util.ButtonLayout;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.Registry;
public class AutoTransToolDialog extends AbstractAIFDialog {
private PropertyTextField text;
private PropertyTextField idtext;
private PropertyTextField svppstext;
private PropertyTextField FCCtext;
private PropertyTextField FCCDEStext;
private PropertyTextField dongtaitext;
private PropertyTextField KCDStext;
private JButton ok;
private JButton cancel;
private JButton directory;
private Registry registry = Registry.getRegistry(AutoTransToolDialog.class);
private TCSession session;
private InterfaceAIFComponent target;
Map<String,String> no_load = new HashMap<>();
Map<String,TCComponentMfgBvrOperation> op_nodesignmap = new HashMap<>();
public AutoTransToolDialog(Frame fm,InterfaceAIFComponent target) {
super(fm);
this.target = target;
op_nodesignmap.clear();
no_load.clear();
init();
}
private void init() {
this.setTitle("自动匹配替换工具");
this.setPreferredSize(new Dimension(500,400));
this.centerToScreen();
this.setLayout(new BorderLayout());
JPanel northPane = new JPanel(new PropertyLayout(10,10,5,5,10,10));
northPane.add("1.1.left",new JLabel("零件号:"));
idtext = new PropertyTextField();
idtext.setColumns(30);
idtext.setRequired(true);
northPane.add("1.2",idtext);
northPane.add("2.1.left",new JLabel("短SVPPS:"));
svppstext = new PropertyTextField();
svppstext.setColumns(30);
svppstext.setRequired(true);
northPane.add("2.2",svppstext);
northPane.add("3.1.left",new JLabel("FCC:"));
FCCtext = new PropertyTextField();
FCCtext.setColumns(30);
FCCtext.setRequired(true);
northPane.add("3.2",FCCtext);
northPane.add("4.1.left",new JLabel("FFC中文描述:"));
FCCDEStext = new PropertyTextField();
FCCDEStext.setColumns(30);
FCCDEStext.setRequired(true);
northPane.add("4.2",FCCDEStext);
northPane.add("5.1.left",new JLabel("动态扭矩:"));
dongtaitext = new PropertyTextField();
dongtaitext.setColumns(30);
dongtaitext.setRequired(true);
northPane.add("5.2",dongtaitext);
northPane.add("6.1.left",new JLabel("KCDS:"));
KCDStext = new PropertyTextField();
KCDStext.setColumns(30);
KCDStext.setRequired(true);
northPane.add("6.2",KCDStext);
northPane.add("7.1.left",new JLabel("数据文件:"));
text = new PropertyTextField();
text.setColumns(30);
text.setRequired(true);
text.setEnabled(false);
northPane.add("7.2",text);
directory = new JButton("...");
northPane.add("7.3",directory);
JPanel southpanel = new JPanel(new ButtonLayout());
ok = new JButton("确定");
cancel = new JButton("取消");
southpanel.add(ok);
southpanel.add(cancel);
this.add(BorderLayout.CENTER,northPane);
this.add(BorderLayout.SOUTH,southpanel);
this.setVisible(true);
cancel.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
AutoTransToolDialog.this.dispose();
}});
directory.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser filechooser = new JFileChooser();
filechooser.setFileSelectionMode(2);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"所有Excel文件(*.xlsx)", new String[] { "xlsx" });
filechooser.setFileFilter(filter);
int r = filechooser.showDialog(null, "选择");
if (r == 0) {
text.setText(filechooser.getSelectedFile().getAbsolutePath());
if (text.getText() != "")
ok.setEnabled(true);
else
ok.setEnabled(false);
}
else if (r == 1) {
text.setText("");
ok.setEnabled(false);
}
}});
ok.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
String path = text.getText();
if( path != null && path.length() > 0) {
String idcol = idtext.getText();
String svppscol = svppstext.getText();
String fcccol = FCCtext.getText();
String fccdescol = FCCDEStext.getText();
String dongtaicol = dongtaitext.getText();
String kcdscol = KCDStext.getText();
File excel = new File(path);
if(!excel.exists()) {
MessageBox.post(AutoTransToolDialog.this,"文件路径不存在", "Message", MessageBox.INFORMATION);
return;
}
if(isValidExcelColumn(idcol) && isValidExcelColumn(svppscol) && isValidExcelColumn(fcccol)
&& isValidExcelColumn(fccdescol) && isValidExcelColumn(dongtaicol) && isValidExcelColumn(kcdscol)) {
op_nodesignmap.clear();
no_load.clear();
int idcol2 = columnToNumber(idcol.toUpperCase());
int svppscol2 = columnToNumber(svppscol.toUpperCase());
int fcccol2 = columnToNumber(fcccol.toUpperCase());
int fccdescol2 = columnToNumber(fccdescol.toUpperCase());
int dongtaicol2 = columnToNumber(dongtaicol.toUpperCase());
int kcdscol2 = columnToNumber(kcdscol.toUpperCase());
try {
//读取EXCEL
//先处理选中对象层级有design的工序获取没有design的工序
opBOMLineData(target);
if(op_nodesignmap.size() > 0) {
TCComponentBOMLine parent = null;
if(target instanceof TCComponentMfgBvrProcessStation) {
TCComponentMfgBvrProcessStation station = (TCComponentMfgBvrProcessStation) target;
String id = station.getProperty("bl_item_item_id");
no_load.put(id, id);
parent = station.parent();
}
else if(target instanceof TCComponentMfgBvrPlantBOP) {
TCComponentMfgBvrPlantBOP plant = (TCComponentMfgBvrPlantBOP) target;
String id = plant.getProperty("bl_item_item_id");
no_load.put(id, id);
parent = plant.parent();
}
else if(target instanceof TCComponentMfgBvrProcessLine) {
TCComponentMfgBvrProcessLine line = (TCComponentMfgBvrProcessLine) target;
String id = line.getProperty("bl_item_item_id");
no_load.put(id, id);
parent = line.parent();
}
if(parent != null) {
System.out.println(parent.getClass()+parent.getProperty("bl_indented_title"));
getparent(parent);
}
if(op_nodesignmap.size() > 0) {
System.out.println("整个结构没有匹配的紧固件");
}
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
AutoTransToolDialog.this.dispose();
}
else {
MessageBox.post(AutoTransToolDialog.this,"请填写正确的列比如A,B,C..", "Message", MessageBox.INFORMATION);
}
Thread thread = new Thread(){
public void run(){
ProgressCustomDialog.lbStatus.setText("正在创建 ....");
}
};
ProgressCustomDialog.show(thread, "执行中", null, null, null);
//session.queueOperation(operation);
}
else {
MessageBox.post(AutoTransToolDialog.this,"请选择文件", "Message", MessageBox.INFORMATION);
}
}});
}
public static int columnToNumber(String column) {
int result = 0;
for (int i = 0; i < column.length(); i++) {
char c = column.charAt(i);
result = result * 26 + (c - 'A' + 1); // 将字母转换为数字
}
return result;
}
// 判断列名是否符合A-Z, AA, AB等格式不区分大小写
public static boolean isValidExcelColumn(String column) {
// 将输入字符串转为大写字母并匹配正则表达式
return column != null && column.toUpperCase().matches("[A-Z]+");
}
//先处理选中对象层级有design的工序
private void opBOMLineData(InterfaceAIFComponent parent) throws Exception {
AIFComponentContext[] children = parent.getChildren();
for(AIFComponentContext child:children) {
InterfaceAIFComponent childcom = child.getComponent();
if(childcom instanceof TCComponentMfgBvrOperation) {
TCComponentMfgBvrOperation op = (TCComponentMfgBvrOperation) childcom;
String bl_rev_object_name = op.getProperty("bl_rev_object_name");
if(bl_rev_object_name.contains("预紧") || bl_rev_object_name.contains("终紧")
|| bl_rev_object_name.contains("紧固")|| bl_rev_object_name.contains("拧紧")
|| bl_rev_object_name.contains("接地")|| bl_rev_object_name.contains("搭铁")) {
AIFComponentContext[] design_children = op.getChildren();
boolean hasdesign = false;
for(AIFComponentContext designchild:design_children) {
InterfaceAIFComponent designchildcom = designchild.getComponent();
if(designchildcom instanceof TCComponentMfgBvrPart) {
hasdesign = true;
//获取design
}
}
if(!hasdesign) {
bl_rev_object_name = bl_rev_object_name.replaceAll("预紧", "");
bl_rev_object_name = bl_rev_object_name.replaceAll("终紧", "");
bl_rev_object_name = bl_rev_object_name.replaceAll("紧固", "");
bl_rev_object_name = bl_rev_object_name.replaceAll("拧紧", "");
// String bl_item_item_id = op.getProperty("bl_item_item_id");
op_nodesignmap.put(bl_rev_object_name, op);
}
}
//
}
else if(childcom instanceof TCComponentMfgBvrProcessStation || childcom instanceof TCComponentMfgBvrProcessLine
|| childcom instanceof TCComponentMfgBvrPlantBOP) {
opBOMLineData(childcom);
}
}
}
/**
* no_load:id
* */
private void getparent(TCComponentBOMLine parent)throws Exception{
if(op_nodesignmap.size() > 0) {
String parentid = parent.getProperty("bl_item_item_id");
AIFComponentContext[] children = parent.getChildren();
for (AIFComponentContext child : children) {
InterfaceAIFComponent childcom = child.getComponent();
String id = childcom.getProperty("bl_item_item_id");
if(op_nodesignmap.size() == 0) {
break;
}
if(no_load.containsKey(id)) {
continue;
}
if(childcom instanceof TCComponentMfgBvrOperation) {
TCComponentMfgBvrOperation op = (TCComponentMfgBvrOperation) childcom;
final String bl_rev_object_name = op.getProperty("bl_rev_object_name");
Set<String> keys = op_nodesignmap.keySet();
boolean found = false;
String haskey = "";
for (String key : keys) {
if (bl_rev_object_name.contains(key)) {
found = true;
haskey = key;
break; // 一旦找到了就退出循环
}
}
if(found) {
AIFComponentContext[] design_children = op.getChildren();
boolean hasdesign = false;
for(AIFComponentContext designchild:design_children) {
InterfaceAIFComponent designchildcom = designchild.getComponent();
if(designchildcom instanceof TCComponentMfgBvrPart) {
hasdesign = true;
//获取design
}
}
if(hasdesign) {
op_nodesignmap.remove(haskey);
}
}
}
else if(childcom instanceof TCComponentMfgBvrProcessStation || childcom instanceof TCComponentMfgBvrProcessLine
|| childcom instanceof TCComponentMfgBvrPlantBOP) {
getparent((TCComponentBOMLine)childcom);
}
if(op_nodesignmap.size() > 0) {
no_load.put(id, id);
}
else {
break;
}
}
//
if(op_nodesignmap.size() > 0) {
no_load.put(parentid, parentid);
if(parent.parent() != null)
getparent(parent.parent());
}
}
}
private void readExcel(File excelfile,int start_rownum,int idcol2,int svppscol2,int fcccol2
,int fccdescol2,int dongtaicol,int kcdscol2) {
Workbook work = null;
try(InputStream is = new FileInputStream(excelfile);){
if (excelfile.getAbsolutePath().endsWith(".xls"))
work = new HSSFWorkbook(is);
else {
work = new XSSFWorkbook(is);
}
Sheet sheet = work.getSheetAt(0);
int count = sheet.getPhysicalNumberOfRows();
for(int i = start_rownum; i < count ;i++) {
Row row = sheet.getRow(i);
String id = ExcelUtil.getStringCellValue(row.getCell(idcol2-1));
String svpps = ExcelUtil.getStringCellValue(row.getCell(svppscol2-1));
String fcc = ExcelUtil.getStringCellValue(row.getCell(fcccol2-1));
String fccdes = ExcelUtil.getStringCellValue(row.getCell(fccdescol2-1));
String dongtai = ExcelUtil.getStringCellValue(row.getCell(dongtaicol-1));
String kcds = ExcelUtil.getStringCellValue(row.getCell(kcdscol2-1));
System.out.println("id:"+id+" svpps:"+svpps+" fcc:"+fcc+" fccdes:"+fccdes+" dongtai:"+dongtai+" kcds:"+kcds);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

@ -0,0 +1,5 @@
RuleInheritanceDialog.sourcelabel=Source configuration object:
RuleInheritanceDialog.targetlabel=The target configuration object:
RuleInheritanceDialog.handoffbutton=Toggle the source and target
RuleInheritanceDialog.okbutton=OK
RuleInheritanceDialog.cancelbutton=Cancel

@ -0,0 +1,5 @@
RuleInheritanceDialog.sourcelabel=\u6E90\u914D\u7F6E\u5BF9\u8C61\uFF1A
RuleInheritanceDialog.targetlabel=\u76EE\u6807\u914D\u7F6E\u5BF9\u8C61\uFF1A
RuleInheritanceDialog.handoffbutton=\u5207\u6362\u6E90\u4E0E\u76EE\u6807
RuleInheritanceDialog.okbutton=\u786E\u5B9A
RuleInheritanceDialog.cancelbutton=\u53D6\u6D88

@ -0,0 +1,56 @@
package com.sq.customization.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.sq.customization.dialogs.AutoTransToolDialog;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrPlantBOP;
import com.teamcenter.rac.kernel.TCComponentMECfgLine;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
public class SampleHandler extends AbstractHandler {
private AbstractAIFUIApplication app;
private TCSession session;
// private Registry registry = Registry.getRegistry(SampleHandler.class);
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
app = AIFUtility.getCurrentApplication();
session = (TCSession) app.getSession();
InterfaceAIFComponent[] target = app.getTargetComponents();
// if(target == null || target.length != 1) {
// MessageBox.post(app.getDesktop(),registry.getString("BOPInitHandler.selecterror"), "Message", MessageBox.INFORMATION);
// return null;
// }
System.out.println(target[0].getType());
System.out.println(target[0].getClass());
if("Mfg0BvrPlantBOP".equals(target[0].getType()) || "Mfg0BvrProcessLine".equals(target[0].getType()) || "Mfg0BvrProcessStation".equals(target[0].getType())) {
new AutoTransToolDialog(app.getDesktop(),target[0]);
// TCComponentMfgBvrPlantBOP targetline = (TCComponentMfgBvrPlantBOP) target[0];
// try {
// AIFComponentContext[] comcontext = targetline.getChildren();
// for(int i = 0; i < comcontext.length; i++) {
// System.out.println(comcontext[i].getComponent().getProperty("bl_indented_title"));
// }
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
return null;
}
}

@ -0,0 +1,2 @@
BOPInitHandler.selecterror=Please select a Mfg0MEPlantBOPRevision\Mfg0MEProcLineRevision\Mfg0MEProcStatnRevision object

@ -0,0 +1,2 @@
BOPInitHandler.selecterror=\u8BF7\u9009\u62E9\u5BF9\u8C61\u4E3A\u6574\u8F66\uFF0C\u4EA7\u7EBF\uFF0C\u5DE5\u4F4D\uFF0C

@ -0,0 +1,43 @@
package com.sq.customization.util;
import java.text.DecimalFormat;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
public class ExcelUtil {
public static String getStringCellValue(Cell cell)
{
String strCell = "";
if(cell == null)
return "";
switch(cell.getCellType()){
case Cell.CELL_TYPE_STRING :
strCell = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC :
if(DateUtil.isCellDateFormatted(cell))
strCell = cell.getDateCellValue().toString();
else
// strCell = String.valueOf(cell.getNumericCellValue());
strCell = new DecimalFormat("#").format(cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN :
strCell = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA :
strCell = cell.getCellFormula();
break;
case Cell.CELL_TYPE_BLANK :
strCell = "";
break;
default:
strCell = "";
break;
}
if(strCell == null || strCell.equals(""))
return "";
return strCell;
}
}

@ -0,0 +1,271 @@
package com.sq.customization.util;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.util.Registry;
public class ProgressCustomDialog implements ActionListener
{
private static final String DEFAULT_STATUS = "Please Waiting";
private static JDialog dialog;
private JProgressBar progressBar;
public static JLabel lbStatus;
private JButton btnCancel;
private static Thread thread; //处理业务的线程
private String statusInfo;
public static String resultInfo;
public static String cancelInfo;
private Dialog parentDlg ;
String message = "";
public static void show(Thread thread,Dialog parentDlg)
{
new ProgressCustomDialog(thread, DEFAULT_STATUS, null, null,parentDlg);
}
public static void show(Thread thread, String statusInfo,Dialog parentDlg)
{
new ProgressCustomDialog(thread, statusInfo, null, null,parentDlg);
}
public static void show(Thread thread, String statusInfo,
String resultInfo, String cancelInfo,Dialog parentDlg)
{
new ProgressCustomDialog(thread, statusInfo, resultInfo, cancelInfo,parentDlg);
}
private ProgressCustomDialog(Thread thread, String statusInfo,
String resultInfo, String cancelInfo,Dialog parentDlg)
{
this.thread = thread;
this.statusInfo = statusInfo;//Status
this.resultInfo = resultInfo;//处理完毕
this.cancelInfo = cancelInfo;//Cancel
this.parentDlg = parentDlg ;
initUI();
startThread();
dialog.setVisible(true);
}
private void initUI()
{
if (parentDlg == null)
{
dialog = new JDialog();
}
else
{
dialog = new JDialog(parentDlg);
}
final JPanel mainPane = new JPanel(null);
progressBar = new JProgressBar();
lbStatus = new JLabel("" + statusInfo);
btnCancel = new JButton("Cancel");
progressBar.setIndeterminate(true);
btnCancel.addActionListener(this);
mainPane.add(progressBar);
mainPane.add(lbStatus);
//mainPane.add(btnCancel);
dialog.getContentPane().add(mainPane);
//dialog.setUndecorated(true); // 除去title
dialog.setResizable(true);
dialog.setAlwaysOnTop(true);
dialog.setSize(590, 120);
dialog.setLocationRelativeTo(null); //设置此窗口相对于指定组件的位置
ImageIcon imageicon = Registry.getRegistry(AbstractAIFDialog.class).getImageIcon("aifDesktop.ICON");//new ImageIcon(getClass().getResource("images/aifdesktop_16.png"));
dialog.setIconImage(imageicon.getImage());
dialog.setTitle("进度信息");
// System.out.println("set @@@@@@@@@@@@@@@@@@@@#######====");
// dialog.setModal(true);
// dialog.setAlwaysOnTop(true);
// UIUtilities.centerToScreen(dialog, 1.0D, 0.75D);
dialog.requestFocusInWindow();
// dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // 不允许关闭
dialog.validate();
dialog.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosed(WindowEvent e)
{
}
@Override
public void windowClosing(WindowEvent e)
{
// MessageBox.post("提醒",
// "关闭该窗口后报表将无法生成。", MessageBox.INFORMATION);
dialog.dispose();
thread.stop();
}
});
mainPane.addComponentListener(new ComponentAdapter()
{
public void componentResized(ComponentEvent e)
{
layout(mainPane.getWidth(), mainPane.getHeight());
}
});
}
private void startThread()
{
new Thread()
{
public void run()
{
try
{
thread.start(); // 处理耗时任务
// 等待事务处理线程结束
thread.join();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(new Dialog(dialog), e.getMessage(), "error",
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
finally
{
// 关闭进度提示框
if (dialog != null)
{
dialog.dispose();
if(resultInfo != null && !resultInfo.trim().equals(""))
{
String title = "进度信息";
JOptionPane.showMessageDialog(new Dialog(dialog), resultInfo, title,
JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
}.start();
}
private void layout(int width, int height)
{
progressBar.setBounds(20, 20, 550, 15);
lbStatus.setBounds(20, 40, 550, 25);
btnCancel.setBounds(width - 85, height - 31, 75, 21);
}
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent e)
{
resultInfo = cancelInfo;
thread.stop();
}
public static void StopStatus()
{
if (dialog != null)
dialog.dispose();
}
public static void main(String[] args) throws Exception
{
Thread thread = new Thread()
{
public void run()
{
int index = 0;
while(index < 5)
{
try
{
sleep(1000);
System.out.println(++index);
}
catch(InterruptedException e)
{
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
}
};
ProgressCustomDialog.show(thread, "Status", "数据处理完毕", "Cancel",null);
}
public Dialog getParentDlg() {
return parentDlg;
}
public void setParentDlg(Dialog parentDlg) {
this.parentDlg = parentDlg;
}
public static JDialog getDialog() {
return dialog;
}
public static void setDialog(JDialog dialog) {
ProgressCustomDialog.dialog = dialog;
}
}
Loading…
Cancel
Save