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;
|
}
|
|
|
}
|