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
package Frame;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.Iterator;
import java.util.List;
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 DataBase.DatabaseManagement;
import Method.GetNowTime;
import PbuliClass.JButtonModel;
import PbuliClass.ShowMessage;
import PbuliClass.greateTables;
import PbuliClass.jinternalFrame;
import home.ChuShiHua;
import tbDataModel.Tb_tongbuanchor;
import tbDataModel_Dell.Dell_TongbuAnchor;
import PbuliClass.Systems;
@SuppressWarnings("rawtypes")
public class AnchorTongbuSet extends jinternalFrame{
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    Container rq;
    NothJPanel northPanel=null;//±±²¿Ãæ°å
    JPanel centerPanel=null;//Öв¿Ãæ°å
    JScrollPane gd=null;//¹ö¶¯Ãæ°å
    static JTable table=null;//ÉêÃ÷±í¸ñ
    JButtonModel but_save=null;//±£´æ°´Å¥
    JButtonModel but_clear=null;//Çå¿Õ°´Å¥
    JButtonModel but_refresh=null;//ˢа´Å¥
    JButtonModel but_tihuan=null;//Ìæ»»»ùÕ¾
    JButtonModel but_tongbu=null;//ÊäÈëͬ²½
    JButtonModel but_shuaxin=null;//ˢа´¼ü
    JTextField jf_anchorA=null;//»ùÕ¾A
    JTextField jf_anchorB=null;//»ùÕ¾B
    JTextField jf_tongbu=null;//ͬ²½»ùÕ¾
    Vector<String> columnName;    
    List list;    
    Vector rowData=null;
    DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
 
 
 
    public AnchorTongbuSet() {//¹¹Ôì·½·¨
        String title="ͬ²½ÉèÖÃ";
        if(Systems.sys().getLanguage().equals("English")) {
            title="Anchor Synchronize Site";
        }
        this.setTitle(title);
        rowData=new Vector();
        this.setFrameIcon(new ImageIcon("image/icon/time.png"));//ÉèÖô°Ìåͼ±ê
        rq=getContentPane();//»ñÈ¡ÈÝÆ÷
        rq.setLayout(new BorderLayout());
        rq.setBackground(UIColor.getNorth_color());
        rq.add(getNorthPanel(),BorderLayout.NORTH);
        rq.add(getGd(),BorderLayout.CENTER);
 
    }
 
