package Frame;
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Component;
|
import java.awt.Container;
|
import java.awt.Dimension;
|
import java.awt.Font;
|
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.ComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.ImageIcon;
|
import javax.swing.JComboBox;
|
import javax.swing.JDialog;
|
import javax.swing.JInternalFrame;
|
import javax.swing.JPanel;
|
import javax.swing.JProgressBar;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTable;
|
import javax.swing.JTextField;
|
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.TableCellRenderer;
|
import javax.swing.table.TableColumn;
|
|
import ColorAndFont.English;
|
import ColorAndFont.NothJPanel;
|
import ColorAndFont.UIColor;
|
import ColorAndFont.buttonTitle;
|
import DataBase.DatabaseManagement;
|
import Method.GetNowTime;
|
import Method.IpIsTrue;
|
import PbuliClass.BuMens;
|
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;
|
import anchor.Anchor_Dell;
|
import tbDataModel.TbGas;
|
@SuppressWarnings("rawtypes")
|
public class GasManage 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;
|
int selectedRow;//±»Ñ¡ÖеÄÐÐ
|
String departMent;//±êÇ©ËùÊôµÄ²¿ÃÅ
|
BuMens bums;
|
AddGasMac addgas=null;
|
AlertGasMac alertgas=null;
|
Container rq;
|
|
|
public GasManage() {//¹¹Ôì·½·¨
|
String title="ÆøÌå´«¸ÐÆ÷¹ÜÀí";
|
if(Systems.sys().getLanguage().equals("English")) {
|
title="Gas sensor management";
|
}
|
this.setTitle(title);
|
rq=getContentPane();//»ñÈ¡ÈÝÆ÷
|
bums=new BuMens();
|
rq.setLayout(new BorderLayout());
|
rq.setBackground(Color.white);
|
rq.add(getGd(),BorderLayout.CENTER);
|
rq.add(getNorthPanel(),BorderLayout.NORTH);
|
this.setFrameIcon(new ImageIcon("image/icon/gas.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(Color.WHITE);
|
|
}
|
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 serch=getSearchFileld().getText().trim();
|
updateSerch(serch);
|
}
|
}
|
});
|
|
}
|
return search;
|
}
|
|
/**ËÑË÷·½·¨*/
|
public void updateSerch(String serch) {
|
if(Anchor_Dell.serch_anchor(serch)==null) {
|
ShowMessage.zidingyi("Ö÷ÈËÄãËÑË÷"+serch+"²»´æÔÚ...");
|
return;
|
}
|
int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
|
if(tagnum >0 ) {
|
for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ
|
tableModel.removeRow(0);
|
}
|
//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½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(addgas==null) {
|
addgas=new AddGasMac("ÐÂÔöÆøÌå´«¸ÐÆ÷¶Ô»°¿ò");
|
}
|
|
}
|
});
|
|
}
|
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(selectedRow!=-1 && alertgas ==null) {
|
alertgas=new AlertGasMac("ÐÞ¸ÄÆøÌå¼ì²âÉ豸¶Ô»°¿ò£¡");
|
}else {
|
ShowMessage.zidingyi("ÇëÑ¡ÔñÐèÒªÐ޸ĵÄÐУ¡");
|
return;
|
}
|
|
}
|
});
|
}
|
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 tongdao=(String) table.getValueAt(selectedRows[i], 6);
|
String collet=(String) table.getValueAt(selectedRows[i], 5);
|
String deleteSql="DELETE FROM tb_gas WHERE id='"+table.getValueAt(selectedRows[i], 0)+"'";
|
Get_Tb_Gass.delete_gas(tongdao,collet);
|
DatabaseManagement.update(deleteSql);// ɾ³ý±êÇ©ÐÅÏ¢
|
}
|
//ɾ³ý³É¹¦ÌáʾÐÅÏ¢
|
ShowMessage.delteSuccess(selectedRows.length);
|
//ɾ³ýËùÓб»Ñ¡ÖеÄÐÐ
|
for(int j=selectedRows.length-1;j>=0;j--){//ÕâÊǹؼü´úÂë
|
tableModel.removeRow(selectedRows[j]);//ɾ³ýÈÎÒⱻѡÖÐÐÐ
|
}
|
table.setModel(tableModel);//¸üбí¸ñÄ£ÐÍ
|
|
}
|
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 warning=new WarningMessage();
|
warning.setMessage("Ñ¡Ôñɾ³ýÈ«²¿½«»á°Ñ±í¸ñÊý¾ÝÈ«²¿É¾³ýÈ·¶¨Âð£¿");
|
int warn=warning.getwarMss(getCenterPanel());
|
int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
|
if(tagnum!=0 && warn==0) {
|
String deleteSql="TRUNCATE TABLE tb_gas";
|
Get_Tb_Gass.deleteall_gas();
|
DatabaseManagement.update(deleteSql);
|
ShowMessage.zidingyi("È«²¿É¾³ý³É¹¦£¡");
|
rq.repaint();
|
updateTable();//ˢбí¸ñ
|
}
|
}
|
});
|
|
}
|
return deleteAll;
|
}
|
|
/**»ñÈ¡µ¼³ö±í¸ñ°´Å¥µÄ·½·¨*/
|
public JButtonModel getOutport() {
|
OutButton.setAddtime("addtime");
|
OutButton.setDataName("tb_gas");
|
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")
|
public JTable getTable() {
|
|
|
if(table==null) {
|
String[] name1= {"É豸±àºÅ", "°²×°Î»ÖÃ", "ÆøÌåÀàÐÍ", "Ũ¶ÈÖµ", "¸æ¾¯Çé¿ö", "²É¼¯ÒǵØÖ·",
|
"ËùÔÚͨµÀ", "¸æ¾¯ãÐÖµ", "IPµØÖ·", "X×ø±ê", "Y×ø±ê", "¸üÐÂʱ¼ä"};//±í¸ñÁÐÃû
|
String[] name2= {"Equipment Number", "Installation Location",
|
"Gas Type", "Concentration Value", "Alarm Condition",
|
"Collection Address","Current Channel",
|
"Alarm Threshold", "IP", "X", "Y", "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();
|
greateTables tables=new greateTables();
|
tableModel=new DefaultTableModel(rowData, columnName){
|
// ʵÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼
|
public boolean isCellEditable(int row,int column){
|
return false;
|
}
|
};
|
table=tables.getTable(tableModel);
|
getRowData(Get_Tb_Gass.get_gass() );
|
|
table.getColumnModel().getColumn(1).setPreferredWidth(155);
|
table.getColumnModel().getColumn(8).setPreferredWidth(100);
|
table.getColumnModel().getColumn(11).setPreferredWidth(155);
|
TableColumn column = table.getColumnModel().getColumn(4);// »ñÈ¡±í¸ñµÚ4ÁжÔÏó
|
column.setCellRenderer(new TableCellRenderer() {// ÉèÖõÚ7ÁеÄäÖȾÆ÷
|
public Component getTableCellRendererComponent(
|
JTable table, Object value, boolean isSelected,
|
boolean hasFocus, int row, int column) {
|
JProgressBar bar=new JProgressBar();//´´½¨½ø¶ÈÌõ
|
bar.setBorderPainted(false);//ÊÇ·ñÏÔʾ½ø¶ÈÌõ±ß¿ò
|
bar.setBackground(Color.white);
|
bar.setValue(99);//ÉèÖýø¶ÈÌõµÄÖµ
|
if(value.equals("Õý³£")) {
|
bar.setForeground(Color.green);//ÏÔʾ½ø¶ÈÌõµÄÑÕÉ«
|
return bar;// °Ñͼ±ê×÷ΪΪäÖȾ¿Ø¼þ
|
}
|
else{
|
bar.setForeground(Color.red);//ÏÔʾ½ø¶ÈÌõµÄÑÕÉ«
|
return bar;// °Ñͼ±ê×÷ΪΪäÖȾ¿Ø¼þ
|
}
|
}
|
});
|
}
|
return table;
|
|
}
|
|
/**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/
|
public void getRowData(Vector<TbGas> gasv ) {
|
Iterator<TbGas> iterator = gasv .iterator();//´´½¨µü´úÆ÷
|
while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
|
TbGas gas = iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
|
Vector<String> row = new Vector<>();
|
row.add(String.valueOf(gas.getId()));
|
row.add(gas.getWei_zhi());
|
row.add(gas.getGas_type());
|
row.add(gas.getNong_du());
|
row.add(gas.getStatus());
|
row.add(gas.getCollect_ip());
|
row.add(gas.getTong_dao());
|
row.add(gas.getWaring_zhi());
|
row.add(gas.getIp());
|
row.add(gas.getX());
|
row.add(gas.getY());
|
row.add(gas.getAddtime());
|
tableModel.addRow(row);
|
}
|
}
|
|
/**ˢбí¸ñ·½·¨*/
|
public void updateTable() {
|
if(tableModel !=null) {
|
tableModel.getDataVector().clear();
|
getRowData(Get_Tb_Gass.get_gass());
|
gd.validate();
|
}
|
}
|
|
|
|
/**ÐÂÔöÆøÌå¼ì²âÉ豸¶Ô»°¿ò*/
|
class AddGasMac extends JDialog implements WindowListener{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
JlableModel id_label=null;
|
JlableModel gasid=null;//ËùÔÚͨµÀ
|
JlableModel gasName=null;//²É¼¯ÒǵØÖ·
|
JlableModel gastype=null;//´«¸ÐÆ÷ÀàÐÍ
|
JlableModel gasip=null;//É豸ip
|
JlableModel gas_x=null;//É豸°²×°X×ø±ê
|
JlableModel gas_y=null;//É豸°²×°Y×ø±ê
|
JlableModel warning=null;//É豸¸æ¾¯ãÐÖµ
|
|
JButtonModel sure=null;//È·¶¨°´Å¥
|
JButtonModel quxiao=null;//È¡Ïû°´Å¥
|
|
|
JTextField gasid_File=null;
|
JTextField id_File=null;
|
JComboBox<String> gasName_box=null;
|
JTextField gasip_File=null;
|
JTextField gas_x_File=null;
|
JTextField gas_y_File=null;
|
JTextField warning_File=null;
|
|
JComboBox<String> gastype_Box=null;//ÆøÌåÀàÐÍÑ¡ÔñÏÂÀÁбí
|
|
JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
|
|
/**¹Ø±Õ¶Ô»°¿ò·½·¨*/
|
public void closeTagDialog() {
|
this.dispose();
|
|
}
|
/**»ñÈ¡¶Ô»°¿ò·½·¨*/
|
public AddGasMac(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);
|
getGasid().setBounds(40,20,100,25);
|
getGasName().setBounds(40,60,100,25);
|
getGastype().setBounds(40,100,100,25);
|
getGasip().setBounds(40,140,100,25);
|
getGas_x().setBounds(40,180,100,25);
|
getGas_y().setBounds(40,220,100,25);
|
getWarning().setBounds(40,260,100,25);
|
|
getSure().setBounds(70,350,80,25);
|
getQuxiao().setBounds(180,350,80,25);
|
|
getGasid_File().setBounds(140,20,120,25);
|
get_gasName_box().setBounds(140,60,120,25);
|
get_gastype_Box().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);
|
getWarning_File().setBounds(140,260,120,25);
|
getId_label().setBounds(40, 300, 80, 25);
|
getId_File().setBounds(140, 300, 120, 25);
|
|
|
mb.add(getGasid());
|
mb.add(getGasName());
|
mb.add(getGastype());
|
mb.add(getGasip());
|
mb.add(getGas_x());
|
mb.add(getGas_y());
|
mb.add(getWarning());
|
mb.add(getSure());
|
mb.add(getQuxiao());
|
mb.add(getGasid_File());
|
mb.add(get_gasName_box());
|
mb.add(getGasip_File());
|
mb.add(getGas_x_File());
|
mb.add(getGas_y_File());
|
mb.add(getWarning_File());
|
mb.add(get_gastype_Box());
|
mb.add(getId_label());
|
mb.add(getId_File());
|
}
|
return mb;
|
}
|
|
|
/**»ñȡȷ¶¨°´Å¥*/
|
public JButtonModel getSure() {
|
if(sure==null) {
|
sure=new JButtonModel("È· ¶¨");
|
sure.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
String tong_dao=getGasid_File().getText().trim();
|
if(tong_dao.equals("")) {
|
ShowMessage.zidingyi("ËùÔÚͨµÀ²»ÄÜΪ¿Õ");
|
return;
|
}
|
String collect_ip=(String) get_gasName_box().getSelectedItem();
|
if(collect_ip.length()>4) {
|
ShowMessage.zidingyi("²É¼¯ÒǵØÖ·²»ÄÜÌ«³¤£¡");
|
return;
|
}
|
String wei_zhi=Get_collectors.get_coleectr(collect_ip).getMacname();
|
String gas_type=(String) get_gastype_Box().getSelectedItem();
|
String nong_du="0";
|
String status="Õý³£";
|
String waring_zhi=getWarning_File().getText();
|
String ip=getGasip_File().getText().trim();
|
String x=getGas_x_File().getText().trim();
|
String y=getGas_y_File().getText().trim();
|
String id=id_File.getText().trim();
|
|
|
|
|
|
|
if(!IpIsTrue.ipCheck(ip)) {
|
ShowMessage.zidingyi("IPµØÖ·ÓдíÎó£¡");
|
return;
|
}
|
|
if(waring_zhi.equals("")) {
|
ShowMessage.zidingyi("¸æ¾¯ãÐÖµ²»ÄÜΪ¿Õ");
|
return;
|
}
|
|
if(id.equals("")) {
|
ShowMessage.zidingyi("É豸±àºÅ²»ÄÜΪ¿Õ");
|
return;
|
}
|
|
if(Get_Tb_Gass.get_tbGas(id) !=null) {
|
ShowMessage.zidingyi("É豸±àºÅÒѾ´æÔÚ²»ÄÜÖØ¸´");
|
return;
|
}
|
|
if(Get_Tb_Gass.get_gas(tong_dao, collect_ip)==null) {
|
String updateSQL="INSERT tb_gas (id,wei_zhi,gas_type,nong_du,status,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime) VALUES ('"
|
+id+"','"
|
+wei_zhi+"','"
|
+gas_type+"','"
|
+nong_du+"','"
|
+status+"','"
|
+collect_ip+"','"
|
+tong_dao+"','"
|
+waring_zhi+"','"
|
+ip+"','"
|
+x+"','"
|
+y+"','"
|
+GetNowTime.now()+"')";
|
ShowMessage.save(DatabaseManagement.update(updateSQL));
|
Get_Tb_Gass.add_gas(id,tong_dao, collect_ip, gas_type, ip, x, y, waring_zhi);
|
|
|
//ÐÂÔöÒ»ÐÐÊý¾Ý,Ïò±í¸ñĩβÌí¼ÓÒ»ÐÐÊý¾Ý
|
Vector<String> addrowData=new Vector<>();
|
addrowData.add(id);
|
addrowData.add(wei_zhi);
|
addrowData.add(gas_type);
|
addrowData.add(nong_du);
|
addrowData.add(status);
|
addrowData.add(collect_ip);
|
addrowData.add(tong_dao);
|
addrowData.add(waring_zhi);
|
addrowData.add(ip);
|
addrowData.add(x);
|
addrowData.add(y);
|
addrowData.add(GetNowTime.now());
|
tableModel.addRow(addrowData);
|
|
|
|
}else {
|
ShowMessage.zidingyi("ËùÔÚͨµÀ"+tong_dao+"²É¼¯ÒÇIP"+collect_ip+"ÒѾ´æÔÚ²»ÄÜÖØ¸´Ìí¼Ó£¡");
|
}
|
|
|
}
|
});
|
}
|
|
return sure;
|
}
|
|
|
|
/**»ñȡȡÏû°´Å¥*/
|
public JButtonModel getQuxiao() {
|
if(quxiao==null) {
|
quxiao=new JButtonModel("È¡ Ïû");
|
quxiao.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
closeTagDialog();
|
addgas=null;
|
}
|
});
|
}
|
return quxiao;
|
}
|
|
/**ËùÔÚͨµÀ*/
|
public JlableModel getGasid() {
|
if(gasid==null) {
|
gasid=new JlableModel("ËùÔÚͨµÀ£º");
|
}
|
return gasid;
|
}
|
|
/**²É¼¯ÒǵØÖ·*/
|
public JlableModel getGasName() {
|
|
if(gasName==null) {
|
gasName=new JlableModel("²É¼¯ÒǵØÖ·£º");
|
}
|
|
return gasName;
|
}
|
|
/**ÆøÌå´«¸ÐÆ÷ÀàÐÍ*/
|
public JlableModel getGastype() {
|
if(gastype==null) {
|
gastype=new JlableModel("´«¸ÐÆ÷ÀàÐÍ£º");
|
}
|
return gastype;
|
}
|
|
/**É豸IP*/
|
public JlableModel getGasip() {
|
if(gasip==null) {
|
gasip=new JlableModel("É豸IP£º");
|
}
|
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 getWarning() {
|
if(warning==null) {
|
warning=new JlableModel("¸æ¾¯ãÐÖµ£º");
|
}
|
return warning;
|
}
|
|
/**ËùÔÚͨµÀÎı¾*/
|
public JTextField getGasid_File() {
|
if(gasid_File==null) {
|
gasid_File=new JTextField(10);
|
}
|
return gasid_File;
|
}
|
|
/**²É¼¯ÒǵØÖ·ÏÂÀ¿ò*/
|
public JComboBox<String> get_gasName_box() {
|
if(gasName_box==null) {
|
gasName_box=new JComboBox<>();//´´½¨ÏÂÀ¿ò¶ÔÏó
|
gasName_box.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
|
String[] type= Get_collectors.get_macid();
|
ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(type);//ÏÂÀÁбíÄ£ÐÍ
|
gasName_box.setModel(coModel);
|
gasName_box.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
String xuan=(String) gasName_box.getSelectedItem();
|
gasip_File.setText(Get_collectors.get_ip(xuan));
|
|
}
|
});
|
}
|
|
return gasName_box;
|
}
|
|
/**É豸IPÎı¾*/
|
public JTextField getGasip_File() {
|
if(gasip_File==null) {
|
gasip_File=new JTextField(10);
|
gasip_File.setEnabled(false);
|
}
|
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 getWarning_File() {
|
if(warning_File==null) {
|
warning_File=new JTextField(10);
|
}
|
return warning_File;
|
}
|
|
/**É豸ÐͺÅÑ¡Ôñ*/
|
public JComboBox<String> get_gastype_Box() {
|
|
if(gastype_Box==null) {
|
gastype_Box=new JComboBox<>();//´´½¨ÏÂÀ¿ò¶ÔÏó
|
gastype_Box.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
|
String[] type= {"Ñ¡ÔñÆøÌåÀàÐÍ","C O","H2S","CH4","CO2","O 2","SO2"};
|
ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(type);//ÏÂÀÁбíÄ£ÐÍ
|
gastype_Box.setModel(coModel);
|
gastype_Box.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
String qiti=(String) gastype_Box.getSelectedItem();
|
switch(qiti){
|
case "C O":
|
warning_File.setText("100");
|
break;
|
case "H2S" :
|
warning_File.setText("10");
|
break;
|
|
case "CH4" :
|
warning_File.setText("25");
|
break;
|
|
case "CO2":
|
warning_File.setText("1000");
|
break;
|
case "O 2":
|
warning_File.setText("23");
|
break;
|
case "SO2":
|
warning_File.setText("10");
|
break;
|
}
|
}
|
});
|
|
}
|
|
return gastype_Box;
|
}
|
public JlableModel getId_label() {
|
if(id_label==null) {
|
id_label=new JlableModel("É豸±àºÅ:");
|
}
|
return id_label;
|
}
|
public JTextField getId_File() {
|
if(id_File==null) {
|
id_File=new JTextField(10);
|
}
|
return id_File;
|
}
|
@Override
|
public void windowOpened(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
@Override
|
public void windowClosing(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
addgas=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 AlertGasMac extends AddGasMac{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
public AlertGasMac(String title) {
|
super(title);
|
// TODO ×Ô¶¯Éú³ÉµÄ¹¹Ô캯Êý´æ¸ù
|
getGasid_File().setText((String) getTable().getValueAt(getSelectedRow(), 6));
|
get_gasName_box().setSelectedItem((String) getTable().getValueAt(getSelectedRow(), 5));
|
get_gastype_Box().setSelectedItem((String) getTable().getValueAt(getSelectedRow(), 2));
|
getGasip_File().setText((String) getTable().getValueAt(getSelectedRow(), 8));
|
getGas_x_File().setText((String) getTable().getValueAt(getSelectedRow(), 9));
|
getGas_y_File().setText((String) getTable().getValueAt(getSelectedRow(), 10));
|
getWarning_File().setText((String) getTable().getValueAt(getSelectedRow(), 7));
|
getId_File().setText((String) getTable().getValueAt(getSelectedRow(), 0));
|
getId_File().setEnabled(false);
|
|
}
|
|
public void windowClosing(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
alertgas=null;
|
|
}
|
/**»ñȡȡÏû°´Å¥*/
|
public JButtonModel getQuxiao() {
|
if(quxiao==null) {
|
quxiao=new JButtonModel("È¡ Ïû");
|
quxiao.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
closeTagDialog();
|
alertgas=null;
|
}
|
});
|
}
|
return quxiao;
|
}
|
|
/**»ñȡȷ¶¨°´Å¥*/
|
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 tong_dao=getGasid_File().getText().trim();
|
String collect_ip=(String) get_gasName_box().getSelectedItem();
|
String gas_type=(String) get_gastype_Box().getSelectedItem();
|
String x=getGas_x_File().getText().trim();
|
String y=getGas_y_File().getText().trim();
|
String warning_zhi=getWarning_File().getText().trim();
|
if(Get_Tb_Gass.alert_gasc(id, tong_dao, collect_ip, gas_type, x, y, warning_zhi)) {
|
ShowMessage.zidingyi("Ð޸ijɹ¦£¡");
|
updateTable() ;
|
}else {
|
ShowMessage.zidingyi("дÈëÊý¾Ý¿âʧ°Ü£¡");
|
}
|
|
}
|
});
|
|
}
|
return sure;
|
}
|
|
}
|
|
}
|