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<selectedRows.length;i++){
|
String macid=(String) table.getValueAt(selectedRows[i], 1);
|
String deleteSql="DELETE FROM tb_collector WHERE id='"+table.getValueAt(selectedRows[i], 0)+"'";
|
Get_collectors.delete_tb_Collector(macid);
|
DatabaseManagement.update(deleteSql);// ɾ³ý±êÇ©ÐÅÏ¢
|
}
|
//ɾ³ý³É¹¦ÌáʾÐÅÏ¢
|
ShowMessage.delteSuccess(selectedRows.length);
|
updateTable();//ˢбí¸ñ
|
|
}
|
else {
|
ShowMessage.chooseRow(buttonTitle.getDelete());
|
}
|
|
}
|
});
|
|
}
|
return delete;
|
}
|
|
|
/**»ñȡȫ²¿É¾³ý°´Å¥µÄ·½·¨*/
|
public JButtonModel getDeleteAll() {
|
if(deleteAll==null){
|
deleteAll=new JButtonModel(buttonTitle.getDeleteall());
|
deleteAll.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
//Ñ¡Ôñ¶Ô»°¿òÈçyes·µ»Ø0£¬NO·µ»Ø1£¬È¡Ïû·µ»Ø2
|
WarningMessage macname=new WarningMessage();
|
macname.setMessage("Ñ¡Ôñɾ³ýÈ«²¿½«»á°Ñ±í¸ñÊý¾ÝÈ«²¿É¾³ýÈ·¶¨Âð£¿");
|
int warn=macname.getwarMss(getCenterPanel());
|
int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
|
if(tagnum!=0 && warn==0) {
|
String deleteSql="TRUNCATE TABLE tb_collector";
|
DatabaseManagement.update(deleteSql);
|
Get_collectors.deleteall_tb_Collector();
|
ShowMessage.zidingyi("È«²¿É¾³ý³É¹¦£¡");
|
rq.repaint();//ÈÝÆ÷ÖØÐ»æÖÆ
|
}
|
}
|
});
|
|
}
|
return deleteAll;
|
}
|
|
/**»ñÈ¡µ¼³ö±í¸ñ°´Å¥µÄ·½·¨*/
|
public JButtonModel getOutport() {
|
OutButton.setAddtime("addtime");
|
OutButton.setDataName("tb_collector");
|
return new OutButton().get_ouotport_button();
|
|
}
|
|
/**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/
|
public JScrollPane getGd() {
|
if(gd==null){
|
gd=new JScrollPane(getTable());
|
gd.getViewport().setBackground(UIColor.getNorth_color());
|
|
}
|
return gd;
|
}
|
/**»ñÈ¡ÈËÔ±±í¸ñµÄ·½·¨*/
|
@SuppressWarnings({ "serial", "unchecked" })
|
public JTable getTable() {
|
|
|
if(table==null) {
|
String[] name1= {"ÐòºÅ","Ö÷»úµØÖ·","ÆðʼµØÖ·","Êý¾Ý³¤¶È","IPµØÖ·","°²×°Î»ÖÃ","X×ø±ê","Y×ø±ê","Ìí¼Óʱ¼ä"};//±í¸ñÁÐÃû
|
String[] name2= {"Serial Number", "Host Address", "Start Address", "Data Length", "IP Address", "Installation Location", "X Coordinate", "Y Coordinate", "Add Time"};//±í¸ñÁÐÃû
|
String[] columnNames=English.columnNames(name1, name2);
|
//Ìí¼Ó±í¸ñÁÐÏòÁ¿
|
Vector<String> columnName=new Vector<>();
|
for(int i=0;i<columnNames.length;i++){
|
columnName.add(columnNames[i]);
|
}
|
//Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý
|
|
|
rowData=new Vector();
|
list = DatabaseManagement.get_alldate_indatabase("tb_collector");//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ
|
|
Iterator iterator = list.iterator();//´´½¨µü´úÆ÷
|
while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
|
List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
|
Vector<String> row = new Vector<>();
|
for(int i=0;i<info.size();i++) {
|
row.add(String.valueOf(info.get(i)));
|
}
|
rowData.add(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
|
}
|
|
greateTables tables=new greateTables();
|
tableModel=new DefaultTableModel(rowData, columnName){
|
// ʵÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼
|
public boolean isCellEditable(int row,int column){
|
return false;
|
}
|
};
|
|
table=tables.getTable(tableModel);
|
|
}
|
return table;
|
|
}
|
|
/**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/
|
@SuppressWarnings("unchecked")
|
public void getRowData(List list ) {
|
Iterator iterator = list.iterator();//´´½¨µü´úÆ÷
|
while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
|
List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
|
Vector<String> row = new Vector<>();
|
for(int i=0;i<info.size();i++) {
|
row.add(String.valueOf(info.get(i)));
|
}
|
rowData.add(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
|
}
|
|
}
|
|
/**ˢбí¸ñ·½·¨*/
|
public void updateTable() {
|
int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý
|
if(tagnum !=0 ) {
|
for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ
|
tableModel.removeRow(0);//ɾ³ýËùÓÐÐÐ
|
}
|
list = DatabaseManagement.get_alldate_indatabase("tb_collector");
|
getRowData(list);
|
}
|
}
|
|
|
|
/**ÐÂÔöÆøÌå²É¼¯ÒǶԻ°¿ò*/
|
class AddColletor extends JDialog implements WindowListener{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
JlableModel macid=null;//Ö÷»úµØÖ·
|
JlableModel startip=null;//ÆðʼµØÖ·
|
JlableModel datlenth=null;//Êý¾Ý³¤¶È
|
JlableModel gasip=null;//´®¿ÚIPµØÖ·
|
JlableModel macname=null;//×Ô¶¨ÒåÉ豸Ãû³Æ
|
JlableModel gas_x=null;//É豸°²×°X×ø±ê
|
JlableModel gas_y=null;//É豸°²×°Y×ø±ê
|
|
|
JButtonModel sure=null;//È·¶¨°´Å¥
|
JButtonModel quxiao=null;//È¡Ïû°´Å¥
|
|
|
JTextField macid_File=null;
|
JTextField startip_File=null;
|
JTextField gasip_File=null;
|
JTextField gas_x_File=null;
|
JTextField gas_y_File=null;
|
JTextField macname_File=null;
|
|
JTextField datlenth_File=null;//Êý¾Ý³¤¶È
|
|
JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
|
|
/**¹Ø±Õ¶Ô»°¿ò·½·¨*/
|
public void closeTagDialog() {
|
this.dispose();
|
|
}
|
/**»ñÈ¡¶Ô»°¿ò·½·¨*/
|
public AddColletor(String title) {
|
super();
|
this.setAlwaysOnTop(true);
|
this.setTitle(title);
|
Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü
|
Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС
|
int width = (int) (screenSize.width* 0.5);// ¼ÆËã´°Ìåпí¶È
|
int height = (int) (screenSize.height * 0.5);// ¼ÆËã´°Ìåпí¶È
|
int x0=width-210;//´°Ìåx0×ø±ê
|
int y0=height-180;//´°Ìåy0×ø±ê
|
Container rq=getContentPane();
|
rq.add(getMb());
|
this.setBounds(x0, y0,420,460);
|
this.addWindowListener((WindowListener) this);
|
this.setVisible(true);
|
}
|
|
|
public JPanel getMb() {
|
if(mb==null){
|
mb=new JPanel();
|
mb.setLayout(null);
|
//Ö÷»úµØÖ·
|
get_macid().setBounds(40,20,100,25);
|
getJbti_zhuji_adress().setLocation(270,20);
|
mb.add(jbti_zhuji_adress);
|
|
//ÆðʼµØÖ·
|
get_startip().setBounds(40,60,100,25);
|
getJbti_qishi_adress().setLocation(270,60);
|
mb.add(jbti_qishi_adress);
|
|
//Êý¾Ý³¤¶È
|
get_datlenth().setBounds(40,100,100,25);
|
getJbti_datalenth_adress().setLocation(270,100);
|
mb.add(jbti_datalenth_adress);
|
|
//ipµØÖ·
|
getGasip().setBounds(40,140,100,25);
|
getJbti_ip_adress().setLocation(270,140);
|
mb.add(jbti_ip_adress);
|
|
getGas_x().setBounds(40,180,100,25);
|
getGas_y().setBounds(40,220,100,25);
|
get_macname().setBounds(40,260,100,25);
|
|
getSure().setBounds(70,350,80,25);
|
getQuxiao().setBounds(180,350,80,25);
|
|
get_macid_File().setBounds(140,20,120,25);
|
get_startip_File().setBounds(140,60,120,25);
|
get_datlenth_File().setBounds(140,100,120,25);
|
getGasip_File().setBounds(140,140,120,25);
|
getGas_x_File().setBounds(140,180,120,25);
|
getGas_y_File().setBounds(140,220,120,25);
|
get_macname_File().setBounds(140,260,120,25);
|
|
|
mb.add(get_macid());
|
mb.add(get_startip());
|
mb.add(get_datlenth());
|
mb.add(getGasip());
|
mb.add(getGas_x());
|
mb.add(getGas_y());
|
mb.add(get_macname());
|
mb.add(getSure());
|
mb.add(getQuxiao());
|
mb.add(get_macid_File());
|
mb.add(get_startip_File());
|
mb.add(getGasip_File());
|
mb.add(getGas_x_File());
|
mb.add(getGas_y_File());
|
mb.add(get_macname_File());
|
mb.add(get_datlenth_File());
|
|
}
|
return mb;
|
}
|
|
|
/**»ñȡȷ¶¨°´Å¥*/
|
public JButtonModel getSure() {
|
if(sure==null) {
|
sure=new JButtonModel("È· ¶¨");
|
sure.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
|
String macid=get_macid_File().getText().trim();//Ö÷»úµØÖ·
|
String startip_tr=get_startip_File().getText().trim();//ÆðʼµØÖ·
|
String datlenth_tr=get_datlenth_File().getText();//Êý¾Ý³¤¶È
|
String ip=getGasip_File().getText().trim();//ÍøÂçµØÖ·
|
String xx=getGas_x_File().getText().trim();
|
String yy=getGas_y_File().getText().trim();
|
String macname_tr=get_macname_File().getText().trim();
|
|
if(macid.equals("")) {
|
ShowMessage.zidingyi("Ö÷»úµØÖ·²»ÄÜΪ¿Õ");
|
return;
|
}
|
|
if(Get_collectors.get_macid(macid)) {
|
ShowMessage.zidingyi(macid+"Ö÷»úµØÖ·ÒѾ´æÔÚ£¡");
|
return;
|
}
|
|
if(Get_collectors.get_ip_adress(ip)) {
|
ShowMessage.zidingyi(ip+" IPµØÖ·ÒѾ´æÔÚ£¬²»ÄÜÖØ¸´£¡");
|
return;
|
}
|
|
if(xx.length()>10) {
|
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<String> 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;
|
}
|
|
}
|