Skip to content

Issue #8212 : Add a Database perspective as an alternative to the SQL editor dialog - #8214

Draft
mattcasters wants to merge 4 commits into
apache:mainfrom
mattcasters:issue-8212
Draft

Issue #8212 : Add a Database perspective as an alternative to the SQL editor dialog#8214
mattcasters wants to merge 4 commits into
apache:mainfrom
mattcasters:issue-8212

Conversation

@mattcasters

Copy link
Copy Markdown
Contributor

Addresses #8212.

First cut of a Database perspective as a non-modal alternative to the SQL editor dialog. This is not a DBeaver clone: no visual query builder, autocomplete, ER diagram, or grid editing. The existing modal SqlEditor and DatabaseExplorerDialog stay in place.

What this adds

  • Perspective 170-HopDatabasePerspective (Ctrl+Shift+D / Cmd+Shift+D).
  • Left: project DatabaseMeta tree with a filter field. Toolbar: connect, disconnect, refresh, open SQL editor, generate DDL, preview 1000 rows, show table info. Connect loads metadata in the background (JDBC is not kept open).
  • Right: SQL editor tabs and table-info tabs. SQL results appear in a sash under the editor (query tabs + messages, close to hide). Long-running work is listed in an operations panel at the bottom with Kill (Statement.cancel).
  • Run lives on the SQL content-editor toolbar. Ctrl+Enter / Cmd+Enter executes the selection, or the blank-line-delimited block around the caret (then split with the dialect script parser). Queries are capped at 1000 rows; timeout follows HOP_QUERY_PREVIEW_TIMEOUT.
  • Open/save .sql files through the normal File menu. Explorer SQL buffers can be sent here via the database icon on the content-editor toolbar (pick a connection).
  • DatabaseWorkbench is a Composite behind IDatabaseWorkbenchHost so the same UI can later float as a dialog or dock, the same way Search does.

Ctrl+Enter (GTK)

SWT StyledText treats Ctrl+Return as TRAVERSE_RETURN (shell default button) and always inserts a newline for CR even with Control held. The SQL tab listens for Traverse + KeyDown, cancels that traversal, and rejects the newline on VerifyKey / SWT.Verify. Hop Web uses Monaco CtrlCmd+EnterexecuteRequested.

Out of scope (follow-ups)

  • Replacing SqlEditor call sites
  • Autocomplete, ER, grid edit
  • Hosting the workbench as a floating dialog or bottom dock
  • Opening this perspective from DatabaseExplorerDialog

Tests / docs

  • SqlExecuteRangeTest, content-editor Run toolbar registration, disabled-perspective inertness
  • User manual: perspective-database.adoc, perspectives list, getting-started Hop Gui

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Run mvn clean install apache-rat:check to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If you have a group of commits related to the same change, please squash your commits into one and force push your branch using git rebase -i.
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

…he SQL editor dialog

First cut of a non-modal Database perspective: project RDBMS tree, SQL editor
tabs with Ctrl+Enter, results sash, table info, and a killable operations panel.
The workbench is a Composite so it can later float as a dialog or dock.

Fixes apache#8212.
…tor limits

The workbench can open as a non-modal window or a bottom-dock tab, like
Search. getRows now calls setQueryLimit so the 1000-row cap reaches the
driver; execStatement applies the statement timeout; cancel watchers are
skipped on Hop Web and started as named daemon threads.

Fixes apache#8224, apache#8228, apache#8229.
@mattcasters

Copy link
Copy Markdown
Contributor Author

Follow-up pushed:

Float / dock (same DatabaseWorkbench Composite as the perspective, Search-style):

  • Float on the connection toolbar, or Tools → Database window, opens a non-modal window
  • Dock opens a tab in the bottom dock
  • One workbench instance per placement

SQL editor issues from the recent “AI Generated” reports:

SQL on table output, lookups, updates and bulk loaders now opens the
floating Database workbench on that connection. The schema/table tree
loads in the background while the suggested SQL can be edited and run.
Database explorer Open SQL, Generate DDL and Truncate use the same path.
@mattcasters

Copy link
Copy Markdown
Contributor Author

SQL from transform dialogs now opens the floating Database window instead of the modal SqlEditor.

DatabaseWorkbenchDialog.openSql(connection, sql):

  1. Opens or focuses the floating workbench
  2. Selects that connection and starts a background schema/table refresh
  3. Puts the generated SQL in an editor tab immediately so you can edit and run (Ctrl+Enter) while the tree loads

Call sites: Table Output, Insert/Update, Update, Synchronize After Merge, SQL File Output, Dimension Lookup, Combination Lookup, and the bulk loaders (MySQL, PostgreSQL, Oracle, SQL Server native, Vertica, MonetDB, CrateDB, Snowflake, Redshift). Database explorer Open SQL / Generate DDL / Truncate uses the same path.

The modal SqlEditor class is still in the tree but no longer opened from these dialogs.

…ive, window and dock

SQL tabs (connection, file or unsaved buffer) are stored per project in the
audit trail, the same way terminal tabs are. Closing the floating window or
dock, switching project, or restarting Hop Gui restores them. Query results
are not persisted.
@mattcasters

Copy link
Copy Markdown
Contributor Author

SQL editor tabs are now remembered across the perspective, floating window and bottom dock, and across Hop Gui restarts (per project, same audit store as terminal tabs).

Stored: connection, filename or unsaved buffer (capped), dirty flag, selected tab.
Not stored: query results, table-info tabs, live JDBC.

Opening Float/Dock flushes the current workbench first so the other placement restores the latest tabs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant