zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
package Frame;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import ColorAndFont.English;
import ColorAndFont.NothJPanel;
import ColorAndFont.UIColor;
import ColorAndFont.buttonTitle;
import PbuliClass.JButtonModel;
import PbuliClass.OutButton;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import PbuliClass.greateTables;
import PbuliClass.jinternalFrame;
import anchor.Anchor;
import anchor.Anchor_Dell;
import anchor.Dell_cengao;
import tbDataModel.Tb_cengzu;
import tbDataModel_Dell.Dell_tbcengzu;
@SuppressWarnings("rawtypes")
public class SuanfaTable  extends jinternalFrame{
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    NothJPanel northJpanel=null;//±±²¿Ãæ°å
    JPanel centerJpanel=null;//Öв¿Ãæ°å
    JButtonModel jbut;//°´Å¥Ä£ÐÍ
    JTextField searchFileld=null;//ËÑË÷Îı¾¿ò
    JButtonModel search=null;//ËÑË÷°´Å¥
    JButtonModel shuaxin=null;//ˢа´Å¥
    JTable table=null;//ÉêÃ÷±í¸ñ
    Vector rowData=null;
    DefaultTableModel tableModel;//±í¸ñÄ£ÐÍ
    int tagnum;//±í¸ñ×ÜÐÐÊý
    Container rq;
    JScrollPane gd;    
 
    public SuanfaTable() {
        rowData=new Vector();
        String title="Ëã·¨ÅäÖñí¸ñ";
        if(Systems.sys().getLanguage().equals("English")) {
            title="SuanFa Table";
        }
        this.setTitle(title);
        this.setFrameIcon(new ImageIcon("image/icon/systemicon.png"));//ÉèÖô°Ìåͼ±ê    
        rq=getContentPane();//»ñÈ¡ÈÝÆ÷
        rq.setLayout(new BorderLayout());
        rq.add(getNorthJpanel(),BorderLayout.NORTH);
        rq.add(getGd());
        this.setBounds(175,0,1000,610);
    }
 
    /**»ñÈ¡±±²¿Ãæ°å*/
    public NothJPanel getNorthJpanel() {
        if(northJpanel==null) {
            northJpanel=new NothJPanel();
            Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
            topicBox.add(getSearchFileld());//Ìí¼ÓËÑË÷Îı¾¿ò
            topicBox.add(Box.createHorizontalStrut(3));// Ìí¼ÓÒ»¸ö3ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getSearch());//Ìí¼ÓËÑË÷°´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getShuaxin());//Ìí¼Óˢа´Å¥ 
            northJpanel.add(topicBox );    
        }
 
        return northJpanel;
    }
 
    /**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/
    public JTextField getSearchFileld() {
        if(searchFileld==null){
            searchFileld=new JTextField(10);
            searchFileld.addKeyListener(new KeyListener() {    //¼üÅÌʼþ¼àÌý                
                public void keyTyped(KeyEvent e) {        
                }                    
                public void keyReleased(KeyEvent e) {
                    int keyCode=e.getKeyCode();
                    if(keyCode==KeyEvent.VK_ENTER) {
                        getSearch().doClick();//ËÑË÷°´Å¥±»µã»÷
                    }                        
                }                    
                public void keyPressed(KeyEvent e) {                
                }
            });
        }
        return searchFileld;
    }
 
 
    /**»ñÈ¡ËÑË÷°´Å¥µÄ·½·¨*/    
    public JButtonModel getSearch() {
        if(search==null){
            search=new JButtonModel(buttonTitle.getSerch());
            search.addActionListener(new ActionListener() {    
                public void actionPerformed(ActionEvent e) {
                    // Ö´ÐÐSQL²éѯÓï¾ä»ñµÃµÄ½á¹û¼¯    
                    try {    
                        if(getSearchFileld().getText().length()>1) {
                            String go=getSearchFileld().getText().trim();
                            updateSerch(go);
                        }
                    } catch (Exception er) {
                        er.printStackTrace();
                    }
                }
            });
        }
        return search;
    }
 
 
    /**»ñȡˢа´Å¥µÄ·½·¨*/    
    public JButtonModel getShuaxin() {
        if(shuaxin==null){
            shuaxin=new JButtonModel(buttonTitle.getRefresh());
            shuaxin.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    updateTable();
                }
            });
 
        }
        return shuaxin;
    }
 
 
    /**»ñÈ¡µ¼³ö±í¸ñ°´Å¥µÄ·½·¨*/    
    public JButtonModel getOutport() {
        OutButton.setAddtime("time");
        OutButton.setDataName("tb_warning");
        return new OutButton().get_ouotport_button();
 
    }
 
    /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/    
    public JScrollPane getGd() {
        gd=new JScrollPane(getTable());
        gd.getViewport().setBackground(UIColor.getNorth_color());
        return gd;
    }
 
 
    /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ 
    public void getRowData(Vector<Anchor> vc) {
        Iterator<Anchor> iterator = vc.iterator();//´´½¨µü´úÆ÷        
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            Anchor tbsuanf=  iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ
            Vector<String> row = new Vector<String>();
            String anchorid=tbsuanf.getAnc_id();
            row.add(anchorid);//»ùÕ¾ID
            String ceng=tbsuanf.getAnc_floor();
            String zu=tbsuanf.getAnc_zu();
            row.add(ceng);//²ã
            row.add(zu);//×é
            row.add(suanfa(ceng,zu));//Ëã·¨
            row.add(tbsuanf.getAnc_distance());//Á¿³Ì
            int cengint=Integer.parseInt(ceng);
            row.add(Dell_cengao.get_tbceng(cengint).getButtom());
            row.add(Dell_cengao.get_tbceng(cengint).getTop());
 
            Anchor acr=Anchor_Dell.get_anchor(anchorid);
 
            //"Èýά»ùÕ¾",
            String sanwei=acr.getBaoliu1();            
            row.add(sanwei);
            //"¿ç²ã¸ß¶È(cm)
            String gaodu=acr.getBaoliu2();
            if(gaodu==null ||gaodu.equals("")) {
                gaodu="ÎÞ";
            }
            row.add(gaodu);
 
            //и߶ÈËùÔÚµÄ×é
            String zu2=acr.getBaoliu3();
            if(zu2==null||zu2.equals("")) {
                zu2="ÎÞ";
            }
            row.add(zu2);
 
            //±Ø¾­¾àÀë(cm)
            String bjjl=acr.getBaoliu4();
            if(bjjl==null||bjjl.equals("")) {
                bjjl="ÎÞ";
            }
            row.add(bjjl);
 
            tableModel.addRow(row);
            ceng=null;
        }
    }
 
 
    /**»ñÈ¡±êÇ©¸æ¾¯±í¸ñµÄ·½·¨*/    
    @SuppressWarnings("serial")
    public JTable getTable() {
        if(table==null) {
            String[] name1= {"»ùÕ¾","²ã","×é","Ë㷨ά¶È ","Á¿³Ì(cm)","µ×¸ß(cm)","¶¥¸ß(cm)","ÆøÑ¹»ùÕ¾","¿ç²ã¸ß¶È(cm)","¿ç²ã×é","±Ø¾­¾àÀë(cm)"};//±í¸ñÁÐÃû
            String[] name2= {"Base station", "dimension", "layer", "group", "base height", "top height"};//±í¸ñÁÐÃû
            String[] columnNames=English.columnNames(name1, name2);
            //Ìí¼Ó±í¸ñÁÐÏòÁ¿
            Vector<String> columnName=new Vector<>();
            for(int i=0;i<columnNames.length;i++){
                columnName.add(columnNames[i]);            
            }
 
            greateTables tables=new greateTables();
            tableModel=new DefaultTableModel(rowData, columnName){  
                //  ÊµÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼­
                public boolean isCellEditable(int row,int column){  
                    return false;  
                }  
            };
            table=tables.getTable(tableModel);
            getRowData(Anchor_Dell.getAnchor_vector());
 
        }
        return table;
    }
 
 
    /**ˢбí¸ñ·½·¨*/
    public void updateTable() {            
        if(tableModel !=null) {
            tableModel.getDataVector().clear();
            getRowData(Anchor_Dell.getAnchor_vector());
            gd.validate();
        }
    }
 
 
    /**ËÑË÷·½·¨*/
    public void updateSerch(String anchorid) {            
        if(Anchor_Dell.get_anchor(anchorid)==null) {
            ShowMessage.zidingyi("ÄãËÑË÷µÄ»ùÕ¾"+anchorid+"²»´æÔÚ...");
            return;
        }
        int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
        if(tagnum >0 ) {
            for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ
                tableModel.removeRow(0);                            
            }
            //½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ
            getRowData(Anchor_Dell.getAnchor_vector());
        }
    }
 
    /**»ñÈ¡»ùÕ¾µÄËã·¨*/
    public String suanfa(String ceng,String zu) {
        StringBuffer a=new StringBuffer();
        String[] zus=zu.split(";");
        Tb_cengzu suanf;
        int size=zus.length;    
        if(size==1) {
            suanf=Dell_tbcengzu.get_tbcengzu(ceng, zu);
            String sf=suanf.getSuan_fa_wei_du();//²ã×éµÄ¶¨Î»Î¬¶È
            a.append(sf);
        }else {
            for(int i=0;i<size;i++) {
                String zustr=zus[i];
                suanf=Dell_tbcengzu.get_tbcengzu(ceng, zustr);
                if(suanf !=null) {
                    String sf=suanf.getSuan_fa_wei_du();//²ã×éµÄ¶¨Î»Î¬¶È
                    if(i !=size-1) {
                        a.append(sf+";");
                    }else {
                        a.append(sf);    
                    }
                }
            }
        }
        return a.toString();
    }
 
 
 
}