 package com.connor.erp.materialquery.ViewStockOfERP;
 
 import com.connor.erp.toolkit.UtilApi;
 import com.teamcenter.rac.aif.AbstractAIFDialog;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.table.DefaultTableModel;
 
 public class ViewStockOfERPDialog extends AbstractAIFDialog {
   private static final long serialVersionUID = 1L;
   
   private JTable table;
   
   private Map<String, List<String[]>> map;
   
   private JScrollPane scrollPane;
   
   public ViewStockOfERPDialog(Map<String, List<String[]>> pmap) {
/*  46 */     super(false);
/*  47 */     this.map = pmap;
/*  48 */     initUI();
   }
   
   private void initUI() {
/*  55 */     setTitle("ERP物料库存");
/*  56 */     String[] colName = { "序号", "物料编号", "物料名称", "组织", "子库", "库存数量" };
/*  57 */     CMap m = new CMap1();
/*  58 */     DefaultTableModel tm = new DefaultTableModel((Object[][])fillData(), (Object[])colName) {
         private static final long serialVersionUID = 1L;
         
         public boolean isCellEditable(int indexRow, int indexColumn) {
/*  65 */           return false;
         }
       };
/*  68 */     this.table = new CTable(m, tm);
/*  69 */     UtilApi.FitTableColumns(this.table);
/*  71 */     this.scrollPane = new JScrollPane(this.table);
/*  72 */     getContentPane().add(this.scrollPane);
   }
   
   public String[][] fillData() {
/*  76 */     Set<String> set = this.map.keySet();
/*  77 */     Iterator<String> iterator = set.iterator();
/*  78 */     List<String> materialList = new ArrayList<String>();
/*  79 */     while (iterator.hasNext()) {
/*  80 */       String material = ((String)iterator.next()).toString();
/*  81 */       materialList.add(material);
     } 
/*  83 */     Collections.sort(materialList, new Comparator<String>() {
           public int compare(String o1, String o2) {
/*  87 */             return o1.compareTo(o2);
           }
         });
/*  91 */     int listSize = materialList.size();
/*  92 */     List<String[]> dataList = (List)new ArrayList<String>();
/*  93 */     for (int i = 0; i < listSize; i++) {
/*  94 */       List<String[]> list = this.map.get(materialList.get(i));
/*  95 */       int listSize2 = list.size();
/*  96 */       for (int j = 0; j < listSize2; j++) {
/*  97 */         String[] arrStr = list.get(j);
/*  98 */         String[] arrayOfString1 = new String[6];
/*  99 */         arrayOfString1[0] = String.valueOf(i + 1);
/* 100 */         arrayOfString1[1] = arrStr[0];
/* 101 */         arrayOfString1[2] = arrStr[1];
/* 102 */         arrayOfString1[3] = arrStr[2];
/* 103 */         arrayOfString1[4] = arrStr[3];
/* 104 */         arrayOfString1[5] = arrStr[4];
/* 105 */         dataList.add(arrayOfString1);
       } 
     } 
/* 108 */     String[][] tableData = new String[dataList.size()][];
/* 109 */     tableData = dataList.<String[]>toArray(tableData);
/* 110 */     return tableData;
   }
 }
