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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
package Frame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import BaoWen.Dell_Baowen;
import ColorAndFont.English;
import ColorAndFont.NothJPanel;
import ColorAndFont.UIColor;
import DataBase.DatabaseManagement;
import Method.GetNowTime;
import PbuliClass.JButtonModel;
import PbuliClass.JCheckBoxModel;
import PbuliClass.JlableModel;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import PbuliClass.WarningMessage;
import PbuliClass.greateTables;
import PbuliClass.jinternalFrame;
import tbDataModel.YuanShiBaoWen;
import tbDataModel_Dell.DellYuanshibaowen;
import tbDataModel_Dell.Dell_Tbicon;
@SuppressWarnings("rawtypes")
public class BaoWenHuiFang extends jinternalFrame implements Runnable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    jinternalFrame jinerFrame=null;
    JInternalFrame jinFrame=null;
    JButtonModel deleteicon=null;
    static JButtonModel jbt_tip=null;
    JlableModel  iconName=null;//ͼ±êÃû³Æ
    JButtonModel jbt_jiazai=null;//±¨ÎļÓÔØ
    JButtonModel jbt_hf=null;//±¨ÎĻطÅ
    JButtonModel shua_xin=null;//ˢбêÇ©
    JCheckBoxModel jc_fast=null;
    JScrollPane gdmb=null;//¹ö¶¯Ãæ°å
    static  JTextField  jt_start=new JTextField(5);
    static JTextField  jt_stop=new JTextField(5);
    static Vector<Vector<String>> serchrowData=null;//ËÑË÷Ò³±í¸ñÏòÁ¿
    DefaultTableModel tableModel=null;
    Vector<String> columnName=null;
    JTable table=null;//ÉêÃ÷±í¸ñ    
    Vector rowData=null;
    List list=null ;
    JPanel centerPanel=null;//Öв¿Ãæ°å
    NothJPanel southJpan=null;//Äϲ¿Ãæ°å
    JButtonModel button=null;
    String fileName="";//Îı¾¿òÄÚÈÝ
    String path;//ͼ±ê±£´æµØÖ·
    String path2;//ͼ±ê±£´æµØÖ·
    Container rq;
    static boolean huifangbaowen=false;
    int baowennum=0;
    int i=0;
    String jizhuntime;//Æðʼʱ¼ä
    int j=1;//¼ÓÔØÍêµÄ±¨ÎÄÌõÊý
    int baowenallnum=0;//±¨ÎĵÄ×ÜÌõÊý
 
    static String statrtime="0";
    static String stoptime="0";
 
    JlableModel  jl_start=new JlableModel("¿ªÊ¼ÐòºÅ:");
    JlableModel  jl_stop=new JlableModel("½áÊøÐòºÅ:");
    JlableModel  jl_txt=new JlableModel("txt¼ÓÔØËÙ¶È(ms):");
 
    public BaoWenHuiFang() {
        rowData=new Vector();
        String title="±¨ÎĻطÅ";
        if(Systems.sys().getLanguage().equals("English")) {
            title="Message playback";
        }
        this.setTitle(title);
        rq=getContentPane();//»ñÈ¡ÈÝÆ÷
        rq.setLayout(new BorderLayout());
        rq.setBackground(UIColor.getNorth_color());
        rq.add(getSouthJpan(),BorderLayout.NORTH);
        rq.add(getGdmb());
        this.setFrameIcon(new ImageIcon("image/icon/save.png"));//ÉèÖô°Ìåͼ±ê        
 
    }
 
 
    public JScrollPane getGdmb() {//»ñµÃ¹ö¶¯Ãæ°å
        if(gdmb==null) {
            gdmb=new JScrollPane(getTable());//¹ö¶¯Ãæ°å
        }
        return gdmb;
    }
 
    public JTable getTable() {//»ñÈ¡table
        if(table==null) {
            String[] name1= {"ÐòºÅ","ip","ÄÚÈÝ","ʱ¼ä"};//±í¸ñÁÐÃû
            String[] name2= {"Serial Number","ip","Content","Time"};//±í¸ñÁÐÃû
            String[] columnNames=English.columnNames(name1, name2);
            //Ìí¼Ó±í¸ñÁÐÏòÁ¿
            columnName=new Vector<>();
            for(int i=0;i<columnNames.length;i++){
                columnName.add(columnNames[i]);            
            }
 
            //Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý
            rowData=new Vector<>();    
            String sql="select * from tb_yuan_shi_bao_wen order by id DESC limit 1000";
            list = DatabaseManagement.serch(sql);//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ    
            getRowData(list);            
            greateTables tables=new greateTables();
            tableModel=new DefaultTableModel(rowData, columnName){  
                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;
 
                //  ÊµÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼­
                public boolean isCellEditable(int row,int column){  
                    return false;  
                }  
            };
 
            table=tables.getTable(tableModel);    
            table.getColumnModel().getColumn(0).setPreferredWidth(90);
        }
        return table;
 
    }
 
 
 
 
    public JButtonModel getDeleteicon() {//»ñȡɾ³ý°´Å¥
        if(deleteicon==null) {
            deleteicon=new JButtonModel("ȫɾ");            
            deleteicon.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    //Ñ¡Ôñ¶Ô»°¿òÈçyes·µ»Ø0£¬NO·µ»Ø1£¬È¡Ïû·µ»Ø2
                    WarningMessage warning=new WarningMessage();
                    warning.setMessage("Ñ¡Ôñɾ³ýÈ«²¿½«»á°Ñ±í¸ñÊý¾ÝÈ«²¿É¾³ýÈ·¶¨Âð£¿");
                    int warn=warning.getwarMss(getSouthJpan());
                    int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
                    if(tagnum!=0 && warn==0) {
                        String deleteSql="TRUNCATE TABLE tb_yuan_shi_bao_wen ";
                        ShowMessage.deleteAll(DatabaseManagement.update(deleteSql));
                        Dell_Tbicon.delete_all_tbicon();
                        rq.repaint();
                    }
                }
            });
        }
        return deleteicon;
    }
 
    public NothJPanel getSouthJpan() {//»ñÈ¡Äϲ¿Ãæ°å
        if(southJpan==null) {
            southJpan=new NothJPanel();
            Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
            topicBox.add( getJc_fast());
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(get_shua_xin());//ÉÏ´«Í¼±ê°´Å¥Ìí¼Ó
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDeleteicon());
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getJbt_jiazai());
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getJbt_hf());
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getJbt_tip());
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù    
            topicBox.add(jl_start );
            topicBox.add(Box.createHorizontalStrut(2));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(jt_start);
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(jl_stop );
            topicBox.add(Box.createHorizontalStrut(2));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(jt_stop);
            topicBox.add(Box.createHorizontalStrut(10));
            southJpan.add(topicBox );
        }   
        return southJpan;
    }
 
 
 
    /**ˢбí¸ñ·½·¨*/
    public void updateTable() {            
        int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý
        if(tagnum !=0 ) {
            for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐР               
                tableModel.removeRow(0);                            
            }        
            String sql="select * from tb_yuan_shi_bao_wen order by id DESC limit 200";
            list = DatabaseManagement.serch(sql);//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ    
            getRowData(list);
 
        }
 
    }
 
    /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ 
    @SuppressWarnings("unchecked")
    public void getRowData(List list ) {
        Iterator iterator = list.iterator();//´´½¨µü´úÆ÷        
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ
            Vector<String> rowV = new Vector<String>();                
            rowV.add((String)info.get(0));
            rowV.add((String)info.get(1));
            rowV.add((String)info.get(2));
            rowV.add((String)info.get(3));
            rowData.add(rowV);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
        }
    }
 
 
 
    public JButtonModel get_shua_xin() {
        if(shua_xin==null) {
            shua_xin=new JButtonModel("Ë¢ ÐÂ");
            shua_xin.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    updateTable();
                }
            });
 
        }
        return shua_xin;
    }
 
 
    public JButtonModel getJbt_jiazai() {
        if(jbt_jiazai==null) {
            jbt_jiazai=new JButtonModel("¼ÓÔØ±¨ÎÄ");
            jbt_jiazai.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
 
                    if(huifangbaowen) {
                        ShowMessage.zidingyi("±¨ÎĻطÅÖÐÇëÏÈÔÝÍ£»Ø·Å...");
                        return;
                    }
                    //Ê×ÏÈÇå¿Õԭʼ±¨Îĵļ¯ºÏ
                    DellYuanshibaowen.clear();
                    jbt_tip.setVisible(true);
                    DellYuanshibaowen.get_ysbw();
                    baowenallnum=DellYuanshibaowen.getVcysbw().size();
                    BaoWenHuiFang.getJbt_tip().setText("  ¼ÓÔØÁË"+baowenallnum+"Ìõ  ");
                    j=1;
                }
            });
        }
        return jbt_jiazai;
    }
 
 
    public JButtonModel getJbt_hf() {
        if(jbt_hf==null) {
            jbt_hf=new JButtonModel("¿ªÊ¼»Ø·Å");
            jbt_hf.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
 
                    if(huifangbaowen) {
                        jbt_hf.setBackground(Color.gray);
                        huifangbaowen=false;
                        jbt_hf.setText("  ¿ªÊ¼»Ø·Å  ");
                    }else {                        
                        if(DellYuanshibaowen.getVcysbw() ==null) {
                            ShowMessage.zidingyi("±¨ÎÄûÓмÓÔØ£¡");
                            return;
                        }else {
                            if(DellYuanshibaowen.getVcysbw().size()==0) {
                                ShowMessage.zidingyi("±¨ÎÄÌõÊýΪ0£¬Çë¼ÓÔØ±¨ÎÄ");
                                return;
                            }
                            jbt_hf.setBackground(Color.blue);
                            baowennum=DellYuanshibaowen.getVcysbw().size();
                            jizhuntime=DellYuanshibaowen.getVcysbw().get(0).getTime();
                            startThread();
                            huifangbaowen=true;
                            jbt_hf.setText("  ÔÝÍ£»Ø·Å  ");
                        }
 
                    }
 
                }
            });
        }
        return jbt_hf;
    }
 
    /**Æô¶¯Ï̵߳ķ½·¨*/
    public void startThread() {
        Thread t=new Thread(this);
        t.start();
    }
 
    public void run() {
        while(DellYuanshibaowen.getVcysbw().size()>0 && huifangbaowen) {
            try { 
                if(huifangbaowen) {
                    huifang();
                    if(i<0) {
                        i=0;
                    }
 
                    if(i>10000) {
                        i=0;                    
                    }
 
                    Thread.sleep(i);//ÐÝÃßʱ¼ä
                }
            } catch (InterruptedException e) {
                e.printStackTrace(); 
            }
        }
    }
 
    /**±¨ÎĻطÅ*/
    @SuppressWarnings("unused")
    public void huifang() {
        //¼ÓÔØµÚÒ»Ìõ±¨ÎÄ
        YuanShiBaoWen ysbw=DellYuanshibaowen.getVcysbw().get(0);
        //½«±¨Îĸøµ½´¦Àí·½·¨
        
        
        //½ÓÊÕ°ü±¨ÎĵÄʱ¼ä
        String time=ysbw.getTime();
        int port=ysbw.getPort();
        
        int inttime=GetNowTime.timestamp(time);
 
        //²åÈëԭʼÊý¾Ý½øÈëԭʼÊý¾Ý¼¯ºÏ
        Dell_Baowen.intsert(ysbw.getIp(),ysbw.getHex(),time,port);
 
        //¸ÃÌõ±¨ÎĺÍÏÂÒ»Ìõ±¨Îļä¸ôʱ¼ä
        i=ysbw.getJiange();
        if(jc_fast.isSelected()) {
            i=0;
        }
        //ɾ³ýµôÒѾ­´¦ÀíµÄ±¨ÎÄ
        DellYuanshibaowen.getVcysbw().removeElement(ysbw);    
        //ÐÞ¸ÄÒѾ­¼ÓÔØµÄ±¨ÎÄÌõÊý
        if(j==baowenallnum) {
            jbt_tip.setText("  "+j+"Ìõ»Ø·ÅÍê±Ï  ");
            jbt_hf.doClick();
        }else {
            jbt_tip.setText("  »Ø·ÅµÚ"+j+"Ìõ  ");
        }
        j++;
 
    }
 
 
 
    public static JButtonModel getJbt_tip() {
        if(jbt_tip==null) {
            jbt_tip=new JButtonModel("");
            jbt_tip.setVisible(false);
        }
        return jbt_tip;
    }
 
 
    public static boolean isHuifangbaowen() {
        return huifangbaowen;
    }
 
 
 
    public static String getStatrtime() {
        return statrtime=jt_start.getText();
    }
 
 
    public static String getStoptime() {
        return stoptime=jt_stop.getText();
    }
 
 
    public JCheckBoxModel getJc_fast() {
        if(jc_fast==null) {
            jc_fast=new JCheckBoxModel("¼±ËٻطÅ","0");
            jc_fast.setBackground(null);
 
        }
        return jc_fast;
    }
 
 
 
 
}