mbien commented on code in PR #8189:
URL: https://github.com/apache/netbeans/pull/8189#discussion_r2462795164
##########
ide/db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.java:
##########
@@ -618,6 +654,48 @@ private void
bConnectionPropertiesActionPerformed(java.awt.event.ActionEvent evt
}
}//GEN-LAST:event_bConnectionPropertiesActionPerformed
+ private void fileBrowseButtonActionPerformed(java.awt.event.ActionEvent evt)
{//GEN-FIRST:event_fileBrowseButtonActionPerformed
+ FileChooserBuilder fileChooserBuilder = new
FileChooserBuilder(NewConnectionPanel.class);
+ fileChooserBuilder.setTitle(NbBundle.getMessage(AddDriverDialog.class,
"NewConnectionFile_Chooser_Title")); //NOI18N
+ fileChooserBuilder.setFilesOnly(true);
+ File existingFile = new File(fileField.getText());
+ if (existingFile.exists() && existingFile.isDirectory()) {
+ fileChooserBuilder.setDefaultWorkingDirectory(existingFile);
+ } else {
+ File parentFile = existingFile.getParentFile();
+ if (parentFile != null && parentFile.exists()) {
+
fileChooserBuilder.setDefaultWorkingDirectory(existingFile.getParentFile());
+ }
+ }
+ File file = fileChooserBuilder.showOpenDialog();
+ if (file != null) {
+ JdbcUrl url = getSelectedJdbcUrl();
+ JdbcUrl.DatabaseFileValidator validator = (url == null) ? null :
url.getDatabaseFileValidator();
+ String validationErrorMessage = null;
+ if (validator != null) {
+ try {
+ validationErrorMessage =
validator.getValidationErrorMessage(file);
+ } catch (IOException e) {
+ LOGGER.log(Level.INFO, "Problem while attempting to
validate database file", e);
+ }
+ }
+ if (validationErrorMessage != null) {
+ String validationErrorMessageFinal = validationErrorMessage;
+ /* Use invokeLater to give the file browser dialog time to
disappear before the new
+ dialog is shown. Otherwise DialogDisplayer can make it appear
behind the
+ New Connection dialog. */
+ SwingUtilities.invokeLater(() -> {
+ NotifyDescriptor msgDesc =
+ new
NotifyDescriptor.Message(validationErrorMessageFinal,
JOptionPane.WARNING_MESSAGE);
+ DialogDisplayer.getDefault().notify(msgDesc);
+ });
Review Comment:
good that you keeping an eye on that since we had the same parent-dispose
race condition before https://github.com/apache/netbeans/pull/6772
I was wondering back then if `invokeLater()` would be sufficient to resolve
it but it seems to be the case. The issue didn't manifest again so far.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists