package Frame; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.swing.Box; import javax.swing.ImageIcon; import javax.swing.JDialog; 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 ColorAndFont.English; import ColorAndFont.NothJPanel; import ColorAndFont.UIColor; import ColorAndFont.buttonTitle; import DataBase.DatabaseManagement; import Method.GetNowTime; import Method.IpIsTrue; import Method.JButtonImage; import Method.Serch; import PbuliClass.Get_Tb_Gass; import PbuliClass.Get_collectors; import PbuliClass.JButtonModel; import PbuliClass.JlableModel; import PbuliClass.OutButton; import PbuliClass.ShowMessage; import PbuliClass.Systems; import PbuliClass.WarningMessage; import PbuliClass.greateTables; import PbuliClass.jinternalFrame; /**²É¼¯ÒǹÜÀí*/ @SuppressWarnings("rawtypes") public class CollectorManege extends jinternalFrame { /** * */ private static final long serialVersionUID = 1L; jinternalFrame jinerFrame=null; JInternalFrame jinFrame=null; JPanel innerPanel=null;//ÄÚ²¿´°ÌåÃæ°å NothJPanel northPanel=null;//Äϲ¿Ãæ°å JPanel centerPanel=null;//Öв¿Ãæ°å JButtonModel jbut=null;//°´Å¥Ä£ÐÍ JTextField searchFileld=null;//ËÑË÷Îı¾¿ò JButtonModel search=null;//ËÑË÷°´Å¥ JButtonModel shuaxin=null;//ˢа´Å¥ JButtonModel add=null;//ÐÂÔö°´Å¥ JButtonModel alter=null;//Ð޸İ´Å¥ JButtonModel delete=null;//ɾ³ý°´Å¥ JButtonModel deleteAll=null;//È«²¿É¾³ý°´Å¥ JScrollPane gd=null;//¹ö¶¯Ãæ°å JTable table=null;//ÉêÃ÷±í¸ñ Vector rowData=null; DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ List list=null; Container rq; int selectedRow;//±»Ñ¡ÖеÄÐÐ AddColletor addcollec=null; JButtonImage jbti_zhuji_adress=null; JButtonImage jbti_qishi_adress=null; JButtonImage jbti_datalenth_adress=null; JButtonImage jbti_ip_adress=null; public CollectorManege() {//¹¹Ôì·½·¨ String title="ÆøÌå²É¼¯ÒǹÜÀí"; if(Systems.sys().getLanguage().equals("English")) { title="Gas collector management"; } this.setTitle(title); rq=getContentPane();//»ñÈ¡ÈÝÆ÷ rq.setLayout(new BorderLayout()); rq.setBackground(UIColor.getNorth_color()); rq.add(getGd(),BorderLayout.CENTER); rq.add(getNorthPanel(),BorderLayout.NORTH); this.setFrameIcon(new ImageIcon("image/icon/colletc.png"));//ÉèÖô°Ìåͼ±ê } /**»ñÈ¡Äϲ¿Ãæ°åµÄ·½·¨*/ public NothJPanel getNorthPanel() { if(northPanel==null) { northPanel=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());//Ìí¼Óˢа´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getAdd());//Ìí¼ÓÐÂÔö°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(get_alter());//Ìí¼Óɾ³ý°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getDelete());//Ìí¼Óɾ³ý°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getDeleteAll());//Ìí¼Óɾ³ýÈ«²¿°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getOutport());//Ìí¼Óµ¼³ö±í¸ñ°´Å¥ northPanel.add(topicBox ); } return northPanel; } /**»ñÈ¡Öв¿Ãæ°åµÄ·½·¨*/ public JPanel getCenterPanel() { if(centerPanel==null) { centerPanel=new JPanel(); centerPanel.add(getGd());//Ìí¼Ó¹ö¶¯Ãæ°å centerPanel.setBackground(UIColor.getNorth_color()); } return centerPanel; } /**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/ 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) { if(getSearchFileld().getText().length()>=1) { String go=getSearchFileld().getText().trim(); updateSerch(Serch.so("tb_collector", go, "macname", "posx", "macid")); } } }); } return search; } /**ËÑË÷·½·¨*/ public void updateSerch(String serch) { int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý if(tagnum !=0 ) { for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ tableModel.removeRow(0); } list = DatabaseManagement.serch(serch);//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ getRowData(list); } } /**»ñȡˢа´Å¥µÄ·½·¨*/ 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 getAdd() { if(add==null){ add=new JButtonModel(buttonTitle.getAddOne()); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(addcollec==null) { addcollec=new AddColletor("ÐÂÔö²É¼¯ÒǶԻ°¿ò"); } } }); } return add; } /**»ñÈ¡±í¸ñ±»Ñ¡ÖеÄÐз½·¨*/ public int getSelectedRow() { selectedRow=getTable().getSelectedRow(); return selectedRow; } public JButtonModel get_alter() { if(alter==null){ alter=new JButtonModel(buttonTitle.getAlert()); alter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(getSelectedRow() ==-1) { ShowMessage.zidingyi("ÇëÑ¡ÔñÐèÒªÐ޸ĵÄÐУ¡"); return; } new AlertCollec("Ð޸IJɼ¯ÒǶԻ°¿ò£¡"); } }); } return alter; } /**»ñȡɾ³ý°´Å¥µÄ·½·¨*/ public JButtonModel getDelete() { if(delete==null){ delete=new JButtonModel(buttonTitle.getDelete()); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ if(selectedRows.length !=0) { for(int i=0;i columnName=new Vector<>(); for(int i=0;i row = new Vector<>(); for(int i=0;i row = new Vector<>(); for(int i=0;i10) { ShowMessage.zidingyi("°²×°Î»Öò»ÄÜÌ«³¤£¡"); return; } if(!IpIsTrue.ipCheck(ip)) { ShowMessage.zidingyi("IPµØÖ·ÓдíÎó£¡"); return; } if(startip_tr.equals("")) { ShowMessage.zidingyi("ÆðʼµØÖ·²»ÄÜΪ¿Õ"); return; } if(datlenth_tr.equals("")) { ShowMessage.zidingyi("Êý¾Ý³¤¶È²»ÄÜΪ¿Õ"); return; } if(xx.equals("")) { ShowMessage.zidingyi("X×ø±ê²»ÄÜΪ¿Õ"); return; } if(yy.equals("")) { ShowMessage.zidingyi("Y×ø±ê²»ÄÜΪ¿Õ"); return; } String updateSQL="INSERT tb_collector (macid,startip,datlenth,ip,macname,posx,posy,addtime) VALUES ('" +macid+"','" +startip_tr+"','" +datlenth_tr+"','" +ip+"','" +macname_tr+"','" +xx+"','" +yy+"','" +GetNowTime.now()+"');"; ShowMessage.save(DatabaseManagement.update(updateSQL)); Get_collectors.add_tb_Collector(Integer.parseInt(macid), Integer.parseInt(startip_tr), Integer.parseInt(datlenth_tr), ip, macname_tr, Integer.parseInt(xx), Integer.parseInt(yy)); //ÐÂÔöÒ»ÐÐÊý¾Ý,Ïò±í¸ñĩβÌí¼ÓÒ»ÐÐÊý¾Ý Vector addrowData=new Vector<>(); addrowData.add(String.valueOf(table.getRowCount()+1)); addrowData.add(macid); addrowData.add(startip_tr); addrowData.add(datlenth_tr); addrowData.add(ip); addrowData.add(macname_tr); addrowData.add(xx); addrowData.add(yy); addrowData.add(GetNowTime.now()); tableModel.addRow(addrowData); } }); } return sure; } /**»ñȡȡÏû°´Å¥*/ public JButtonModel getQuxiao() { if(quxiao==null) { quxiao=new JButtonModel("È¡ Ïû"); quxiao.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeTagDialog(); } }); } return quxiao; } /**É豸ͨµÀ*/ public JlableModel get_macid() { if(macid==null) { macid=new JlableModel("Ö÷»úµØÖ·£º"); } return macid; } /**°²×°Î»ÖÃ*/ public JlableModel get_startip() { if(startip==null) { startip=new JlableModel("ÆðʼµØÖ·£º"); } return startip; } /**ÆøÌåÉ豸ÀàÐÍ*/ public JlableModel get_datlenth(){ if(datlenth==null) { datlenth=new JlableModel("Êý¾Ý³¤¶È£º"); } return datlenth; } /**É豸IP*/ public JlableModel getGasip() { if(gasip==null) { gasip=new JlableModel("ÍøÂçµØÖ·£º"); } return gasip; } /**X×ø±ê*/ public JlableModel getGas_x() { if(gas_x==null) { gas_x=new JlableModel("°²×°X×ø±ê£º"); } return gas_x; } /**Y×ø±ê*/ public JlableModel getGas_y() { if(gas_y==null) { gas_y=new JlableModel("°²×°Y×ø±ê£º"); } return gas_y; } /**¸æ¾¯ãÐÖµÉèÖÃ*/ public JlableModel get_macname() { if(macname==null) { macname=new JlableModel("°²×°Î»Öãº"); } return macname; } /**É豸ͨµÀÎı¾*/ public JTextField get_macid_File() { if(macid_File==null) { macid_File=new JTextField(10); } return macid_File; } /**°²×°Î»ÖÃÎı¾*/ public JTextField get_startip_File() { if(startip_File==null) { startip_File=new JTextField(10); } return startip_File; } /**É豸IPÎı¾*/ public JTextField getGasip_File() { if(gasip_File==null) { gasip_File=new JTextField(10); } return gasip_File; } /**X×ø±êÎı¾*/ public JTextField getGas_x_File() { if(gas_x_File==null) { gas_x_File=new JTextField(10); } return gas_x_File; } /**Y×ø±êÎı¾*/ public JTextField getGas_y_File() { if(gas_y_File==null) { gas_y_File=new JTextField(10); } return gas_y_File; } /**°²×°Î»ÖÃ*/ public JTextField get_macname_File() { if(macname_File==null) { macname_File=new JTextField(10); } return macname_File; } /**Êý¾Ý³¤¶È*/ public JTextField get_datlenth_File() { if(datlenth_File==null) { datlenth_File=new JTextField();//´´½¨ÏÂÀ­¿ò¶ÔÏó } return datlenth_File; } @Override public void windowOpened(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowClosing(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù addcollec=null; } @Override public void windowClosed(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowIconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeiconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowActivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeactivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } } /**ÐÞ¸ÄÆøÌåÉ豸¶Ô»°¿ò*/ class AlertCollec extends AddColletor{ /** * */ private static final long serialVersionUID = 1L; public AlertCollec(String title) { super(title); // TODO ×Ô¶¯Éú³ÉµÄ¹¹Ô캯Êý´æ¸ù get_macid_File().setText((String) table.getValueAt(getSelectedRow(), 1)); get_macid_File().setEnabled(false); get_startip_File().setText((String) getTable().getValueAt(getSelectedRow(), 2)); get_datlenth_File().setText((String) getTable().getValueAt(getSelectedRow(), 3)); getGasip_File().setText((String) getTable().getValueAt(getSelectedRow(), 4)); getGas_x_File().setText((String) getTable().getValueAt(getSelectedRow(), 6)); getGas_y_File().setText((String) getTable().getValueAt(getSelectedRow(), 7)); get_macname_File().setText((String) getTable().getValueAt(getSelectedRow(), 5)); } /**»ñȡȷ¶¨°´Å¥*/ public JButtonModel getSure() { if(sure==null) { sure=new JButtonModel("È· ¶¨"); sure.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String id=(String) getTable().getValueAt(getSelectedRow(), 0);//ÐòºÅ String macid=get_macid_File().getText().trim();//Ö÷»úµØÖ· String startip_tr=get_startip_File().getText().trim();//ÆðʼµØÖ· String datlenth_tr=get_datlenth_File().getText().trim();//Êý¾Ý³¤¶È String ip=getGasip_File().getText().trim();//ÍøÂçµØÖ· String xx=getGas_x_File().getText().trim();//°²×°X×ø±ê String yy=getGas_y_File().getText().trim();//°²×°Y×ø±ê String macname_tr=get_macname_File().getText().trim();//°²×°Î»Öà if(macid.equals("") || startip_tr.equals("") || datlenth_tr.equals("") || ip.equals("") ||xx.equals("") || yy.equals("") ) { ShowMessage.zidingyi("Êý¾Ý²»ÄÜΪ¿Õ£¡"); return; } if(!IpIsTrue.ipCheck(ip)) { ShowMessage.zidingyi("IPµØÖ·ÓдíÎó£¡"); return; } String updateSQL="UPDATE tb_collector SET macid='" +macid +"' , startip='" +startip_tr +"' , datlenth='" +datlenth_tr +"' , ip='" +ip +"' , posx='" +xx +"' , posy='" +yy+"' , macname='" +macname_tr +"' where id='" +id+"'"; if(DatabaseManagement.update(updateSQL)==1) { Get_collectors.alert_collector(Integer.parseInt(macid), Integer.parseInt(startip_tr), Integer.parseInt(datlenth_tr), ip, macname_tr, Integer.parseInt(xx), Integer.parseInt(yy)); Get_Tb_Gass.alert_ip(ip,macid,macname_tr); ShowMessage.zidingyi("Ð޸ijɹ¦£¡"); updateTable() ; }else { ShowMessage.zidingyi("дÈëÊý¾Ý¿âʧ°Ü£¡"); } } }); } return sure; } } public JButtonImage getJbti_zhuji_adress() { if(jbti_zhuji_adress==null) { jbti_zhuji_adress= new JButtonImage(""); jbti_zhuji_adress.setToolTipText("²ÎÊý½âÊÍ"); jbti_zhuji_adress.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù ShowMessage.zidingyi_24("Ö÷»úµØÖ·ÎªÆøÌå²É¼¯ÒǵĵØÖ·¡£"); } }); } return jbti_zhuji_adress; } public JButtonImage getJbti_qishi_adress() { if(jbti_qishi_adress==null) { jbti_qishi_adress= new JButtonImage(""); jbti_qishi_adress.setToolTipText("²ÎÊý½âÊÍ"); jbti_qishi_adress.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù ShowMessage.zidingyi_24("ÆðʼµØÖ·Îª´«¸ÐÆ÷µÄµØÖ·Ò»°ã´Ó1¿ªÊ¼"); } }); } return jbti_qishi_adress; } public JButtonImage getJbti_datalenth_adress() { if(jbti_datalenth_adress==null) { jbti_datalenth_adress=new JButtonImage(""); jbti_datalenth_adress.setToolTipText("²ÎÊý½âÊÍ"); jbti_datalenth_adress.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù ShowMessage.zidingyi_24("Ò»¸ö²É¼¯ÒÇÉÏÓм¸¸ö´«¸ÐÆ÷³¤¶È¾Íд¼¸¡£"); } }); } return jbti_datalenth_adress; } public JButtonImage getJbti_ip_adress() { if(jbti_ip_adress==null) { jbti_ip_adress=new JButtonImage(""); jbti_ip_adress.setToolTipText("²ÎÊý½âÊÍ"); jbti_ip_adress.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù ShowMessage.zidingyi_24("¸ÃµØÖ·ÎªÍøÂç´®¿ÚµÄµØÖ·£¬µØÖ·ÐèÒªºÍ·þÎñÆ÷ÔÚÍ¬Ò»Íø¶Î¡£"); } }); } return jbti_ip_adress; } }