Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Add Database Connection dialog for SQLite and DuckDB #8189

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eirikbakke
Copy link
Contributor

@eirikbakke eirikbakke commented Jan 24, 2025

The "Add Database Connection" dialog supports various kinds of database-specific connection fields (host, port, database name etc.) These are automatically substituted into the JDBC driver specific JDBC URL.

This PR adds support for a "File" field, which will be shown if the user is using the JDBC drivers for SQLite or DuckDB. There is a "Browse" button that can be used to pick the file from a file browser. Furthermore, the username and password fields are hidden for these drivers, which are known not to require this kind of authentication.

image

For SQLite and DuckDB, there's a warning if the selected file is not of the right kind. (Useful because SQLite files do not have any kind of standardized file extension.)

image

For comparison, this is what the Add Database Connection dialog looked like before, for SQLite:

image

(There are some proprietary JDBC drivers for SQLite that do allow a password to be used for encryption, but in this rare case the user could use a connection property to pass this information instead.)

@eirikbakke eirikbakke added UI User Interface FormDesigner GUI builder, also known as Matisse ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Jan 24, 2025
@eirikbakke
Copy link
Contributor Author

eirikbakke commented Jan 24, 2025

The NewConnectionPanel uses the NetBeans Matisse Form Builder, by the way. The way it works is that the form contains every possible field available, and then individual fields are shown or hidden depending on what fields are used in the JDBC URL template string.

Here is the full dialog as it appears in the form builder:

image

To insert the "File" field I ended up hand-editing the ".form" file, reloading it in the form builder, making some adjustments, and then saving it again together with freshly generated initComponents() code. So the final "form" file committed here is generated by Matisse, not hand-edited by me.

…SQLite and DuckDB URL templates.

Also validate the selected file in the SQLite and DuckDB cases.
@eirikbakke eirikbakke added this to the NB26 milestone Jan 24, 2025
@eirikbakke
Copy link
Contributor Author

I added another commit which recognizes Snowflake JDBC URLs, just since we're already making enhancements to this piece of code.

Comment on lines +18 to +29
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=100
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-limit-width=100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not intended to commit module specific indentation settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's intentional, because it influences how Matisse form builder code is generated. The settings stored here ensure the code is generated with the same settings as earlier, simplifying diffs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see some settings that seem specific to my own IDE though. But removing any of them seemed to make them ineffective. I can just remove the file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. I haven't considered global ide settings messing with codegen - but it makes sense of course.

we should still try to avoid adding those module specific settings since NB has ~800 projects. Would be good to have a central place for this and let everything inherit it - but I don't think this is possible, otherwise we likely would have a central formatter file somewhere already. (I did see hint settings though)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) FormDesigner GUI builder, also known as Matisse UI User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants