northPanel.add(this.dataSourceComboBox);
JLabel tableLabel = new JLabel("表:");
tableLabel.setIcon(IconUtils.createImageIcon(ICON_CLASS_PATH + "database_table.png"));
northPanel.add(tableLabel);
this.tableComboBox = new JComboBox(new DefaultComboBoxModel());
this.tableComboBox.setPreferredSize(new Dimension(150, 29));
this.tableComboBox.addPopupMenuListener(new PopupMenuListener() {
public void popupMenuCanceled(PopupMenuEvent e) {
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
try {
Object selectedItem = dataSourceComboBox.getSelectedItem();
String datasourceName = null != selectedItem ? selectedItem.toString() : null;
Vector dataVector = metadataService.getTables(datasourceName);
tableComboBox.setModel(new DefaultComboBoxModel(dataVector));
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
}
}