You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1093 lines
35 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.connor.rb.plm.rb012;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import com.connor.rb.plm.entity.ZC_LBJ_list;
import com.connor.rb.plm.newcombox.RwJComboBox;
import com.connor.rb.plm.util.ClassAttributeBean;
import com.connor.rb.plm.util.ClassProperty;
import com.connor.rb.plm.util.PlmLocaleUtil;
import com.connor.rb.plm.util.SoaServerUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.classification.common.G4MUnitSystemOptionButton;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCClassificationService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentICO;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSAdminClassAttribute;
import com.teamcenter.rac.kernel.ics.ICSKeyLov;
import com.teamcenter.rac.kernel.ics.ICSProperty;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
public class CreatDialog extends AbstractAIFDialog {
private AbstractAIFApplication app;
private TCSession session;
private TCPreferenceService service;
private List<ClassAttributeBean> classList = new ArrayList<ClassAttributeBean>();
private JLabel[] labels1 = null;
//private JComboBox<String> comb = null;
private String className = "";
private Map<String,Object> map2;
private List<Object> idList = new ArrayList<Object>();
//<2F>Ż<EFBFBD>:TextField<6C><64><EFBFBD><EFBFBD>
private List<Object> fieldList=new ArrayList<Object>();
//box<6F><78><EFBFBD><EFBFBD>
private List<Object> comboxList=new ArrayList<Object>();
private Map<String,String> fieldmap=new HashMap<>();
private Map<String,String> comboxmap=new HashMap<>();
private List<String> yylyList=new ArrayList<String>();
//end
private List<Object> clearanceList = new ArrayList<Object>();
private Map<String,JComboBox<String>> boxMap = new HashMap<String, JComboBox<String>>();
private List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
private String cph = "";
private String th = "";
private String revId = "";
private String newID = "";
private String type = "";
private String targetType = "";
private boolean flag = true;
private String url = "";
private JTextField showDate1;
private JScrollPane scr2;
private SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d HH:mm");
private JTextField nameField = null;
private TCComponentItemRevision targetRev = null;
private Map<String,String> zc_lbj_map;//<2F>ܳɻ<DCB3><C9BB>㲿<EFBFBD><E3B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>ֵ<EFBFBD><D6B5>
private int f=0;
private int h=4;
private int v=4;
private boolean boflag=false;
private InterfaceAIFComponent targetComp;
public CreatDialog (AbstractAIFApplication app) {
super(false);
this.app = app;
this.targetComp=app.getTargetComponent();
this.session = (TCSession) app.getSession();
this.service = session.getPreferenceService();
this.url = service.getStringValue("Autocode_SendClassServer_URL");
}
@Override
public void run() {
this.initUI();
}
public void initUI(){
setTitle("<22><>ʱ<EFBFBD><CAB1><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>");
this.setLayout(new PropertyLayout());
Dimension dimension = new Dimension();
dimension.setSize(750,630);
Dimension mindis=new Dimension();
Dimension maxdis=new Dimension();
mindis.setSize(750,640);
maxdis.setSize(760,1200);
this.setMaximumSize(maxdis);
this.setMinimumSize(mindis);
this.setPreferredSize(dimension);
// this.setLayout(new BorderLayout());
// Dimension dimension = new Dimension();
// dimension.setSize(450,630);
// this.setPreferredSize(dimension);
JPanel parentPanel = new JPanel(new PropertyLayout());
scr2 = new JScrollPane(parentPanel);
scr2.setPreferredSize(new Dimension(720, 530));
JPanel classJpanel = new JPanel(new PropertyLayout());// <20><><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD>
classJpanel.add("1.1.center.top",scr2);
//"1.1.center.top",
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4>ڸĶ<DAB8><C4B6><EFBFBD><EFBFBD><EFBFBD>
this.addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e) {
// TODO Auto-generated method stub
Component component2=e.getComponent();
int h=component2.getHeight();
if(h>630) {
scr2.setPreferredSize(new Dimension(component2.getWidth()-30,h-110));
scr2.revalidate();
scr2.repaint();
classJpanel.setPreferredSize(new Dimension(component2.getWidth(),h-110));
classJpanel.revalidate();
classJpanel.repaint();
}
}
@Override
public void componentMoved(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentShown(ComponentEvent e) {
// TODO Auto-generated method stub
}
@Override
public void componentHidden(ComponentEvent e) {
// TODO Auto-generated method stub
}
});
//<2F>Ż<EFBFBD>
try {
zc_lbj_map = targetComp.getProperties();
} catch (Exception e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
String objtype = targetComp.getType();
System.out.println("<22><EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+objtype);
if(objtype.equals("RB3_ZCRevision")) {
System.out.println(objtype);
boflag=true;
}else {
System.out.println(objtype);
}
//end<6E>Ż<EFBFBD>
if(targetComp instanceof TCComponentItemRevision) {
targetRev = (TCComponentItemRevision) targetComp;
try {
targetType = targetRev.getItem().getType();
if("RB3_ZC".equals(targetType)) {
type = targetRev.getStringProperty("rb3_zclx");
flag = false;
}else if("RB3_LBJ".equals(targetType)){
type = targetRev.getStringProperty("rb3_lbjlx");
}
String name = targetRev.getStringProperty("object_name");
nameField = new JTextField(18);
nameField.setText(name);
DateChooser dateChooser1 = DateChooser.getInstance("yyyy-M-d HH:mm");
Date date = new Date();
Date newDate = stepMonth(date, +3);
System.out.println("<22><>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ڣ<EFBFBD>" + df.format(newDate));
String time = df.format(newDate);
showDate1 = new JTextField(time);
dateChooser1.register(showDate1);
parentPanel.add("1.1.center.top", new JLabel(""));
parentPanel.add("2.1.center.top", new JLabel("<22><><EFBFBD><EFBFBD>"));
parentPanel.add("2.2.center.top", nameField);
parentPanel.add("3.1.center.top", new JLabel("<22><>Ч<EFBFBD><D0A7>"));
parentPanel.add("3.2.center.top", showDate1);
cph = targetRev.getStringProperty("rb3_cph");
th = targetRev.getStringProperty("rb3_th");
String id = targetRev.getStringProperty("item_id");
revId = targetRev.getStringProperty("item_revision_id");
StringBuilder sb = new StringBuilder("LS-");
sb.append(id);
newID = sb.toString();
className = targetRev.getClassificationClass();
TCComponentICO[] icos = targetRev.getClassificationObjects();
if(icos == null || icos.length <= 0){
MessageBox.post("ѡ<>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>з<EFBFBD><D0B7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>","<22><>ʾ",MessageBox.INFORMATION);
return;
}
Map<Integer, String> claMap = new HashMap<Integer, String>();
if(icos != null && icos.length>0){
ICSProperty[] icss = icos[0].getICSProperties(true);
for (ICSProperty ics : icss) {
claMap.put(ics.getId(), ics.getValue());
}
}
TCClassificationService classificationService = session.getClassificationService();
ICSAdminClass c = classificationService.newICSAdminClass();
c.load(className);
ICSAdminClassAttribute[] icsAttrS = c.getAttributes();
if (icsAttrS != null) {
for (ICSAdminClassAttribute attr : icsAttrS) {
ClassAttributeBean bean = new ClassAttributeBean();
if (attr.isReferenceAttribute()) {// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
continue;
}
if (attr.isReference()) {
continue;
}
int propID = attr.getAttributeId();
bean.setId(propID);
String propDisName = attr.getName();
bean.setName(propDisName);
int attrType = attr.getFormat1().getType();
bean.setType(attrType);
if (claMap != null
&& claMap.containsKey(propID)) {
bean.setVal(claMap.get(propID));
} else {
bean.setVal("");
}
ICSKeyLov lov1 = attr.getFormat1().getKeyLov();
lov1 = (lov1 == null ? attr.getFormat2().getKeyLov() : lov1);
if (lov1 != null) {
bean.setIslov(true);
String[] keys = lov1.getKeys();
Map<String,String> map1 = new HashMap<String,String>();
for (String key : keys) {
String value = lov1.getValueOfKey(key);
map1.put(value, key);// <<3C><>ʾֵ,<2C><>ʵֵ>
if(key.equals(bean.getVal())&&(!bean.getVal().equals(""))){
bean.setVal(value);
}
}
bean.setLov(map1);
} else {
bean.setIslov(false);
}
classList.add(bean);
}
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
labels1 = new JLabel[classList.size()];
for (int i = 0; i<classList.size();i++) {
ClassAttributeBean bean = classList.get(i);
String attrName = bean.getName();
labels1[i] = new JLabel(bean.getName());
parentPanel.add((h+i)+".1.center.top", labels1[i]);
labels1[i].setBounds(5, 5, 5, 5);
if(bean.isIslov()){
JComboBox<String> comb = new JComboBox<String>();
//<2F>Ż<EFBFBD>
JTextField jt=new JTextField(9);
JButton bu=new JButton("<22><><EFBFBD><EFBFBD>");
//end
comb.setEditable(false);
comb.setSize(new Dimension(60,40));
comb.addItem(bean.getVal());
for (Entry<String, String> entry : bean.getLov().entrySet()) {
if(!(bean.getVal().equals(entry.getKey()))) {
comb.addItem(entry.getKey());
}
}
//<2F>Ż<EFBFBD>
bu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String tip=jt.getText();
System.out.println("<22><><EFBFBD><EFBFBD>"+tip);
if(tip.length()>0) {
SearchJComItem.changeBox(comb, tip);
}
}
});
//end
map2 = new HashMap<String, Object>();
map2.put("JComboBox", comb);
values.add(map2);
parentPanel.add((h+i)+".2.center.top", comb);
parentPanel.add((h+i)+".3.center.top", jt);
parentPanel.add((h+i)+".4.center.top", bu);
}else{
JTextField field = new JTextField(18);
map2 = new HashMap<String, Object>();
map2.put("JTextField", field);
values.add(map2);
parentPanel.add((h+i)+".2.center.top", field);
field.setText(bean.getVal());
System.out.println("attrName================"+attrName);
System.out.println("PlmLocale.getString(\"PartNumber\")================"+PlmLocaleUtil.getString("PartNumber"));
if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)) {
clearanceList.add(field);
JComboBox<String> box = new JComboBox<String>();
//<2F>Ż<EFBFBD>
JTextField jt=new JTextField(9);
JButton bu=new JButton("<22><><EFBFBD><EFBFBD>");
//end
box.addItem(" ");
clearanceList.add(box);
String[] strs = new String[] {"C0","C2","C3","C4","C5"};
for (int K = 0; K < strs.length; K++) {
box.addItem(strs[K]);
}
//<2F>Ż<EFBFBD>
bu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String tip=jt.getText();
System.out.println("<22><><EFBFBD><EFBFBD>"+tip);
if(tip.length()>0) {
SearchJComItem.changeBox(box, tip);
}
}
});
//end
boxMap.put(attrName, box);
parentPanel.add((h+i)+".3.center.top", box);
//<2F>Ż<EFBFBD>
parentPanel.add((h+i)+".4.center.top",jt);
parentPanel.add((h+i)+".5.center.top",bu);
//end
v+=h+i+1;
}else if((PlmLocaleUtil.getString("PartNumber")).equals(attrName)){
idList.add(field);
JComboBox<String> box = new JComboBox<String>();
JTextField jt=new JTextField(9);
JButton bu=new JButton("<22><><EFBFBD><EFBFBD>");
idList.add(box);
box.addItem(" ");
String[] strs = new String[99];
for (int K = 0; K < 99; K++) {
if(K < 9) {
strs[K] = "0"+(K+1);
}else {
strs[K] = (K+1)+"";
}
}
for (int K = 0; K < strs.length; K++) {
box.addItem(strs[K]);
}
//<2F>Ż<EFBFBD>
bu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String tip=jt.getText();
System.out.println("<22><><EFBFBD><EFBFBD>"+tip);
if(tip.length()>0) {
SearchJComItem.changeBox(box, tip);
}
}
});
//end
boxMap.put(attrName, box);
parentPanel.add((h+i)+".3.center.top", box);
parentPanel.add((h+i)+".4.center.top",jt);
parentPanel.add((h+i)+".5.center.top",bu);
}
}
v=h+i+1;
}
//<2F>Ż<EFBFBD>
parentPanel.add(v+".1.center.top",new JLabel(" "));
parentPanel.add(v+".2.center.top",new JLabel("***********<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********"));
v+=1;
if(boflag) {
//System.out.println("<22><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD>:"+h);
for(int i=0;i<ZC_LBJ_list.ZCPros.size();i++) {
System.out.println("ѭ<><D1AD><EFBFBD><EFBFBD>"+i+"<22><>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>Ϊ"+ZC_LBJ_list.ZCDisPros.get(i)+"("+ZC_LBJ_list.ZCPros.get(i)+")");
parentPanel.add((v+i)+".1.center.top",new JLabel(ZC_LBJ_list.ZCDisPros.get(i)));
boolean b = ZC_LBJ_list.map.containsKey(ZC_LBJ_list.ZCPros.get(i));
try {
if(b) {
System.out.println("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Lov<6F><76><EFBFBD><EFBFBD>");
if(ZC_LBJ_list.ZCPros.get(i).equals("rb3_scgc1")) {
String na=ZC_LBJ_list.ZCPros.get(i);
String[] vals = ((TCComponentItemRevision) targetComp).getTCProperty(na).getStringValueArray();
JComboBox nbox=new RwJComboBox(new String[] {""});
nbox.setEditable(true);
TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(i));
TCComponentListOfValues zcprolov = zclov.getLOV();
String[] comboxitems;
List<String> disVal=new ArrayList<String>();
for(int a=0;a<vals.length;a++) {
if(vals[a]!=null && !vals[a].equals("")) {
String disname = zcprolov.getListOfValues().getDisplayableValue(vals[a]);
disVal.add(disname);
}
}
if(zcprolov!=null) {
comboxitems = zcprolov.getListOfValues().getLOVDisplayValues();
//ComboBoxModel model = new DefaultComboBoxModel(comboxitems);
nbox=new RwJComboBox(comboxitems);
nbox.setEditable(true);
nbox.setName(na);
nbox.setSize(new Dimension(60,40));
if(disVal.size()>0) {
StringBuilder sb=new StringBuilder();
for(int t=0;t<disVal.size();t++) {
if(t!=(vals.length-1)) {
sb.append(disVal.get(t));
sb.append(",");
}else {
sb.append(disVal.get(t));
}
}
JTextField ed=(JTextField)nbox.getEditor().getEditorComponent();
ed.setText(sb.toString());
}
comboxList.add(nbox);
}
parentPanel.add((v+i)+".2.center.top",nbox);
}else if(ZC_LBJ_list.ZCPros.get(i).equals("rb3_yyly")){
String na=ZC_LBJ_list.ZCPros.get(i);
String[] vals = ((TCComponentItemRevision) targetComp).getTCProperty(na).getStringValueArray();
JComboBox nbox=new RwJComboBox(new String[] {""});
nbox.setEditable(true);
TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(i));
TCComponentListOfValues zcprolov = zclov.getLOV();
TCComponentListOfValues[] listLov = zcprolov.getListOfFilters();
for(int p=0;p<listLov.length;p++) {
TCComponentListOfValues zilov = listLov[p];
String[] zilovDisName = zilov.getListOfValues().getLOVDisplayValues();
String[] lsValues = zilov.getListOfValues().getStringListOfValues();
for(int q=0;q<zilovDisName.length;q++) {
yylyList.add(zilovDisName[q]);
}
for(int s=0;s<lsValues.length;s++) {
System.out.println("<22><>ʵֵΪ:"+lsValues[s]);
}
}
List<String> disVal=new ArrayList<String>();
if(vals.length>0) {
for(int e=0;e<listLov.length;e++) {
TCComponentListOfValues elov = listLov[e];
String disname=null;
for(int a=0;a<vals.length;a++) {
try {
disname = elov.getListOfValues().getDisplayableValue(vals[a]);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(disname!=null) {
disVal.add(disname);
}
}
}
}
String[] comboxitems;
if(zcprolov!=null) {
if(yylyList.size()>0) {
comboxitems=new String[yylyList.size()];
for(int g=0;g<yylyList.size();g++) {
comboxitems[g]=yylyList.get(g);
}
nbox=new RwJComboBox(comboxitems);
nbox.setEditable(true);
nbox.setName(na);
nbox.setSize(new Dimension(60,40));
if(disVal.size()>0) {
StringBuilder sb=new StringBuilder();
for(int t=0;t<disVal.size();t++) {
if(t!=(vals.length-1)) {
sb.append(disVal.get(t));
sb.append(",");
}else {
sb.append(disVal.get(t));
}
}
JTextField ed=(JTextField)nbox.getEditor().getEditorComponent();
ed.setText(sb.toString());
}
comboxList.add(nbox);
}
}
parentPanel.add((v+i)+".2.center.top",nbox);
}else {
JComboBox zcBox=new JComboBox<String>();
zcBox.setSize(new Dimension(60,40));
zcBox.setName(ZC_LBJ_list.ZCPros.get(i));
TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.ZCPros.get(i));
TCComponentListOfValues zcprolov = zclov.getLOV();
String[] comboxitems;
JTextField jt=new JTextField(9);
JButton bu=new JButton("<22><><EFBFBD><EFBFBD>");
if(zcprolov!=null) {
comboxitems = zcprolov.getListOfValues().getLOVDisplayValues();
ComboBoxModel model = new DefaultComboBoxModel(comboxitems);
zcBox.setModel(model);
bu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String tip=jt.getText();
System.out.println("<22><><EFBFBD><EFBFBD>"+tip);
if(tip.length()>0) {
SearchJComItem.changeBox(zcBox, tip);
}
}
});
comboxList.add(zcBox);
}
zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i)));
if((ZC_LBJ_list.ZCDisPros.get(i)).equals("<22><>ʱ<EFBFBD><CAB1><EFBFBD>ϱ<EFBFBD>ʶ")) {
zcBox.setSelectedIndex(-1);
}
parentPanel.add((v+i)+".2.center.top",zcBox);
parentPanel.add((v+i)+".3.center.top",jt);
parentPanel.add((v+i)+".4.center.top",bu);
}
}else {
JTextField field=new JTextField(18);
field.setName(ZC_LBJ_list.ZCPros.get(i));
field.setText(zc_lbj_map.get(ZC_LBJ_list.ZCPros.get(i)));
parentPanel.add((v+i)+".2.center.top",field);
fieldList.add(field);
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}else {
for(int i=0;i<ZC_LBJ_list.LBJPros.size();i++) {
System.out.println("ѭ<><D1AD><EFBFBD><EFBFBD>"+i+"<22><>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>Ϊ"+ZC_LBJ_list.LBJDisPros.get(i)+"("+ZC_LBJ_list.LBJPros.get(i)+")");
parentPanel.add((v+i)+".1.center.top",new JLabel(ZC_LBJ_list.LBJDisPros.get(i)));
boolean b = ZC_LBJ_list.map.containsKey(ZC_LBJ_list.LBJPros.get(i));
try {
if(b) {
System.out.println("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Lov<6F><76><EFBFBD><EFBFBD>");
if(ZC_LBJ_list.LBJPros.get(i).equals("rb3_scgc1")||ZC_LBJ_list.LBJPros.get(i).equals("rb3_yyly")) {
//System.out.println("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
String na=ZC_LBJ_list.LBJPros.get(i);
String[] vals = ((TCComponentItemRevision) targetComp).getTCProperty(na).getStringValueArray();
JComboBox nbox=new RwJComboBox(new String[] {""});
nbox.setEditable(true);
TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(i));
TCComponentListOfValues zcprolov = zclov.getLOV();
String[] comboxitems;
List<String> disVal=new ArrayList<String>();
for(int a=0;a<vals.length;a++) {
if(vals[a]!=null && !vals[a].equals("")) {
String disname = zcprolov.getListOfValues().getDisplayableValue(vals[a]);
disVal.add(disname);
}
}
if(zcprolov!=null) {
comboxitems = zcprolov.getListOfValues().getLOVDisplayValues();
//ComboBoxModel model = new DefaultComboBoxModel(comboxitems);
nbox=new RwJComboBox(comboxitems);
nbox.setEditable(true);
nbox.setName(na);
nbox.setSize(new Dimension(60,40));
if(disVal.size()>0) {
StringBuilder sb=new StringBuilder();
for(int t=0;t<disVal.size();t++) {
if(t!=(vals.length-1)) {
sb.append(disVal.get(t));
sb.append(",");
}else {
sb.append(disVal.get(t));
}
}
JTextField ed=(JTextField)nbox.getEditor().getEditorComponent();
ed.setText(sb.toString());
}
comboxList.add(nbox);
}
parentPanel.add((v+i)+".2.center.top",nbox);
}else {
JComboBox zcBox=new JComboBox<String>();
zcBox.setSize(new Dimension(60,40));
zcBox.setName(ZC_LBJ_list.LBJPros.get(i));
TCProperty zclov = ((TCComponentItemRevision) targetComp).getTCProperty(ZC_LBJ_list.LBJPros.get(i));
TCComponentListOfValues zcprolov = zclov.getLOV();
String[] comboxitems;
JTextField jt=new JTextField(9);
JButton bu=new JButton("<22><><EFBFBD><EFBFBD>");
if(zcprolov!=null) {
comboxitems = zcprolov.getListOfValues().getLOVDisplayValues();
ComboBoxModel model = new DefaultComboBoxModel(comboxitems);
zcBox.setModel(model);
bu.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String tip=jt.getText();
System.out.println("<22><><EFBFBD><EFBFBD>"+tip);
if(tip.length()>0) {
SearchJComItem.changeBox(zcBox, tip);
}
}
});
comboxList.add(zcBox);
}
zcBox.setSelectedItem(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i)));
if((ZC_LBJ_list.LBJDisPros.get(i)).equals("<22><>ʱ<EFBFBD><CAB1><EFBFBD>ϱ<EFBFBD>ʶ")) {
zcBox.setSelectedIndex(-1);
}
parentPanel.add((v+i)+".2.center.top",zcBox);
parentPanel.add((v+i)+".3.center.top",jt);
parentPanel.add((v+i)+".4.center.top",bu);
}
}else {
JTextField field=new JTextField(18);
field.setName(ZC_LBJ_list.LBJPros.get(i));
field.setText(zc_lbj_map.get(ZC_LBJ_list.LBJPros.get(i)));
parentPanel.add((v+i)+".2.center.top",field);
fieldList.add(field);
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
// for(Map.Entry<String,String> e:zc_lbj_map.entrySet()) {
// System.out.println(e.getKey()+"==="+e.getValue());
// parentPanel.add(h+".1.center.top",new JLabel(e.getKey()));
// JTextField field=new JTextField(18);
// field.setName(e.getKey());
// field.setText(e.getValue());
// parentPanel.add(h+".2.center.top",field);
// h++;
// }
//end<6E>Ż<EFBFBD>
JPanel southPanel = new JPanel(new FlowLayout());
southPanel.setPreferredSize(new Dimension(250, 50));
JButton button = new JButton("<22>½<EFBFBD>");
JButton button1 = new JButton("ȡ<><C8A1>");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
createItem();
}
});
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
});
southPanel.add(button);
southPanel.add(button1);
this.add("1.1.center.top",new JLabel(" "));
//this.add(new JLabel(" "),BorderLayout.NORTH);
//this.add(classJpanel,BorderLayout.CENTER);
this.add("2.1.center.top",classJpanel);
//this.add(southPanel,BorderLayout.SOUTH);
this.add("3.1.center.top",southPanel);
pack();
centerToScreen(1.0D, 0.75D);
this.showDialog();
}
protected void createItem() {
// TODO Auto-generated method stub
if(idList.size() > 0) {
JTextField idField = (JTextField) idList.get(0);
JComboBox<String> idBox = (JComboBox<String>) idList.get(1);
String idFieldText = idField.getText();
String idBoxText = (String) idBox.getSelectedItem();
if(!("".equals(idFieldText.trim())) && !("".equals(idBoxText.trim()))) {
MessageBox.post("<22><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>ͬʱ<CDAC><CAB1>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ", MessageBox.INFORMATION);
return;
}
// if("".equals(idFieldText.trim()) && "".equals(idBoxText.trim())) {
// MessageBox.post("<22><><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD>дһ<D0B4><D2BB>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ", MessageBox.INFORMATION);
// return;
// }
}
if(clearanceList.size() > 0) {
JTextField clearanceField = (JTextField) clearanceList.get(0);
JComboBox<String> clearanceBox = (JComboBox<String>) clearanceList.get(1);
String clearanceFieldText = clearanceField.getText();
String clearanceBoxText = (String) clearanceBox.getSelectedItem();
if(!("".equals(clearanceFieldText.trim())) && !("".equals(clearanceBoxText.trim()))) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ", MessageBox.INFORMATION);
return;
}
if("".equals(clearanceFieldText.trim()) && "".equals(clearanceBoxText.trim())) {
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>дһ<D0B4><D2BB>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><>ʾ", MessageBox.INFORMATION);
return;
}
}
String[] keys1 = new String[]{"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID"};
String[] values1 = new String[]{newID};
List<TCComponent> compList = queryObject("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID", keys1, values1);
if(compList != null && compList.size() > 0) {
MessageBox.post("ϵͳ<CFB5><CDB3><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ڸ<EFBFBD>ID<49>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󴴽<EFBFBD>!!!!", "<22><>ʾ", MessageBox.INFORMATION);
return;
}
TCComponentItemRevision newRev = null;
try {
TCComponentItemType typeComponent = (TCComponentItemType) session
.getTypeComponent(targetType);
TCComponentItem newItem = typeComponent.create(newID, revId, targetType,
nameField.getText(), "", null);
if (newItem != null) {
session.getUser().getHomeFolder()
.add("contents", newItem);
session.getUser().getHomeFolder().refresh();
}
newRev = newItem.getLatestItemRevision();
//<2F>Ż<EFBFBD>
for(int k=0;k<fieldList.size();k++){
JTextField jt = (JTextField)fieldList.get(k);
String key=jt.getName();
String val=jt.getText();
fieldmap.put(key, val);
}
for(int m=0;m<comboxList.size();m++) {
JComboBox cbo=(JComboBox)comboxList.get(m);
cbo.setEditable(false);
String key=cbo.getName();
System.out.println("combox<6F><78>NameΪ:"+key);
if(key.equals("rb3_scgc1")||key.equals("rb3_yyly")) {
JTextField ed=(JTextField)cbo.getEditor().getEditorComponent();
String text = ed.getText();
if(!text.equals("") && text!=null) {
List<String> proList=new ArrayList<>();
String[] split = text.split(",");
TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key);
TCComponentListOfValues lov = tclov.getLOV();
for(int p=0;p<split.length;p++) {
String realVal=(String)lov.getListOfValues().getRealValue(split[p]);
proList.add(realVal);
}
Object[] array = proList.toArray();
String[] svals=new String[array.length];
for(int s=0;s<array.length;s++) {
svals[s]=(String)array[s];
}
newRev.getTCProperty(key).setStringValueArray(svals);
}
}else {
String val=(String) cbo.getSelectedItem();
TCProperty tclov = ((TCComponentItemRevision) targetComp).getTCProperty(key);
TCComponentListOfValues lov = tclov.getLOV();
String realVal = (String)lov.getListOfValues().getRealValue(val);
System.out.println("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ֵΪ:"+val);
comboxmap.put(key,realVal);
}
}
newRev.setProperties(fieldmap);
newRev.setProperties(comboxmap);
//end<6E>Ż<EFBFBD>
String time1 = showDate1.getText();
Date date = df.parse(time1);
newRev.setDateProperty("rb3_yxq", date);
newRev.setStringProperty("rb3_th", th);
newRev.setStringProperty("rb3_cph", cph);
String statu = "";
if ("A1".equals(revId)) {
statu = "<22><>:Conceptual design";
} else if ("B1".equals(revId)) {
statu = "<22><>:Product design";
} else if ("R1".equals(revId)) {
statu = "<22><>:Process design/Sample delivery";
} else if ("P1".equals(revId)) {
statu = "P:Pilot production/small batch";
} else if ("M1".equals(revId)) {
statu = "M:Mass production";
}
newRev.setStringProperty("rb3_smzqzt", statu);
newRev.setStringProperty("rb3_lswlbs", "Temporary");
if(flag) {
newRev.setStringProperty("rb3_lbjlx", type);
}else {
newRev.setStringProperty("rb3_zclx", type);
}
TCComponent[] references = targetRev.getReferenceListProperty("TC_Is_Represented_By");
List<TCComponentItemRevision> pics = new ArrayList<TCComponentItemRevision>();
List<String> picID = new ArrayList<String>();
for (int i = 0; i < references.length; i++) {
if(references[i] instanceof TCComponentItemRevision) {
TCComponentItemRevision pic = (TCComponentItemRevision) references[i];
String pic_type = pic.getItem().getType();
String rev_id = pic.getStringProperty("item_revision_id");
String id = pic.getStringProperty("item_id");
String pic_name = pic.getStringProperty("object_name");
StringBuilder sb = new StringBuilder("LS-");
sb.append(id);
String picNewID = sb.toString();
String[] keys2 = new String[]{"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID"};
String[] values2 = new String[]{picNewID};
List<TCComponent> picList = queryObject("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID", keys2, values2);
if(picList != null) {
if(picList.size() > 0) {
TCComponent tcComponent = picList.get(0);
if(tcComponent instanceof TCComponentItem) {
TCComponentItemRevision rev = ((TCComponentItem) tcComponent).getLatestItemRevision();
if(!(picID.contains(picNewID))) {
picID.add(picNewID);
pics.add(rev);
}
}
}
}else {
TCComponentItemType picType = (TCComponentItemType) session
.getTypeComponent(pic_type);
TCComponentItem picItem = picType.create(picNewID, rev_id, pic_type,
pic_name, "", null);
TCComponentItemRevision picRev = picItem.getLatestItemRevision();
newRev.add("TC_Is_Represented_By", picRev);
picID.add(picNewID);
}
}
}
if(pics.size() > 0) {
for (int i = 0; i < pics.size(); i++) {
TCComponentItemRevision rev = pics.get(i);
newRev.add("TC_Is_Represented_By",rev);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
MessageBox.post("<22><>ʱ<EFBFBD><CAB1><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>ʧ<EFBFBD><CAA7>!!!!", "<22><><EFBFBD><EFBFBD>", MessageBox.INFORMATION);
e.printStackTrace();
return;
}
List<String> vals = new ArrayList<String>();
for (Map<String,Object> value : values) {
for (Map.Entry<String,Object> entry : value.entrySet()) {
String type = entry.getKey();
if(type.equals("JComboBox")){
JComboBox<String> comb1 = (JComboBox<String>) entry.getValue();
String val = (String) comb1.getSelectedItem();
vals.add(val);
}else{
JTextField field1 = (JTextField) entry.getValue();
String val = field1.getText();
vals.add(val);
}
}
}
Integer[] classKeys = new Integer[classList.size()];
String[] classVals = new String[classList.size()];
System.out.println("size============================"+classList.size());
for(int i=0;i<labels1.length;i++){
String val = vals.get(i);
if(val == null || val.trim()==""){
continue;
}
String val2 = "";
if (classList.get(i).isIslov()) {
val2 = classList.get(i).getLov().get(val);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵֵ
System.out.println("val2================"+val2);
System.out.println("val================"+val);
} else {
val2 = val;
}
classKeys[i] = classList.get(i).getId();
String attrName = classList.get(i).getName();
if((PlmLocaleUtil.getString("RadialInternalClearance")).equals(attrName)
|| (PlmLocaleUtil.getString("PartNumber")).equals(attrName)) {
if("".equals(val2.trim())) {
JComboBox<String> box = boxMap.get(attrName);
val2 = (String) box.getSelectedItem();
}
}
classVals[i] = val2;
}
disposeDialog();
sendObjToClassficationByWebService(className,newRev, classKeys, classVals);//<2F><><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
MessageBox.post("<22><>ʱ<EFBFBD><CAB1><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!!!!", "<22><><EFBFBD><EFBFBD>", MessageBox.INFORMATION);
}
/**
* <20><><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
*/
public void sendObjToClassficationByWebService(String class_id,
TCComponentItemRevision rev, Integer[] keys, String[] vals) {
try {
System.out.println("class_id-----dddddd----->" + class_id);
if (!class_id.replace(" ", "").equals("")) {
List<ClassProperty> propList = new ArrayList<ClassProperty>();
for (int i = 0; i < keys.length; i++) {
if(keys[i] != null && vals[i] != null) {
ClassProperty prop = new ClassProperty(keys[i], vals[i]);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
propList.add(prop);
}
}
String json = SoaServerUtil.objectToJson(propList);// <20><>Java<76><61><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊjson<6F><6E><EFBFBD><EFBFBD>
SoaServerUtil.grantWritePrivilege(session, rev);// <20><><EFBFBD><EFBFBD>дȨ<D0B4><C8A8>
SoaServerUtil.sendToClass(rev.getUid(), class_id, json, url);// <20><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
SoaServerUtil.grantReadPrivilege(session, rev);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static Date stepMonth(Date sourceDate, int month) {
Calendar c = Calendar.getInstance();
c.setTime(sourceDate);
c.add(Calendar.MONTH, month);
return c.getTime();
}
/**
* ͨ<><CDA8><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>
*
* @param queryName <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
* @param keys <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
* @param values <20><>ѯֵ
* @return
*/
public List<TCComponent> queryObject(String queryName, String[] keys, String[] values) {
TCComponent[] components = null;
try {
TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery");
TCComponentQuery query = (TCComponentQuery) queryType.find(queryName);
if (query == null) {
MessageBox.post("û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ѯ:" + queryName, "<22><><EFBFBD><EFBFBD>", MessageBox.ERROR);
return null;
}
components = query.execute(keys, values);
} catch (TCException e) {
e.printStackTrace();
}
if (components != null && components.length > 0) {
List<TCComponent> compList = Arrays.asList(components);
return compList;
} else {
return null;
}
}
}