package Frame;
|
import java.awt.BorderLayout;
|
import java.awt.Container;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusListener;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Vector;
|
import javax.swing.Box;
|
import javax.swing.ImageIcon;
|
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.ShowMessage;
|
import PbuliClass.Systems;
|
import PbuliClass.greateTables;
|
import PbuliClass.jinternalFrame;
|
import anchor.Anchor;
|
import anchor.Anchor_Dell;
|
import anchor.Anchor_nerby_dell;
|
import home.ChuShiHua;
|
@SuppressWarnings("rawtypes")
|
public class AnchorNearby extends jinternalFrame{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
Container rq;
|
NothJPanel northPanel=null;//±±²¿Ãæ°å
|
JPanel centerPanel=null;//Öв¿Ãæ°å
|
JScrollPane gd=null;//¹ö¶¯Ãæ°å
|
static JTable table=null;//ÉêÃ÷±í¸ñ
|
JButtonModel but_serch=null;//ËÑË÷°´Å¥
|
JButtonModel but_save=null;//±£´æ°´Å¥
|
JButtonModel but_issave=null;//±£´æÑ¡ÖÐ
|
JButtonModel but_clear=null;//Çå¿Õ°´Å¥
|
JButtonModel but_refresh=null;//ˢа´Å¥
|
JButtonModel but_tihuan=null;//Ìæ»»»ùÕ¾
|
JButtonModel but_siji=null;//4»ùÕ¾¿ìËÙÅäÖÃ
|
JTextField jf_serch=null;
|
JTextField jf_anchorA=null;//»ùÕ¾A
|
JTextField jf_anchorB=null;//»ùÕ¾B
|
Vector<String> columnName;
|
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 AnchorNearby() {//¹¹Ôì·½·¨
|
String title="ÁÙ½üÅäÖÃ";
|
if(Systems.sys().getLanguage().equals("English")) {
|
title="Approaching Site";
|
}
|
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) {
|
nerbyopen=false;
|
choose_anchor.removeAllElements();
|
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(10));
|
topicBox.add(getBut_refresh());
|
topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
|
topicBox.add(getBut_issave());
|
topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
|
topicBox.add(getJf_anchorA());
|
topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
|
topicBox.add(getJf_anchorB());
|
topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
|
topicBox.add(getBut_tihuan());
|
topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö10ÏñËØ¿íµÄˮƽ֧Öù
|
topicBox.add(getBut_siji());
|
topicBox.add(Box.createHorizontalStrut(10));
|
topicBox.add(getBut_save());
|
|
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();//±í¸ñ×ÜÐÐÊý
|
boolean succ=false;
|
for(int i=0;i<tagnum;i++) {
|
String anchorid=(String) table.getValueAt(i, 0);
|
String near1=(String) table.getValueAt(i, 1);
|
String near2=(String) table.getValueAt(i, 2);
|
String near3=(String) table.getValueAt(i, 3);
|
String near4=(String) table.getValueAt(i, 4);
|
String near5=(String) table.getValueAt(i, 5);
|
String near6=(String) table.getValueAt(i, 6);
|
String near7=(String) table.getValueAt(i, 7);
|
String near8=(String) table.getValueAt(i, 8);
|
String near9=(String) table.getValueAt(i, 9);
|
String near10=(String) table.getValueAt(i, 10);
|
String qiehuan=(String) table.getValueAt(i,11);
|
String baoliu1=(String) table.getValueAt(i,12);
|
String baoliu2=(String) table.getValueAt(i,13);
|
near1=near1.replaceAll(" ", "");
|
near2=near2.replaceAll(" ", "");
|
near3=near3.replaceAll(" ", "");
|
near4=near4.replaceAll(" ", "");
|
near5=near5.replaceAll(" ", "");
|
near6=near6.replaceAll(" ", "");
|
near6=near6.replaceAll(" ", "");
|
near7=near7.replaceAll(" ", "");
|
near8=near8.replaceAll(" ", "");
|
near9=near9.replaceAll(" ", "");
|
near10=near10.replaceAll(" ", "");
|
qiehuan=qiehuan.replaceAll(" ", "");
|
baoliu1=baoliu1.replaceAll(" ", "");
|
|
String[] ziduan= {"near1","near2","near3","near4","near5","near6","near7",
|
"near8","near9","near10","qiehuan","baoliu1","baoliu2","anchorid"};
|
String[] zhi= {near1,near2,near3,near4,near5,near6,near7,near8,near9,near10,
|
qiehuan,baoliu1,baoliu2,anchorid};
|
succ=DatabaseManagement.fast_alert_dbase("tb_anchor_nearby", ziduan, zhi);
|
Anchor_nerby_dell.alert_anchorby(anchorid, near1, near2, near3, near4, near5,
|
near6, near7, near8,near9, near10,qiehuan,baoliu1,baoliu2);
|
}
|
if(succ) {
|
ChuShiHua.write_nearby();
|
ShowMessage.zidingyi("Êý¾Ý±£´æ³É¹¦...");
|
//дÈëÁÙ½ü»ùÕ¾
|
}
|
}
|
});
|
}
|
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);
|
String near1=(String) table.getValueAt(a, 1);
|
String near2=(String) table.getValueAt(a, 2);
|
String near3=(String) table.getValueAt(a, 3);
|
String near4=(String) table.getValueAt(a, 4);
|
String near5=(String) table.getValueAt(a, 5);
|
String near6=(String) table.getValueAt(a, 6);
|
String near7=(String) table.getValueAt(a, 7);
|
String near8=(String) table.getValueAt(a, 8);
|
String near9=(String) table.getValueAt(a, 9);
|
String near10=(String) table.getValueAt(a, 10);
|
String qiehuan=(String) table.getValueAt(a,11);
|
String baoliu1=(String) table.getValueAt(a,12);//×îÔ¶²â¾à¾àÀë
|
String baoliu2=(String) table.getValueAt(a,13);
|
near1=near1.replaceAll(" ", "");
|
near2=near2.replaceAll(" ", "");
|
near3=near3.replaceAll(" ", "");
|
near4=near4.replaceAll(" ", "");
|
near5=near5.replaceAll(" ", "");
|
near6=near6.replaceAll(" ", "");
|
near6=near6.replaceAll(" ", "");
|
near7=near7.replaceAll(" ", "");
|
near8=near8.replaceAll(" ", "");
|
near9=near9.replaceAll(" ", "");
|
near10=near10.replaceAll(" ", "");
|
qiehuan=qiehuan.replaceAll(" ", "");
|
baoliu1=baoliu1.replaceAll(" ", "");
|
String[] ziduan= {"near1","near2","near3","near4","near5","near6",
|
"near7","near8","near9","near10","qiehuan","baoliu1","baoliu2","anchorid"};
|
String[] zhi= {near1,near2,near3,near4,near5,near6,near7,near8,near9,near10,
|
qiehuan,baoliu1,baoliu2,anchorid};
|
boolean succ=DatabaseManagement.fast_alert_dbase("tb_anchor_nearby", ziduan, zhi);
|
Anchor_nerby_dell.alert_anchorby(anchorid, near1, near2, near3, near4, near5, near6,
|
near7, near8,near9, near10,qiehuan,baoliu1,baoliu2);
|
if(succ) {
|
Anchor anchor=Anchor_Dell.get_anchor(anchorid);
|
ChuShiHua.write_anchor_near(anchor);
|
ShowMessage.zidingyi(anchorid+"ÁÙ½üÅäÖÃÒÑÏ·¢");
|
}
|
}
|
|
}
|
});
|
}
|
return but_issave;
|
}
|
|
public JButtonModel getBut_clear() {
|
if(but_clear==null) {
|
but_clear=new JButtonModel("Çå¿Õ");
|
}
|
return but_clear;
|
}
|
|
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( DatabaseManagement.get_alldate_indatabase("tb_anchor_nearby"));
|
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","ÁÙ½ü1","ÁÙ2","ÁÙ3","ÁÙ4","ÁÙ5","ÁÙ6","ÁÙ7","ÁÙ8","ÁÙ9","ÁÙ10","Çл»¾àÀë","×îÔ¶²â¾à","allout"};//±í¸ñÁÐÃû
|
String[] name2= {
|
"Anchor ID",
|
"Near1",
|
"Near2",
|
"Near3",
|
"Near4",
|
"Near5",
|
"Near6",
|
"Near7",
|
"Near8",
|
"Near9",
|
"Near10",
|
"Handover Distance",
|
"fastdistance",
|
"allout"};//±í¸ñÁÐÃû
|
String[] columnNames=English.columnNames(name1, name2);
|
columnName=new Vector<>();
|
for(int i=0;i<columnNames.length;i++){
|
columnName.add(columnNames[i]);
|
}
|
|
//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ
|
list = DatabaseManagement.table_base("tb_anchor_nearby","ASC","anchorid");
|
greateTables tables=new greateTables();
|
tableModel=new DefaultTableModel(rowData, columnName);
|
table=tables.getTable(tableModel);
|
getRowData(list );
|
}
|
return table;
|
|
}
|
|
|
/**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/
|
@SuppressWarnings({ "unchecked"})
|
public void getRowData(List list ) {
|
Iterator iterator = list.iterator();//´´½¨µü´úÆ÷
|
while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
|
List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ
|
Vector<String> row = new Vector();
|
for(int i=0;i<11;i++) {
|
String anchorner=(String)info.get(i);
|
if(anchorner==null) {
|
ShowMessage.zidingyi_24("ÁÙ½ü»ùվΪNULL±¨´í");
|
return;
|
}
|
if(anchorner.length()>2 ) {
|
row.add(anchorner);// »ùÕ¾ID
|
}
|
}
|
|
if(row.size() !=11) {
|
int size=row.size();
|
for(int j=0;j<(11-size);j++) {
|
row.add(" ");// »ùÕ¾ID
|
}
|
}
|
row.add((String)info.get(11));//Ìí¼ÓÇл»¾àÀë
|
String fastdis="65535";
|
String a=(String)info.get(12);
|
if( a!=null) {
|
fastdis=a;
|
}
|
row.add(fastdis);//×îÔ¶²â¾à
|
|
String allout=(String)info.get(13);//ËùÓвâ¾àÊä³ö
|
if( allout==null) {
|
allout="0";
|
}
|
row.add(allout);
|
|
tableModel.addRow(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
|
row=null;
|
}
|
}
|
|
public JButtonModel getBut_tihuan() {
|
if(but_tihuan==null) {
|
but_tihuan=new JButtonModel("»ùÕ¾AÌæ»»B");
|
but_tihuan.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
String anchora=jf_anchorA.getText().trim();
|
String anchorb=jf_anchorB.getText().trim();
|
anchora=anchora.replaceAll(" ", "");
|
anchorb=anchorb.replaceAll(" ", "");
|
for(int i=0;i<table.getRowCount();i++) {
|
for(int j=0;j<table.getColumnCount();j++) {
|
if(table.getValueAt(i, j).equals(anchora)) {
|
table.setValueAt(anchorb, i, j);
|
}
|
}
|
}
|
ShowMessage.zidingyi("È«²¿Ìæ»»Íê±Ï...");
|
}
|
});
|
}
|
return but_tihuan;
|
}
|
|
public JTextField getJf_anchorA() {
|
if(jf_anchorA==null) {
|
jf_anchorA=new JTextField(4);
|
jf_anchorA.setText("A");
|
jf_anchorA.addFocusListener(new FocusListener() {
|
|
@Override
|
public void focusLost(FocusEvent e) {
|
|
}
|
|
@Override
|
public void focusGained(FocusEvent e) {
|
jf_anchorA.setText("");
|
}
|
});
|
}
|
return jf_anchorA;
|
}
|
|
public JTextField getJf_anchorB() {
|
if(jf_anchorB==null) {
|
jf_anchorB=new JTextField(4);
|
jf_anchorB.setText("B");
|
jf_anchorB.addFocusListener(new FocusListener() {
|
|
@Override
|
public void focusLost(FocusEvent e) {
|
|
}
|
|
@Override
|
public void focusGained(FocusEvent e) {
|
jf_anchorB.setText("");
|
}
|
});
|
}
|
return jf_anchorB;
|
}
|
|
/**»ñȡѡÖÐÐлùÕ¾¼¯ºÏ*/
|
public static 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;
|
}
|
|
/**4»ùÕ¾¿ìËÙÅäÖð´Å¥*/
|
public JButtonModel getBut_siji() {
|
if(but_siji==null) {
|
but_siji=new JButtonModel("¿ìËÙÅäÖÃ");
|
but_siji.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
int size=table.getRowCount();
|
if(size>10 || size<2) {
|
ShowMessage.zidingyi("µ±Ç°»ùÕ¾ÊýÁ¿²»Ö§³Ö¿ìËÙÅäÖÃģʽ£¡");
|
return;
|
}
|
|
String[] anchor=new String[size];
|
|
for(int i=0;i<size;i++) {
|
anchor[i]=(String) table.getValueAt(i, 0);
|
}
|
|
for(int i=0;i<size;i++) {
|
Vector<String> anchorids=new Vector<String>();
|
|
for(int j=0;j<size;j++) {
|
if(i !=j) {
|
anchorids.add(anchor[j]);
|
}
|
}
|
|
for(int k=0;k<anchorids.size();k++) {
|
table.setValueAt(anchorids.get(k), i,k+1);
|
}
|
|
}
|
|
ShowMessage.zidingyi("¿ìËÙÅäÖÃÁÙ½üÍê±Ï£¡");
|
|
}
|
});
|
}
|
return but_siji;
|
}
|
|
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(Anchor_nerby_dell.get_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¼¯ºÏ
|
String sql="select * from tb_anchor_nearby where anchorid='"+serch+"'";
|
list=DatabaseManagement.get_moudata_indatabase(sql);
|
getRowData(list);
|
}
|
}else {
|
ShowMessage.zidingyi("ÊÕÈëÐèÒªËÑË÷»ùÕ¾ID");
|
}
|
}
|
});
|
|
}
|
return but_serch;
|
}
|
|
public JTextField getJf_serch() {
|
if(jf_serch==null) {
|
jf_serch=new JTextField(6);
|
}
|
return jf_serch;
|
}
|
|
|
|
|
|
|
}
|