我有以下问题:
我正在实现一个基于 Netbeans 平台的 RCP 应用程序。我向应用程序添加了一个新的自定义辅助选项面板。
在设计面板并设置正确的方法之后(我实现了在字段更改时从控制器调用更改的方法的部分)我从选项面板(视图)修改了有效方法以对所有字段进行正确验证. 据我了解,这是由控制器调用以在保存之前验证表单。唯一的问题是,从我所看到的情况中永远不会调用此方法,因此在其中完成的任何验证都不会被激活。
有人可以告诉我我做错了什么吗?谢谢!
boolean valid() {
if (addressTextField.getText().isEmpty()) {
return false;
}
if (portTextField.getText().isEmpty()) {
return false;
}
if (userTextField.getText().isEmpty()) {
return false;
}
if (passwordPasswordField.getPassword().length == 0) {
return false;
}
if (databaseNameTextField.getText().isEmpty()) {
return false;
}
//TODO: change this back to the connection string builder after testing
String databaseURL = "jdbc:mysql://" + addressTextField.getText().trim() + ":" + portTextField.getText().trim() + "/" + databaseNameTextField.getText().trim() +
"?user=" + userTextField.getText().trim() + "&password=" + StringUtilities.charToString(passwordPasswordField.getPassword());
if(!SQLDatabaseConnectionManagerImpl.testPing(databaseURL)) {
messageLabel.setText("");
messageLabel.setForeground(Color.red);
messageLabel.setText(NbBundle.getBundle(ImportDataOptionsPanel.class).getString("ImportDataOptionsPanel.connectionErrorMessage.text"));
debug("Error on database connection with the following connection string: " + databaseURL, ImportDataOptionsPanel.IMPORTANT);
return false;
}
return true;
}