package Frame; import java.awt.BorderLayout; import java.awt.Color; 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.List; import java.util.Vector; import javax.swing.Box; import javax.swing.ImageIcon; import javax.swing.JComboBox; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import BaoWen.Dell_GNGGA; import ColorAndFont.English; import ColorAndFont.UIColor; import ColorAndFont.buttonTitle; import DataBase.DatabaseManagement; import PbuliClass.JButtonModel; import PbuliClass.JlableModel; import PbuliClass.ShowMessage; import PbuliClass.Systems; import PbuliClass.greateTables; import PbuliClass.jinternalFrame; import tbDataModel.Tb_gps; import urt.Dell_gps; import urt.Urt_read; @SuppressWarnings("rawtypes") public class Gps_Manage extends jinternalFrame { /** * */ private static final long serialVersionUID = 1L; JPanel inJpanel=null;//ÄÚ²¿Ãæ°å JPanel northJpanel=null;//±±²¿Ãæ°å JPanel centerJpanel=null;//Öв¿Ãæ°å JTextField searchFileld=null;//ËÑË÷Îı¾¿ò JTextField jf_jingdu=null;//¾­¶ÈÎı¾¿ò JTextField jf_weidu=null;//γ¶ÈÎı¾¿ò JTextField jf_th=null;//¼Ð½ÇÎı¾¿ò JlableModel jl_ck=new JlableModel("Ô­µã»ùÕ¾:"); JTextField jf_yanchor=new JTextField(Dell_gps.getUrtcankao());//Ö¸¶¨Ô­µã²Î¿¼»ùÕ¾ JButtonModel search=null;//ËÑË÷°´Å¥ JButtonModel shuaxin=null;//ˢа´Å¥ JButtonModel delete=null;//ɾ³ý°´Å¥ JButtonModel deleteAll=null;//È«²¿É¾³ý°´Å¥ JButtonModel jbt_readpeizhi=null;//¶ÁÈ¡ÅäÖà JButtonModel jbt_alljie=null;//²ÉÓÃËùÓеĽâURTģʽ JButtonModel jbt_saveac=null;//±£´æÔ­µã»ùÕ¾ JComboBox comboBox; JButtonModel but_urtstop=null;//Ëø¶¨URTģʽ²»ÔÚ»ùÕ¾½ÓÊÕÊý¾Ý JButtonModel but_save=null; JTable table=null;//ÉêÃ÷±í¸ñ DefaultTableModel tableModel=null;//±í¸ñÄ£ÐÍ List list=null; JScrollPane gd; Vector rowData=null; //URTģʽֹͣ½ÓÊÕ´¦Àí»ùÕ¾GPSÊý¾Ý static boolean urt_stop=false; boolean urtopen=Systems.sys().getUrt().equals("1"); public Gps_Manage() { rowData=new Vector(); this.setTitle(English.name("URTÊý¾Ý", "Gas Data")); this.setFrameIcon(new ImageIcon("image/icon/gpsm.png"));//ÉèÖô°Ìåͼ±ê this.add(getInJpanel()); } /**»ñÈ¡ÄÚ²¿´°ÌåµÄÄÚ²¿Ãæ°å*/ public JPanel getInJpanel() { if(inJpanel==null) { inJpanel=new JPanel(); inJpanel.setLayout(new BorderLayout());//ÉèÖÃÃæ°åΪ±ß½ç²¼¾Ö inJpanel.setBackground(Color.WHITE);//ÉèÖÃÃæ°å±³¾°Îª°×É« inJpanel.add(getNorthJpanel(),BorderLayout.NORTH); inJpanel.add(getGd(),BorderLayout.CENTER); } return inJpanel; } /**»ñÈ¡±±²¿Ãæ°å*/ public JPanel getNorthJpanel() { if(northJpanel==null) { northJpanel=new JPanel(); Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷ topicBox.add(getSearchFileld());//Ìí¼ÓËÑË÷Îı¾¿ò topicBox.add(Box.createHorizontalStrut(3));// Ìí¼ÓÒ»¸ö3ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getSearch());//Ìí¼ÓËÑË÷°´Å¥ topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getShuaxin());//Ìí¼Óˢа´Å¥ topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getDelete() );//ɾ³ý topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getJbt_readpeizhi());//¶ÁÈ¡ÅäÖà if(urtopen) { topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getBut_urtstop()); topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(getJbt_alljie()); topicBox.add(Box.createHorizontalStrut(20)); topicBox.add(jl_ck); topicBox.add(jf_yanchor); topicBox.add(Box.createHorizontalStrut(5)); topicBox.add(getJbt_saveac()); } northJpanel.add(topicBox ); } return northJpanel; } /**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/ public JTextField getSearchFileld() { if(searchFileld==null){ searchFileld=new JTextField(5); 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) { String so=getSearchFileld().getText(); if(so.length()>2) { updateSerch(so); }else { ShowMessage.zidingyi("ÊäÈëµÄËÑË÷ÄÚÈݲ»ÕýÈ·"); } } }); } 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 getDelete() { if(delete==null){ delete=new JButtonModel(buttonTitle.getDelete()); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ int size=selectedRows.length; if( size!=0) { //ɾ³ýËùÓб»Ñ¡ÖеÄÐÐ for(int j=selectedRows.length-1;j>=0;j--){//ÕâÊǹؼü´úÂë String tagid=(String) table.getValueAt(selectedRows[j],0); Dell_gps.delete(tagid); tableModel.removeRow(selectedRows[j]);//ɾ³ýÈÎÒⱻѡÖÐÐÐ } table.setModel(tableModel);//¸üбí¸ñÄ£ÐÍ //ɾ³ý³É¹¦ÌáʾÐÅÏ¢ ShowMessage.delteSuccess(size); } else { ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèҪɾ³ýµÄÐУ¡"); } } }); } return delete; } /**»ñȡȫ²¿É¾³ý°´Å¥µÄ·½·¨*/ public JButtonModel getDeleteAll() { if(deleteAll==null){ deleteAll=new JButtonModel(buttonTitle.getDeleteall()); deleteAll.setEnabled(false); deleteAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); } return deleteAll; } /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/ public JScrollPane getGd() { gd=new JScrollPane(getTable()); gd.getViewport().setBackground(UIColor.getNorth_color()); return gd; } /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ @SuppressWarnings("unchecked") public void getRowData(Vector list ) { Iterator iterator = list.iterator();//´´½¨µü´úÆ÷ while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ Tb_gps tag = iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ Vector row = new Vector(); //"ÐòºÅ","É豸±àºÅ","γ¶È","¾­¶È","GPS״̬","ÎÀÐÇÊý","º£°Î¸ß","²î·ÖÕ¾ID","µçÁ¿","¸üÐÂʱ¼ä" if(tag !=null) { String gps_state=(String)tag.getGps_state(); row.add(tag.getTagid()); row.add(tag.getGps_weidu()); row.add(tag.getGsp_jingdu()); row.add(gps_state); row.add(tag.getGps_num()); row.add(tag.getGps_haiba_gao()); row.add(tag.getFloor()); row.add(tag.getGps_power()); row.add(tag.getAddtime()); row.add(tag.getCcid()); row.add(tag.getBaoliu4());//CRMÀ´Ô´ tableModel.addRow(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý } } } /**±í¸ñ*/ @SuppressWarnings("serial") public JTable getTable() { if(table==null) { String name1="É豸±àºÅ"; String name2="γ¶È"; String name3="¾­¶È"; String name4="¶¨Î»×´Ì¬"; String name5="ÎÀÐÇÊý"; String name6="º£°Î¸ß(Ã×)"; String name7="ËùÔÚ²ã"; String name8="µçÁ¿(%)"; String name9="¸üÐÂʱ¼ä"; String name10="Á÷Á¿¿¨ºÅ"; String name11="CRM"; if(Systems.sys().getLanguage().equals("English")) { name1="DeviceID"; name2="Latitude"; name3="Longitude"; name4="GpsStatus"; name5="GpsNum"; name6="HighAltitude(m)"; name7="Floor"; name8="Power(%)"; name9="AddTime"; name10="CCID"; name11="CRM"; } String[] columnNames= {name1,name2,name3,name4,name5,name6,name7,name8,name9,name10,name11};//±í¸ñÁÐÃû //Ìí¼Ó±í¸ñÁÐÏòÁ¿ Vector columnName=new Vector<>(); for(int i=0;i=0;j--){//ÕâÊǹؼü´úÂë String tagid=(String) table.getValueAt(selectedRows[j],0); Urt_read.read_tag(tagid,"01","33",1); } } else { ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèÒª¶ÁÈ¡µÄÉ豸ÐУ¡"); } } }); } return jbt_readpeizhi; } public JButtonModel getJbt_alljie() { if(jbt_alljie==null) { jbt_alljie=new JButtonModel("²»²ÉÓõ;«¶ÈÊý¾Ý"); jbt_alljie.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean a=Dell_GNGGA.isUrtmode1(); if(a) { Dell_GNGGA.setUrtmode1(false); jbt_alljie.setText("²»²ÉÓõ;«¶ÈÊý¾Ý"); }else { Dell_GNGGA.setUrtmode1(true); jbt_alljie.setText("²ÉÓõ;«¶ÈÊý¾Ý"); } } }); } return jbt_alljie; } public JButtonModel getJbt_saveac() { if(jbt_saveac==null) { jbt_saveac=new JButtonModel("±£´æ"); jbt_saveac.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String a=jf_yanchor.getText(); String[] ziduan= {"baoliu1","tagid"}; String[] zhi= {a,a}; DatabaseManagement.fast_alert_dbase("tb_gps", ziduan, zhi); ShowMessage.zidingyi("±£´æ³É¹¦"); } }); } return jbt_saveac; } }