commit 83346f4fda7a91bcf88482c39e8fb1d8794dac74 Author: lijh Date: Tue Mar 10 16:34:27 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..449b375 --- /dev/null +++ b/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..93317c2 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.sb.problem + + + + + + 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..bb29a1d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=GBK diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..0c68a61 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..be4e7e1 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,31 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: sbProblem +Bundle-SymbolicName: com.connor.sb.problem;singleton:=true +Bundle-Version: 1.0.0 +Export-Package: com.connor.mdbksplm.ProblemReport, + com.teamcenter.rac.stylesheet +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.kernel, + com.teamcenter.rac.aifrcp, + com.teamcenter.rac.common, + com.teamcenter.rac.tcapps, + com.teamcenter.rac.util, + com.teamcenter.rac.ui, + com.teamcenter.rac.ui.commands, + com.teamcenter.rac.workflow.processdesigner, + org.apache.poi, + TcSoaCoreRac +Automatic-Module-Name: com.connor.mdbksplm +Bundle-ClassPath: lib/swingx-1.6.1.jar, + ., + lib/aspose-words-17.4.0-jdk16.jar, + lib/commons-collections4-4.1.jar, + lib/xmlbeans-2.6.0.jar, + lib/jdom2-2.0.6.jar, + src/com/teamcenter/rac/stylesheet/, + lib/mssql-jdbc-8.2.2.jre8.jar +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: com.teamcenter.soa.exceptions 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..a123513 --- /dev/null +++ b/build.properties @@ -0,0 +1,13 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/swingx-1.6.1.jar,\ + lib/aspose-words-17.4.0-jdk16.jar,\ + lib/commons-collections4-4.1.jar,\ + lib/xmlbeans-2.6.0.jar,\ + lib/jdom2-2.0.6.jar,\ + src/com/teamcenter/rac/stylesheet/,\ + lib/mssql-jdbc-8.2.2.jre8.jar diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/lib/aspose-words-17.4.0-jdk16.jar b/lib/aspose-words-17.4.0-jdk16.jar new file mode 100644 index 0000000..e8bd66c Binary files /dev/null and b/lib/aspose-words-17.4.0-jdk16.jar differ diff --git a/lib/commons-collections4-4.1.jar b/lib/commons-collections4-4.1.jar new file mode 100644 index 0000000..43a9413 Binary files /dev/null and b/lib/commons-collections4-4.1.jar differ diff --git a/lib/jdom2-2.0.6.jar b/lib/jdom2-2.0.6.jar new file mode 100644 index 0000000..2850ca1 Binary files /dev/null and b/lib/jdom2-2.0.6.jar differ diff --git a/lib/mssql-jdbc-8.2.2.jre8.jar b/lib/mssql-jdbc-8.2.2.jre8.jar new file mode 100644 index 0000000..8fc6c0b Binary files /dev/null and b/lib/mssql-jdbc-8.2.2.jre8.jar differ diff --git a/lib/swingx-1.6.1.jar b/lib/swingx-1.6.1.jar new file mode 100644 index 0000000..b0bcc87 Binary files /dev/null and b/lib/swingx-1.6.1.jar differ diff --git a/lib/xmlbeans-2.6.0.jar b/lib/xmlbeans-2.6.0.jar new file mode 100644 index 0000000..d1b6627 Binary files /dev/null and b/lib/xmlbeans-2.6.0.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..87c620c --- /dev/null +++ b/plugin.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/connor/mdbksplm/ProblemReport/NewProblemReportFrame.java b/src/com/connor/mdbksplm/ProblemReport/NewProblemReportFrame.java new file mode 100644 index 0000000..18ad212 --- /dev/null +++ b/src/com/connor/mdbksplm/ProblemReport/NewProblemReportFrame.java @@ -0,0 +1,875 @@ +package com.connor.mdbksplm.ProblemReport; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; + +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +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 com.connor.mdbksplm.treamlist.CNProperty; +import com.connor.mdbksplm.util.ProgressBarDemo; +import com.connor.mdbksplm.util.WaitingDialog; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenCommand; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class NewProblemReportFrame extends JFrame{ + private static final long serialVersionUID = 1L; + private TCSession session; + private AbstractAIFUIApplication app; + protected TCUserService userService; + + private JPanel leftPanel = new JPanel(new BorderLayout()); + private JButton okButton; + private JButton exButton; + + private String SearchName = null; + // string:Դ:prosource + // date:: creation_date01| creation_date02 + private List> searchList = new ArrayList<>(); + + // Դ:Form.mt8_prosource:15 + private List> colList = new ArrayList<>(); + + private Integer cur = new Integer(0); + + HashMap fMap = new HashMap<>(); + HashMap dMap = new HashMap<>(); + HashMap, String> boxMap = new HashMap<>(); + + List> allSj = new ArrayList<>(); + private Integer num = new Integer(0); + + // ţⱨ + HashMap baogao = new HashMap<>(); + + private SimpleDateFormat formatter= new SimpleDateFormat("dd-M -yyyy"); + private SimpleDateFormat formatter2= new SimpleDateFormat("yyyy-MM-dd"); + private SimpleDateFormat formatter3= new SimpleDateFormat("yyyy-M-d"); + + private String[] columns; + +// ProgressBarDemo wait = new ProgressBarDemo(); + private WaitingDialog waiting; + + public NewProblemReportFrame(AbstractAIFUIApplication app) { +// super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + public void initUI() { + FindData(); + this.setTitle("ⱨ濴"); + this.setPreferredSize(new Dimension(1500, 600)); + this.setLayout(new BorderLayout()); + + Font font = new Font("", Font.PLAIN, 12);//1ʵ + Font font2 = new Font("", Font.PLAIN, 10);//1ʵ + + JPanel leftTJPanel = new JPanel(new PropertyLayout(2,10,5,20,5,5)); + cur = 0; + for(int i=0;i list = searchList.get(i); + if("string".equals(list.get(0))) { // StringͿؼ + cur++; + JLabel label = new JLabel(list.get(1)); //ؼ + label.setPreferredSize(new Dimension(100, 22)); + label.setFont(font); + leftTJPanel.add(cur + ".1.left",label); + + cur++; + if(list.size() > 3) { + JComboBox field = new JComboBox(); + field.setPreferredSize(new Dimension(140, 22)); + field.setFont(font); + CNProperty cn1 = new CNProperty(); + cn1.setLovName(list.get(3)); + cn1.initProperty(); + field.addItem(" "); + for(int k=0;k columnsList = new ArrayList<>(); + for(int i=0; i 2) { // 2get(3)Ϊп + Integer valueOf = Integer.valueOf(colList.get(i).get(2)); + createTable.getColumnModel().getColumn(i+1).setPreferredWidth(valueOf); + System.out.println("" + (i+2) + "óʼп" + valueOf); + } + } +// createTable.getColumnModel().getColumn(createTable.getColumnCount()-2).setPreferredWidth(10); +// createTable.getColumnModel().getColumn(createTable.getColumnCount()-1).setPreferredWidth(10); + + doubleAdd(createTable); + + // ӱͷ¼ + JTableHeader header = createTable.getTableHeader(); + header.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + int column = createTable.columnAtPoint(e.getPoint()); + System.out.println("Clicked column header " + (column + 1)); + allSj = sortByIndexAndUpdateMap(allSj,(column + 1),null,baogao); + clearTable(createTable); + createTable.updateUI(); + num = 0; + DefaultTableModel m = (DefaultTableModel) createTable.getModel(); + for(List list : allSj) { + m.addRow(list.toArray()); + } + //setTableCellBackgroundByLastColumn(createTable); + createTable.updateUI(); + } + + }); + + JScrollPane scrollRight = new JScrollPane(createTable); + scrollRight.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); //ˮƽҪʱɼ + scrollRight.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); //Ҫʱɼ + + JPanel endP = new JPanel(new BorderLayout()); + endP.add(scroll, BorderLayout.WEST); + endP.add(scrollRight, BorderLayout.CENTER); + + this.setLayout(new BorderLayout()); +// this.add(scroll, BorderLayout.WEST); + this.add(endP, BorderLayout.CENTER); + this.add(buttonPanel, BorderLayout.SOUTH); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.pack(); + this.setResizable(true); + this.setLocationRelativeTo(null); +// this.setExtendedState(JFrame.MAXIMIZED_BOTH); + this.setExtendedState(JFrame.NORMAL); +// this.setUndecorated(false); + this.setVisible(true); + + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + +// wait.showProgressBar();// +// waiting = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), "ȴʾ", "ڼأԺ ..."); + waiting = new WaitingDialog(null,"ȴʾ", "ڼأԺ ..."); + waiting.SetDialogMessage("ڼأԺ ..."); + waiting.setVisible(true);// + + List textList = new ArrayList<>(); + List tjList = new ArrayList<>(); + fMap.forEach((k,v) -> { + if(k != null && !"".equals(k.getText())) { + textList.add(k.getText()); + tjList.add(v); + } + }); + boxMap.forEach((k,v) -> { + if(k != null && !"".equals(k.getSelectedItem().toString()) && + !" ".equals(k.getSelectedItem().toString())) { + textList.add(k.getSelectedItem().toString()); + tjList.add(v); + } + }); + dMap.forEach((k,v) -> { + if(k != null && k.getDate() != null) { + textList.add(formatter3.format(k.getDate())+" 00:00"); + tjList.add(v); + } + }); + System.out.println("ѯƣ" + SearchName); + if(tjList == null || tjList.size() == 0) { + tjList.add("id01"); + textList.add("*"); + } else { + for(int i=0; i(); + for(int i=0; i 0) { + project = proList[0]; + } + TCComponent form = referenceListProperty[0]; // 汾 + TCComponentItem item = rev.getItem(); // 汾 + //colList + List sj = new ArrayList<>(); + num ++; + sj.add(num.toString()); + for(int j=0; j 1) { + String dx = split[0]; // ʲô + String shux = split[1]; // ʵ + if("Item".equals(dx)) { + String property = item.getProperty(shux); + try { + Date dateProperty = item.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { + } + sj.add(property == null ? "" : property); + } else if("Rev".equals(dx)) { + String property = rev.getProperty(shux); + try { + Date dateProperty = rev.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { + } + sj.add(property == null ? "" : property); + } else if("Form".equals(dx)) { + String property = form.getProperty(shux); + try { + Date dateProperty = form.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { +// try { +// TCComponent relatedComponent = form.getRelatedComponent(shux); +// if(relatedComponent != null) { +// property = relatedComponent.toString(); +// } +// } catch (Exception ee) { +// +// } + } + sj.add(property == null ? "" : property); + } else if("Proj".equals(dx)) { + if(project == null) { + sj.add(""); + } else { + String property = project.getProperty(shux); + try { + Date dateProperty = project.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { + } + sj.add(property == null ? "" : property); + } + } else { + sj.add(""); + } + }else { + if(string.equals("ECRID")) { + String ids = ""; + TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy"); + System.out.println("ECRID=============="+relatedComponents.length); + for (int k = 0; k < relatedComponents.length; k++) { + if(relatedComponents[k].getType().equals("SB6_ECRLRevision") || relatedComponents[k].getType().equals("SB6_ECRXRevision")) { + ids += relatedComponents[k].getStringProperty("item_id")+";"; + } + } + sj.add(qc(ids)); + } + + if(string.equals("ECNID")) { + String ids = ""; + TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID1==================="+relatedComponents.length); + for (int k = 0; k < relatedComponents.length; k++) { + if(relatedComponents[k].getType().equals("SB6_ECNLRevision") || relatedComponents[k].getType().equals("SB6_ECNXRevision")) { + ids += relatedComponents[k].getStringProperty("item_id")+";"; + } + + + if(relatedComponents[k].getType().equals("SB6_ECRLRevision")) { + TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID2==================="+relatedComponents2.length); + + for (int m = 0; m < relatedComponents2.length; m++) { + if(relatedComponents2[m].getType().equals("SB6_ECNLRevision")) { + ids += relatedComponents2[m].getStringProperty("item_id")+";"; + } + } + } + + + if(relatedComponents[k].getType().equals("SB6_ECRXRevision")) { + TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID2==================="+relatedComponents2.length); + + for (int m = 0; m < relatedComponents2.length; m++) { + if(relatedComponents2[m].getType().equals("SB6_ECNXRevision")) { + ids += relatedComponents2[m].getStringProperty("item_id")+";"; + } + } + } + + } + sj.add(qc(ids)); + } + + if(string.equals("ECOID")) { + + String ids = ""; + TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID1==================="+relatedComponents.length); + for (int k = 0; k < relatedComponents.length; k++) { + + if(relatedComponents[k].getType().equals("SB6_ECRLRevision")) { + TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID2==================="+relatedComponents2.length); + + for (int m = 0; m < relatedComponents2.length; m++) { + if(relatedComponents2[m].getType().equals("SB6_ECNLRevision")) { + + TCComponent[] relatedComponents3 = relatedComponents2[m].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID3==================="+relatedComponents3.length); + for (int n = 0; n < relatedComponents3.length; n++) { + if(relatedComponents3[n].getType().equals("SB6_ECORevision")) { + + ids += relatedComponents3[n].getStringProperty("item_id")+";"; + } + + } + } + } + } + + + if(relatedComponents[k].getType().equals("SB6_ECRXRevision")) { + TCComponent[] relatedComponents4 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID4==================="+relatedComponents4.length); + for (int f = 0; f < relatedComponents4.length; f++) { + if(relatedComponents4[f].getType().equals("SB6_ECNXRevision")) { + TCComponent[] relatedComponents5 = relatedComponents4[f].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID5==================="+relatedComponents5.length); + + for (int g = 0; g < relatedComponents5.length; g++) { + if(relatedComponents5[g].getType().equals("SB6_ECORevision")) { + + ids += relatedComponents5[g].getStringProperty("item_id")+";"; + } + } + } + } + } + } + sj.add(qc(ids)); + } + + } + } + + baogao.put(num.toString(), item); + allSj.add(sj); + } + clearTable(createTable); + DefaultTableModel m = (DefaultTableModel) createTable.getModel(); + for(int i=0; i list = new ArrayList(); + for (int i = 0; i < split.length; i++) { + if(!list.contains(split[i])) { + list.add(split[i]); + } + } + + if(list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + qcStr += list.get(i)+";"; + } + } + qcStr = qcStr.substring(0, qcStr.length() - 1); + return qcStr; + } + + private void FindData() { + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] strs = preferenceService.getStringValues("Connor_PRXDashBoard_SearchConfig"); + if(strs != null && strs.length >0) { + SearchName = strs[0]; + System.out.println("ѯƣ" + SearchName); + + + for(int i=1; i list = new ArrayList<>(); + String[] split = strs[i].split(":"); + if(split != null && split.length > 2) { + list.add(split[0]); // ؼ + list.add(split[1]); // ؼ + String[] split2 = split[2].split("\\|"); + if(split2 != null && split2.length > 1) { + list.add(split2[0]); // ؼڣѯ + list.add(split2[1]); + } else { + list.add(split[2]); // ؼStringһѯ + if(split.length > 3) { + list.add(split[3]); // ؼStringLOV + } + } + } + searchList.add(list); + } + } + + strs = preferenceService.getStringValues("Connor_PRXDashBoard_ShowConfig"); + if(strs != null && strs.length >0) { + for(int i=0; i list = new ArrayList<>(); + String[] split = strs[i].split(":"); + if(split != null && split.length > 0) { + for(int j=0; j 0) { + model.removeRow(0); + } + } + + public void exportData() { + // TODO Auto-generated method stub + exButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // ļѡ + JFileChooser jfc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory()); + jfc.setDialogTitle("Choose a directory to export the file"); + jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnValue = jfc.showSaveDialog(null); + if (returnValue == JFileChooser.APPROVE_OPTION) { + File selectedDirectory = jfc.getSelectedFile(); + // ݵExcel + try { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String format = df.format(new Date()); + String fw = selectedDirectory.getAbsolutePath() + "/ⱨ濴-" + format + ".xlsx"; + writeExcel(fw, allSj); + JOptionPane.showMessageDialog(null, "ɹ!"); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + }); + } + + // excel + public void writeExcel(String filePath, List> data) throws IOException { + // һ + XSSFWorkbook workbook = new XSSFWorkbook(); + // һ + XSSFSheet sheet = workbook.createSheet(); + // һУдͷ + XSSFRow rowHeader = sheet.createRow(0); + // ͷԪ + XSSFCell headerCell = rowHeader.createCell(0); + // ñͷԪֵ + + // һԪϲ󣬽һеһк͵һһкϲ + CellRangeAddress region = new CellRangeAddress(0, 0, 0, data.get(0).size() - 1); + // ʹaddMergedRegionԪϲӦõ + sheet.addMergedRegion(region); +// // ñͷԪʽ + CellStyle style = workbook.createCellStyle(); + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); + headerCell.setCellStyle(style); + headerCell.setCellValue("⿴"); + // д + XSSFRow rowNext = sheet.createRow(1); + for(int i=0; i rowData = data.get(i); + // ǰݣд뵽 + for (int j = 0; j < rowData.size(); j++) { + // һԪ + XSSFCell cell = row.createCell(j); + // õԪֵ + cell.setCellValue(rowData.get(j)); + } + } + // һļ + FileOutputStream outputStream = new FileOutputStream(filePath); + // д뵽ļ + workbook.write(outputStream); + // رļ + outputStream.close(); + } + + // ˫¼ + public void doubleAdd(JTable table) { + table.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + if (e.getClickCount() == 2) { + System.out.println("˫"); + int row = table.rowAtPoint(e.getPoint()); + String valueAt = (String)table.getValueAt(row, 0); + TCComponent tcComponent = baogao.get(valueAt); + openForm(tcComponent); + } + return; + } + }); + } + + // 򿪶 + private void openForm(TCComponent form) { +// try{ +// boolean modifiable = false; +// TCComponentUser currentUser = session.getUser(); +// String zuzhi = currentUser.getLoginGroup().toString(); +// System.out.println("currentUser:" + currentUser.toString()); +// System.out.println("zuzhi:" + zuzhi); +// // owning_group +// TCComponent[] members = form.getRelatedComponents("owning_group"); +// if(members!=null && members.length>0) { +// System.out.println("֯鲻Ϊ"); +// for(int i=0;i 0 ? num : -num; + } + + // ¹ + public List> sortByIndexAndUpdateMap(List> data, int index, + HashMap map, HashMap map2) { + System.out.println(""); + HashMap newMap = new HashMap(); + HashMap newMap2 = new HashMap(); + + List> sortedList = new ArrayList<>(data); + // ð + if(sortedList.get(0).get(index-1).compareTo(sortedList.get(sortedList.size() -1 ).get(index-1)) < 0) { + System.out.println("ӴС"); + for (int i = 0; i < sortedList.size() - 1; i++) { + for (int j = 0; j < sortedList.size() - 1 - i; j++) { + List list1 = sortedList.get(j); + List list2 = sortedList.get(j + 1); + if (list1.get(index-1).compareTo(list2.get(index-1)) < 0) { + // list1ĵiԪСlist2ĵiԪأλ + sortedList.set(j, list2); + sortedList.set(j + 1, list1); + } + } + } + } else { + System.out.println("С"); + for (int i = 0; i < sortedList.size() - 1; i++) { + for (int j = 0; j < sortedList.size() - 1 - i; j++) { + List list1 = sortedList.get(j); + List list2 = sortedList.get(j + 1); + if (list1.get(index-1).compareTo(list2.get(index-1)) > 0) { + // list1ĵiԪСlist2ĵiԪأλ + sortedList.set(j, list2); + sortedList.set(j + 1, list1); + } + } + } + } + + // List>ÿListĵһԪأmapе + for (int i = 0; i < sortedList.size(); i++) { + List list = sortedList.get(i); + String oldIndex = list.get(0); + String newIndex = String.valueOf(i + 1); +// // List +// list.set(0, newIndex); + // ȡԭTCComponent + TCComponent comp = map2.get(oldIndex); + // TCComponentµ + map2.remove(oldIndex); + newMap2.put(newIndex, comp); + } + + baogao = newMap2; + + // List>ÿListĵһԪ + for (int i = 0; i < sortedList.size(); i++) { + List list = sortedList.get(i); + list.set(0, String.valueOf(i + 1)); + } + + System.out.println(""); + return sortedList; + } +} diff --git a/src/com/connor/mdbksplm/ProblemReport/NewProblemReportHandler.java b/src/com/connor/mdbksplm/ProblemReport/NewProblemReportHandler.java new file mode 100644 index 0000000..1519728 --- /dev/null +++ b/src/com/connor/mdbksplm/ProblemReport/NewProblemReportHandler.java @@ -0,0 +1,19 @@ +package com.connor.mdbksplm.ProblemReport; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class NewProblemReportHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("ʼ"); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + NewProblemReportFrame dialog = new NewProblemReportFrame(app); + dialog.initUI(); + return null; + } +} \ No newline at end of file diff --git a/src/com/connor/mdbksplm/ProblemReport/ProblemReportFrame.java b/src/com/connor/mdbksplm/ProblemReport/ProblemReportFrame.java new file mode 100644 index 0000000..37f4f06 --- /dev/null +++ b/src/com/connor/mdbksplm/ProblemReport/ProblemReportFrame.java @@ -0,0 +1,875 @@ +package com.connor.mdbksplm.ProblemReport; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; + +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +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 com.connor.mdbksplm.treamlist.CNProperty; +import com.connor.mdbksplm.util.ProgressBarDemo; +import com.connor.mdbksplm.util.WaitingDialog; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.open.OpenCommand; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class ProblemReportFrame extends JFrame{ + private static final long serialVersionUID = 1L; + private TCSession session; + private AbstractAIFUIApplication app; + protected TCUserService userService; + + private JPanel leftPanel = new JPanel(new BorderLayout()); + private JButton okButton; + private JButton exButton; + + private String SearchName = null; + // string:Դ:prosource + // date:: creation_date01| creation_date02 + private List> searchList = new ArrayList<>(); + + // Դ:Form.mt8_prosource:15 + private List> colList = new ArrayList<>(); + + private Integer cur = new Integer(0); + + HashMap fMap = new HashMap<>(); + HashMap dMap = new HashMap<>(); + HashMap, String> boxMap = new HashMap<>(); + + List> allSj = new ArrayList<>(); + private Integer num = new Integer(0); + + // ţⱨ + HashMap baogao = new HashMap<>(); + + private SimpleDateFormat formatter= new SimpleDateFormat("dd-M -yyyy"); + private SimpleDateFormat formatter2= new SimpleDateFormat("yyyy-MM-dd"); + private SimpleDateFormat formatter3= new SimpleDateFormat("yyyy-M-d"); + + private String[] columns; + +// ProgressBarDemo wait = new ProgressBarDemo(); + private WaitingDialog waiting; + + public ProblemReportFrame(AbstractAIFUIApplication app) { +// super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + public void initUI() { + FindData(); + this.setTitle("ⱨ濴"); + this.setPreferredSize(new Dimension(1500, 600)); + this.setLayout(new BorderLayout()); + + Font font = new Font("", Font.PLAIN, 12);//1ʵ + Font font2 = new Font("", Font.PLAIN, 10);//1ʵ + + JPanel leftTJPanel = new JPanel(new PropertyLayout(2,10,5,20,5,5)); + cur = 0; + for(int i=0;i list = searchList.get(i); + if("string".equals(list.get(0))) { // StringͿؼ + cur++; + JLabel label = new JLabel(list.get(1)); //ؼ + label.setPreferredSize(new Dimension(100, 22)); + label.setFont(font); + leftTJPanel.add(cur + ".1.left",label); + + cur++; + if(list.size() > 3) { + JComboBox field = new JComboBox(); + field.setPreferredSize(new Dimension(140, 22)); + field.setFont(font); + CNProperty cn1 = new CNProperty(); + cn1.setLovName(list.get(3)); + cn1.initProperty(); + field.addItem(" "); + for(int k=0;k columnsList = new ArrayList<>(); + for(int i=0; i 2) { // 2get(3)Ϊп + Integer valueOf = Integer.valueOf(colList.get(i).get(2)); + createTable.getColumnModel().getColumn(i+1).setPreferredWidth(valueOf); + System.out.println("" + (i+2) + "óʼп" + valueOf); + } + } +// createTable.getColumnModel().getColumn(createTable.getColumnCount()-2).setPreferredWidth(10); +// createTable.getColumnModel().getColumn(createTable.getColumnCount()-1).setPreferredWidth(10); + + doubleAdd(createTable); + + // ӱͷ¼ + JTableHeader header = createTable.getTableHeader(); + header.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + int column = createTable.columnAtPoint(e.getPoint()); + System.out.println("Clicked column header " + (column + 1)); + allSj = sortByIndexAndUpdateMap(allSj,(column + 1),null,baogao); + clearTable(createTable); + createTable.updateUI(); + num = 0; + DefaultTableModel m = (DefaultTableModel) createTable.getModel(); + for(List list : allSj) { + m.addRow(list.toArray()); + } + //setTableCellBackgroundByLastColumn(createTable); + createTable.updateUI(); + } + + }); + + JScrollPane scrollRight = new JScrollPane(createTable); + scrollRight.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); //ˮƽҪʱɼ + scrollRight.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); //Ҫʱɼ + + JPanel endP = new JPanel(new BorderLayout()); + endP.add(scroll, BorderLayout.WEST); + endP.add(scrollRight, BorderLayout.CENTER); + + this.setLayout(new BorderLayout()); +// this.add(scroll, BorderLayout.WEST); + this.add(endP, BorderLayout.CENTER); + this.add(buttonPanel, BorderLayout.SOUTH); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.pack(); + this.setResizable(true); + this.setLocationRelativeTo(null); +// this.setExtendedState(JFrame.MAXIMIZED_BOTH); + this.setExtendedState(JFrame.NORMAL); +// this.setUndecorated(false); + this.setVisible(true); + + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + +// wait.showProgressBar();// +// waiting = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), "ȴʾ", "ڼأԺ ..."); + waiting = new WaitingDialog(null,"ȴʾ", "ڼأԺ ..."); + waiting.SetDialogMessage("ڼأԺ ..."); + waiting.setVisible(true);// + + List textList = new ArrayList<>(); + List tjList = new ArrayList<>(); + fMap.forEach((k,v) -> { + if(k != null && !"".equals(k.getText())) { + textList.add(k.getText()); + tjList.add(v); + } + }); + boxMap.forEach((k,v) -> { + if(k != null && !"".equals(k.getSelectedItem().toString()) && + !" ".equals(k.getSelectedItem().toString())) { + textList.add(k.getSelectedItem().toString()); + tjList.add(v); + } + }); + dMap.forEach((k,v) -> { + if(k != null && k.getDate() != null) { + textList.add(formatter3.format(k.getDate())+" 00:00"); + tjList.add(v); + } + }); + System.out.println("ѯƣ" + SearchName); + if(tjList == null || tjList.size() == 0) { + tjList.add("id01"); + textList.add("*"); + } else { + for(int i=0; i(); + for(int i=0; i 0) { + project = proList[0]; + } + TCComponent form = referenceListProperty[0]; // 汾 + TCComponentItem item = rev.getItem(); // 汾 + //colList + List sj = new ArrayList<>(); + num ++; + sj.add(num.toString()); + for(int j=0; j 1) { + String dx = split[0]; // ʲô + String shux = split[1]; // ʵ + if("Item".equals(dx)) { + String property = item.getProperty(shux); + try { + Date dateProperty = item.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { + } + sj.add(property == null ? "" : property); + } else if("Rev".equals(dx)) { + String property = rev.getProperty(shux); + try { + Date dateProperty = rev.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { + } + sj.add(property == null ? "" : property); + } else if("Form".equals(dx)) { + String property = form.getProperty(shux); + try { + Date dateProperty = form.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { +// try { +// TCComponent relatedComponent = form.getRelatedComponent(shux); +// if(relatedComponent != null) { +// property = relatedComponent.toString(); +// } +// } catch (Exception ee) { +// +// } + } + sj.add(property == null ? "" : property); + } else if("Proj".equals(dx)) { + if(project == null) { + sj.add(""); + } else { + String property = project.getProperty(shux); + try { + Date dateProperty = project.getDateProperty(shux); + if(dateProperty != null) { + property = formatter2.format(dateProperty); + } + } catch(Exception eee) { + } + sj.add(property == null ? "" : property); + } + } else { + sj.add(""); + } + }else { + if(string.equals("ECRID")) { + String ids = ""; + TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy"); + System.out.println("ECRID=============="+relatedComponents.length); + for (int k = 0; k < relatedComponents.length; k++) { + if(relatedComponents[k].getType().equals("SB6_ECRLRevision") || relatedComponents[k].getType().equals("SB6_ECRXRevision")) { + ids += relatedComponents[k].getStringProperty("item_id")+";"; + } + } + sj.add(qc(ids)); + } + + if(string.equals("ECNID")) { + String ids = ""; + TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID1==================="+relatedComponents.length); + for (int k = 0; k < relatedComponents.length; k++) { + if(relatedComponents[k].getType().equals("SB6_ECNLRevision") || relatedComponents[k].getType().equals("SB6_ECNXRevision")) { + ids += relatedComponents[k].getStringProperty("item_id")+";"; + } + + + if(relatedComponents[k].getType().equals("SB6_ECRLRevision")) { + TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID2==================="+relatedComponents2.length); + + for (int m = 0; m < relatedComponents2.length; m++) { + if(relatedComponents2[m].getType().equals("SB6_ECNLRevision")) { + ids += relatedComponents2[m].getStringProperty("item_id")+";"; + } + } + } + + + if(relatedComponents[k].getType().equals("SB6_ECRXRevision")) { + TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID2==================="+relatedComponents2.length); + + for (int m = 0; m < relatedComponents2.length; m++) { + if(relatedComponents2[m].getType().equals("SB6_ECNXRevision")) { + ids += relatedComponents2[m].getStringProperty("item_id")+";"; + } + } + } + + } + sj.add(qc(ids)); + } + + if(string.equals("ECOID")) { + + String ids = ""; + TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID1==================="+relatedComponents.length); + for (int k = 0; k < relatedComponents.length; k++) { + + if(relatedComponents[k].getType().equals("SB6_ECRLRevision")) { + TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID2==================="+relatedComponents2.length); + + for (int m = 0; m < relatedComponents2.length; m++) { + if(relatedComponents2[m].getType().equals("SB6_ECNLRevision")) { + + TCComponent[] relatedComponents3 = relatedComponents2[m].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID3==================="+relatedComponents3.length); + for (int n = 0; n < relatedComponents3.length; n++) { + if(relatedComponents3[n].getType().equals("SB6_ECORevision")) { + + ids += relatedComponents3[n].getStringProperty("item_id")+";"; + } + + } + } + } + } + + + if(relatedComponents[k].getType().equals("SB6_ECRXRevision")) { + TCComponent[] relatedComponents4 = relatedComponents[k].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID4==================="+relatedComponents4.length); + for (int f = 0; f < relatedComponents4.length; f++) { + if(relatedComponents4[f].getType().equals("SB6_ECNXRevision")) { + TCComponent[] relatedComponents5 = relatedComponents4[f].getRelatedComponents("CMImplementedBy"); + System.out.println("ECNID5==================="+relatedComponents5.length); + + for (int g = 0; g < relatedComponents5.length; g++) { + if(relatedComponents5[g].getType().equals("SB6_ECORevision")) { + + ids += relatedComponents5[g].getStringProperty("item_id")+";"; + } + } + } + } + } + } + sj.add(qc(ids)); + } + + } + } + + baogao.put(num.toString(), item); + allSj.add(sj); + } + clearTable(createTable); + DefaultTableModel m = (DefaultTableModel) createTable.getModel(); + for(int i=0; i list = new ArrayList(); + for (int i = 0; i < split.length; i++) { + if(!list.contains(split[i])) { + list.add(split[i]); + } + } + + if(list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + qcStr += list.get(i)+";"; + } + } + qcStr = qcStr.substring(0, qcStr.length() - 1); + return qcStr; + } + + private void FindData() { + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] strs = preferenceService.getStringValues("Connor_PRLDashBoard_SearchConfig"); + if(strs != null && strs.length >0) { + SearchName = strs[0]; + System.out.println("ѯƣ" + SearchName); + + + for(int i=1; i list = new ArrayList<>(); + String[] split = strs[i].split(":"); + if(split != null && split.length > 2) { + list.add(split[0]); // ؼ + list.add(split[1]); // ؼ + String[] split2 = split[2].split("\\|"); + if(split2 != null && split2.length > 1) { + list.add(split2[0]); // ؼڣѯ + list.add(split2[1]); + } else { + list.add(split[2]); // ؼStringһѯ + if(split.length > 3) { + list.add(split[3]); // ؼStringLOV + } + } + } + searchList.add(list); + } + } + + strs = preferenceService.getStringValues("Connor_PRLDashBoard_ShowConfig"); + if(strs != null && strs.length >0) { + for(int i=0; i list = new ArrayList<>(); + String[] split = strs[i].split(":"); + if(split != null && split.length > 0) { + for(int j=0; j 0) { + model.removeRow(0); + } + } + + public void exportData() { + // TODO Auto-generated method stub + exButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // ļѡ + JFileChooser jfc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory()); + jfc.setDialogTitle("Choose a directory to export the file"); + jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnValue = jfc.showSaveDialog(null); + if (returnValue == JFileChooser.APPROVE_OPTION) { + File selectedDirectory = jfc.getSelectedFile(); + // ݵExcel + try { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String format = df.format(new Date()); + String fw = selectedDirectory.getAbsolutePath() + "/ⱨ濴-" + format + ".xlsx"; + writeExcel(fw, allSj); + JOptionPane.showMessageDialog(null, "ɹ!"); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + }); + } + + // excel + public void writeExcel(String filePath, List> data) throws IOException { + // һ + XSSFWorkbook workbook = new XSSFWorkbook(); + // һ + XSSFSheet sheet = workbook.createSheet(); + // һУдͷ + XSSFRow rowHeader = sheet.createRow(0); + // ͷԪ + XSSFCell headerCell = rowHeader.createCell(0); + // ñͷԪֵ + + // һԪϲ󣬽һеһк͵һһкϲ + CellRangeAddress region = new CellRangeAddress(0, 0, 0, data.get(0).size() - 1); + // ʹaddMergedRegionԪϲӦõ + sheet.addMergedRegion(region); +// // ñͷԪʽ + CellStyle style = workbook.createCellStyle(); + style.setAlignment(HSSFCellStyle.ALIGN_CENTER); + headerCell.setCellStyle(style); + headerCell.setCellValue("⿴"); + // д + XSSFRow rowNext = sheet.createRow(1); + for(int i=0; i rowData = data.get(i); + // ǰݣд뵽 + for (int j = 0; j < rowData.size(); j++) { + // һԪ + XSSFCell cell = row.createCell(j); + // õԪֵ + cell.setCellValue(rowData.get(j)); + } + } + // һļ + FileOutputStream outputStream = new FileOutputStream(filePath); + // д뵽ļ + workbook.write(outputStream); + // رļ + outputStream.close(); + } + + // ˫¼ + public void doubleAdd(JTable table) { + table.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + if (e.getClickCount() == 2) { + System.out.println("˫"); + int row = table.rowAtPoint(e.getPoint()); + String valueAt = (String)table.getValueAt(row, 0); + TCComponent tcComponent = baogao.get(valueAt); + openForm(tcComponent); + } + return; + } + }); + } + + // 򿪶 + private void openForm(TCComponent form) { +// try{ +// boolean modifiable = false; +// TCComponentUser currentUser = session.getUser(); +// String zuzhi = currentUser.getLoginGroup().toString(); +// System.out.println("currentUser:" + currentUser.toString()); +// System.out.println("zuzhi:" + zuzhi); +// // owning_group +// TCComponent[] members = form.getRelatedComponents("owning_group"); +// if(members!=null && members.length>0) { +// System.out.println("֯鲻Ϊ"); +// for(int i=0;i 0 ? num : -num; + } + + // ¹ + public List> sortByIndexAndUpdateMap(List> data, int index, + HashMap map, HashMap map2) { + System.out.println(""); + HashMap newMap = new HashMap(); + HashMap newMap2 = new HashMap(); + + List> sortedList = new ArrayList<>(data); + // ð + if(sortedList.get(0).get(index-1).compareTo(sortedList.get(sortedList.size() -1 ).get(index-1)) < 0) { + System.out.println("ӴС"); + for (int i = 0; i < sortedList.size() - 1; i++) { + for (int j = 0; j < sortedList.size() - 1 - i; j++) { + List list1 = sortedList.get(j); + List list2 = sortedList.get(j + 1); + if (list1.get(index-1).compareTo(list2.get(index-1)) < 0) { + // list1ĵiԪСlist2ĵiԪأλ + sortedList.set(j, list2); + sortedList.set(j + 1, list1); + } + } + } + } else { + System.out.println("С"); + for (int i = 0; i < sortedList.size() - 1; i++) { + for (int j = 0; j < sortedList.size() - 1 - i; j++) { + List list1 = sortedList.get(j); + List list2 = sortedList.get(j + 1); + if (list1.get(index-1).compareTo(list2.get(index-1)) > 0) { + // list1ĵiԪСlist2ĵiԪأλ + sortedList.set(j, list2); + sortedList.set(j + 1, list1); + } + } + } + } + + // List>ÿListĵһԪأmapе + for (int i = 0; i < sortedList.size(); i++) { + List list = sortedList.get(i); + String oldIndex = list.get(0); + String newIndex = String.valueOf(i + 1); +// // List +// list.set(0, newIndex); + // ȡԭTCComponent + TCComponent comp = map2.get(oldIndex); + // TCComponentµ + map2.remove(oldIndex); + newMap2.put(newIndex, comp); + } + + baogao = newMap2; + + // List>ÿListĵһԪ + for (int i = 0; i < sortedList.size(); i++) { + List list = sortedList.get(i); + list.set(0, String.valueOf(i + 1)); + } + + System.out.println(""); + return sortedList; + } +} diff --git a/src/com/connor/mdbksplm/ProblemReport/ProblemReportHandler.java b/src/com/connor/mdbksplm/ProblemReport/ProblemReportHandler.java new file mode 100644 index 0000000..48e864f --- /dev/null +++ b/src/com/connor/mdbksplm/ProblemReport/ProblemReportHandler.java @@ -0,0 +1,19 @@ +package com.connor.mdbksplm.ProblemReport; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class ProblemReportHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("ʼ"); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + ProblemReportFrame dialog = new ProblemReportFrame(app); + dialog.initUI(); + return null; + } +} \ No newline at end of file diff --git a/src/com/connor/mdbksplm/treamlist/CNProperty.java b/src/com/connor/mdbksplm/treamlist/CNProperty.java new file mode 100644 index 0000000..b0d4403 --- /dev/null +++ b/src/com/connor/mdbksplm/treamlist/CNProperty.java @@ -0,0 +1,241 @@ +package com.connor.mdbksplm.treamlist; + +/** + * @copyRight 㽭տƼ޹˾ + * @author E-mail:hub@connor.net.cn + * @date ʱ䣺2017-7-2 7:59:01 + * @version v1.0 + * @parameter + * @since + * @return + */ + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +import javax.xml.bind.annotation.XmlAttribute; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +import com.teamcenter.soa.client.model.LovValue; + +public class CNProperty { + // + String lovName; // lov + Boolean isLov = true; // Ƿlov + Boolean isMust; // Ƿ + String propertyType;// + String displayName;// ʾ + String realName;// ʵ + String defaultValue; + public List lovValueList; + public List lovDisplayValueList; + public int selectIndex = -1; + public Object value; + public TCComponentListOfValues lov; + public HashMap lovDesc = new HashMap<>(); + + public void initProperty() { + try { + this.lovValueList = new ArrayList<>(); + this.lovDisplayValueList = new ArrayList<>(); + if (this.isLov) { + lov = TCComponentListOfValuesType.findLOVByName(lovName); + if (lov != null) { + + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + + /* + * MessageBox.post(""+lov.getNumberOfLOVFilters(),"",MessageBox.INFORMATION);; + * TCComponentListOfValues[] fLovs= new TCComponentListOfValues[0] + * ;//lov.getNumberOfLOVFilters(); + * + * for(TCComponentListOfValues flov : fLovs) { + * + * ListOfValuesInfo info = flov.getListOfValues(true); + * info.getLOVDisplayValues(); List lovValueList = info.getValues(); + * for (LovValue lovV : lovValueList) { + * this.lovDisplayValueList.add(lovV.getDisplayValue()); + * this.lovValueList.add(lovV.getStringValue()); } + * + * } + */ + // lov.PROP_LOV_VALUE_FILTERS; + System.out.println("̬lovName=" + lovName); + + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = "object_name"; // lovĺֵ̨ + filter.order = 1; + filter.numberToReturn = 100; + filter.maxResults = 100; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + + + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; + + String desc = ""; + String name = ""; + for (String key : map.keySet()) { + System.out.println("key=" + key + ",value=" + map.get(key)[0]); + + // * + if(key.equals("mt8_lovdesc")) { + desc = map.get(key)[0] != null ? map.get(key)[0] : ""; + } + if(key.equals("object_name")) { + name = map.get(key)[0] != null ? map.get(key)[0] : ""; + } + // * + + } + lovDesc.put(name, desc); + for (String key : realmap.keySet()) { + System.out.println("key2=" + key + ",value2=" + map.get(key)[0]); + } + String disval = ""; + String val = ""; + String key1 = "object_name";// ʵֵ ʾֵһ + String key2 = "object_desc";// ʾֵڶ + String key3 = "mt8_lovdesc"; + + if (map.containsKey(key1)) { + val = realmap.get(key1)[0]; + disval = map.get(key1)[0]; + } + if (map.containsKey(key2)) { + String tempval = map.get(key2)[0]; + if (!tempval.equals("") && !lovName.equals("LB2_QD")) { + disval = disval + " " + tempval; + } + } + + if (!val.equals("")) { + this.lovDisplayValueList.add(disval); + this.lovValueList.add(val); + } + + } + + } else { + + ListOfValuesInfo info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList = info.getValues(); + for (LovValue lovV : lovValueList) { + this.lovDisplayValueList.add(lovV.getDisplayValue()); + this.lovValueList.add(lovV.getStringValue()); + } + } + + } + + } + } catch (TCException e) { + e.printStackTrace(); + } + + } + + public CNProperty() { + } + + public CNProperty(String realName, String displayName, String propertyType, Boolean isMust, Boolean isLov, + String lovName) { + this.realName = realName; + this.displayName = displayName; + this.propertyType = propertyType; + this.isMust = isMust; + this.isLov = isLov; + this.lovName = lovName; + } + + @XmlAttribute(name = "defaultValue") + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + @XmlAttribute(name = "lovName") + public String getLovName() { + return lovName; + } + + public void setLovName(String lovName) { + this.lovName = lovName; + } + + @XmlAttribute(name = "isLov") + public Boolean getIsLov() { + return isLov; + } + + public void setIsLov(Boolean isLov) { + this.isLov = isLov; + } + + @XmlAttribute(name = "isMust") + public Boolean getIsMust() { + return isMust; + } + + public void setIsMust(Boolean isMust) { + this.isMust = isMust; + } + + @XmlAttribute(name = "propertyType") + public String getPropertyType() { + return propertyType; + } + + public void setPropertyType(String propertyType) { + this.propertyType = propertyType; + } + + @XmlAttribute(name = "displayName") + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @XmlAttribute(name = "realName") + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public HashMap getLovDesc(){ + return lovDesc; + + } +} \ No newline at end of file diff --git a/src/com/connor/mdbksplm/treamlist/FormCheckUtil.java b/src/com/connor/mdbksplm/treamlist/FormCheckUtil.java new file mode 100644 index 0000000..05e4712 --- /dev/null +++ b/src/com/connor/mdbksplm/treamlist/FormCheckUtil.java @@ -0,0 +1,258 @@ +package com.connor.mdbksplm.treamlist; + +import java.awt.Color; +import java.awt.Component; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JRadioButton; +import javax.swing.JTable; +import javax.swing.JTextArea; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentRuleHandler; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCHandlerType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.iTextField; + +@SuppressWarnings("deprecation") +public class FormCheckUtil { + private TCComponentForm tcform; + private HashMap allComponents = new HashMap(); + public boolean isNeedCheck = false; + public Vector vtModifiableAttr = new Vector(); // ޸ + public Vector vtReqAttr = new Vector(); // + + public FormCheckUtil(TCComponentForm tcform, HashMap allComponents) { + this.tcform = tcform; + this.allComponents = allComponents; + } + + + public boolean isNeedCheck() { + return isNeedCheck; + } + + + public void setNeedCheck(boolean isNeedCheck) { + this.isNeedCheck = isNeedCheck; + } + + /** + * checkHandler:ȡHanderõIJ + */ + public void checkHandler() { + //System.out.println("checkHandler ....start"); + try { + TCComponent[] component = tcform.getReferenceListProperty("process_stage_list"); + //System.out.println("component.length=============" + component.length); + if(component == null || component.length == 0){ + return; + } + Vector componentV = new Vector(); + for(TCComponent c : component) { + System.out.println("componentV=============" + c); + componentV.add(c); + } +// String strProcessStage = tcform.getProperty("process_stage"); + TCComponent[] strProcessStage = tcform.getReferenceListProperty("process_stage_list"); + String strProcess = ""; +// if(strProcessStage.indexOf(",")>strProcessStage.indexOf("/")+ 1) { +// strProcess = strProcessStage.substring(strProcessStage.indexOf("/")+ 1,strProcessStage.indexOf(","));//lidy20181001 TODO +// } else +// strProcess = strProcessStage.substring(strProcessStage.indexOf("/")+ 1); + if(strProcessStage!=null) { + if(strProcessStage.length>1) + strProcess = strProcessStage[1].getReferenceProperty("parent_process").toString(); + else + strProcess = strProcessStage[0].getReferenceProperty("parent_process").toString(); + } + System.out.println("strProcess = " + strProcess); + + TCComponentTask task = null; + TCSession session = tcform.getSession(); + TCComponentUser user = session.getUser(); + TCComponent taskinbox = user.getReferenceProperty("taskinbox"); + TCComponent[] tasks = taskinbox.getReferenceListProperty("contents"); + //System.out.println("tasks.length=============" + tasks.length); + for(int i = 0; i < tasks.length ; i++){ + if(tasks[i].getType().equals("TasksToPerform")){ + TCComponent[] mytasks = tasks[i].getReferenceListProperty("contents"); + System.out.println("mytasks.length=============" + mytasks.length); + for(int j = 0 ; j < mytasks.length ;j++){ + TCComponent parentProcess = mytasks[j].getReferenceProperty("parent_process"); + System.out.println("parentProcess=============" + parentProcess); + if(strProcess.equals(parentProcess.toString())){ +// if(componentV.contains(parentProcess)){//TODO lidy20190115 + TCComponent taskparent = null; + String strTaskType = mytasks[j].getType(); + System.out.println("strTaskType = " + strTaskType); + if(strTaskType.equals("EPMConditionTask") || + strTaskType.equals("EPMDoTask") || + strTaskType.equals("EPMTask") || + strTaskType.equals("EPMAcknowledgeTask") || + strTaskType.equals("EPMReviewTask")){ + taskparent = mytasks[j]; + }else{ + taskparent = mytasks[j].getReferenceProperty("parent_task"); + } + for(int k = 1; k < component.length ; k ++){ + System.out.println("taskparent.getUid()======" + taskparent.getUid() + "======component[k].getUid()======" + component[k].getUid()); + if(taskparent.equals(component[k])){ + task = (TCComponentTask) taskparent; + break; + } + } + } + } + } + } + if(task == null){ + return; + } + System.out.println("task = " + task); + String strFormType = tcform.getType(); + System.out.println("strFormType = " + strFormType); + + TCComponent handlerComponent = task.getHandler(TCHandlerType.RULE, TCComponentTaskTemplate.START_ACTION, "EPMC_check_form_attribute"); + System.out.println("handlerComponent = " + handlerComponent); + if (handlerComponent != null && handlerComponent instanceof TCComponentRuleHandler) { + TCComponentRuleHandler handler = (TCComponentRuleHandler) handlerComponent; + String[] args = handler.getArguments(); + if (args != null && args.length > 0) { + for (int i = 0; i < args.length; i++) { + System.out.println("args[" + i + "]:::::::::::" + args[i]); + String argumentValue = args[i].split("=")[1]; + if (args[i].startsWith("-form_type")) { + argumentValue = argumentValue.replace("", ";"); + if (argumentValue.contains(";")) { + String[] arrValue = argumentValue.split(";"); + for (int j = 0; j < arrValue.length; j++) { + if(strFormType.equals(arrValue[j])){ + isNeedCheck = true; + break; + } + } + } else { + if(strFormType.equals(argumentValue)){ + isNeedCheck = true; + } + } + System.out.println("Formͣform_type::::" + argumentValue); + } else if (args[i].startsWith("-modifiable_attr")) { + argumentValue = argumentValue.replace("", ";"); + if (argumentValue.contains(";")) { + String[] arrValue = argumentValue.split(";"); + for (int j = 0; j < arrValue.length; j++) { + vtModifiableAttr.add(arrValue[j]); + } + } else { + vtModifiableAttr.add(argumentValue); + } + System.out.println("Formдԣmodifiable_attr::::" + argumentValue); + } else if (args[i].startsWith("-require_attr")) { + argumentValue = argumentValue.replace("", ";"); + if (argumentValue.contains(";")) { + String[] arrValue = argumentValue.split(";"); + for (int j = 0; j < arrValue.length; j++) { + vtReqAttr.add(arrValue[j]); + } + } else { + vtReqAttr.add(argumentValue); + } + System.out.println("Formԣrequire_attr::::" + argumentValue); + } + } + } + } + System.out.println("isNeedCheck = " + isNeedCheck); + System.out.println("vtModifiableAttr = " + vtModifiableAttr); + System.out.println("vtReqAttr = " + vtReqAttr); + } catch (TCException e) { + e.printStackTrace(); + } + //System.out.println("checkHandler ....end"); + } + + /** + * setEnable:Կɱ༭ + */ + @SuppressWarnings("unchecked") + public void setEnable() { + System.out.println("setEnable()...start"); + //FormUtilApi formApi = new FormUtilApi(tcform.getSession()); + if (vtModifiableAttr.size() > 0) { + Iterator> iter = allComponents.entrySet().iterator(); + while(iter.hasNext()) { + Entry entry = (Entry)iter.next(); + String name = (String)entry.getKey(); + Component component = (Component)entry.getValue(); + if(!vtModifiableAttr.contains(name)){ + if (component instanceof iTextField || + component instanceof DateButton || + component instanceof JButton || + component instanceof JRadioButton || + component instanceof JCheckBox || + component instanceof JTextArea || + component instanceof JTable || + component instanceof JComboBox) { + component.setEnabled(false); + } else { + component.setEnabled(true); + } + continue; + } + if (component instanceof iTextField) { + iTextField textField = (iTextField) component; + System.out.println("iTextField-" + name + "=======setEnabled"); + textField.setEnabled(true); + textField.setEditable(true); + }else if(component instanceof JTextArea){ + JTextArea areaField = (JTextArea) component; + System.out.println("JTextArea-" + name + "=======setEnabled"); + areaField.setEnabled(true); + areaField.setEditable(true); + areaField.setBackground(Color.WHITE); + }else if(component instanceof JComboBox){ + JComboBox cbo = (JComboBox) component; + System.out.println("JComboBox-" + name + "=======setEnabled"); + cbo.setEnabled(true); + //cbo.setEditable(true); + cbo.setBackground(Color.white); + }else if(component instanceof DateButton){ + DateButton datebtn = (DateButton) component; + System.out.println("DateButton-" + name + "=======setEnabled"); + datebtn.setEnabled(true); + }else if(component instanceof JButton){ + JButton btn = (JButton) component; + System.out.println("JButton-" + name + "=======setEnabled"); + btn.setEnabled(true); + }else if(component instanceof JCheckBox){ + JCheckBox btn = (JCheckBox) component; + System.out.println("JCheckBox-" + name + "=======setEnabled"); + btn.setEnabled(true); + }else if(component instanceof JTable){ + JTable table = (JTable) component; + System.out.println("JTable-" + name + "=======setEnabled"); + table.setEnabled(true); + } + } + } + System.out.println("setEnable()...end"); + } + +// private Boolean inProcess(TCComponent target, TCComponent process) { +// return false; +// } +} diff --git a/src/com/connor/mdbksplm/util/BusyLabelDemo.java b/src/com/connor/mdbksplm/util/BusyLabelDemo.java new file mode 100644 index 0000000..7260cf3 --- /dev/null +++ b/src/com/connor/mdbksplm/util/BusyLabelDemo.java @@ -0,0 +1,42 @@ +package com.connor.mdbksplm.util; + +import org.jdesktop.swingx.JXBusyLabel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; + +public class BusyLabelDemo { + private JFrame frame; + private JPanel panel; + private JXBusyLabel busyLabel; + public BusyLabelDemo() { + frame = new JFrame("УԵ......"); + panel = new JPanel(new BorderLayout()); + busyLabel = new JXBusyLabel(); + panel.add(busyLabel, BorderLayout.CENTER); + frame.add(panel); + frame.setPreferredSize(new Dimension(400, 100)); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setLocationRelativeTo(null); + } + public void showBusyLabel() { + busyLabel.setBusy(true); + frame.setVisible(true); + } + public void hideBusyLabel() { + busyLabel.setBusy(false); + frame.setVisible(false); + } +// public static void main(String[] args) { +// BusyLabelDemo demo = new BusyLabelDemo(); +// demo.showBusyLabel(); +// try { +// Thread.sleep(5000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// demo.hideBusyLabel(); +// } +} diff --git a/src/com/connor/mdbksplm/util/ConnorUtils.java b/src/com/connor/mdbksplm/util/ConnorUtils.java new file mode 100644 index 0000000..f758f1d --- /dev/null +++ b/src/com/connor/mdbksplm/util/ConnorUtils.java @@ -0,0 +1,440 @@ +package com.connor.mdbksplm.util; + +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Window; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JFileChooser; +import javax.swing.JTable; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.TableColumn; + + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Utilities; + + +public class ConnorUtils { + //TCķ + public static TCPreferenceService service; + public static TCSession session; + public static TCUserService userService; + static { + if (session == null) { + session = (TCSession) (AIFUtility.getCurrentApplication().getSession()); + } + if (service == null) + service = session.getPreferenceService(); + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + /** + * ڶתΪַ + * @param sdf SimpleDateFormat + * @param date ڶ + * @return ڵַ + */ + public static String getDate2String(SimpleDateFormat sdf, Date date) { + if (sdf == null || date == null) { + return ""; + } + return sdf.format(date); + } + + /** + * ȡֵѡ + * + * @param prefName + * @param split ָ + * @return HashMapʽѡ + */ + public static LinkedHashMap getPrefStrHashMap(String prefName, String split) { + LinkedHashMap map = new LinkedHashMap(); + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + if (strs != null) { + for (String str : strs) { + String temp[] = str.split(split); + if(temp!=null) { + if(temp.length==2) { + map.put(temp[0], temp[1]); + }else { + map.put(temp[0],""); + } + } + } + } + return map; + } + /** + * ȡֵѡ + * + * @param prefName + * @param split ָ + * @return + */ + public static HashMap> getPrefListHashMap(String prefName, String split) { + HashMap> map = new HashMap>(); + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + if (strs != null) { + for (String str : strs) { + String temp[] = str.split(split); + if(temp!=null) { + if(map.containsKey(temp[0])) { + List list = map.get(temp[0]); + if(list==null) { + list = new ArrayList(); + } + if(temp.length==2) { + list.add(temp[1]); + }else { + list.add(""); + } + }else { + List list = new ArrayList(); + if(temp.length==2) { + list.add(temp[1]); + }else { + list.add(""); + } + map.put(temp[0], list); + } + } + } + } + return map; + } + + public static String getPrefValue(String prefName){ + return service.getStringValue(prefName); + } + + public static String[] getPrefValues(String prefName){ + return service.getStringValues(prefName); + } + + public static void setByPass(boolean val) { + try { + if (userService == null) { + userService = ConnorUtils.session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = ""; + if (val) { + userService.call("Connor_set_bypass", obj); + } else { + userService.call("Connor_close_bypass", obj); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * ͨpuidȡģ + * @param templetePuid ģpuid + * + * @return ģļ + * + */ + public static File getTempleteData(String templetePuid){ + + if(templetePuid==null) { + return null; + } + File file = null; + try { + TCComponentDataset dataset = (TCComponentDataset) session.stringToComponent(templetePuid); + String[] types = dataset.getProperty("ref_names").split(","); + String temp = System.getenv("temp"); + File[] files = dataset.getFiles(types[0],temp); + if(files!=null && files.length>0) { + file = files[0]; + } + } catch (Exception e) { + MessageBox.post(""+e.getMessage(),"", 2); + return null; + } + if(file == null || !file.exists()) { + MessageBox.post("ݼpuid"+templetePuid+"ģʧ","", 2); + return null; + } + return file; + } + + public static Connection getOracleConnection() { + Connection connection=null; + try { + // + Class.forName("oracle.jdbc.driver.OracleDriver"); + String[] dbinfos = ConnorUtils.getPrefValues("OA_GET_COST_Conn"); + String user = dbinfos[0]; + String password = dbinfos[1]; + String url = "jdbc:oracle:thin:@" + dbinfos[2]; + connection = DriverManager.getConnection(url, user, password); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + MessageBox.post("ݿʧܣʧԭ"+e.getMessage(),"ʾ",MessageBox.INFORMATION); + } catch (SQLException e) { + e.printStackTrace(); + MessageBox.post("ݿʧܣʧԭ"+e.getMessage(),"ʾ",MessageBox.INFORMATION); + } + return connection; + } + + public static Connection getSqlServerConnection() { + Connection connection=null; + try { + // + Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); + String[] dbinfos = ConnorUtils.getPrefValues("MT_dbinfo"); + String user = dbinfos[0]; + String password = dbinfos[1]; + String url = "jdbc:sqlserver://"+dbinfos[3] +":1433;DataBaseName=" + dbinfos[2]; + connection = DriverManager.getConnection(url, user, password); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + MessageBox.post("ݿʧܣʧԭ"+e.getMessage(),"ʾ",MessageBox.INFORMATION); + } catch (SQLException e) { + e.printStackTrace(); + MessageBox.post("ݿʧܣʧԭ"+e.getMessage(),"ʾ",MessageBox.INFORMATION); + } + return connection; + } + + public static Connection getERPConnection() { + Connection connection=null; + try { + // + Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); + String[] dbinfos = ConnorUtils.getPrefValues("MT_ERP_DBinfo"); + String user = dbinfos[0]; + String password = dbinfos[1]; + String url = "jdbc:sqlserver://"+dbinfos[3] +";DataBaseName=" + dbinfos[2]; + connection = DriverManager.getConnection(url, user, password); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + MessageBox.post("ݿʧܣʧԭ"+e.getMessage(),"ʾ",MessageBox.INFORMATION); + } catch (SQLException e) { + e.printStackTrace(); + MessageBox.post("ݿʧܣʧԭ"+e.getMessage(),"ʾ",MessageBox.INFORMATION); + } + return connection; + } + + public static void ChangeValue(String[] value1,String[] value2) { + String[] temp; + temp = value1; + value1 = value2; + value2 = temp; + } + /** + * ļ + * @param parent + * @return + */ + public static File chooseDirectory(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + /** + * ļ͹ļ + */ + public static File chooseFile(Component parent,String type) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + MyFileFilter mFilter = new MyFileFilter(type); + fileChooser.addChoosableFileFilter(mFilter); + fileChooser.setFileFilter(mFilter); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + + public static void HiddenCell(int column,JTable table) { + TableColumn tc = table.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + public static void post(Component var0,String value,String title) { + Dialog var16 = Utilities.getParentDialog(var0); + if (var16 != null) { + MessageBox.post(var16, value, title, 2); + } else { + MessageBox.post(Utilities.getParentFrame(var0), value, title, 2); + } + } + + // lovֵ + public static Map getLOVs(String lovName) { + Map map = new LinkedHashMap(); + map.put("", ""); + try { + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) { + ListOfValuesInfo listOfValues = lov[0].getListOfValues(); + String[] realval = listOfValues.getStringListOfValues(); + for (int i = 0; i < realval.length; i++) { + String disval = listOfValues.getDisplayableValue(realval[i]); + map.put(disval, realval[i]); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return map; + } + + public static TCComponent getLatestReleaseRevison(TCComponent component) throws Exception{ + TCComponent[] revisions = component.getTCProperty("revision_list").getReferenceValueArray(); + for (int i = revisions.length-1; i >= 0; i--) { + TCComponent[] release_statuas = revisions[i].getReferenceListProperty("release_status_list"); + if (release_statuas!=null && release_statuas.length > 0) { + return revisions[i]; + } + } + return null; + } + + public static TCComponent getLastReleaseRevisonFormByStatus(TCComponent component) throws Exception{ + String[] cpxpzt_status = session.getPreferenceService().getStringValues("Cpxpzt"); + TCComponent[] revisions = component.getTCProperty("revision_list").getReferenceValueArray(); + for (int i = revisions.length-1; i >= 0; i--) { + TCComponent[] release_statuses = revisions[i].getReferenceListProperty("release_status_list"); + if (release_statuses!=null && release_statuses.length > 0) { + for(TCComponent release_status:release_statuses) { + for(String sxx_value:cpxpzt_status) { + if (release_status.getStringProperty("object_name").equals(sxx_value)) { + return revisions[i].getReferenceListProperty("IMAN_master_form_rev")[0]; + } + } + } + } + } + return null; + } + + public static boolean isDigit(String str) { + if (ConnorUtils.isEmpty(str)) { + return false; + } + char[] chars = str.toCharArray(); + int len = chars.length; + for (int i = 0; i < len; i++) { + char c = chars[i]; + if (!(c >= '0' && c <= '9')) { + return false; + } + } + return true; + } + + public static boolean isNumericzidai(String str) { + Pattern pattern = Pattern.compile("-?[0-9]+\\.?[0-9]*"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + } + + public static void getClassification(TCComponentItemRevision rev) { + try { + TCComponentICO[] icos = rev.getClassificationObjects(); + if(icos==null || icos.length==0) { + return; + } + for(int i=0;i void deepCopy(List src, List dest) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(src); + oos.flush(); + oos.close(); + bos.close(); + byte[] byteData = bos.toByteArray(); + ByteArrayInputStream bais = new ByteArrayInputStream(byteData); + List copy = (List) new ObjectInputStream(bais).readObject(); + bais.close(); + dest.clear(); + dest.addAll(copy); + } catch (Exception e) { + // 쳣 + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/mdbksplm/util/MyFileFilter.java b/src/com/connor/mdbksplm/util/MyFileFilter.java new file mode 100644 index 0000000..078c2b5 --- /dev/null +++ b/src/com/connor/mdbksplm/util/MyFileFilter.java @@ -0,0 +1,26 @@ +package com.connor.mdbksplm.util; + +import java.io.File; + +import javax.swing.filechooser.FileFilter; + +public class MyFileFilter extends FileFilter{ + + private String type=""; + + + public MyFileFilter(String type) { + this.type = type; + } + @Override + public boolean accept(File file) { + String name = file.getName(); + return file.isDirectory() || name.toLowerCase().endsWith("."+type); + } + + @Override + public String getDescription() { + return "*."+type; + } + +} diff --git a/src/com/connor/mdbksplm/util/ProgressBar.java b/src/com/connor/mdbksplm/util/ProgressBar.java new file mode 100644 index 0000000..29e6dc9 --- /dev/null +++ b/src/com/connor/mdbksplm/util/ProgressBar.java @@ -0,0 +1,177 @@ +/** + * @file ProgressBar.java + * + * @brief Create progress bar + * + * @author Yanghui + * + * @history + * ================================================================ + * Date Name Description of Change + * 25-July-2008 Yanghui this class is used to create + * progress bar. + */ +package com.connor.mdbksplm.util; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; + +/** + * @class ProgressBar + * @brief Create progress bar + * @author Yanghui + */ +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * @var ProgressBar.progressbar + * @brief JProgressBar + */ + private JProgressBar progressbar; + + /** + * @var ProgressBar.label + * @brief label used to tips + */ + private JLabel label; + + /** + * @var ProgressBar.timer + * @brief timer used to timing operation + */ + private Timer timer; + + /** + * @var ProgressBar.bool + * @brief bool used to flag thread return + */ + private boolean bool = false; + + /** + * @var Progressbar.registry + * @brief Registry + */ + private Registry registry; + + /** + * @fn public ProgressBar() + * @brief constructor + * @param[in] null + */ + private String showLable = null; + + public ProgressBar(String showlable) { + super(true); + showLable = showlable; + this.setAlwaysOnTop(true); + } + + /** + * @fn public void setBool(boolean bool) + * @brief set bool value + * @param[in] bool + * @param[out] null + */ + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * @fn private void initUI() + * @brief createDialog method + * @param[in] null + * @param[out] null + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.label = new JLabel(showLable, JLabel.CENTER); + this.progressbar = new JProgressBar(); + this.progressbar.setOrientation(JProgressBar.HORIZONTAL); + this.progressbar.setMinimum(0); + this.progressbar.setMaximum(100); + this.progressbar.setValue(0); + this.progressbar.setPreferredSize(new Dimension(200, 15)); + this.progressbar.setBorderPainted(true); + this.timer = new Timer(50, (ActionListener) this); + this.timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + bool = true; + } + }); + this.setVisible(true); + } + + /** + * @class TaskThread + * @brief Create progressbar + * + */ + class TaskThread extends Thread { + private ProgressBar bar; + + public TaskThread(ProgressBar bar) { + this.bar = bar; + } + + public void run() { + if (bool == false) { + // Set Status is running. + // session.setStatus(registry.getString("export Running")); + } + for (int i = 0; i < i + 1; i++) { + timer.start(); + int value = progressbar.getValue(); + if (value < 100) { + value = value + 5; + progressbar.setValue(value); + } else { + timer.stop(); + progressbar.setValue(0); + } + try { + sleep(100); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (bool == true) { + this.bar.setVisible(false); + this.bar.disposeDialog(); + this.bar.dispose(); + this.interrupt(); + return; + + } + + } + } + } + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/connor/mdbksplm/util/ProgressBarDemo.java b/src/com/connor/mdbksplm/util/ProgressBarDemo.java new file mode 100644 index 0000000..cef750d --- /dev/null +++ b/src/com/connor/mdbksplm/util/ProgressBarDemo.java @@ -0,0 +1,52 @@ +package com.connor.mdbksplm.util; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import java.awt.BorderLayout; +import java.awt.Dimension; +public class ProgressBarDemo { + private JFrame frame; + private JPanel panel; + private JProgressBar progressBar; + private JLabel label; + public ProgressBarDemo() { + frame = new JFrame(""); + panel = new JPanel(new BorderLayout()); + progressBar = new JProgressBar(); + progressBar.setMinimum(0); + progressBar.setMaximum(100); + label = new JLabel("ڼأԵ..."); + panel.add(progressBar, BorderLayout.CENTER); + panel.add(label, BorderLayout.SOUTH); + frame.add(panel); + frame.setPreferredSize(new Dimension(400, 100)); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setLocationRelativeTo(null); + } + public void showProgressBar() { + progressBar.setIndeterminate(true); + frame.setVisible(true); + } + public void hideProgressBar() { + progressBar.setIndeterminate(false); + frame.setVisible(false); + } + public void updateProgress(int value) { + progressBar.setValue(value); + } +// public static void main(String[] args) { +// ProgressBarDemo demo = new ProgressBarDemo(); +// demo.showProgressBar(); +// for (int i = 0; i <= 100; i++) { +// try { +// Thread.sleep(50); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +//// demo.updateProgress(i); +// } +// demo.hideProgressBar(); +// } +} \ No newline at end of file diff --git a/src/com/connor/mdbksplm/util/ProgressBarThread.java b/src/com/connor/mdbksplm/util/ProgressBarThread.java new file mode 100644 index 0000000..e493098 --- /dev/null +++ b/src/com/connor/mdbksplm/util/ProgressBarThread.java @@ -0,0 +1,23 @@ +package com.connor.mdbksplm.util; + +public class ProgressBarThread extends Thread { + + private ProgressBar bar; + + private String title; + + public ProgressBarThread(String title, String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + bar.initUI(); + } + + public void setBool(boolean bool) { + bar.setBool(true); + bar.setAlwaysOnTop(false); + } +} diff --git a/src/com/connor/mdbksplm/util/S8ProgressBar.java b/src/com/connor/mdbksplm/util/S8ProgressBar.java new file mode 100644 index 0000000..ea6a996 --- /dev/null +++ b/src/com/connor/mdbksplm/util/S8ProgressBar.java @@ -0,0 +1,105 @@ +package com.connor.mdbksplm.util; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.Timer; + +public class S8ProgressBar extends AbstractAIFDialog + implements ActionListener +{ + private static final long serialVersionUID = 1L; + private JProgressBar progressbar; + private JLabel label; + private Timer timer; + private boolean bool = false; + private String showLable = null; + + public S8ProgressBar(String showlable) { + super(true); + this.showLable = showlable; + } + + public void setBool(boolean bool) + { + this.bool = bool; + } + + public void initUI() + { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + this.label = new JLabel(this.showLable, 0); + this.progressbar = new JProgressBar(); + this.progressbar.setOrientation(0); + this.progressbar.setMinimum(0); + this.progressbar.setMaximum(100); + this.progressbar.setValue(0); + this.progressbar.setPreferredSize(new Dimension(200, 15)); + this.progressbar.setBorderPainted(true); + this.timer = new Timer(50, this); + this.timer.setRepeats(false); + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", this.label); + mainPanel.add("3.1.center", this.progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + //setLocation(500, 200); + centerToScreen(); + TaskThread thread = new TaskThread(this); + thread.start(); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + S8ProgressBar.this.bool = true; + } + }); + setVisible(true); + } + + public void actionPerformed(ActionEvent arg0) + { + } + + class TaskThread extends Thread + { + private S8ProgressBar bar; + + public TaskThread(S8ProgressBar bar) { + this.bar = bar; + } + + public void run() + { + for (int i = 0; i < i + 1; i++) { + S8ProgressBar.this.timer.start(); + int value = S8ProgressBar.this.progressbar.getValue(); + if (value < 100) { + value += 5; + S8ProgressBar.this.progressbar.setValue(value); + } else { + S8ProgressBar.this.timer.stop(); + S8ProgressBar.this.progressbar.setValue(0); + } + try { + sleep(100L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (S8ProgressBar.this.bool) { + this.bar.setVisible(false); + this.bar.dispose(); + return; + } + } + } + } +} \ No newline at end of file diff --git a/src/com/connor/mdbksplm/util/S8ProgressBarThread.java b/src/com/connor/mdbksplm/util/S8ProgressBarThread.java new file mode 100644 index 0000000..57684a9 --- /dev/null +++ b/src/com/connor/mdbksplm/util/S8ProgressBarThread.java @@ -0,0 +1,27 @@ +package com.connor.mdbksplm.util; + +public class S8ProgressBarThread extends Thread +{ + private S8ProgressBar bar; + private String title; + + public S8ProgressBarThread(String title, String message) + { + this.title = title; + this.bar = new S8ProgressBar(message); + } + + public void run() { + this.bar.setTitle(this.title); + this.bar.initUI(); + } + + public void stopBar() { + this.bar.setBool(true); + } + + public void setBarMsg(String str) + { + this.bar.setTitle(str); + } +} \ No newline at end of file diff --git a/src/com/connor/mdbksplm/util/SoaServerUtil.java b/src/com/connor/mdbksplm/util/SoaServerUtil.java new file mode 100644 index 0000000..b8e2618 --- /dev/null +++ b/src/com/connor/mdbksplm/util/SoaServerUtil.java @@ -0,0 +1,177 @@ +//package com.connor.mdbksplm.util; +//import java.util.ArrayList; +//import java.util.List; +// +//import org.apache.axiom.om.OMAbstractFactory; +//import org.apache.axiom.om.OMElement; +//import org.apache.axiom.om.OMFactory; +//import org.apache.axiom.om.OMNamespace; +//import org.apache.axis2.AxisFault; +//import org.apache.axis2.addressing.EndpointReference; +//import org.apache.axis2.client.Options; +//import org.apache.axis2.client.ServiceClient; +// +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.TCAccessControlService; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCComponentUser; +//import com.teamcenter.rac.kernel.TCComponentUserType; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.TCUserService; +// +//public class SoaServerUtil { +// +// public static TCPreferenceService preferenceService; +// public static String priverUserID; +// public static String webServiceURL; +// +// static{ +// try { +// +// if(preferenceService == null){ +// preferenceService = ((TCSession) AIFUtility.getCurrentApplication().getSession()).getPreferenceService(); +// } +// +// if(priverUserID == null){ +// priverUserID = preferenceService.getString(TCPreferenceService.TC_preference_site, "Autocode_PriverUser_ID"); +// } +// +// if(webServiceURL == null){ +// webServiceURL = preferenceService.getString(TCPreferenceService.TC_preference_site, "Autocode_SendClassServer_URL"); +// } +// +// }catch(Exception e){ +// e.printStackTrace(); +// } +// } +// +// public static void sendToClass(String wsoPUID, String classID, String json) { +// try { +// ServiceClient sc = new ServiceClient(); +// Options opts = new Options(); +// String url = webServiceURL;//"http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; +// EndpointReference end = new EndpointReference(url); +// opts.setTo(end); +// opts.setAction("SendToClass"); +// sc.setOptions(opts); +// OMFactory fac = OMAbstractFactory.getOMFactory(); +// OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); +// OMElement method = fac.createOMElement("SendToClass", omNs); +// OMElement value = fac.createOMElement("wsoPuiid", omNs); +// value.setText(wsoPUID); +// OMElement value1 = fac.createOMElement("classID", omNs); +// value1.setText(classID); +// OMElement value2 = fac.createOMElement("JsonContainer", omNs); +// // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" +// value2.setText(json); +// +// method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); +// +// OMElement res = sc.sendReceive(method); +// res.getFirstElement().getText(); +// System.out.println(res.getFirstElement().getText()); +// } catch (AxisFault e) { +// e.printStackTrace(); +// } +// +// } +// +// public static void grantReadPrivilege(TCSession tcSession, TCComponent tccomponent +// ) { +// try { +// TCAccessControlService accessControlService = tcSession +// .getTCAccessControlService(); +// TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); +// TCComponentUser user = type.find(priverUserID);//2135 +// +// if(user ==null){ +// return; +// } +// if(tcSession.getUser().equals(user)){ +// return; +// } +// +// String[] as2 = new String[] { "READ" }; +// +// if (tccomponent instanceof TCComponentItemRevision) { +// TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent) +// .getItem(); +// openByPass(tcSession); +// accessControlService.grantPrivilege(tempItem, user, as2); +// closeByPass(tcSession); +// +// +// openByPass(tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// closeByPass(tcSession); +// } else { +// openByPass(tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// closeByPass(tcSession); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public static void grantWritePrivilege(TCSession tcSession, TCComponent tccomponent +// ) { +// try { +// TCAccessControlService accessControlService = tcSession +// .getTCAccessControlService(); +// TCComponentUserType type = (TCComponentUserType) tcSession.getTypeComponent("User"); +// +// TCComponentUser user = type.find(priverUserID);//2135 +// if(user ==null){ +// return; +// } +// if(tcSession.getUser().equals(user)){ +// return; +// } +// +// String[] as2 = new String[] { "READ", "WRITE" ,"DELETE"}; +// +// if (tccomponent instanceof TCComponentItemRevision) { +// TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent) +// .getItem(); +// openByPass(tcSession); +// accessControlService.grantPrivilege(tempItem, user, as2); +// closeByPass(tcSession); +// +// +// openByPass(tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// closeByPass(tcSession); +// } else { +// openByPass(tcSession); +// accessControlService.grantPrivilege(tccomponent, user, as2); +// closeByPass(tcSession); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public static void openByPass(TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[1]; +// obj[0] = "origin"; +// userservice.call("Connor_set_bypass", obj); +// } +// +// public static void closeByPass(TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[1]; +// obj[0] = "origin"; +// userservice.call("Connor_close_bypass", obj); +// } +// +//} diff --git a/src/com/connor/mdbksplm/util/WaitingDialog.java b/src/com/connor/mdbksplm/util/WaitingDialog.java new file mode 100644 index 0000000..688076d --- /dev/null +++ b/src/com/connor/mdbksplm/util/WaitingDialog.java @@ -0,0 +1,70 @@ +package com.connor.mdbksplm.util; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; + +public class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog +{ + public JPanel panel ; + JProgressBar progressBar =null; + public WaitingDialog(Frame arg0, String title, String message) + { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /*JLabel label = new JLabel(message); + System.out.println("message:"+message); + System.out.println("label:"+label); + panel.add(label);*/ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER,new Label(message)); + panel.add(BorderLayout.SOUTH,progressBar); + + + panel.setPreferredSize(new Dimension(350,60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + + public void SetDialogMessage(String sMessage) + { + try + { + Component[] components = panel.getComponents(); + for(int i = 0 ; i < components.length ; i++) + { + if(components[i] instanceof Label) + { + Label label = (Label)components[i]; + label.setText(sMessage); + break; + } + } + } + catch(Exception e) + { + } + finally + { + } + return; + } +}