    /**»ñÈ¡±±²¿Ãæ°åµÄ·½·¨*/    
    public NothJPanel getNorthPanel() {
        if(northPanel==null) {
            northPanel=new NothJPanel();
            northPanel.setBackground(UIColor.getNorth_color());//ÉèÖÃÃæ°å±³¾°Îª°×É«
            Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
            topicBox.add(getBut_shuaxin() );
            topicBox.add(Box.createHorizontalStrut(20));
            topicBox.add(getBut_save());
            topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getBut_refresh());
            topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getJf_anchorA());
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getJf_anchorB());
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getBut_tihuan());
            topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getJf_tongbu());
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getBut_tongbu());
            
            northPanel.add(topicBox );
        }
        return northPanel;
    }
 
    public JButtonModel getBut_save() {
        if(but_save==null) {
            but_save=new JButtonModel(buttonTitle.getSave());
            but_save.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý
                    int saveok=0;
                    for(int i=0;i<tagnum;i++) {
                        String anchorid=(String) table.getValueAt(i, 0);
                        String rootanchorid=(String) table.getValueAt(i, 1);
                        String type=(String) table.getValueAt(i, 2);
                        String state=(String) table.getValueAt(i, 3);
 
                        //ÐÞ¸Äͬ²½»ùÕ¾¼¯ºÏÊý¾Ý
                        Dell_TongbuAnchor.alert_rootanchor(anchorid, rootanchorid, type, state); 
 
                        //½«Í¬²½»ùÕ¾ÅäÖñ£´æ½øÈëÊý¾Ý¿â
                        String updateSQL="UPDATE tb_tongbuanchor SET rootanchorid='"+rootanchorid
                                +"',type='"+type
                                +"',state='"+state
                                +"',addtime='"+GetNowTime.now2()
                                +"'where anchorid='"+anchorid+"'";    
                        saveok=DatabaseManagement.update(updateSQL);
                    }
                    if(saveok !=0) {
                        ShowMessage.zidingyi("Êý¾ÝдÈëÊý¾Ý¿â±£´æ³É¹¦");
                        ChuShiHua.write_tongbu();
                    }
 
                }
            });
        }
        return but_save;
    }
 
 
 
 
 
    public JButtonModel getBut_clear() {
        if(but_clear==null) {
            but_clear=new JButtonModel("Çå¿Õ");
        }
        return but_clear;
    }
 
    public JButtonModel getBut_refresh() {
        if(but_refresh==null) {
            but_refresh=new JButtonModel(buttonTitle.getDelete());
            but_refresh.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    updateTable();
                }
            });
        }
        return but_refresh;
    }
 
    
    /**ˢбí¸ñ·½·¨*/
    public void updateTable() {    
        if(tableModel !=null) {
        tableModel.getDataVector().clear();
        getRowData(Dell_TongbuAnchor.getRootanchor_vector());
        gd.validate();
        }
    }
 
    /**»ñÈ¡Öв¿Ãæ°åµÄ·½·¨*/    
    public JPanel getCenterPanel() {
        if(centerPanel==null) {
            centerPanel=new JPanel();
            centerPanel.add(getGd());//Ìí¼Ó¹ö¶¯Ãæ°å
            centerPanel.setBackground(UIColor.getNorth_color());
 
        }
        return centerPanel;
    }
 
    /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/    
    public JScrollPane getGd() {
        if(gd==null){
            gd=new JScrollPane();
            gd.getViewport().setBackground(UIColor.getNorth_color());
            gd.setViewportView(getTable());
 
        }
        return gd;
    }
 
    /**»ñÈ¡»ùÕ¾±í¸ñµÄ·½·¨*/    
    public JTable getTable() {
        if(table==null) {            
            //Ìí¼Ó±í¸ñÁÐÏòÁ¿
            String[] name1= {"»ùÕ¾ID","ͬ²½»ùÕ¾","»ùÕ¾ÀàÐÍ","ͬ²½×´Ì¬","¸üÐÂʱ¼ä"};//±í¸ñÁÐÃû
            String[] name2= {"Anchor ID", "synchronization Anchor", "Anchor type", "synchronization status", "update time"};//±í¸ñÁÐÃû
            String[] columnNames=English.columnNames(name1, name2);
            columnName=new Vector<>();
            for(int i=0;i<columnNames.length;i++){
                columnName.add(columnNames[i]);            
            }
            
            greateTables tables=new greateTables();
            tableModel=new DefaultTableModel(rowData, columnName);
 
            table=tables.getTable(tableModel);
            getRowData(Dell_TongbuAnchor.getRootanchor_vector());
        }
        return table;
 
    }
 
    /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/
    @SuppressWarnings({ "unchecked"})
    public void getRowData(Vector<Tb_tongbuanchor> tbv ) {         
        Iterator<Tb_tongbuanchor> iterator = tbv.iterator();//´´½¨µü´úÆ÷        
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            Tb_tongbuanchor info =  iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ
            Vector row = new Vector();
            row.add(info.getAnchorid());
            row.add(info.getRootanchorid());
            row.add(info.getType());
            row.add(info.getState());
            row.add(info.getAddtime());            
            tableModel.addRow(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
        }
    }
 
    public JButtonModel getBut_tihuan() {
        if(but_tihuan==null) {
            but_tihuan=new JButtonModel(English.name("»ùÕ¾AÌæ»»B", "A Replace B"));
            but_tihuan.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    String anchora=jf_anchorA.getText().trim();
                    String anchorb=jf_anchorB.getText().trim();
                    for(int i=0;i<table.getRowCount();i++) {
                        for(int j=0;j<table.getColumnCount();j++) {
                            if(table.getValueAt(i, j).equals(anchora)) {
                                table.setValueAt(anchorb, i, j);
                            }
                        }
                    }
                    ShowMessage.zidingyi("Ö÷ÈËÎÒÒÑÈ«²¿Ìæ»»Íê±Ï...");
                }
            });
        }
        return but_tihuan;
    }
 
    public JTextField getJf_anchorA() {
        if(jf_anchorA==null) {
            jf_anchorA=new JTextField(4);
            jf_anchorA.setText("     A     ");
            jf_anchorA.addFocusListener(new FocusListener() {
 
                @Override
                public void focusLost(FocusEvent e) {
 
                }
 
                @Override
                public void focusGained(FocusEvent e) {
                    jf_anchorA.setText("");
                }
            });
        }
        return jf_anchorA;
    }
 
    public JTextField getJf_anchorB() {
        if(jf_anchorB==null) {
            jf_anchorB=new JTextField(4);
            jf_anchorB.setText("     B     ");
            jf_anchorB.addFocusListener(new FocusListener() {
 
                @Override
                public void focusLost(FocusEvent e) {
 
                }
 
                @Override
                public void focusGained(FocusEvent e) {
                    jf_anchorB.setText("");
                }
            });
        }
        return jf_anchorB;
    }
 
    public JButtonModel getBut_tongbu() {
        if(but_tongbu==null) {
            but_tongbu=new JButtonModel(English.name("ͬ²½»ùÕ¾", "Submit"));
            but_tongbu.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    
                    String tongbuanc=getJf_tongbu().getText().trim();
                    if(tongbuanc.length()<4 || tongbuanc.equals("ÊäÈëͬ²½»ùÕ¾")) {
                        ShowMessage.zidingyi("ÊäÈëµÄͬ²½»ùÕ¾IDÓÐÎóÇë×¢Òâ¼ì²é...");
                        return;
                    }
                    for(int i=0;i<table.getRowCount();i++) {
                        for(int j=0;j<table.getColumnCount();j++) {
                            if(table.getValueAt(i, 0).equals(tongbuanc)) {
                                table.setValueAt("0", i, 1);
                                table.setValueAt("1", i, 2);
                            }else {
                                table.setValueAt(tongbuanc, i, 1);
                                table.setValueAt("0", i, 2);
                            }
                        }
                    }
                    ShowMessage.zidingyi("ͬ²½ÅäÖøüÐÂÍê±Ï,¼ì²âÈ·ÈϺóµã»÷±£´æ...");
                }
            });
        }
        return but_tongbu;
    }
 
    public JTextField getJf_tongbu() {
        if(jf_tongbu==null) {
            jf_tongbu=new JTextField(10);
            jf_tongbu.setText("ÊäÈëͬ²½»ùÕ¾");
            jf_tongbu.addFocusListener(new FocusListener() {
                public void focusLost(FocusEvent e) {
 
                }
                public void focusGained(FocusEvent e) {
                    jf_tongbu.setText("");
                }
            });
        }
        return jf_tongbu;
    }
 
    public JButtonModel getBut_shuaxin() {
        if(but_shuaxin==null) {
            but_shuaxin=new JButtonModel("Ë¢ÐÂ");
            but_shuaxin.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    updateTable();                    
                }
            });
        }
        return but_shuaxin;
    }
 
 
}