Browse Source

REPORT-50096 处理下切换数据连接场景

bugfix/10.0
hades 3 years ago
parent
commit
9dcb81b4a8
  1. 9
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

9
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -100,6 +100,7 @@ public class JDBCDefPane extends JPanel {
private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor(); private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
private JDBCDatabaseConnection jdbcDatabase; private JDBCDatabaseConnection jdbcDatabase;
private boolean needRefresh = true;
public JDBCDefPane() { public JDBCDefPane() {
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
@ -201,11 +202,11 @@ public class JDBCDefPane extends JPanel {
} }
public void populate(JDBCDatabaseConnection jdbcDatabase) { public void populate(JDBCDatabaseConnection jdbcDatabase) {
needRefresh = false;
if (jdbcDatabase == null) { if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection(); jdbcDatabase = new JDBCDatabaseConnection();
} }
this.jdbcDatabase = jdbcDatabase; this.jdbcDatabase = jdbcDatabase;
this.dbtypeComboBox.removeActionListener(dbtypeActionListener);
if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver") if (ComparatorUtils.equals(jdbcDatabase.getDriver(), "sun.jdbc.odbc.JdbcOdbcDriver")
&& jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) { && jdbcDatabase.getURL().startsWith("jdbc:odbc:Driver={Microsoft")) {
this.dbtypeComboBox.setSelectedItem("Access"); this.dbtypeComboBox.setSelectedItem("Access");
@ -230,7 +231,6 @@ public class JDBCDefPane extends JPanel {
this.dbtypeComboBox.setSelectedItem(OTHER_DB); this.dbtypeComboBox.setSelectedItem(OTHER_DB);
} }
} }
this.dbtypeComboBox.addActionListener(dbtypeActionListener);
this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver()); this.driverComboBox.setSelectedItem(jdbcDatabase.getDriver());
this.urlTextField.setText(jdbcDatabase.getURL()); this.urlTextField.setText(jdbcDatabase.getURL());
this.userNameTextField.setText(jdbcDatabase.getUser()); this.userNameTextField.setText(jdbcDatabase.getUser());
@ -254,6 +254,7 @@ public class JDBCDefPane extends JPanel {
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE); this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun()); this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis()); this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
needRefresh = true;
} }
public JDBCDatabaseConnection update() { public JDBCDatabaseConnection update() {
@ -306,7 +307,9 @@ public class JDBCDefPane extends JPanel {
} }
} }
// 更改数据库类型后 数据库名称置空和之前逻辑保持一致 // 更改数据库类型后 数据库名称置空和之前逻辑保持一致
jdbcDatabase.setDatabase(StringUtils.EMPTY); if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
} }
}; };

Loading…
Cancel
Save