commit fa18e9316657dc9275045a57e1b2c04ff1c87312 Author: lijh Date: Tue Mar 10 11:21:25 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..1383d8d --- /dev/null +++ b/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..1ed110c --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.ac + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..79acb27 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/com/connor/ac/util/FileUtil.java=UTF-8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..cf63b5f --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,39 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Ac +Bundle-SymbolicName: com.connor.ac; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.ac.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="11000.2.0", + com.teamcenter.rac.kernel;bundle-version="11000.2.0", + com.teamcenter.rac.common;bundle-version="11000.2.0", + com.teamcenter.rac.tcapps;bundle-version="11000.2.0", + com.teamcenter.rac.ui;bundle-version="11000.2.0", + com.teamcenter.rac.util;bundle-version="11000.2.0", + com.teamcenter.rac.external;bundle-version="11000.2.0", + org.apache.poi.39;bundle-version="3.9.0" +Bundle-ActivationPolicy: lazy +Export-Package: com.alibaba.fastjson, + com.alibaba.fastjson.annotation, + com.alibaba.fastjson.asm, + com.alibaba.fastjson.parser, + com.alibaba.fastjson.parser.deserializer, + com.alibaba.fastjson.serializer, + com.alibaba.fastjson.support.config, + com.alibaba.fastjson.support.hsf, + com.alibaba.fastjson.support.jaxrs, + com.alibaba.fastjson.support.retrofit, + com.alibaba.fastjson.support.spring, + com.alibaba.fastjson.support.spring.annotation, + com.alibaba.fastjson.support.spring.messaging, + com.alibaba.fastjson.support.springfox, + com.alibaba.fastjson.util, + com.connor.AC_01, + com.connor.ac, + com.connor.ac.bean, + com.connor.ac.util +Bundle-ClassPath: aclib/fastjson-1.2.47.jar, + . diff --git a/aclib/cn.com.ebewin.ysr_1.0.0.jar b/aclib/cn.com.ebewin.ysr_1.0.0.jar new file mode 100644 index 0000000..a9ece48 Binary files /dev/null and b/aclib/cn.com.ebewin.ysr_1.0.0.jar differ diff --git a/aclib/com.connor.dongmu.plm_1.0.0.jar b/aclib/com.connor.dongmu.plm_1.0.0.jar new file mode 100644 index 0000000..83b9bc8 Binary files /dev/null and b/aclib/com.connor.dongmu.plm_1.0.0.jar differ diff --git a/aclib/fastjson-1.2.47.jar b/aclib/fastjson-1.2.47.jar new file mode 100644 index 0000000..f342bca Binary files /dev/null and b/aclib/fastjson-1.2.47.jar differ diff --git a/aclib/slf4j-api-1.7.25.jar b/aclib/slf4j-api-1.7.25.jar new file mode 100644 index 0000000..0143c09 Binary files /dev/null and b/aclib/slf4j-api-1.7.25.jar differ diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..70f379c --- /dev/null +++ b/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + aclib/fastjson-1.2.47.jar diff --git a/icons/sample.gif b/icons/sample.gif new file mode 100644 index 0000000..34fb3c9 Binary files /dev/null and b/icons/sample.gif differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..bfabf7c --- /dev/null +++ b/plugin.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + - + + + + + diff --git a/src/com/connor/AC_01/ACSysCatalogStyle.java b/src/com/connor/AC_01/ACSysCatalogStyle.java new file mode 100644 index 0000000..c1a42e0 --- /dev/null +++ b/src/com/connor/AC_01/ACSysCatalogStyle.java @@ -0,0 +1,1232 @@ +package com.connor.AC_01; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.*; +import java.util.Map.Entry; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jacorb.idl.runtime.int_token; + +import com.connor.ac.bean.SysCatalogRevisionMasterBean; +import com.connor.ac.util.ACFinalUtil; +import com.connor.ac.util.FileUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +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.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; + +public class ACSysCatalogStyle extends AbstractRendering{ + /** + * + */ + private static final long serialVersionUID = 1L; + private JButton synButton; + private JButton impButton; + private JButton excButton; + private JPanel rootPanel; + private JPanel topPanel; + private JPanel topCBPanel; + private JTextField cb_jtf; + private JScrollPane scrollPanel; + private JPanel buttomPanel; + private JTable partsTable; + private DefaultTableModel dtm; + private Object titleNames[] = {"", "", "", "","Ա", "","", "ǷҪ", "ûͼ","ƻɱ", "ȡ","ƻʱ"}; + private List valueLists; + private List saveValueLists; + private TCComponentForm formComp; + private TableCellTextAreaRenderer renderer; +// private TCProperty properties[]; + private TCProperty propertiesArray[]; +// private int isAddAll = 1; + private boolean isCheckOut = false; + private boolean isOK = true; + private boolean isOK_one = true; + TCComponentForm tcForm; + private String project; + private String projectID; + private String revID; +// private TCFormProperty formProperties[]; + public ACSysCatalogStyle(TCComponentForm arg0) throws Exception { + super(arg0); + formComp = arg0; + TCComponentItemRevision fileItemLastRev = (TCComponentItemRevision) formComp.getReferenceProperty("item_revision"); + project = fileItemLastRev.getProperty("item_id"); + projectID = project.substring(0, project.indexOf("_")); + project = projectID.substring(0, 2) + projectID.substring(projectID.length()-4); + revID = fileItemLastRev.getProperty("item_revision_id"); + + loadRendering(); + } + + + @Override + public void loadRendering() { + init(); + } + + private void init() { + System.out.println("ʼʼ"); + isOK = true; + isOK_one = false; + valueLists = new ArrayList<>(); + saveValueLists = new ArrayList<>(); + getFormVlue(); + setLayout(new BorderLayout()); + setBackground(Color.WHITE); + excButton = new JButton(""); + excButton.setEnabled(true); + excButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + int result = fileChooser.showOpenDialog(abstractAIFUIApplication.getApplicationPanel()); + if (result == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + if (file.isFile() && file.getName().endsWith(".xlsx")) { + // ѡļ + System.out.println("ѡļǣ" + file.getAbsolutePath()); + } else { + MessageBox.post("", "ѡһExcelļ", MessageBox.ERROR); + } + //ȡexcelе + LinkedHashMap readExcel = readExcel(file); + DefaultTableModel model = (DefaultTableModel) partsTable.getModel(); // ȡģ + int rowCount = model.getRowCount(); + for(int i=0;i> parseJTable = parseJTable(partsTable); +// //ϲ +// LinkedHashMap> mergeMap = mergeMap(parseJTable,readExcel); +// for (Map.Entry> entry : mergeMap.entrySet()) { +// String key = entry.getKey(); +// List values = entry.getValue(); +// System.out.println("key: " + key); +// System.out.println("values:"); +// for (String value : values) { +// System.out.println(value); +// } +// System.out.println(); +// } +// //ӵ +// refreshTable(partsTable,titleNames, mergeMap); + } + } + }); + + synButton = new JButton("ͬ"); + synButton.setEnabled(true); + synButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + synListenter(); + } + }); + + impButton = new JButton(""); + impButton.setEnabled(true); + impButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + exExcel(); + } + }); + + JButton delButton = new JButton(""); + delButton.setEnabled(true); + delButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + if(partsTable.getRowCount()>0) { + for(int i=partsTable.getRowCount(); i>0; i--) { + dtm.removeRow(i-1); + } + } + synButton.setEnabled(true); + saveValueLists = new ArrayList<>(); + } + }); + + partsTable = getjTable(partsTable, titleNames ,getValues(valueLists)); + topPanel = new JPanel(new BorderLayout()); + scrollPanel = new JScrollPane(); + scrollPanel.getViewport().add(partsTable, null); + scrollPanel.validate(); + topPanel.add("Center", scrollPanel); + buttomPanel = new JPanel(new FlowLayout()); + buttomPanel.add(excButton); + buttomPanel.add(synButton); + buttomPanel.add(impButton); +// buttomPanel.add(delButton);//TODO delButton + rootPanel = new JPanel(new BorderLayout()); + + //yjh20201126 + topCBPanel = new JPanel(); + FlowLayout flowLayout = new FlowLayout(); + flowLayout.setAlignment(FlowLayout.LEFT); + topCBPanel.setLayout(flowLayout); + JLabel jl = new JLabel("ƻɱۼƣ"); + cb_jtf = new JTextField(20); + cb_jtf.setEditable(false); + + Double a = 0.00; + for (int i = 0; i < dtm.getRowCount(); i++) { + String v = dtm.getValueAt(i, 9).toString().trim(); + if(!v.isEmpty()) + a += Double.parseDouble(v); + } + cb_jtf.setText(String.valueOf(a)); + topCBPanel.add(jl); + topCBPanel.add(cb_jtf); + + rootPanel.add("North",topCBPanel); + //end + + rootPanel.add("Center", topPanel); + rootPanel.add("South", buttomPanel); + add(rootPanel, "Center"); + } + + +// public static void refreshTable(JTable table, Object[] titleNames, LinkedHashMap> map) { +// DefaultTableModel model = (DefaultTableModel) table.getModel(); // ȡģ +// model.setRowCount(0); // ձе +// model.setColumnIdentifiers(titleNames); // ñ +// int index = 1; // кŴ1ʼ +// for (String key : map.keySet()) { // map +// List values = map.get(key); +// Object[] row = new Object[values.size() + 2]; // +// row[0] = index++; // к +// row[1] = key; // keyֵ +// for (int i = 0; i < values.size(); i++) { // valueֵ +// row[i + 2] = values.get(i); +// } +// model.addRow(row); // ӵģ +// } +// table.setModel(model); // µıģø +// } + +// public LinkedHashMap> mergeMap(LinkedHashMap> map1, LinkedHashMap> map2) { +// for (String key : map2.keySet()) { +// if (map1.containsKey(key)) { +// map1.replace(key, map2.get(key)); +// } else { +// map1.put(key, map2.get(key)); +// } +// } +// return map1; +// } + +// public LinkedHashMap parseJTable(JTable table) { +// LinkedHashMap result = new LinkedHashMap<>(); +// int rowCount = table.getRowCount(); +// for (int i = 1; i < rowCount; i++) { // ӵڶпʼȡ +// String key = (String) table.getValueAt(i, 1); // ȡBеֵΪkey +// if (key == null || key.isEmpty()) { // keyΪգ +// break; +// } +// List values = new ArrayList<>(); +// for (int j = 2; j < 8; j++) { // ȡCHеֵΪvalue +// String value = (String) table.getValueAt(i, j); +// values.add(value); +// } +// result.put(key, values); // key-valuemap +// } +// return result; +// } + + public LinkedHashMap readExcel(File file) { + LinkedHashMap map = new LinkedHashMap<>(); + try { + FileInputStream inputStream = new FileInputStream(file); + Workbook workbook = new XSSFWorkbook(inputStream); + Sheet sheet = workbook.getSheetAt(0); // ȡһSheetҳ + for (int i = 2; i <= sheet.getLastRowNum(); i++) { // ӵпʼȡ + Row row = sheet.getRow(i); + //ȡ λ ǰ油 Ŀ_ + Cell zxlbCell = row.getCell(4); + String zxlb = zxlbCell.getStringCellValue(); + System.out.println("zxlb====="+zxlb); + Cell keyCell = row.getCell(1); // B + String key = keyCell.getStringCellValue(); + if (key == null || key.trim().equals("")) { // keyΪʱ + break; + } + Cell valueCell = row.getCell(6); + String value = null; + try { + value = valueCell.getStringCellValue(); + } catch (Exception e) { + double dateCellValue = valueCell.getNumericCellValue(); + value = String.valueOf(dateCellValue); + } + + + + if(zxlb != null && zxlb.equals("λ") && !key.contains(project)) { + map.put(project+"_"+key, value); + System.out.println("bjz===="+project+"_"+key); + }else { + map.put(key, value); + } + + } + inputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return map; + } + + private void exExcel(){ + InputStream input = null; + FileOutputStream output = null; + try { + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponentQueryType imanQueryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) imanQueryType.find("Projects..."); + TCComponent[] projects = query.getExecuteResultsList(new String[]{ "Ŀ ID" }, new String[]{ projectID }).toTCComponentArray(); + File model = getModel(session); + System.out.println("model:"+model.getPath()); + File directory = FileUtil.saveExcelChooser(projectID+"-Ŀɱƻ-"+revID, "Microsoft Excel*.xlsx"); + if(directory.exists()) + directory.delete(); + input = new FileInputStream(model); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow row = sheet.getRow(9); + XSSFCell cell = row.getCell(2); + if(projects!=null && projects.length>0) + cell.setCellValue(projects[0].getProperty("project_name")); + cell = row.getCell(4); + cell.setCellValue(cb_jtf.getText()); + row = sheet.getRow(10); + cell = row.getCell(4); + cell.setCellValue(projectID); +// insertRow(sheet, 2, impTable.getRowCount()); + int rowsCount = partsTable.getRowCount(); + if(rowsCount>7) { +// for(int i=1; i= totleLen) + { + for(int i = 0; i < titleNames.length; i++) + partsTable.getColumnModel().getColumn(i).setPreferredWidth(105); + + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + for (int i = 1; i < partsTable.getRowCount()+1; i++) { + if(i%2==0) + renderer.setOneRowBackgroundColor(partsTable,true, i, new Color(238,238,238)); + } + } + return partsTable; + } + + + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object columNameObjects[], Object objects[][]) + { + if(dtm == null) + dtm = new DefaultTableModel(objects, columNameObjects); + this.dtm = dtm; + return dtm; + } + /** + * ʼ + */ + private void getFormVlue() + { + valueLists = new ArrayList<>(); + try + { + propertiesArray = formComp.getTCProperties(ACFinalUtil.AC_CATALOG_PROP_NAMES); + if(propertiesArray != null) + { + String valueStrs0[] = propertiesArray[0] != null ? propertiesArray[0].getStringArrayValue() : new String[0]; + String valueStrs1[] = propertiesArray[1] != null ? propertiesArray[1].getStringArrayValue() : new String[0]; + double valueStrs2[] = propertiesArray[2] != null ? propertiesArray[2].getDoubleArrayValue() : new double[0]; + String valueStrs3[] = propertiesArray[4] != null ? propertiesArray[4].getStringArrayValue() : new String[0]; + String valueStrs5[] = propertiesArray[6] != null ? propertiesArray[6].getStringArrayValue() : new String[0]; + double valueStrs7[] = propertiesArray[8] != null ? propertiesArray[8].getDoubleArrayValue() : new double[0]; + String valueStrs9[] = propertiesArray[9] != null ? propertiesArray[9].getStringArrayValue() : new String[0]; + + String valueStrs4[] = propertiesArray[3] != null ? propertiesArray[3].getStringArrayValue() : new String[0]; + String valueStrs6[] = propertiesArray[5] != null ? propertiesArray[5].getStringArrayValue() : new String[0]; + String valueStrs8[] = propertiesArray[7] != null ? propertiesArray[7].getStringArrayValue() : new String[0]; + double valueStrs11[] = propertiesArray[10] != null ? propertiesArray[10].getDoubleArrayValue() : new double[0]; + + + //20201030ص߼ + if(valueStrs7.length != valueStrs0.length ){ + if(valueStrs0.length == valueStrs1.length && valueStrs0.length == valueStrs2.length && + valueStrs0.length == valueStrs3.length && valueStrs0.length == valueStrs5.length && + /*valueStrs0.length == valueStrs7.length && */valueStrs0.length == valueStrs9.length && valueStrs0.length != 0) + { + for(int i = 0; i < valueStrs0.length; i++) + { + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(valueStrs0[i]); + bean.setYsr8_object(valueStrs1[i]); + bean.setYsr8_Quantity(valueStrs2[i]==0?"0.00":doubleTwoString(valueStrs2[i])); + bean.setYsr8_Category(valueStrs3[i]); + bean.setYsr8_Electric(valueStrs5[i]); + bean.setYsr8_Cost(""); + bean.setYsr8_Cancel(valueStrs9[i]); + + + + + + if(valueStrs4.length > i) {bean.setYsr8_Designer(valueStrs4[i]);} + else { + bean.setYsr8_Designer(""); + } + + if(valueStrs6.length > i) {bean.setYsr8_SubProjectType(valueStrs6[i]);} + else { + bean.setYsr8_SubProjectType(""); + } + + if(valueStrs8.length > i) { bean.setYsr8_CustomPartCode(valueStrs8[i]);} + else { + bean.setYsr8_CustomPartCode(""); + } + + if(valueStrs11.length > i) {bean.setYsr8_PlanWorkTime(doubleTwoString(valueStrs11[i]));} + else { + bean.setYsr8_PlanWorkTime(""); + } + valueLists.add(bean); + } + } + + }else{ + //ԭ߼ + if(valueStrs0.length == valueStrs1.length && valueStrs0.length == valueStrs2.length && + valueStrs0.length == valueStrs3.length && valueStrs0.length == valueStrs5.length && + valueStrs0.length == valueStrs7.length && valueStrs0.length == valueStrs9.length && valueStrs0.length != 0) + { + for(int i = 0; i < valueStrs0.length; i++) + { + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(valueStrs0[i]); + bean.setYsr8_object(valueStrs1[i]); + bean.setYsr8_Quantity(valueStrs2[i]==0?"0.00":doubleTwoString(valueStrs2[i])); + bean.setYsr8_Category(valueStrs3[i]); + bean.setYsr8_Electric(valueStrs5[i]); + bean.setYsr8_Cost(valueStrs7[i]==0?"":doubleTwoString(valueStrs7[i])); + bean.setYsr8_Cancel(valueStrs9[i]); + + if(valueStrs4.length > i) {bean.setYsr8_Designer(valueStrs4[i]);} + else { + bean.setYsr8_Designer(""); + } + + if(valueStrs6.length > i) {bean.setYsr8_SubProjectType(valueStrs6[i]);} + else { + bean.setYsr8_SubProjectType(""); + } + + if(valueStrs8.length > i) { bean.setYsr8_CustomPartCode(valueStrs8[i]);} + else { + bean.setYsr8_CustomPartCode(""); + } + + if(valueStrs11.length > i) {bean.setYsr8_PlanWorkTime(doubleTwoString(valueStrs11[i]));} + else { + bean.setYsr8_PlanWorkTime(""); + } + valueLists.add(bean); + } + } + } + } + // System.out.println("valueLists--"+valueLists.size()); + //System.out.println(valueLists); + + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + + public Object[][] getValues(List beanList) + { + Object objects[][] = new Object[beanList.size()][12]; + for(int i = 0; i < beanList.size(); i++) + { + SysCatalogRevisionMasterBean bean = (SysCatalogRevisionMasterBean)beanList.get(i); + objects[i][0] = i+1; + objects[i][1] = bean.getYsr8_ID().equals("") ? "" : bean.getYsr8_ID(); + objects[i][2] = bean.getYsr8_object().equals("") ? "" : bean.getYsr8_object(); + objects[i][3] = bean.getYsr8_Quantity().equals("") ? "" : bean.getYsr8_Quantity(); + objects[i][5] = bean.getYsr8_Category().equals("") ? "" : bean.getYsr8_Category(); + objects[i][7] = bean.getYsr8_Electric().equals("") ? "" : bean.getYsr8_Electric(); + objects[i][9] = bean.getYsr8_Cost().equals("") ? "" : bean.getYsr8_Cost(); + objects[i][10] = bean.getYsr8_Cancel().equals("") ? "" : bean.getYsr8_Cancel(); + + objects[i][4] = bean.getYsr8_Designer() == null ||bean.getYsr8_Designer().equals("") ? "" : bean.getYsr8_Designer(); + objects[i][6] = bean.getYsr8_SubProjectType() == null || bean.getYsr8_SubProjectType().equals("") ? "" : bean.getYsr8_SubProjectType(); + objects[i][8] = bean.getYsr8_CustomPartCode() == null || bean.getYsr8_CustomPartCode().equals("") ? "" : bean.getYsr8_CustomPartCode(); + + objects[i][11] = bean.getYsr8_PlanWorkTime() == null || bean.getYsr8_PlanWorkTime().equals("") || bean.getYsr8_PlanWorkTime().equals(".00")? "" : bean.getYsr8_PlanWorkTime(); + + } + + return objects; + } + + /** + * ͬť + */ + private void synListenter(){ + try { + int rowCount = partsTable.getRowCount(); + saveValueLists.clear(); + isOK = false; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + File file = getFile(session); + isCheckOut = true; + if(file!=null){ + if(rowCount<1){ + System.out.println("ݲ"); + getCellText(file); +// synButton.setEnabled(false); + }else{ + System.out.println("ݴ"); + getCellText2(file); +// synButton.setEnabled(false); + } + Double a = 0.00; + for (int i = 0; i < dtm.getRowCount(); i++) { + String v = dtm.getValueAt(i, 9).toString().trim(); + if(!v.isEmpty()) + a += Double.parseDouble(v); + } + cb_jtf.setText(String.valueOf(a)); + }else{ + System.out.println("Ҳļ"); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(""+e.getMessage(), "ERROR", MessageBox.ERROR); + } + } + /** + * Excelͬ + * @param file + * @throws Exception + */ + private void getCellText(File file) throws Exception { + isOK_one = true; + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(fis); + // ȡexcelĵ + // ҵһҳ + XSSFSheet sheet = wb.getSheetAt(0); + int rowIndex = 2; + int index = 1; + // һΪ׼ + while (true) { + XSSFRow nextRow = sheet.getRow(rowIndex); + if (nextRow == null || nextRow.getCell(1)==null || nextRow.getCell(1).getCellType()==XSSFCell.CELL_TYPE_BLANK) { + break; + } + XSSFRow row = sheet.getRow(rowIndex); + // ȡԪ + int count1 = dtm.getColumnCount(); + String[] temp1 = new String[count1]; + + String id = (String) getCellValue(row.getCell(1), true); + if(!id.contains(project)) { + id = project+"_"+id; + } + String[] props = { + id, + (String) getCellValue(row.getCell(2), false), + (String) getCellValue(row.getCell(3), false), + (String) getCellValue(row.getCell(4), false), + (String) getCellValue(row.getCell(5), false), + (String) getCellValue(row.getCell(6), false), + (String) getCellValue(row.getCell(7), false), + (String) getCellValue(row.getCell(8), false), + "0.00", + (String) getCellValue(row.getCell(9), false), + (String) getCellValue(row.getCell(10), false), + }; + temp1[0] = Integer.toString(index++); + for (int j = 0; j < props.length; j++) { + if(props[j].equals("") || props[j].equals("0.00")){ + temp1[j + 1]=""; + }else{ + temp1[j + 1] = props[j]; + } + } + dtm.addRow(temp1); + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(props[0]); + bean.setYsr8_object(props[1]); + bean.setYsr8_Quantity(props[2]); + bean.setYsr8_Category(props[4]); + bean.setYsr8_Electric(props[6]); + bean.setYsr8_Cost(props[8]); + bean.setYsr8_Cancel(props[9]); + + bean.setYsr8_Designer(props[3]); + bean.setYsr8_SubProjectType(props[5]); + bean.setYsr8_CustomPartCode(props[7]); + bean.setYsr8_PlanWorkTime(props[10]); + saveValueLists.add(bean); + + if(index%2==0) + renderer.setOneRowBackgroundColor(partsTable, true, index-2, new Color(238, 238, 238)); + rowIndex++; + } + } + + /** + * ExcelĶԱͬ + * @param file + * @throws Exception + */ + private void getCellText2(File file) throws Exception { + + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(fis); + // ȡexcelĵ + // ҵһҳ + + XSSFSheet sheet = wb.getSheetAt(0); + int rowIndex = 2; + //int index = dtm.getRowCount(); + int ysr8_ID = 0; + Map excelID = new HashMap(); + // һΪ׼ + while (true) { + XSSFRow nextRow = sheet.getRow(rowIndex); + if (nextRow == null || nextRow.getCell(1)==null || nextRow.getCell(1).getCellType()==XSSFCell.CELL_TYPE_BLANK) { + break; + } + // ȡԪ + XSSFRow row = sheet.getRow(rowIndex); + + String str = getCellValue(row.getCell(1), true).toString(); + if(!str.contains(project)) { + str = project+"_"+str; + } +// System.out.println("str:"+str); + excelID.put(str, "1-"+rowIndex); + rowIndex++; + } +// System.out.println(excelID); + + for (int i = 0; i < dtm.getColumnCount(); i++) { + if(dtm.getColumnName(i).equals("")){ + ysr8_ID = i; + break; + } + } + StringBuilder tabID = new StringBuilder(""); + if(!revID.equals("A")) { + for (int i = 0; i < dtm.getRowCount(); i++) { + String value = partsTable.getModel().getValueAt(i, ysr8_ID).toString(); + if(excelID.get(value)==null){ + if(value.contains(project))//lidy + tabID.append("").append(value); + } + } + } + + if(tabID.length()>0){ + MessageBox.post("Ŀ"+tabID.substring(1)+"ϵͳĿ¼ȡ޷ͬ", "ʾ", MessageBox.INFORMATION); + saveValueLists.addAll(valueLists); + }else{ + TableCellEditor tablecelleditor = partsTable.getCellEditor(); + if(tablecelleditor != null) { + tablecelleditor.stopCellEditing(); + } + Map id_cost = new HashMap(); + try { + for (int i = 0; i < dtm.getRowCount(); i++) { + Object v = dtm.getValueAt(i, 9); + System.out.println(v); + Double.valueOf(v==null || v.toString().trim().equals("")?"0.00":v.toString()); + id_cost.put(dtm.getValueAt(i, 1).toString(), v.toString()); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("ɱд쳣","ʾ",MessageBox.INFORMATION); + } + System.out.println("---map"+id_cost); + dtm.setRowCount(0); + int rowIndex2 = 2; + int index = 1; + while (true) { + XSSFRow nextRow = sheet.getRow(rowIndex2); + if (nextRow == null || nextRow.getCell(1)==null || nextRow.getCell(1).getCellType()==XSSFCell.CELL_TYPE_BLANK) { + if(nextRow == null){ + System.out.println("aaa"); + break; + } + if(nextRow.getCell(1) == null){ + System.out.println("bbb"); + break; + } + if(nextRow.getCell(1).getCellType() == XSSFCell.CELL_TYPE_BLANK){ + System.out.println("ccc"); + break; + } + break; + } + XSSFRow row = sheet.getRow(rowIndex2); + // ȡԪ + int count1 = dtm.getColumnCount(); + String[] temp1 = new String[count1]; + + String id = (String) getCellValue(row.getCell(1), true); + if(!id.contains(project)) { + id = project+"_"+id; + } + String[] props = { + id, + (String) getCellValue(row.getCell(2), false), + (String) getCellValue(row.getCell(3), false), + (String) getCellValue(row.getCell(4), false), + (String) getCellValue(row.getCell(5), false), + (String) getCellValue(row.getCell(6), false), + (String) getCellValue(row.getCell(7), false), + (String) getCellValue(row.getCell(8), false), + id_cost.get(id) == null || id_cost.get(id).isEmpty()?"0.00":id_cost.get(id), + (String) getCellValue(row.getCell(9), false), + (String) getCellValue(row.getCell(10), false), + }; + temp1[0] = Integer.toString(index++); + for (int j=0; j") || props[j].equals("0.00")){ + temp1[j+1] = ""; + }else{ + temp1[j+1] = props[j]; + } + } + dtm.addRow(temp1); + SysCatalogRevisionMasterBean bean = new SysCatalogRevisionMasterBean(); + bean.setYsr8_ID(props[0]); + bean.setYsr8_object(props[1]); + bean.setYsr8_Quantity(props[2]); + bean.setYsr8_Category(props[4]); + bean.setYsr8_Electric(props[6]); + bean.setYsr8_Cost(props[8]); + bean.setYsr8_Cancel(props[9]); + + bean.setYsr8_Designer(props[3]); + bean.setYsr8_SubProjectType(props[5]); + bean.setYsr8_CustomPartCode(props[7]); + bean.setYsr8_PlanWorkTime(props[10]); + saveValueLists.add(bean); + + + if(index%2==0) + renderer.setOneRowBackgroundColor(partsTable, true, index-2, new Color(238, 238, 238)); + + rowIndex2++; + + } + } + } + + /** + * ȡԪ + * @param cell + * @return + */ + private Object getCellValue(XSSFCell cell, boolean first) { + Object o = null; + if(cell == null){ + o = ""; + return o; + } + int cellType = cell.getCellType(); + switch (cellType) { + case XSSFCell.CELL_TYPE_BLANK: + o = ""; + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + o = cell.getBooleanCellValue(); + break; + case XSSFCell.CELL_TYPE_ERROR: + o = "Bad value!"; + break; + case XSSFCell.CELL_TYPE_NUMERIC: +// o = new BigDecimal(String.valueOf(cell.getNumericCellValue())).stripTrailingZeros().toPlainString(); + o = cell.getNumericCellValue(); + o = doubleTwoString((double) o); + if(first){ + o = new BigDecimal((String)o).stripTrailingZeros().toPlainString(); + } + break; + default: + o = cell.getRichStringCellValue().getString(); + } + return o; + } + public String doubleTwoString(double o){ + DecimalFormat df = new DecimalFormat("#.00"); + String str = df.format(o); + return str; + } + + + /** + * ȡģļ + * @param session session + * @param fileName ļ + * @param Filetype ļ + * @return + */ + public File getFile(TCSession session) { + try { + TCComponentDataset dat = null; + TCComponentItemRevision fileItemLastRev = (TCComponentItemRevision) formComp.getReferenceProperty("item_revision"); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" : comps.length); + // IMAN_specificationϵµж + for (TCComponent compt : comps) { + // ȡ + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // ж + if (type.equals("MSExcelX")) { + System.out.println("ȷ"); + dat = (TCComponentDataset)compt; + } + } + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("δҵļ"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + private File getModel(TCSession session) throws Exception { + TCPreferenceService service = session.getPreferenceService(); + String modelID = service.getStringValue(ACFinalUtil.EXCEL_MODEL_FILE); + if(modelID==null || modelID.isEmpty()) + throw new Exception("δҵѡ:"+ACFinalUtil.EXCEL_MODEL_FILE); + TCComponentDataset dat1 = null; + TCComponentItem modelItem = ((TCComponentItemType)session.getTypeService().getTypeComponent("Item")).findItems(modelID)[0]; + TCComponent[] comps = modelItem.getLatestItemRevision().getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" : comps.length); + // IMAN_specificationϵµж + for (TCComponent compt : comps) { + // ж + if (compt.getType().equals("MSExcelX")) { + System.out.println("ȷ"); + dat1 = (TCComponentDataset)compt; + } + } + if(dat1!=null){ + TCComponentTcFile[] tcFile = dat1.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + throw new Exception("δģļ"); + } + else + { +// File file = tcFile[0].getFmsFile(); + File file = tcFile[0].getFile(System.getProperty("java.io.tmpdir")); + if(file.exists()) + file.delete(); + return tcFile[0].getFile(System.getProperty("java.io.tmpdir")); + } + }else{ + throw new Exception("δģļ"); + } + } + + /** + * ȡµѷİ汾 + * @param item + * @return + */ + public TCComponentItemRevision getLastItemRevision(TCComponentItem item) { + try { + TCComponentItemRevision[] items = item.getReleasedItemRevisions(); + int revId = 0; + TCComponentItemRevision itemRevision = null; + for (int i = 0; i < items.length; i++) { + String revisionId = items[i].getStringProperty("item_revision_id"); + System.out.println(revisionId); + if(Integer.parseInt(revisionId) >= revId ) + { + itemRevision = items[i]; + revId = Integer.parseInt(revisionId); + } + } + return itemRevision; + + } catch (NumberFormatException e) { + TCComponentItemRevision[] items; + try { + items = item.getReleasedItemRevisions(); + String revId = "A"; + TCComponentItemRevision itemRevision = null; + for (int i = 0; i < items.length; i++) { + String revisionId = items[i].getStringProperty("item_revision_id"); + if(revisionId.compareTo(revId) >= 0){ + System.out.println("revisionId--"+revisionId); + itemRevision = items[i]; + revId = revisionId; + } + } + return itemRevision; + } catch (Exception e1) { + e1.printStackTrace(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * ǩ + * + */ + public void saveWLProps() + { + + if(saveValueLists == null) + { + System.out.println("бΪ"); + return; + } + //ͬ + if(saveValueLists.size()<1 && isOK) + { + saveValueLists.addAll(valueLists); + saveWLProps2(); + return; + } + //һ + if(saveValueLists.size()>0&&isOK_one){ + saveWLProps2(); + isOK_one = false; + return; + + } + saveWLProps2(); + } + + + public void saveWLProps2(){ + System.out.println("saveWLProps2"); + TableCellEditor tablecelleditor = partsTable.getCellEditor(); + if(tablecelleditor != null) + { + tablecelleditor.stopCellEditing(); + } + Map id_cost = new HashMap(); + try { + for (int i = 0; i < dtm.getRowCount(); i++) { + Object v = dtm.getValueAt(i, 9); +// System.out.println(dtm.getValueAt(i, 6)); + Double cellvalue = Double.valueOf(v==null||v.toString().trim().equals("")?"0.00":v.toString()); + id_cost.put(dtm.getValueAt(i, 1).toString(), cellvalue); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("ɱд쳣","ʾ",MessageBox.INFORMATION); + return; + } + String valueStrs0[] = new String[saveValueLists.size()]; + String valueStrs1[] = new String[saveValueLists.size()]; + double valueStrs2[] = new double[saveValueLists.size()]; + String valueStrs3[] = new String[saveValueLists.size()]; + String valueStrs5[] = new String[saveValueLists.size()]; + double valueStrs7[] = new double[saveValueLists.size()]; + String valueStrs9[] = new String[saveValueLists.size()]; + + String valueStrs4[] = new String[saveValueLists.size()]; + String valueStrs6[] = new String[saveValueLists.size()]; + String valueStrs8[] = new String[saveValueLists.size()]; + double valueStrs11[] = new double[saveValueLists.size()]; + + + for(int i = 0; i < saveValueLists.size(); i++) + { + SysCatalogRevisionMasterBean bean = (SysCatalogRevisionMasterBean)saveValueLists.get(i); + valueStrs0[i] = bean.getYsr8_ID(); + valueStrs1[i] = bean.getYsr8_object(); + valueStrs2[i] = Double.valueOf(bean.getYsr8_Quantity()); + valueStrs3[i] = bean.getYsr8_Category(); + valueStrs5[i] = bean.getYsr8_Electric(); + //valueStrs7[i] = Double.valueOf(bean.getYsr8_Cost().equals("")?"0.00":bean.getYsr8_Cost()); + valueStrs7[i] = id_cost.get(bean.getYsr8_ID()); + valueStrs9[i] = bean.getYsr8_Cancel(); + + valueStrs4[i] = bean.getYsr8_Designer()==null?"":bean.getYsr8_Designer(); + valueStrs6[i] = bean.getYsr8_SubProjectType()==null?"":bean.getYsr8_SubProjectType(); + valueStrs8[i] = bean.getYsr8_CustomPartCode()==null?"":bean.getYsr8_CustomPartCode(); + + if(bean.getYsr8_PlanWorkTime() == null || bean.getYsr8_PlanWorkTime().isEmpty() || bean.getYsr8_PlanWorkTime().equals("")) { + valueStrs11[i] = 0.00; + }else { + valueStrs11[i] = Double.valueOf(bean.getYsr8_PlanWorkTime()); + } + } + + try + { + if(propertiesArray[0] != null) + propertiesArray[0].setStringValueArray(valueStrs0); + if(propertiesArray[1] != null) + propertiesArray[1].setStringValueArray(valueStrs1); + if(propertiesArray[2] != null) + propertiesArray[2].setDoubleValueArray(valueStrs2); + if(propertiesArray[4] != null) + propertiesArray[4].setStringValueArray(valueStrs3); + if(propertiesArray[6] != null) + propertiesArray[6].setStringValueArray(valueStrs5); + if(propertiesArray[8] != null) + propertiesArray[8].setDoubleValueArray(valueStrs7); + if(propertiesArray[9] != null) + propertiesArray[9].setStringValueArray(valueStrs9); + + if(propertiesArray[3] != null) + propertiesArray[3].setStringValueArray(valueStrs4);; + if(propertiesArray[5] != null) + propertiesArray[5].setStringValueArray(valueStrs6); + if(propertiesArray[7] != null) + propertiesArray[7].setStringValueArray(valueStrs8); + if(propertiesArray[10] != null) + propertiesArray[10].setDoubleValueArray(valueStrs11); + + formComp.lock(); + formComp.setTCProperties(propertiesArray); + formComp.save(); + formComp.unlock(); + //saveValueLists.clear(); + }catch(Exception e1) { + e1.printStackTrace(); + } + } +// @Override +// public boolean checkForSave(Object arg0) { +// +// return false; +// } +// + @Override + public void save() { + System.out.println(""); + saveWLProps(); + isCheckOut = false; + //isAddAll=1; + super.save(); + } + @Override + public void saveRendering() { + System.out.println("ǩ"); + saveWLProps(); + isCheckOut = false; + } + + @Override + public boolean isRenderingModified() { + //saveWLProps(); + if(isCheckOut){ + //System.out.println("鿴"); + return true; + } + return false; + } + + @Override + public void setRenderingReadWrite() { + + super.setRenderingReadWrite(); + } + + @Override + public void setRenderingReadOnly() { + super.setRenderingReadOnly(); + impButton.setEnabled(true); + } + + + + /** + * ñͷıɫ + * @param table + */ + public static void setTableHeadColor(JTable table, Color color){ + table.getTableHeader().setBackground(color); + table.getTableHeader().setReorderingAllowed(false); + } +} diff --git a/src/com/connor/AC_01/TMomFormStyle.java b/src/com/connor/AC_01/TMomFormStyle.java new file mode 100644 index 0000000..30aaa57 --- /dev/null +++ b/src/com/connor/AC_01/TMomFormStyle.java @@ -0,0 +1,678 @@ +//package com.connor.AC_01; +// +///*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. +////Jad home page: http://www.kpdus.com/jad.html +////Decompiler options: packimports(3) radix(10) lradix(10) +////Source File Name: TMomFormStyle.java +// +// +//import com.connor.dongmu.plm.bean.TMomProcessBean; +//import com.connor.dongmu.plm.util.TMomFinalUtil; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCProperty; +//import com.teamcenter.rac.stylesheet.AbstractRendering; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.rac.util.PropertyLayout; +//import java.awt.BorderLayout; +//import java.awt.Color; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Toolkit; +//import java.awt.datatransfer.Clipboard; +//import java.awt.datatransfer.StringSelection; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.KeyEvent; +//import java.awt.event.KeyListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.io.PrintStream; +//import java.util.ArrayList; +//import java.util.HashMap; +//import javax.swing.JButton; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTabbedPane; +//import javax.swing.JTable; +//import javax.swing.JTextField; +//import javax.swing.JTree; +//import javax.swing.JViewport; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.table.TableColumn; +//import javax.swing.table.TableColumnModel; +//import javax.swing.table.TableModel; +// +////Referenced classes of package com.connor.dongmu.plm.handlers.tmom005: +//// TableCellTextAreaRenderer +// +//public class TMomFormStyle extends AbstractRendering +// implements ActionListener, MouseListener, KeyListener +//{ +// private class showERPCountDialog extends AbstractAIFDialog +// { +// +// public void init() +// { +// setTitle("\u7269\u6599\u6D4F\u89C8"); +// setPreferredSize(new Dimension(900, 150)); +// table = getjTable(table, defaultTM, ckNames, ckCounts); +// panel = new JPanel(new BorderLayout()); +// panel2 = new JPanel(new FlowLayout()); +// panel3 = new JPanel(new BorderLayout()); +// simpleCopyButton = new JButton("\u590D\u5236\u5355\u4E2A\u5E93\u5B58"); +// simpleCopyButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// simpleCopyAction(e); +// } +// +// final showERPCountDialog this$1; +// +// +// { +// this$1 = showERPCountDialog.this; +// +// } +// } +//); +// copyButton = new JButton("\u590D\u5236\u5168\u90E8\u5E93\u5B58"); +// copyButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// totleCopyAction(e); +// } +// +// final showERPCountDialog this$1; +// +// +// { +// this$1 = showERPCountDialog.this; +// +// } +// } +//); +// closeButton = new JButton("\u5173\u95ED"); +// closeButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// closeAction(e); +// } +// +// final showERPCountDialog this$1; +// +// +// { +// this$1 = showERPCountDialog.this; +// +// } +// } +//); +// panel2.add(simpleCopyButton); +// panel2.add(copyButton); +// panel2.add(closeButton); +// panel3.add(new JScrollPane(table), "Center"); +// panel.add(panel2, "South"); +// panel.add(panel3, "Center"); +// add(panel, "Center"); +// pack(); +// centerToScreen(); +// showDialog(); +// } +// +// private void simpleCopyAction(ActionEvent e) +// { +// int colIndex = table.getSelectedColumn(); +// if(colIndex != -1) +// setClipboard((new StringBuilder()).append(ckCounts[0][colIndex]).toString()); +// } +// +// private void totleCopyAction(ActionEvent e) +// { +// StringBuffer sb = new StringBuffer(); +// for(int i = 0; i < ckNames.length; i++) +// { +// sb.append(ckNames[i]); +// if(i != ckNames.length - 1) +// sb.append("|"); +// } +// +// sb.append("\r\n"); +// for(int i = 0; i < ckCounts[0].length; i++) +// { +// sb.append(ckCounts[0][i]); +// if(i != ckCounts[0].length - 1) +// sb.append("|"); +// } +// +// setClipboard(sb.toString()); +// } +// +// private void closeAction(ActionEvent e) +// { +// dispose(); +// } +// +// private Object ckNames[]; +// private Object ckCounts[][]; +// private String wlCode; +// private JPanel panel; +// private JPanel panel2; +// private JPanel panel3; +// private JButton simpleCopyButton; +// private JButton copyButton; +// private JButton closeButton; +// private JTable table; +// private DefaultTableModel defaultTM; +// final TMomFormStyle this$0; +// +// +// +// +// public showERPCountDialog(String wlCode, Object ckNames[], Object ckCounts[][]) +// { +// this$0 = TMomFormStyle.this; +// +// this.wlCode = wlCode; +// this.ckNames = ckNames; +// this.ckCounts = ckCounts; +// init(); +// } +// } +// +// private class writeWLCodeDialog extends AbstractAIFDialog +// { +// +// public void init() +// { +// System.out.println("\u521D\u59CB\u5316\u754C\u9762"); +// setTitle("\u8BF7\u8F93\u5165\u5DE5\u827A\u4FE1\u606F"); +// setPreferredSize(new Dimension(300, 130)); +// lable = new JLabel("\u7269\u6599\u7F16\u7801\uFF1A"); +// textField = new JTextField(24); +// panel = new JPanel(new BorderLayout()); +// panel2 = new JPanel(new FlowLayout()); +// panel3 = new JPanel(new FlowLayout()); +// okButton = new JButton("\u786E\u5B9A"); +// okButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// okAction(e); +// } +// +// final writeWLCodeDialog this$1; +// +// +// { +// this$1 = writeWLCodeDialog.this; +// +// } +// } +//); +// celButton = new JButton("\u53D6\u6D88"); +// celButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// celAction(e); +// } +// +// final writeWLCodeDialog this$1; +// +// +// { +// this$1 = writeWLCodeDialog.this; +// +// } +// } +//); +// panel2.add(lable); +// panel2.add(textField); +// panel3.add(okButton); +// panel3.add(celButton); +// panel.add(panel3, "South"); +// panel.add(panel2, "Center"); +// add(panel, "Center"); +// pack(); +// centerToScreen(); +// showDialog(); +// } +// +// private void okAction(ActionEvent actionevent) +// { +// } +// +// private void celAction(ActionEvent e) +// { +// dispose(); +// } +// +// private JPanel panel; +// private JPanel panel2; +// private JPanel panel3; +// private JLabel lable; +// private JTextField textField; +// private JButton okButton; +// private JButton celButton; +// final TMomFormStyle this$0; +// +// +// +// public writeWLCodeDialog() +// { +// this$0 = TMomFormStyle.this; +// +// init(); +// } +// } +// +// +// public TMomFormStyle(TCComponent arg0) +// throws Exception +// { +// super(arg0); +// recordIndex = 0; +// System.out.println("++++++++++++++++++++++++++++++++"); +// formComp = arg0; +// loadRendering(); +// } +// +// public void getFormVlue() +// { +// valueLists = new ArrayList(); +// try +// { +// properties = formComp.getTCProperties(TMomFinalUtil.TM2_PRICE_PROP_NAMES); +// propertiesArray = formComp.getTCProperties(TMomFinalUtil.TM2_PROCESS_PROP_NAMES); +// if(propertiesArray != null) +// { +// String valueStrs0[] = propertiesArray[0] != null ? propertiesArray[0].getStringArrayValue() : new String[0]; +// String valueStrs1[] = propertiesArray[1] != null ? propertiesArray[1].getStringArrayValue() : new String[0]; +// String valueStrs2[] = propertiesArray[2] != null ? propertiesArray[2].getStringArrayValue() : new String[0]; +// String valueStrs3[] = propertiesArray[3] != null ? propertiesArray[3].getStringArrayValue() : new String[0]; +// String valueStrs4[] = propertiesArray[4] != null ? propertiesArray[4].getStringArrayValue() : new String[0]; +// String valueStrs5[] = propertiesArray[5] != null ? propertiesArray[5].getStringArrayValue() : new String[0]; +// String valueStrs6[] = propertiesArray[6] != null ? propertiesArray[6].getStringArrayValue() : new String[0]; +// if(valueStrs0.length == valueStrs1.length && valueStrs0.length == valueStrs2.length && valueStrs0.length == valueStrs3.length && valueStrs0.length == valueStrs4.length && valueStrs0.length == valueStrs5.length && valueStrs0.length == valueStrs6.length && valueStrs0.length != 0) +// { +// for(int i = 0; i < valueStrs0.length; i++) +// { +// TMomProcessBean bean = new TMomProcessBean(); +// bean.setTm2_DocLineNo(valueStrs0[i]); +// bean.setTm2_ProjectNam(valueStrs1[i]); +// bean.setTm2_ProjectFee(valueStrs2[i]); +// bean.setTm2_ProjectMark(valueStrs3[i]); +// bean.setTm2_ProjectEqui(valueStrs4[i]); +// bean.setTm2_ProjectSuggest(valueStrs5[i]); +// bean.setTm2_ONum(valueStrs6[i]); +// valueLists.add(bean); +// } +// +// } +// } +// if(properties != null) +// { +// propTexts = new JTextField[properties.length]; +// priceValues = new String[properties.length]; +// for(int i = 0; i < properties.length; i++) +// priceValues[i] = properties[i] != null ? properties[i].getStringValue() : ""; +// +// } +// } +// catch(TCException e) +// { +// e.printStackTrace(); +// } +// } +// +// public void saveWLProps() +// { +// if(valueLists == null) +// { +// System.out.println("\u5C5E\u6027\u5217\u8868\u4E3A\u7A7A"); +// return; +// } +// String valueStrs0[] = new String[valueLists.size()]; +// String valueStrs1[] = new String[valueLists.size()]; +// String valueStrs2[] = new String[valueLists.size()]; +// String valueStrs3[] = new String[valueLists.size()]; +// String valueStrs4[] = new String[valueLists.size()]; +// String valueStrs5[] = new String[valueLists.size()]; +// String valueStrs6[] = new String[valueLists.size()]; +// for(int i = 0; i < valueLists.size(); i++) +// { +// TMomProcessBean bean = (TMomProcessBean)valueLists.get(i); +// valueStrs0[i] = bean.getTm2_DocLineNo(); +// valueStrs1[i] = bean.getTm2_ProjectNam(); +// valueStrs2[i] = bean.getTm2_ProjectFee(); +// valueStrs3[i] = bean.getTm2_ProjectMark(); +// valueStrs4[i] = bean.getTm2_ProjectEqui(); +// valueStrs5[i] = bean.getTm2_ProjectSuggest(); +// valueStrs6[i] = bean.getTm2_ONum(); +// } +// +// try +// { +// if(propertiesArray[0] != null) +// propertiesArray[0].setStringValueArray(valueStrs0); +// if(propertiesArray[1] != null) +// propertiesArray[1].setStringValueArray(valueStrs1); +// if(propertiesArray[2] != null) +// propertiesArray[2].setStringValueArray(valueStrs2); +// if(propertiesArray[3] != null) +// propertiesArray[3].setStringValueArray(valueStrs3); +// if(propertiesArray[4] != null) +// propertiesArray[4].setStringValueArray(valueStrs4); +// if(propertiesArray[5] != null) +// propertiesArray[5].setStringValueArray(valueStrs5); +// if(propertiesArray[6] != null) +// propertiesArray[6].setStringValueArray(valueStrs6); +// for(int i = 0; i < properties.length; i++) +// properties[i].setStringValue(priceValues[i]); +// +// formComp.setTCProperties(propertiesArray); +// formComp.setTCProperties(properties); +// } +// catch(TCException e) +// { +// e.printStackTrace(); +// } +// catch(Exception e1) +// { +// e1.printStackTrace(); +// } +// } +// +// public boolean checkForSave(Object obj) +// { +// saveWLProps(); +// System.out.println("\u7B7E\u5165\u5E76\u4FDD\u5B58"); +// return super.checkForSave(obj); +// } +// +// public void save() +// { +// saveWLProps(); +// System.out.println("\u4FDD\u5B58"); +// super.save(); +// } +// +// public void init() +// { +// System.out.println("====>>>> \u521D\u59CB\u5316\u754C\u9762 <1>"); +// clorMap = new HashMap(); +// fontMap = new HashMap(); +// valueLists = new ArrayList(); +// getFormVlue(); +// setLayout(new BorderLayout()); +// setBackground(Color.WHITE); +// rootPanel = new JPanel(new BorderLayout()); +// addButton = new JButton("\u6DFB\u52A0"); +// addButton.setEnabled(true); +// delButton = new JButton("\u5220\u9664"); +// delButton.setEnabled(true); +// emptyLable = new JLabel(" "); +// addButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// addRow(e); +// } +// +// final TMomFormStyle this$0; +// +// +// { +// this$0 = TMomFormStyle.this; +// +// } +// } +//); +// delButton.addActionListener(new ActionListener() { +// +// public void actionPerformed(ActionEvent e) +// { +// delRow(e); +// } +// +// final TMomFormStyle this$0; +// +// +// { +// this$0 = TMomFormStyle.this; +// +// } +// } +//); +// partsTable = getjTable(partsTable, dtm, titleNames, getValues(valueLists)); +// topPanel = new JPanel(new BorderLayout()); +// scrollPanel = new JScrollPane(); +// scrollPanel.getViewport().add(partsTable, null); +// scrollPanel.validate(); +// topPanel.add("Center", scrollPanel); +// buttomPanel = new JPanel(new FlowLayout()); +// buttomPanel.add(addButton); +// buttomPanel.add(emptyLable); +// buttomPanel.add(delButton); +// rootPanel = new JPanel(new BorderLayout()); +// rootPanel.add("Center", topPanel); +// rootPanel.add("South", buttomPanel); +// JPanel firstPanel = new JPanel(new PropertyLayout()); +// for(int i = 0; i < TMomFinalUtil.TM2_PRICE_PROP_NAMES_ZH_CH.length; i += 3) +// { +// propTexts[i] = new JTextField(24); +// propTexts[i].setText(priceValues[i]); +// firstPanel.add((new StringBuilder(String.valueOf(i / 3 + 1))).append(".1.right.top.preferred.preferred").toString(), new JLabel(TMomFinalUtil.TM2_PRICE_PROP_NAMES_ZH_CH[i])); +// firstPanel.add((new StringBuilder(String.valueOf(i / 3 + 1))).append(".2.left.top.preferred.preferred").toString(), propTexts[i]); +// if(i + 1 == TMomFinalUtil.TM2_PRICE_PROP_NAMES_ZH_CH.length) +// break; +// propTexts[i + 1] = new JTextField(24); +// propTexts[i + 1].setText(priceValues[i + 1]); +// firstPanel.add((new StringBuilder(String.valueOf(i / 3 + 1))).append(".3.right.top.preferred.preferred").toString(), new JLabel(TMomFinalUtil.TM2_PRICE_PROP_NAMES_ZH_CH[i + 1])); +// firstPanel.add((new StringBuilder(String.valueOf(i / 3 + 1))).append(".4.left.top.preferred.preferred").toString(), propTexts[i + 1]); +// if(i + 2 == TMomFinalUtil.TM2_PRICE_PROP_NAMES_ZH_CH.length) +// break; +// propTexts[i + 2] = new JTextField(24); +// propTexts[i + 2].setText(priceValues[i + 2]); +// firstPanel.add((new StringBuilder(String.valueOf(i / 3 + 1))).append(".5.right.top.preferred.preferred").toString(), new JLabel(TMomFinalUtil.TM2_PRICE_PROP_NAMES_ZH_CH[i + 2])); +// firstPanel.add((new StringBuilder(String.valueOf(i / 3 + 1))).append(".6.left.top.preferred.preferred").toString(), propTexts[i + 2]); +// } +// +// JTabbedPane tabPane = new JTabbedPane(); +// tabPane.add("\u62A5\u4EF7\u4FE1\u606F", new JScrollPane(firstPanel)); +// tabPane.add("\u5DE5\u827A\u4FE1\u606F", new JScrollPane(rootPanel)); +// add(tabPane, "Center"); +// } +// +// private void addRow(ActionEvent e) +// { +// new writeWLCodeDialog(); +// } +// +// private void delRow(ActionEvent e) +// { +// int index = partsTable.getSelectedRow(); +// if(index == -1) +// { +// MessageBox.post("\u8BF7\u9009\u62E9\u8868\u683C\u540E\u518D\u6267\u884C\u5220\u9664\u64CD\u4F5C\uFF01", "Warning", 4); +// return; +// } else +// { +// valueLists.remove(index); +// dtm.removeRow(index); +// dtm.fireTableStructureChanged(); +// dtm.fireTableDataChanged(); +// scrollPanel.validate(); +// return; +// } +// } +// +// public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object titleNames[], Object values[][]) +// { +// int simpleLen = 105; +// int totleLen = 900; +// if(partsTable == null) +// { +// partsTable = new JTable(getTableModel(dtm, titleNames, values)) { +// +// public boolean isCellEditable(int row, int column) +// { +// return false; +// } +// +// final TMomFormStyle this$0; +// +// +// { +// this$0 = TMomFormStyle.this; +// +// } +// } +//; +// partsTable.setDefaultRenderer(Object.class, new TableCellTextAreaRenderer()); +// if(simpleLen * titleNames.length >= totleLen) +// { +// for(int i = 0; i < titleNames.length; i++) +// partsTable.getColumnModel().getColumn(i).setPreferredWidth(105); +// +// partsTable.setAutoResizeMode(0); +// } else +// { +// partsTable.setAutoResizeMode(1); +// } +// } +// return partsTable; +// } +// +// public DefaultTableModel getTableModel(DefaultTableModel dtm, Object columNameObjects[], Object objects[][]) +// { +// if(dtm == null) +// dtm = new DefaultTableModel(objects, columNameObjects); +// return dtm; +// } +// +// public java.util.List getAllChildItemId() +// { +// java.util.List idList = new ArrayList(); +// return idList; +// } +// +// public Object[][] getValues(java.util.List beanList) +// { +// Object objects[][] = new Object[beanList.size()][7]; +// for(int i = 0; i < beanList.size(); i++) +// { +// objects[i][0] = ((TMomProcessBean)beanList.get(i)).getTm2_DocLineNo(); +// objects[i][1] = ((TMomProcessBean)beanList.get(i)).getTm2_ProjectNam(); +// objects[i][2] = ((TMomProcessBean)beanList.get(i)).getTm2_ProjectFee(); +// objects[i][3] = ((TMomProcessBean)beanList.get(i)).getTm2_ProjectMark(); +// objects[i][4] = ((TMomProcessBean)beanList.get(i)).getTm2_ProjectEqui(); +// objects[i][5] = ((TMomProcessBean)beanList.get(i)).getTm2_ProjectSuggest(); +// objects[i][6] = ((TMomProcessBean)beanList.get(i)).getTm2_ONum(); +// } +// +// return objects; +// } +// +// public void setClipboard(String str) +// { +// StringSelection ss = new StringSelection(str); +// Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null); +// } +// +// public void actionPerformed(ActionEvent actionevent) +// { +// } +// +// public void loadRendering() +// throws TCException +// { +// init(); +// } +// +// public void saveRendering() +// { +// } +// +// public static void main(String args1[]) +// { +// } +// +// public void keyTyped(KeyEvent keyevent) +// { +// } +// +// public void keyPressed(KeyEvent e) +// { +// int colIndex = partsTable.getSelectedColumn(); +// int rowIndex = partsTable.getSelectedRow(); +// if(colIndex == 0 && rowIndex == partsTable.getRowCount() - 1) +// e.getKeyCode(); +// } +// +// public void keyReleased(KeyEvent keyevent) +// { +// } +// +// public void mouseClicked(MouseEvent mouseevent) +// { +// } +// +// public void mousePressed(MouseEvent mouseevent) +// { +// } +// +// public void mouseReleased(MouseEvent mouseevent) +// { +// } +// +// public void mouseEntered(MouseEvent mouseevent) +// { +// } +// +// public void mouseExited(MouseEvent mouseevent) +// { +// } +// +// private JPanel rootPanel; +// private JPanel topPanel; +// private JPanel buttomPanel; +// private JScrollPane scrollPanel; +// private JLabel emptyLable; +// private JButton addButton; +// private JButton delButton; +// private JTable partsTable; +// private Object titleNames[] = { +// "\u884C\u53F7", "\u5DE5\u5E8F", "\u5DE5\u5E8F\u8D39", "\u5DE5\u5E8F\u5907\u6CE8", "\u5DE5\u5E8F\u8BBE\u5907", "\u9879\u76EE\u5EFA\u8BAE", "\u6392\u5E8F\u53F7" +// }; +// private HashMap clorMap; +// private HashMap fontMap; +// private String priceValues[]; +// private java.util.List valueLists; +// private DefaultTableModel dtm; +// private int recordIndex; +// private TCComponent formComp; +// private TCProperty properties[]; +// private TCProperty propertiesArray[]; +// private JTextField propTexts[]; +// private JTree tree; +// +// +//} +// +// +///* +// DECOMPILATION REPORT +// +// Decompiled from: Z:\peixun\eclipse\workspace\com.connor.ac\aclib\com.connor.dongmu.plm_1.0.0.jar +// Total time: 103 ms +// Jad reported messages/errors: +// Exit status: 0 +// Caught exceptions: +//*/ \ No newline at end of file diff --git a/src/com/connor/AC_01/TableCellTextAreaRenderer.java b/src/com/connor/AC_01/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..9e4e4d7 --- /dev/null +++ b/src/com/connor/AC_01/TableCellTextAreaRenderer.java @@ -0,0 +1,78 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. +// Jad home page: http://www.kpdus.com/jad.html +// Decompiler options: packimports(3) radix(10) lradix(10) +// Source File Name: TMomFormStyle.java + +package com.connor.AC_01; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.table.*; + +public class TableCellTextAreaRenderer extends JTextArea + implements TableCellRenderer +{ + + private int rowIndex; + private Color color; + private boolean isSet = false; + public TableCellTextAreaRenderer() + { + setLineWrap(true); + setWrapStyleWord(true); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) + { + + if(isSet){ + if (row == rowIndex) { + setBackground(color); + setForeground(Color.BLACK); + }else if(row > rowIndex){ + setBackground(Color.WHITE); + setForeground(Color.BLACK); + }else{ + setBackground(Color.WHITE); + setForeground(Color.BLACK); + } + } + int maxPreferredHeight = 0; + for(int i = 0; i < table.getColumnCount(); i++) + { + setText((new StringBuilder()).append(table.getValueAt(row, i)).toString()); + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, getPreferredSize().height); + } + + if(table.getRowHeight(row) != maxPreferredHeight) + table.setRowHeight(row, maxPreferredHeight); + setText(value != null ? value.toString() : ""); + return this; + } + + + public void setOneRowBackgroundColor(JTable partsTable, boolean table, final int rowIndex1, + final Color color1) { + isSet=table; + rowIndex = rowIndex1; + color = color1; + int columnCount = partsTable.getColumnCount(); + for (int i = 0; i < columnCount; i++) { + partsTable.getColumn(partsTable.getColumnName(i)).setCellRenderer(this); + } + } +} + + +/* + DECOMPILATION REPORT + + Decompiled from: Z:\peixun\eclipse\workspace\com.connor.ac\aclib\com.connor.dongmu.plm_1.0.0.jar + Total time: 57 ms + Jad reported messages/errors: + Exit status: 0 + Caught exceptions: +*/ diff --git a/src/com/connor/AC_05/ProblemReportImportAction.java b/src/com/connor/AC_05/ProblemReportImportAction.java new file mode 100644 index 0000000..7d4b873 --- /dev/null +++ b/src/com/connor/AC_05/ProblemReportImportAction.java @@ -0,0 +1,28 @@ +package com.connor.AC_05; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.kernel.TCSession; + +public class ProblemReportImportAction extends AbstractAIFAction { + private AbstractAIFApplication app; + private String commandName; + + public ProblemReportImportAction(AbstractAIFApplication app, String commandName) { + super(app, commandName); + this.app = app; + this.commandName = commandName; + } + @Override + public void run() { + //Command + ProblemReportImportCommand command = new ProblemReportImportCommand(this.app); + try { + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + +} diff --git a/src/com/connor/AC_05/ProblemReportImportCommand.java b/src/com/connor/AC_05/ProblemReportImportCommand.java new file mode 100644 index 0000000..a74c659 --- /dev/null +++ b/src/com/connor/AC_05/ProblemReportImportCommand.java @@ -0,0 +1,19 @@ +package com.connor.AC_05; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; + +public class ProblemReportImportCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + public ProblemReportImportCommand(AbstractAIFApplication app) { + this.app = app; + // TODO Auto-generated constructor stub + } + @Override + public void executeModal() throws Exception { + ProblemReportImportDialog dialog = new ProblemReportImportDialog(app); + new Thread(dialog) + .start(); + + } +} diff --git a/src/com/connor/AC_05/ProblemReportImportDialog.java b/src/com/connor/AC_05/ProblemReportImportDialog.java new file mode 100644 index 0000000..730790a --- /dev/null +++ b/src/com/connor/AC_05/ProblemReportImportDialog.java @@ -0,0 +1,234 @@ +package com.connor.AC_05; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +import com.connor.ac.util.ACFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.PropertyDateComponent; +import com.teamcenter.rac.util.MessageBox; + +public class ProblemReportImportDialog extends AbstractAIFDialog { + private AbstractAIFApplication app; + private TCSession session; + + private String url; + private String[] modelFiles; + + private TCComponentFolder targetFolder; + + private JButton b_reload; + private JButton b_imp; + private JButton b_cel; + protected JComboBox b_company; + protected DefaultTableModel tm_pro; + protected JTable t_pro; + + public String[] HEADER = new String[] { "", "ID", "Ҫ", "ûҪ","ύ", "ύ", "Ŀ", "ͼƬ˵", "˵", "ԭ(߱)","","ļƻʱ","ɹ","ɹƻʱ","ӹ","ӹƻʱ","ʵʩ","ʵʩƻʱ","״̬"}; + public int[] HEADERWIDTH = new int[] { 50, 100, 50, 100,50, 50, 100, 70, 100, 100, 80, 80, 80, 80, 80, 80, 80, 80 }; + + public ProblemReportImportDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) this.app.getSession(); + } + + @Override + public void run() { + try { + System.out.println("ʼִ"); + targetFolder = (TCComponentFolder)app.getTargetComponent(); + String folderName = targetFolder.getStringProperty("object_name"); + if(folderName.equals("6ⷴ")){ + System.out.println(targetFolder==null); + System.out.println(folderName); + if(targetFolder!=null){ +//-------------------------------------/------------------------------- + chooserLoading(); + showDialog(); +//-------------------------------------/------------------------------- + + } + }else { + MessageBox.post("ѡ\"6ⷴ\"ļ","ʾ",MessageBox.INFORMATION); + } + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post("ѡ\"6ⷴ\"ļ","ʾ",MessageBox.INFORMATION); + } + } + private void chooserLoading(){ + JFileChooser chooser = new JFileChooser(); + int statu = chooser.showOpenDialog(this); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if(statu==JFileChooser.APPROVE_OPTION){ + File f = chooser.getSelectedFile(); + this.url= f.getPath(); + initUI(); + } + } + + private void addListeners() { + + this.b_reload.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + }); + this.b_cel.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + }); + this.b_imp.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + }); + } + + private void initUI() { + this.setTitle("ҳ"); + this.setPreferredSize(new Dimension(1300, 400)); + this.setMinimumSize(new Dimension(800, 300)); + this.setLayout(new BorderLayout()); + JPanel jpa = initQueryPanel(); + JPanel jpa1 = initTablePanel(); + JPanel jpa2 = initBtnPanel(); + if(jpa!=null && jpa1!=null && jpa2!=null){ + this.add(BorderLayout.NORTH, jpa); + this.add(BorderLayout.CENTER, jpa1); + this.add(BorderLayout.SOUTH, jpa2); + } + } + private JPanel initBtnPanel() { + JPanel panel = new JPanel(); + Box b1=Box.createHorizontalBox(); //Box + panel.add(b1); +// b1.add(Box.createVerticalStrut(100)); + b1.add(Box.createHorizontalGlue()); + b_imp = new JButton("벢"); + b1.add(b_imp); + b1.add(Box.createHorizontalStrut(40)); //ӳΪ40ˮƽ + b_cel = new JButton("ȡ"); + b1.add(b_cel); + b1.add(Box.createHorizontalGlue()); + return panel; + } + + private JPanel initTablePanel() { + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); + tm_pro = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + + @Override + public Class getColumnClass(int columnIndex) { + if(columnIndex==0) { + return Double.class; + } + return super.getColumnClass(columnIndex); + } + + }; + t_pro = new JTable(tm_pro); + tm_pro.setDataVector(null, HEADER); + t_pro.getTableHeader().setReorderingAllowed(false); // вƶᷢת󣨵У + this.t_pro.setRowHeight(23); + this.t_pro.setAutoCreateRowSorter(true); + //TableRowSorter sorter=new TableRowSorter(tm_workflow); + //this.t_pro.setRowSorter(sorter); + // this.t_part.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + TableColumnModel colModel = this.t_pro.getColumnModel(); + int colCnt = HEADERWIDTH.length; + colModel.getColumn(0).setMaxWidth(HEADERWIDTH[0]); + for (int i = 0; i < colCnt; i++) { + colModel.getColumn(i).setPreferredWidth(HEADERWIDTH[i]); + } + JScrollPane scroll = new JScrollPane(t_pro); + panel.add(BorderLayout.CENTER, scroll); + return panel; + } + + private JPanel initQueryPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); + panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 7, 5)); + String folderProId = null; + try { + if(targetFolder!=null){ + folderProId = targetFolder.getStringProperty("project_ids"); + }else{ + MessageBox.post("δָĿ","ʾ",MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + JTextField xm_text = new JTextField(folderProId); + Dimension dim1 = new Dimension(150, 25); + xm_text.setPreferredSize(dim1); + xm_text.setEditable(false); + panel.add(new JLabel("Ŀ ")); + panel.add(xm_text); + + panel.add(new JLabel(" ģ ")); + TCPreferenceService service = session.getPreferenceService(); + modelFiles = service.getStringValues(ACFinalUtil.AC_Workflow_Temp_Name); + if(modelFiles==null){ + MessageBox.post("δAC_Workflow_Temp_Nameѡ","ʾ",MessageBox.INFORMATION); + modelFiles = new String[]{}; + } + for (int i = 0; i < modelFiles.length; i++) { + modelFiles[i] = modelFiles[i].split("=")[0]; + } + b_company = new JComboBox(modelFiles); + panel.add(b_company); + Dimension dim = new Dimension(80, 25); + + b_reload = new JButton("¼"); + b_reload.setPreferredSize(dim); + panel.add(b_reload); + return panel; + + } + +} diff --git a/src/com/connor/AC_05/ProblemReportImportHandler.java b/src/com/connor/AC_05/ProblemReportImportHandler.java new file mode 100644 index 0000000..71d884e --- /dev/null +++ b/src/com/connor/AC_05/ProblemReportImportHandler.java @@ -0,0 +1,28 @@ +package com.connor.AC_05; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class ProblemReportImportHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + String commandName = null; + try { + commandName = arg0.getCommand().getName(); + } catch (NotDefinedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + ProblemReportImportAction action = new ProblemReportImportAction(app, commandName); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/ac/Activator.java b/src/com/connor/ac/Activator.java new file mode 100644 index 0000000..a7046d7 --- /dev/null +++ b/src/com/connor/ac/Activator.java @@ -0,0 +1,61 @@ +package com.connor.ac; + +import org.eclipse.jface.resource.ImageDescriptor; +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.connor.ac"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + 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; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/src/com/connor/ac/bean/SysCatalogRevisionMasterBean.java b/src/com/connor/ac/bean/SysCatalogRevisionMasterBean.java new file mode 100644 index 0000000..713b854 --- /dev/null +++ b/src/com/connor/ac/bean/SysCatalogRevisionMasterBean.java @@ -0,0 +1,86 @@ +package com.connor.ac.bean; + +public class SysCatalogRevisionMasterBean { + private String ysr8_ID;// + private String ysr8_object;// + private String ysr8_Quantity;// + private String ysr8_Category;// + private String ysr8_Electric;//ǷҪ + private String ysr8_Cost;//ƻɱ + private String ysr8_Cancel;//ȡ + + + + private String ysr8_Designer;//Ա + private String ysr8_SubProjectType;// + private String ysr8_CustomPartCode;//ûͼ + private String ysr8_PlanWorkTime;//ƻʱ + public String getYsr8_Designer() { + return ysr8_Designer; + } + public void setYsr8_Designer(String ysr8_Designer) { + this.ysr8_Designer = ysr8_Designer; + } + public String getYsr8_SubProjectType() { + return ysr8_SubProjectType; + } + public void setYsr8_SubProjectType(String ysr8_SubProjectType) { + this.ysr8_SubProjectType = ysr8_SubProjectType; + } + public String getYsr8_CustomPartCode() { + return ysr8_CustomPartCode; + } + public void setYsr8_CustomPartCode(String ysr8_CustomPartCode) { + this.ysr8_CustomPartCode = ysr8_CustomPartCode; + } + public String getYsr8_PlanWorkTime() { + return ysr8_PlanWorkTime; + } + public void setYsr8_PlanWorkTime(String ysr8_PlanWorkTime) { + this.ysr8_PlanWorkTime = ysr8_PlanWorkTime; + } + public String getYsr8_ID() { + return ysr8_ID; + } + public void setYsr8_ID(String ysr8_ID) { + this.ysr8_ID = ysr8_ID; + } + public String getYsr8_object() { + return ysr8_object; + } + public void setYsr8_object(String ysr8_object) { + this.ysr8_object = ysr8_object; + } + public String getYsr8_Quantity() { + return ysr8_Quantity; + } + public void setYsr8_Quantity(String ysr8_Quantity) { + this.ysr8_Quantity = ysr8_Quantity; + } + public String getYsr8_Category() { + return ysr8_Category; + } + public void setYsr8_Category(String ysr8_Category) { + this.ysr8_Category = ysr8_Category; + } + public String getYsr8_Electric() { + return ysr8_Electric; + } + public void setYsr8_Electric(String ysr8_Electric) { + this.ysr8_Electric = ysr8_Electric; + } + public String getYsr8_Cost() { + return ysr8_Cost; + } + public void setYsr8_Cost(String ysr8_Cost) { + this.ysr8_Cost = ysr8_Cost; + } + public String getYsr8_Cancel() { + return ysr8_Cancel; + } + public void setYsr8_Cancel(String ysr8_Cancel) { + this.ysr8_Cancel = ysr8_Cancel; + } + + +} diff --git a/src/com/connor/ac/handlers/SampleHandler.java b/src/com/connor/ac/handlers/SampleHandler.java new file mode 100644 index 0000000..94e1347 --- /dev/null +++ b/src/com/connor/ac/handlers/SampleHandler.java @@ -0,0 +1,34 @@ +package com.connor.ac.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.jface.dialogs.MessageDialog; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class SampleHandler extends AbstractHandler { + /** + * The constructor. + */ + public SampleHandler() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); + MessageDialog.openInformation( + window.getShell(), + "Ac", + "Hello, Eclipse world"); + return null; + } +} diff --git a/src/com/connor/ac/util/ACFinalUtil.java b/src/com/connor/ac/util/ACFinalUtil.java new file mode 100644 index 0000000..7bcea52 --- /dev/null +++ b/src/com/connor/ac/util/ACFinalUtil.java @@ -0,0 +1,11 @@ +package com.connor.ac.util; + +public class ACFinalUtil { + public static final String AC_CATALOG_PROP_NAMES[] = { "ysr8_ID", "ysr8_object", "ysr8_Quantity","ysr8_Designer1", "ysr8_Category", "ysr8_SubProjectType1","ysr8_Electric", + "ysr8_CustomPartCode1","ysr8_Cost", "ysr8_Cancel","ysr8_PlanWorkTime" }; + public static final String AC_CATALOG_PROP_NAMES_ZH_CH[] = {}; + // ---------------ALL---------------------------------------------- + public static final String EXCEL_MODEL_FILE = "YSR_SysCatalog_Model";// Excelģļ + //public static final String AC_Workflow_Temp_Name = "AC_Workflow_Temp_Name";// ģ + public static final String AC_Workflow_Temp_Name = "Connor_Import_Item_Workflow";// ģ +} diff --git a/src/com/connor/ac/util/FileUtil.java b/src/com/connor/ac/util/FileUtil.java new file mode 100644 index 0000000..1a7fd3c --- /dev/null +++ b/src/com/connor/ac/util/FileUtil.java @@ -0,0 +1,455 @@ +package com.connor.ac.util; + +import java.awt.Frame; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.log4j.Logger; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +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.DateUtil; +import org.apache.poi.ss.usermodel.Name; +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.AreaReference; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class FileUtil { + + private static final Logger log = Logger.getLogger(FileUtil.class); + + public static void main(String[] args) { + String path = "E:\\TEMP\\newName.xlsx"; + File file = new File(path); + //getCellValueByName(file, "��Ŀ���"); + file = renameFile(file, "2"); + System.out.println(file.getName()); + } + + public static File renameFile(File file, String newName) { + String fileName = file.getName(); + String fileSuffix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); + + File newFile = new File(file.getParent() + "\\" + newName + fileSuffix); + file.renameTo(newFile); + return newFile; + } + + public static void writeToExcel(File file, JTable table) { + Integer colCount = table.getColumnCount() - 1; + Integer rowCount = table.getRowCount(); + try { + String fileName = file.getName().toLowerCase(); + Workbook workBook = fileName.endsWith("xls") ? new HSSFWorkbook() : new XSSFWorkbook(); + Sheet sheet = workBook.createSheet("sheet0"); + + for (int i = 0; i < rowCount; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < colCount; j++) { + row.createCell(j); + } + } + // ��ӱ��� + for (int i = 0; i < colCount; i++) { + sheet.getRow(0).getCell(i).setCellValue(table.getColumnName(i)); + } + + // ������� + for (int i = 1; i < rowCount; i++) { + for (int j = 0; j < colCount; j++) { + Object value = table.getValueAt(i, j); + sheet.getRow(i).getCell(j).setCellValue(value != null ? value + "" : ""); + } + } + + CellStyle style = workBook.createCellStyle(); + + for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) { + Row row = sheet.getRow(i); + row.setHeightInPoints(20f); + for (int k = 0; k < row.getLastCellNum(); k++) { + row.getCell(k).setCellStyle(style); + sheet.setColumnWidth(k, 5000); + } + } + sheet.setColumnWidth(0, 5000); + + FileOutputStream fileOut = new FileOutputStream(file); + workBook.write(fileOut); + fileOut.flush(); + fileOut.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static boolean writeToExcel(JDialog dialog, File file, JTable table, int col, Map propertiesMap) { + InputStream input = null; + FileOutputStream output = null; + try { + input = new FileInputStream(file); + XSSFWorkbook wb=new XSSFWorkbook(input); + XSSFSheet sheet=wb.getSheetAt(0); + XSSFRow row; + XSSFCell cell; + for (int i = 0; i < table.getRowCount(); i++) { + row=sheet.getRow(2+i); + if(row.getCell(col)==null) { + cell=row.createCell(col); + }else { + cell=row.getCell(col); + } + Object tableObj = table.getValueAt(i, col); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(tableObj==null?"":tableObj.toString()); + } + output=new FileOutputStream(file.getPath()); + wb.write(output); + } catch (Exception e1) { + e1.printStackTrace(); + return false; + }finally { + if(output!=null) { + try { + output.close(); + } catch (Exception e) { + JOptionPane.showMessageDialog(dialog, propertiesMap.get("error")+":"+e.getMessage(), + propertiesMap.get("error"), JOptionPane.WARNING_MESSAGE); + e.printStackTrace(); + return false; + } + } + if(input!=null) { + try { + input.close(); + } catch (Exception e) { + JOptionPane.showMessageDialog(dialog, propertiesMap.get("error")+":"+e.getMessage(), + propertiesMap.get("error"), JOptionPane.WARNING_MESSAGE); + e.printStackTrace(); + return false; + } + } + } + return true; + } + + public static String[] getCellValueByName(File file, String cellName) { + String[] cellValue = null; + try { + log.info("file:" + file.getAbsolutePath()); + FileInputStream fileIn = new FileInputStream(file); + boolean isExcelX = file.getName().matches("^.+\\.(?i)(xlsx)$"); + + Workbook workbook = isExcelX ? new XSSFWorkbook(fileIn) : new HSSFWorkbook(fileIn); + int nameIndex = workbook.getNameIndex(cellName); + log.info("nameIndex:" + nameIndex); + if (nameIndex < 0) { + return null; + } + Name name = workbook.getNameAt(nameIndex); + AreaReference aref = new AreaReference(name.getRefersToFormula()); + CellReference[] cellRef = aref.getAllReferencedCells(); + cellValue = new String[cellRef.length]; + for (int i = 0; i < cellRef.length; i++) { + Sheet sheet = workbook.getSheet(cellRef[i].getSheetName()); + Row row = sheet.getRow(cellRef[i].getRow()); + Cell cell = row.getCell(cellRef[i].getCol()); + cellValue[i] = cell.toString(); + log.info("cellValue:" + cellValue[i]); + } + } catch (IOException e) { + e.printStackTrace(); + } + return cellValue; + } + + public static List> readExcel(File file) { + try { + log.info("file:" + file.getAbsolutePath()); + FileInputStream fileIn = new FileInputStream(file); + boolean isExcelX = file.getName().matches("^.+\\.(?i)(xlsx)$"); + + Workbook workbook = isExcelX ? new XSSFWorkbook(fileIn) : new HSSFWorkbook(fileIn); + Sheet sheet = workbook.getSheetAt(0); + log.info("sheet:" + workbook.getSheetName(0)); + if (sheet.getRow(1) == null || sheet.getRow(1).getCell(0) == null) { + log.info("sheet.getRow(1).getCell(0) == null"); + return null; + } + + List> listDatas = new ArrayList>(); + + Integer totalRows = sheet.getPhysicalNumberOfRows(); + Integer totalCells = 0; + if (totalRows >= 1 && sheet.getRow(1) != null) { + totalCells = sheet.getRow(1).getPhysicalNumberOfCells(); + } + + for (int r = 0; r < totalRows; r++) { + Row row = sheet.getRow(r); + if (row == null) { + continue; + } + ArrayList listRows = new ArrayList(); + + for (short c = 0; c < totalCells; c++) { + Cell cell = row.getCell(c); + String cellValue = ""; + if (cell == null) { + cellValue = ""; + } else if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()) { + if (HSSFDateUtil.isCellDateFormatted(cell)) { + cellValue = String.valueOf(DateUtil.getExcelDate(cell.getDateCellValue())); + } else { + cellValue = getRightStr(cell.getNumericCellValue() + ""); + } + } else if (Cell.CELL_TYPE_STRING == cell.getCellType()) { + cellValue = cell.getStringCellValue().trim(); + } else if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) { + cellValue = cell.getBooleanCellValue() + ""; + } else { + cellValue = cell.toString().trim(); + } + listRows.add(cellValue); + } + listDatas.add(listRows); + } + fileIn.close(); + return listDatas; + } catch (IOException e) { + e.printStackTrace(); + JOptionPane.showMessageDialog(null, e.getMessage(), null, JOptionPane.ERROR_MESSAGE); + return null; + } + } + + private static String getRightStr(String sNum) { + DecimalFormat decimalFormat = new DecimalFormat("#.000000"); + String resultStr = decimalFormat.format(new Double(sNum)); + if (resultStr.matches("^[-+]?\\d+\\.[0]+$")) { + resultStr = resultStr.substring(0, resultStr.indexOf(".")); + } + return resultStr; + } + + public static File saveExcelChooser(File file) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); + File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + chooser.setCurrentDirectory(currentDir); + String saveType[] = { "xls", "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Microsoft Excel Worksheet(*.xls, *.xlsx)", saveType)); + chooser.setSelectedFile(file); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + } + return dir; + } + + public static File openFileChooser(String fileType) { + JFileChooser chooser = new JFileChooser(); + FileFilter fileFilter = getFilter(fileType); + chooser.setAcceptAllFileFilterUsed(false); + chooser.addChoosableFileFilter(fileFilter); + chooser.setMultiSelectionEnabled(false); + chooser.setFileFilter(fileFilter); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setSelectedFile(desktopDir); + File file = null; + int returnVal = chooser.showOpenDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + file = chooser.getSelectedFile(); + if (file == null) { + JOptionPane.showMessageDialog(new Frame(), "file not exists"); + return null; + } + } + return file; + } + + private static FileFilter getFilter(String fileType) { + FileFilter fileFilter = null; + if (fileType.equals("csv")) { + fileFilter = new FileFilter() { + + @Override + public boolean accept(File f) { + String fileName = f.getName(); + if (f.isDirectory() || fileName.endsWith(".csv")) + return true; + return false; + } + + @Override + public String getDescription() { + return "CSV(���ŷָ�)��*.csv��"; + } + }; + } else if (fileType.equals("excel")) { + fileFilter = new FileFilter() { + + @Override + public boolean accept(File f) { + String fileName = f.getName(); + if (f.isDirectory() || fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) + return true; + return false; + } + + @Override + public String getDescription() { + return "Microsoft Excel Worksheet(*.xls, *.xlsx)"; + } + }; + } + return fileFilter; + } + + public static void copyRow(XSSFWorkbook wb,XSSFRow fromRow,XSSFRow toRow,boolean copyValueFlag){ + for (Iterator cellIt = fromRow.cellIterator(); cellIt.hasNext();) { + XSSFCell tmpCell = (XSSFCell) cellIt.next(); + XSSFCell newCell = toRow.createCell(tmpCell.getColumnIndex()); + copyCell(wb, tmpCell, newCell, copyValueFlag); + } + } + public static void copyCell(XSSFWorkbook wb,XSSFCell srcCell, XSSFCell distCell, boolean copyValueFlag) { + XSSFCellStyle newstyle=wb.createCellStyle(); + copyCellStyle(srcCell.getCellStyle(), newstyle); +// distCell.setEncoding(srcCell.getEncoding()); + //样式 + distCell.setCellStyle(newstyle); + //评论 +// if (srcCell.getCellComment() != null) { +// distCell.setCellComment(srcCell.getCellComment()); +// } + // 不同数据类型处理 + int srcCellType = srcCell.getCellType(); +// if(srcCell.getColumnIndex()==8) +// System.out.println(srcCell.getColumnIndex()+"::"+srcCellType); + distCell.setCellType(srcCellType); + if (copyValueFlag) { + if (srcCellType == XSSFCell.CELL_TYPE_NUMERIC) { + if (HSSFDateUtil.isCellDateFormatted(srcCell)) { + distCell.setCellValue(srcCell.getDateCellValue()); + } else { + distCell.setCellValue(srcCell.getNumericCellValue()); + } + } else if (srcCellType == XSSFCell.CELL_TYPE_STRING) { + distCell.setCellValue(srcCell.getRichStringCellValue()); + } else if (srcCellType == XSSFCell.CELL_TYPE_BLANK) { + // nothing21 + } else if (srcCellType == XSSFCell.CELL_TYPE_BOOLEAN) { + distCell.setCellValue(srcCell.getBooleanCellValue()); + } else if (srcCellType == XSSFCell.CELL_TYPE_ERROR) { + distCell.setCellErrorValue(srcCell.getErrorCellValue()); + } else if (srcCellType == XSSFCell.CELL_TYPE_FORMULA) { + distCell.setCellFormula(srcCell.getCellFormula().replaceAll("2", distCell.getRowIndex()+1+"")); + System.out.println(distCell.getRowIndex()+","+distCell.getColumnIndex()+":"+distCell.getCellFormula()+"<<"+srcCell.getCellFormula()); + } else { // nothing29 + } + } + } + public static void copyCellStyle(XSSFCellStyle fromStyle, XSSFCellStyle toStyle) { + toStyle.setAlignment(fromStyle.getAlignment()); + //边框和边框颜色 + toStyle.setBorderBottom(fromStyle.getBorderBottom()); + toStyle.setBorderLeft(fromStyle.getBorderLeft()); + toStyle.setBorderRight(fromStyle.getBorderRight()); + toStyle.setBorderTop(fromStyle.getBorderTop()); + toStyle.setTopBorderColor(fromStyle.getTopBorderColor()); + toStyle.setBottomBorderColor(fromStyle.getBottomBorderColor()); + toStyle.setRightBorderColor(fromStyle.getRightBorderColor()); + toStyle.setLeftBorderColor(fromStyle.getLeftBorderColor()); + + //背景和前景 + toStyle.setFillBackgroundColor(fromStyle.getFillBackgroundColor()); + toStyle.setFillForegroundColor(fromStyle.getFillForegroundColor()); + + toStyle.setDataFormat(fromStyle.getDataFormat()); + toStyle.setFillPattern(fromStyle.getFillPattern()); +// toStyle.setFont(fromStyle.getFont(null)); + toStyle.setHidden(fromStyle.getHidden()); + toStyle.setIndention(fromStyle.getIndention());//首行缩进 + toStyle.setLocked(fromStyle.getLocked()); + toStyle.setRotation(fromStyle.getRotation());//旋转 + toStyle.setVerticalAlignment(fromStyle.getVerticalAlignment()); + toStyle.setWrapText(fromStyle.getWrapText()); + + } + public static void insertRow(Workbook wb, Sheet sheet, int starRow, int rows) { + sheet.shiftRows(starRow+1, sheet.getLastRowNum(), rows, true, false); + starRow = starRow - 1; + for (int i = 0; i < rows; i++) { + Row sourceRow = null; + Row targetRow = null; + Cell sourceCell = null; + Cell targetCell = null; + short m; + + starRow = starRow + 1; + sourceRow = sheet.getRow(starRow); + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + + for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + +// targetCell.setEncoding(sourceCell.getEncoding()); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + public static File saveExcelChooser(String defaultFile, String s) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + chooser.setSelectedFile(new File(defaultFile)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter(s, saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + if(dir.exists()) + dir.delete(); + System.out.println("saveExcelChooser1:" + dir.getPath()); + } + return dir; + } +} diff --git a/src/com/connor/ac/util/test.java b/src/com/connor/ac/util/test.java new file mode 100644 index 0000000..82932ab --- /dev/null +++ b/src/com/connor/ac/util/test.java @@ -0,0 +1,231 @@ +package com.connor.ac.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.WindowConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableModel; + + +import com.connor.AC_01.ACSysCatalogStyle; +import com.connor.ac.bean.SysCatalogRevisionMasterBean; +import com.teamcenter.rac.stylesheet.PropertyObjectLink; +import com.teamcenter.rac.util.MessageBox; + + + +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.JSONArray; +//import com.alibaba.fastjson.JSONObject; +// +// +//import java.io.*; + +public class test { + + static JTable table; + static String editValue = ""; + public static void main(String[] args) throws Exception { + + + + + + JFrame jf = new JFrame("Դ"); + jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + // + JPanel panel = new JPanel(); + + // ͷ + String[] columnNames = {"", "", "", "ѧ", "Ӣ", "ܷ"}; + + // + Object[][] rowData = { + {1, "", 80, 80, 80, 240}, + {2, "John", 70, 80, 90, 240}, + {3, "Sue", 70, 70, 70, 210}, + {4, "Jane", 80, 70, 60, 210}, + {5, "Joe_05", 80, 70, 60, 210}, + {6, "Joe_06", 80, 70, 60, 210}, + {7, "Joe_07", 80, 70, 60, 210}, + {8, "Joe_08", 80, 70, 60, 210}, + {9, "Joe_09", 80, 70, 60, 210}, + {10, "Joe_10", 80, 70, 60, 210}, + {11, "Joe_11", 80, 70, 60, 210}, + {12, "Joe_12", 80, 70, 60, 210}, + {13, "Joe_13", 80, 70, 60, 210}, + {14, "Joe_14", 80, 70, 60, 210}, + {15, "Joe_15", 80, 70, 60, 210}, + {16, "Joe_16", 80, 70, 60, 210}, + {17, "Joe_17", 80, 70, 60, 210}, + {18, "Joe_18", 80, 70, 60, 210}, + {19, "Joe_19", 80, 70, 60, 210}, + {20, "Joe_20", 80, 70, 60, 210} + }; + + // һָ ͷ + table = new JTable(rowData, columnNames); + + // ñɫ + table.setForeground(Color.BLACK); // ɫ + table.setFont(new Font(null, Font.PLAIN, 14)); // ʽ + table.setSelectionForeground(Color.DARK_GRAY); // ѡкɫ + table.setSelectionBackground(Color.LIGHT_GRAY); // ѡк屳 + table.setGridColor(Color.GRAY); // ɫ + + // ñͷ + table.getTableHeader().setFont(new Font(null, Font.BOLD, 14)); // ñͷʽ + table.getTableHeader().setForeground(Color.RED); // ñͷɫ + table.getTableHeader().setResizingAllowed(false); // òֶıп + table.getTableHeader().setReorderingAllowed(false); // ò϶ + + // и + table.setRowHeight(30); + + // һпΪ40 + table.getColumnModel().getColumn(0).setPreferredWidth(40); + + // ùӿڴСôСݣҪ϶ܿ + table.setPreferredScrollableViewportSize(new Dimension(400, 300)); + +// table. addFocusListener(new FocusListener() { +// public void focusLost(FocusEvent e) { +// //ʧȥʱ +// System.out.println("...."); +// +// } +// public void focusGained(FocusEvent e) { +// // ȡʱ +// System.out.println("....."); +// +// } +// }); + + table.getModel().addTableModelListener(new TableModelListener(){ + + @Override + public void tableChanged(TableModelEvent e) { + //int row=e.getFirstRow();//ıĵԪڵʼֵΪ0 + System.out.println("1213"); + } + }); + + // ŵ УͷԶӵ嶥 + JScrollPane scrollPane = new JScrollPane(table); + + // + panel.add(scrollPane); +JButton a = new JButton("ͬ"); +a.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + table.getCellEditor().stopCellEditing(); + TableModel model = table.getModel(); +// Map id_cost = new HashMap(); +// try { +// for (int i = 0; i < model.getRowCount(); i++) { +// //System.out.println(model.getValueAt(i, 5).toString()); +// Double.valueOf(model.getValueAt(i, 5).toString()==""?"0.00":model.getValueAt(i, 5).toString()); +// id_cost.put(model.getValueAt(i, 1).toString(), model.getValueAt(i, 5).toString()); +// } +// +// } catch (Exception e) { +// System.out.println("ɱд쳣"); +// } +// System.out.println(id_cost); + + Object[] props = { + 20, "Joe_20", 80, 70, 60, 210 + }; + + } +}); +panel.add(a); + // + jf.setContentPane(panel); + + jf.pack(); + jf.setLocationRelativeTo(null); + jf.setVisible(true); + + } +// public static String readJsonFile(String fileName) { +// String jsonStr = ""; +// try { +// File jsonFile = new File(fileName); +// FileReader fileReader = new FileReader(jsonFile); +// Reader reader = new InputStreamReader(new FileInputStream(jsonFile),"utf-8"); +// int ch = 0; +// StringBuffer sb = new StringBuffer(); +// while ((ch = reader.read()) != -1) { +// sb.append((char) ch); +// } +// fileReader.close(); +// reader.close(); +// jsonStr = sb.toString(); +// return jsonStr; +// } catch (IOException e) { +// e.printStackTrace(); +// return null; +// } +// } +// public static void readTxtFile(String filePath){ +// try { +// String encoding="utf-8"; +// File file=new File(filePath); +// if(file.isFile() && file.exists()){ //жļǷ +// InputStreamReader read = new InputStreamReader( +// new FileInputStream(file),encoding);//ǵʽ +// BufferedReader bufferedReader = new BufferedReader(read); +// String lineTxt = null; +// String lineTxtRo = ""; +// while((lineTxt = bufferedReader.readLine()) != null){ +// //System.out.println(lineTxt); +// lineTxtRo+=lineTxt; +// } +// System.out.println(lineTxtRo); +// read.close(); +// }else{ +// System.out.println("Ҳָļ"); +// } +// } catch (Exception e) { +// System.out.println("ȡļݳ"); +// e.printStackTrace(); +// } +// +// } +// +// public static void main(String[] args) { +// String path = "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\bb-2020-7-10-13-19-39.txt"; +// readTxtFile(path); +//// String s = readJsonFile(path); +//// JSONObject jobj = JSON.parseObject(s); +//// JSONArray movies = jobj.getJSONArray("robotBodyList");//JSONArray +//// for (int i = 0 ; i < movies.size();i++){ +//// JSONObject key = (JSONObject)movies.get(i); +//// String name = (String)key.get("projCode"); +//// +//// System.out.println(name); +//// +//// } +// } +} diff --git a/src/com/teamcenter/rac/form/form_user.properties b/src/com/teamcenter/rac/form/form_user.properties new file mode 100644 index 0000000..49c941d --- /dev/null +++ b/src/com/teamcenter/rac/form/form_user.properties @@ -0,0 +1 @@ +YSR8_SysCatalogRevisionMaster.FORMJAVARENDERING=com.connor.AC_01.ACSysCatalogStyle \ No newline at end of file