📄 frameofdict.java~33~
字号:
//----------------------------
menuItem = new JMenuItem("退出",KeyEvent.VK_T);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
menu.add(menuItem);
//----------------------------
menuBar.add(menu);
//----------------------------------------------------------------------
menu = new JMenu("查询");
//----------------------------
menuItem = new JMenuItem("查找表",KeyEvent.VK_T);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame subframe = new JFrame();
JOptionPane optionPane = new JOptionPane();
if(fileName == " ") {
JOptionPane.showMessageDialog(subframe, "不存在可查询的表!");
return;
}
String tableName = (String)optionPane.showInputDialog(subframe,
"输入所要查找表的名字:",
"查找表",
JOptionPane.QUESTION_MESSAGE);
if(dict.findTheTable(fileName,tableName)) {
int index = rowBeSelected01;
int count = table01.getRowCount();
int selectRow = 0;
for(int i = 1;i <= count;i ++) {//从当前选中的字段的下一个字段开始寻找,遍历table01全表一遍
selectRow = index + i;
if(selectRow >= count)
selectRow = selectRow - count;
String valueOfTable01 = table01.getValueAt(selectRow,0).toString();
if(tableName.compareTo(valueOfTable01) == 0)
break;
}
table01.setRowSelectionInterval(selectRow,selectRow);
rowBeSelected01 = selectRow;
}else {
JOptionPane.showMessageDialog(subframe, "没有找到所要查找的表!");
}
}
});
menu.add(menuItem);
//----------------------------
menuItem = new JMenuItem("全局查找字段",KeyEvent.VK_T);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame subframe = new JFrame();
JOptionPane optionPane = new JOptionPane();
if(fileName == " ") {
JOptionPane.showMessageDialog(subframe, "不存在可查询的表!");
return;
}
String columnName = (String) optionPane.showInputDialog(subframe,
"对全局的查找将不能对同一表内的重复字段进行查找! \n"+
" 输入所要查找字段的名字:",
"查找字段",
JOptionPane.QUESTION_MESSAGE);
int index = rowBeSelected01;
int selectRow01 = 0;
int selectRow02 = 0;
Vector allTables = new Vector();
allTables = dict.collectTable(fileName);
Vector tableValue = new Vector();
tableValue = (Vector)allTables.elementAt(rowBeSelected01);
String tableName = tableValue.elementAt(0).toString();
boolean flag = false;
int countTables = allTables.size();
int c = 1;
while(c <= countTables){//从当前选中的字段的下一个字段开始寻找,遍历table01全表一遍
selectRow01 = index + c;
if(selectRow01 >= countTables)
selectRow01 = selectRow01 - countTables;
tableValue = (Vector)allTables.elementAt(selectRow01);
tableName = tableValue.elementAt(0).toString();
if (dict.findTheColumn(fileName,tableName,columnName)) {
flag = true;
int index01 = rowBeSelected01;
int count01 = table01.getRowCount();
for (int i = 1; i <= count01; i++) {//从当前选中的字段的下一个字段开始寻找,遍历table01全表一遍
selectRow01 = index01 + i;
if(selectRow01 >= count01)
selectRow01 = selectRow01 - count01;
String valueOfTable01 = table01.getValueAt(selectRow01, 0).toString();
if (tableName.compareTo(valueOfTable01) == 0)
break;
}
table01.setRowSelectionInterval(selectRow01, selectRow01);
rowBeSelected01 = selectRow01;
int index02 = rowBeSelected02;
int count02 = table02.getRowCount();
if(rowBeSelected02 >= count02) {//防止在table02中选中不存在的多余字段
rowBeSelected02 = 0;
index02 = rowBeSelected02;
}
for (int i = 1; i <= count02; i++) {//从当前选中的字段的下一个字段开始寻找,遍历table02全表一遍
selectRow02 = index02 + i;
if(selectRow02 >= count02)
selectRow02 = selectRow02 - count02;
String valueOfTable02 = table02.getValueAt(selectRow02, 0).toString();
if (columnName.compareTo(valueOfTable02) == 0)
break;
}
table02.setRowSelectionInterval(selectRow02, selectRow02);
rowBeSelected02 = selectRow02;
}
if(flag == true)//如果已经寻找到所求字段,则推出此次查找
break;
c ++;
}
if(flag == false) {
JOptionPane.showMessageDialog(subframe, "没有找到所要查找的字段!");
}
}
});
menu.add(menuItem);
//----------------------------
menuItem = new JMenuItem("当前表查找字段",KeyEvent.VK_T);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame subframe = new JFrame();
JOptionPane optionPane = new JOptionPane();
if(fileName == " ") {
JOptionPane.showMessageDialog(subframe, "不存在可查询的表!");
return;
}
String columnName = (String) optionPane.showInputDialog(subframe,
"只对当前表进行检索,可查找该表内的重复字段。 \n"+
" 输入所要查找字段的名字:",
"查找字段",
JOptionPane.QUESTION_MESSAGE);
Vector allTables = new Vector();
allTables = dict.collectTable(fileName);
Vector tableValue = new Vector();
tableValue = (Vector)allTables.elementAt(rowBeSelected01);
String tableName = tableValue.elementAt(0).toString();
int selectRow02 = 0;
boolean flag = false;
if (dict.findTheColumn(fileName,tableName,columnName)) {
flag = true;
int index02 = rowBeSelected02;
int count02 = table02.getRowCount();
if(rowBeSelected02 >= count02) {//防止在table02中选中不存在的多余字段
rowBeSelected02 = 0;
index02 = rowBeSelected02;
}
for (int i = 1; i <= count02; i++) {//从当前选中的字段的下一个字段开始寻找,遍历table02全表一遍
selectRow02 = index02 + i;
if(selectRow02 >= count02)
selectRow02 = selectRow02 - count02;
String valueOfTable02 = table02.getValueAt(selectRow02, 0).toString();
if (columnName.compareTo(valueOfTable02) == 0)
break;
}
table02.setRowSelectionInterval(selectRow02, selectRow02);
rowBeSelected02 = selectRow02;
}
if(flag == false) {
JOptionPane.showMessageDialog(subframe, "没有找到所要查找的字段!");
}
}
});
menu.add(menuItem);
//----------------------------
menu.addSeparator();
//----------------------------
menuItem = new JMenuItem("查找表名注释",KeyEvent.VK_T);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame subframe = new JFrame();
JOptionPane optionPane = new JOptionPane();
if(fileName == " ") {
JOptionPane.showMessageDialog(subframe, "不存在可查询的表!");
return;
}
String commentValue = (String)optionPane.showInputDialog(subframe,
"输入所要查找表注释的名字:",
"查找表名注释",
JOptionPane.QUESTION_MESSAGE);
if(dict.findTableComment(fileName,commentValue)) {
int index = rowBeSelected01;
int count = table01.getRowCount();
int selectRow = 0;
for(int i = 1;i <= count;i ++) {//从当前选中的字段的下一个字段开始寻找,遍历table01全表一遍
selectRow = index + i;
if(selectRow >= count)
selectRow = selectRow - count;
String valueOfTable01 = table01.getValueAt(selectRow,1).toString();
if(commentValue.compareTo(valueOfTable01) == 0)
break;
}
table01.setRowSelectionInterval(selectRow,selectRow);
rowBeSelected01 = selectRow;
}else {
JOptionPane.showMessageDialog(subframe, "没有找到所要查找的表名注释!");
}
}
});
menu.add(menuItem);
//----------------------------
menuItem = new JMenuItem("全局查找字段名注释",KeyEvent.VK_T);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame subframe = new JFrame();
JOptionPane optionPane = new JOptionPane();
if(fileName == " ") {
JOptionPane.showMessageDialog(subframe, "不存在可查询的表!");
return;
}
String commentValue = (String) optionPane.showInputDialog(subframe,
"对全局的查找将不能对同一表内的重复字段进行查找! \n"+
" 输入所要查找字段注释:",
"查找字段名注释",
JOptionPane.QUESTION_MESSAGE);
int index = rowBeSelected01;
int selectRow01 = 0;
int selectRow02 = 0;
Vector allTables = new Vector();
allTables = dict.collectTable(fileName);
Vector tableValue = new Vector();
tableValue = (Vector)allTables.elementAt(rowBeSelected01);
String tableName = tableValue.elementAt(0).toString();
boolean flag = false;
int countTables = allTables.size();
int c = 1;
while(c <= countTables){//从当前选中的字段的下一个字段开始寻找,遍历table01全表一遍
selectRow01 = index + c;
if(selectRow01 >= countTables)
selectRow01 = selectRow01 - countTables;
tableValue = (Vector)allTables.elementAt(selectRow01);
tableName = tableValue.elementAt(0).toString();
if (dict.findColumnComment(fileName,tableName,commentValue)) {
flag = true;
int index01 = rowBeSelected01;
int count01 = table01.getRowCount();
for (int i = 1; i <= count01; i++) {//从当前选中的字段的下一个字段开始寻找,遍历table01全表一遍
selectRow01 = index01 + i;
if(selectRow01 >= count01)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -