package Frame;
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
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.WindowEvent;
|
import java.awt.event.WindowListener;
|
import java.util.List;
|
import java.util.Vector;
|
import javax.swing.Box;
|
import javax.swing.ImageIcon;
|
import javax.swing.JDialog;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTable;
|
import javax.swing.JTextField;
|
import javax.swing.event.InternalFrameEvent;
|
import javax.swing.event.InternalFrameListener;
|
import javax.swing.table.DefaultTableModel;
|
import ColorAndFont.English;
|
import ColorAndFont.NothJPanel;
|
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 tag.Tag_Dell;
|
import tbDataModel.Tb_gas_anchor;
|
import tbDataModel_Dell.Dell_tag_gas_jiaozhun_value;
|
import tbDataModel_Dell.Dell_tb_gas_anchor;
|
@SuppressWarnings("rawtypes")
|
public class Gas_anchor_frame extends jinternalFrame{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
Container rq;
|
NothJPanel northPanel=null;//±±²¿Ãæ°å
|
JPanel centerPanel=null;//Öв¿Ãæ°å
|
JScrollPane gd=null;//¹ö¶¯Ãæ°å
|
JTable table=null;//ÉêÃ÷±í¸ñ
|
JButtonModel but_add=null;//ÐÂÔöÆøÑ¹»ùÕ¾
|
JButtonModel but_serch=null;//ËÑË÷°´Å¥
|
JButtonModel but_save=null;//±£´æ°´Å¥
|
JButtonModel but_issave=null;//±£´æÑ¡ÖÐ
|
JButtonModel but_refresh=null;//ˢа´Å¥
|
JButtonModel but_delete=null;//ɾ³ý°´Å¥
|
JTextField jf_serch=null;
|
Vector<String> columnName;
|
AddTag_id adddialog=null;
|
List list;
|
Vector rowData=null;
|
DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
|
Vector nearanchor=new Vector();
|
static Vector<String> choose_anchor=new Vector<String>();
|
static boolean nerbyopen=false;
|
|
|
|
public Gas_anchor_frame() {//¹¹Ôì·½·¨
|
String title="ÆøÑ¹»ùÕ¾¹ÜÀíÒ³Ãæ";
|
if(Systems.sys().getLanguage().equals("English")) {
|
title="GasAnchorSet";
|
}
|
this.setTitle(title);
|
rowData=new Vector();
|
this.setFrameIcon(new ImageIcon("image/icon/linjing.png"));//ÉèÖô°Ìåͼ±ê
|
rq=getContentPane();//»ñÈ¡ÈÝÆ÷
|
rq.setLayout(new BorderLayout());
|
rq.setBackground(UIColor.getNorth_color());
|
rq.add(getNorthPanel(),BorderLayout.NORTH);
|
rq.add(getGd(),BorderLayout.CENTER);
|
nerbyopen=true;
|
this.addInternalFrameListener(new InternalFrameListener() {
|
|
@Override
|
public void internalFrameOpened(InternalFrameEvent e) {
|
|
}
|
|
@Override
|
public void internalFrameIconified(InternalFrameEvent e) {
|
}
|
|
@Override
|
public void internalFrameDeiconified(InternalFrameEvent e) {
|
}
|
|
@Override
|
public void internalFrameDeactivated(InternalFrameEvent e) {
|
}
|
|
@Override
|
public void internalFrameClosing(InternalFrameEvent e) {
|
table=null;
|
}
|
|
@Override
|
public void internalFrameClosed(InternalFrameEvent e) {
|
}
|
|
@Override
|
public void internalFrameActivated(InternalFrameEvent e) {
|
}
|
});
|
|
}
|
|
/**»ñÈ¡±±²¿Ãæ°åµÄ·½·¨*/
|
public NothJPanel getNorthPanel() {
|
if(northPanel==null) {
|
northPanel=new NothJPanel();
|
Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
|
topicBox.add(getJf_serch());
|
topicBox.add(Box.createHorizontalStrut(5));
|
topicBox.add(getBut_serch());
|
topicBox.add(Box.createHorizontalStrut(20));
|
topicBox.add(getBut_refresh());
|
topicBox.add(Box.createHorizontalStrut(20));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
|
topicBox.add(getBut_issave());
|
topicBox.add(Box.createHorizontalStrut(20));
|
topicBox.add(getBut_save());
|
topicBox.add(Box.createHorizontalStrut(20));
|
topicBox.add(getBut_add());
|
topicBox.add(Box.createHorizontalStrut(20));
|
topicBox.add(getBut_delete());
|
|
northPanel.add(topicBox );
|
}
|
return northPanel;
|
}
|
|
public JButtonModel getBut_save() {
|
if(but_save==null) {
|
but_save=new JButtonModel("È«²¿±£´æ");
|
but_save.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý
|
for(int i=0;i<tagnum;i++) {
|
String anchorid=(String) table.getValueAt(i, 0);//ÆøÑ¹»ùÕ¾ID
|
String anchorid2=(String) table.getValueAt(i, 1); //±¸ÓÃÆøÑ¹»ùÕ¾ID
|
String anchorx=(String) table.getValueAt(i, 2);//ÆøÑ¹»ùÕ¾X×ø±ê
|
String anchory=(String) table.getValueAt(i, 3); //ÆøÑ¹»ùÕ¾Y×ø±ê
|
String anchorz=(String) table.getValueAt(i, 4); //ÆøÑ¹»ùÕ¾Z×ø±ê
|
//Èç¹û±êÇ©IDΪ¿ÕÔò·µ»Ø
|
if(anchorid.equals("")) {
|
ShowMessage.zidingyi( "É豸±àºÅID²»ÄÜΪ¿Õ");
|
return;
|
}
|
if(anchorz.length()<2) {
|
ShowMessage.zidingyi( "É豸°²×°¸ß¶ÈZ×ø±ê²»ÕýÈ·Çë¼ì²é...");
|
return;
|
}
|
|
Tb_gas_anchor gas=Dell_tb_gas_anchor.get_Tb_gas_anchor(anchorid);
|
if(gas !=null) {
|
Dell_tb_gas_anchor.add_alert(anchorid, anchorid2, anchorx,
|
anchory, anchorz,"-1", "-1");
|
updateTable();//Ë¢ÐÂ
|
}else {
|
ShowMessage.zidingyi( "Ìí¼ÓµÄÉ豸±àºÅ"+anchorid+"²»´æÔÚ£¬±£´æÊ§°Ü...");
|
}
|
}
|
}
|
});
|
}
|
return but_save;
|
}
|
|
public JButtonModel getBut_issave() {
|
if(but_issave==null) {
|
but_issave=new JButtonModel("±£´æÑ¡ÖÐ");
|
but_issave.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ
|
int size=selectedRows.length;
|
if(size==0) {
|
ShowMessage.zidingyi_24("ÇëÏÈÑ¡ÖÐÐèÒª±£´æµÄÐÐ");
|
return;
|
}
|
for(int i=0;i<size;i++) {
|
int a=selectedRows[i];
|
String anchorid=(String) table.getValueAt(a, 0);//ÆøÑ¹»ùÕ¾ID
|
String anchorid2=(String) table.getValueAt(a, 1); //±¸ÓÃÆøÑ¹»ùÕ¾ID
|
String anchorx=(String) table.getValueAt(a, 2);//ÆøÑ¹»ùÕ¾X×ø±ê
|
String anchory=(String) table.getValueAt(a, 3); //ÆøÑ¹»ùÕ¾Y×ø±ê
|
String anchorz=(String) table.getValueAt(a, 4); //ÆøÑ¹»ùÕ¾Z×ø±ê
|
//Èç¹û±êÇ©IDΪ¿ÕÔò·µ»Ø
|
if(anchorid.equals("")) {
|
ShowMessage.zidingyi( "É豸±àºÅID²»ÄÜΪ¿Õ");
|
return;
|
}
|
if(anchorz.length()<2) {
|
ShowMessage.zidingyi( "É豸°²×°¸ß¶ÈZ×ø±ê²»ÕýÈ·Çë¼ì²é...");
|
return;
|
}
|
|
Tb_gas_anchor gas=Dell_tb_gas_anchor.get_Tb_gas_anchor(anchorid);
|
if(gas !=null) {
|
Dell_tb_gas_anchor.add_alert(anchorid, anchorid2, anchorx,
|
anchory, anchorz,"-1", "-1");
|
updateTable();//Ë¢ÐÂ
|
}else {
|
ShowMessage.zidingyi( "Ìí¼ÓµÄÉ豸±àºÅ"+anchorid+"²»´æÔÚ£¬±£´æÊ§°Ü...");
|
}
|
}
|
}
|
});
|
}
|
return but_issave;
|
}
|
|
|
public JButtonModel getBut_refresh() {
|
if(but_refresh==null) {
|
but_refresh=new JButtonModel(buttonTitle.getRefresh());
|
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_tb_gas_anchor.getGas_anchorvc());
|
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","±¸ÓÃÉ豸ID"," X×ø±ê","Y×ø±ê","Z×ø±ê","״̬","ÆøÑ¹Öµ","¸üÐÂʱ¼ä"};//±í¸ñÁÐÃû
|
String[] name2= {"anchorid2",
|
"anchorx",
|
"anchory",
|
"anchorz",
|
"onlievar",
|
"gasvalue",
|
"refresh_time"
|
};//±í¸ñÁÐÃû
|
String[] columnNames=English.columnNames(name1, name2);
|
columnName=new Vector<>();
|
for(int i=0;i<columnNames.length;i++){
|
columnName.add(columnNames[i]);
|
}
|
|
//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ
|
greateTables tables=new greateTables();
|
tableModel=new DefaultTableModel(rowData, columnName);
|
table=tables.getTable(tableModel);
|
getRowData(Dell_tb_gas_anchor.getGas_anchorvc());
|
}
|
return table;
|
|
}
|
|
|
/**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/
|
public void getRowData(Vector<Tb_gas_anchor> gas_anchorvc ) {
|
int size=gas_anchorvc.size();
|
for(int i=0;i<size;i++) {
|
Tb_gas_anchor info=gas_anchorvc .get(i);
|
Vector<String> row = new Vector<String> ();
|
String anchorid=info.getAnchorid(); //ÆøÑ¹»ùÕ¾ID
|
String anchorid2=info.getAnchorid2(); //±¸ÓÃÆøÑ¹»ùÕ¾ID
|
String anchorx=info.getAnchorx(); //ÆøÑ¹»ùÕ¾X×ø±ê
|
String anchory=info.getAnchory(); //ÆøÑ¹»ùÕ¾Y×ø±ê
|
String anchorz=info.getAnchorz(); //ÆøÑ¹»ùÕ¾Z×ø±ê
|
String onlie=info.getOnlie(); //ÆøÑ¹»ùվ״̬ÔÚÏß1ÀëÏß0
|
String gasvalue=info.getGasvalue(); //ÆøÑ¹»ùÕ¾ÆøÑ¹Öµ
|
String refresh_time=info.getRefresh_time(); //ÆøÑ¹»ùÕ¾¸üÐÂÊý¾Ýʱ¼ä
|
|
if(onlie.equals("-1")) {
|
onlie="δ֪";
|
}else if(onlie.equals("1")) {
|
onlie="ÔÚÏß";
|
}else if(onlie.equals("0")) {
|
onlie="ÀëÏß";
|
}
|
if(gasvalue.equals("-1")) {
|
gasvalue="δ֪";
|
}
|
row.add(anchorid);
|
row.add(anchorid2);
|
row.add(anchorx); //ÆøÑ¹»ùÕ¾X×ø±ê
|
row.add(anchory); //ÆøÑ¹»ùÕ¾Y×ø±ê
|
row.add(anchorz); //ÆøÑ¹»ùÕ¾Z×ø±ê
|
row.add(onlie); //ÆøÑ¹»ùվ״̬ÔÚÏß1ÀëÏß0
|
row.add(gasvalue); //ÆøÑ¹»ùÕ¾ÆøÑ¹Öµ
|
row.add(refresh_time); //ÆøÑ¹»ùÕ¾¸üÐÂÊý¾Ýʱ¼ä
|
tableModel.addRow(row);
|
}
|
}
|
|
|
|
/**»ñȡѡÖÐÐлùÕ¾¼¯ºÏ*/
|
public Vector<String> getChoose_anchor() {
|
if(nerbyopen) {
|
if(choose_anchor.size() !=0) {
|
choose_anchor.removeAllElements();
|
}
|
int size=table.getSelectedRowCount();
|
if(size==1) {
|
choose_anchor=new Vector<String>();
|
for(int i=0;i<11;i++) {
|
int row=table.getSelectedRow();
|
String anchorid=(String) table.getValueAt(row, i);
|
if(anchorid.length()>3) {
|
choose_anchor.add(anchorid);
|
}
|
}
|
}
|
}
|
return choose_anchor;
|
}
|
|
public JButtonModel getBut_serch() {
|
if(but_serch==null) {
|
but_serch=new JButtonModel("ËÑË÷");
|
but_serch.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
if(jf_serch.getText().length()>=1) {
|
String serch=jf_serch.getText().trim();
|
if(Dell_tb_gas_anchor.getserch_gasanchor(serch).size()==0) {
|
ShowMessage.zidingyi("ËÑË÷µÄ"+serch+"²»´æÔÚ");
|
return;
|
}
|
|
int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
|
if(tagnum >0 ) {
|
for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ
|
tableModel.removeRow(0);
|
}
|
getRowData(Dell_tb_gas_anchor.getserch_gasanchor(serch));
|
}
|
}else {
|
ShowMessage.zidingyi("ÊÕÈëÐèÒªËÑË÷»ùÕ¾ID");
|
}
|
}
|
});
|
|
}
|
return but_serch;
|
}
|
|
public JTextField getJf_serch() {
|
if(jf_serch==null) {
|
jf_serch=new JTextField(6);
|
}
|
return jf_serch;
|
}
|
|
public JButtonModel getBut_add() {
|
if(but_add==null) {
|
but_add=new JButtonModel("ÐÂÔöÉ豸");
|
but_add.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
if(adddialog==null) {
|
adddialog=new AddTag_id("ÐÂÔö¶Ô»°¿ò");
|
}
|
|
}
|
});
|
}
|
return but_add;
|
}
|
|
|
/**ÐÂÔö±êÇ©IDÕ¾¶Ô»°¿ò*/
|
class AddTag_id extends JDialog implements WindowListener{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
JlableModel jl_a1=new JlableModel ("É豸±àºÅID:");
|
JlableModel jl_a2=new JlableModel ("±¸ÓÃÉ豸±àºÅ:");
|
JlableModel jl_a3=new JlableModel ("°²×°X×ø±ê/cm:");
|
JlableModel jl_a4=new JlableModel ("°²×°Y×ø±ê/cm:");
|
JlableModel jl_a5=new JlableModel ("°²×°Z×ø±ê/cm:");
|
|
JTextField jt_a1=new JTextField();
|
JTextField jt_a2=new JTextField();
|
JTextField jt_a3=new JTextField();
|
JTextField jt_a4=new JTextField();
|
JTextField jt_a5=new JTextField();
|
|
|
JButtonModel sure=null;//È·¶¨°´Å¥
|
JButtonModel quxiao=null;//È¡Ïû°´Å¥
|
JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
|
|
/**¹Ø±Õ¶Ô»°¿ò·½·¨*/
|
public void closeTagDialog() {
|
this.dispose();
|
adddialog=null;
|
|
}
|
|
|
/**»ñÈ¡¶Ô»°¿ò·½·¨*/
|
public AddTag_id(String title) {
|
super();
|
//this.setModal(true);//´°Ìå×èÈû
|
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-175;//´°Ìåx0×ø±ê
|
int y0=height-250;//´°Ìåy0×ø±ê
|
Container rq=getContentPane();
|
rq.add(getMb());
|
this.addWindowListener((WindowListener) this);
|
this.setBounds(x0, y0,360,360);
|
this.setVisible(true);
|
}
|
|
/**»ñÈ¡Ãæ°å*/
|
public JPanel getMb() {
|
if(mb==null){
|
mb=new JPanel();
|
mb.setLayout(null);
|
mb.setBackground(Color.white);
|
mb.add(jl_a1);
|
mb.add(jl_a2);
|
mb.add(jl_a3);
|
mb.add(jl_a4);
|
mb.add(jl_a5);
|
mb.add(jt_a1);
|
mb.add(jt_a2);
|
mb.add(jt_a3);
|
mb.add(jt_a4);
|
mb.add(jt_a5);
|
mb.add(getSure());
|
mb.add(getQuxiao());
|
|
|
int height=30;
|
int width=120;
|
int jg=20;
|
int x1=30;
|
int x2=x1+width;
|
int y0=30;
|
int y1=y0+1*(height+jg);
|
int y2=y0+2*(height+jg);
|
int y3=y0+3*(height+jg);
|
int y4=y0+4*(height+jg);
|
int y5=y0+5*(height+jg);
|
|
jl_a1.setBounds(x1, y0, width, height);
|
jl_a2.setBounds(x1, y1, width, height);
|
jl_a3.setBounds(x1, y2, width, height);
|
jl_a4.setBounds(x1, y3, width, height);
|
jl_a5.setBounds(x1, y4, width, height);
|
|
jt_a1.setBounds(x2, y0, width, height);
|
jt_a2.setBounds(x2, y1, width, height);
|
jt_a3.setBounds(x2, y2, width, height);
|
jt_a4.setBounds(x2, y3, width, height);
|
jt_a5.setBounds(x2, y4, width, height);
|
|
getSure().setBounds(x1,y5,100, height);
|
getQuxiao().setBounds(x2+20,y5,100,height);
|
|
}
|
|
return mb;
|
}
|
|
|
|
/**»ñȡȷ¶¨°´Å¥*/
|
public JButtonModel getSure() {
|
if(sure==null) {
|
sure=new JButtonModel("È· ¶¨");
|
sure.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
|
String anchorid=jt_a1.getText().trim();//ÆøÑ¹»ùÕ¾ID
|
String anchorid2=jt_a2.getText().trim(); //±¸ÓÃÆøÑ¹»ùÕ¾ID
|
String anchorx=jt_a3.getText().trim();//ÆøÑ¹»ùÕ¾X×ø±ê
|
String anchory=jt_a4.getText().trim(); //ÆøÑ¹»ùÕ¾Y×ø±ê
|
String anchorz=jt_a5.getText().trim(); //ÆøÑ¹»ùÕ¾Z×ø±ê
|
//Èç¹û±êÇ©IDΪ¿ÕÔò·µ»Ø
|
if(anchorid.equals("")) {
|
ShowMessage.zidingyi( "É豸±àºÅID²»ÄÜΪ¿Õ");
|
return;
|
}
|
if(anchorz.length()<2) {
|
ShowMessage.zidingyi( "É豸°²×°¸ß¶ÈZ×ø±ê²»ÕýÈ·Çë¼ì²é...");
|
return;
|
}
|
|
Tb_gas_anchor gas=Dell_tb_gas_anchor.get_Tb_gas_anchor(anchorid);
|
if(gas==null) {
|
Dell_tb_gas_anchor.add_alert(anchorid, anchorid2, anchorx,
|
anchory, anchorz,"-1", "-1");
|
updateTable();//Ë¢ÐÂ
|
}else {
|
ShowMessage.zidingyi( "Ìí¼ÓµÄÉ豸±àºÅ"+anchorid+"ÒѾ´æÔÚ£¬ÇëÎðÖØ¸´Ìí¼Ó...");
|
}
|
}
|
});
|
}
|
return sure;
|
}
|
|
|
|
/**»ñȡȡÏû°´Å¥*/
|
public JButtonModel getQuxiao() {
|
if(quxiao==null) {
|
quxiao=new JButtonModel("È¡ Ïû");
|
quxiao.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
closeTagDialog();
|
adddialog=null;
|
}
|
});
|
}
|
return quxiao;
|
}
|
@Override
|
public void windowOpened(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
@Override
|
public void windowClosing(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
adddialog=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) {
|
|
|
}
|
@Override
|
public void windowDeactivated(WindowEvent e) {
|
|
}
|
|
}
|
|
|
public JButtonModel getBut_delete() {
|
if(but_delete==null) {
|
but_delete=new JButtonModel("ɾ³ýÉ豸");
|
but_delete.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ
|
if(selectedRows.length ==0) {
|
ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèҪɾ³ýµÄÐУ¡");
|
return;
|
}
|
|
if(selectedRows.length !=0) {
|
for(int i=0;i<selectedRows.length;i++){
|
String anchorid=(String) table.getValueAt(selectedRows[i], 0);
|
String deleteSql="DELETE FROM tb_gas_anchor WHERE anchorid='"+anchorid+"'";
|
if(DatabaseManagement.update(deleteSql) !=0) {
|
Tb_gas_anchor anchoridtb= Dell_tb_gas_anchor.get_Tb_gas_anchor(anchorid);
|
Dell_tb_gas_anchor.getGas_anchorvc().removeElement(anchoridtb);
|
Dell_tag_gas_jiaozhun_value.delete_gas_anchor(anchorid, 1);
|
Tag_Dell.remove_tag(anchorid);
|
}
|
}
|
|
//ɾ³ýËùÓб»Ñ¡ÖеÄÐÐ
|
for(int j=selectedRows.length-1;j>=0;j--){//ÕâÊǹؼü´úÂë
|
tableModel.removeRow(selectedRows[j]);//ɾ³ýÈÎÒⱻѡÖÐÐÐ
|
|
}
|
table.setModel(tableModel);//¸üбí¸ñÄ£ÐÍ
|
|
ShowMessage.zidingyi(selectedRows.length+"Ìõ¼Ç¼ɾ³ý³É¹¦£¡"); //ɾ³ý³É¹¦ÌáʾÐÅÏ¢
|
}
|
|
}
|
});
|
|
}
|
return but_delete;
|
}
|
|
public void setBut_delete(JButtonModel but_delete) {
|
this.but_delete = but_delete;
|
}
|
|
|
|
}
|