[Bug]: Cannot select or copy rows from a read-only result grid
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 476
- Avg merge
- 18h 32m
- Merged PRs (30d)
- 216
Description
### Apache Hop version?
2,20
### Java version?
21
### Operating system
Windows
### What happened?
## The problem
I run a query and want to work with the result: read the values, select a few rows and copy them
into a spreadsheet, or pick up one order number to use elsewhere. The result grid is read-only, which
is right — but read-only also blocks the ordinary things a user does with a result:
- clicking a cell opens an inline editor over it instead of selecting the row,
- that editor takes the right-click, so the grid's own context menu is out of reach,
- the selection and copy actions in that menu are disabled,
- and there is no way to copy a single cell value.
## What happens today
On `main` (`ad8c53380d`): Database perspective → connect → SQL tab → `SELECT * FROM ` → Run.
| | Do | Expected | Actual |
|---|---|---|---|
| 1 | Left-click a cell | the row is selected | a text editor is placed over the cell, covering the value |
| 2 | Right-click in that cell | the grid's context menu | the platform's text menu (Undo / Cut / Paste). The grid's own menu cannot be reached |
| 3 | Right-click a row, outside the editor | usable actions | *Select all rows*, *Clear selection*, *Filtered selection* and *Copy selected lines to clipboard* are all disabled |
| 4 | Copy a single cell value | some way to do it | there is none. The nearest workaround is selecting text inside the editor from step 1 |
The same happens in every read-only grid, including the SQL results and the execution views.
## Expected behavior and proposed change
A read-only result grid should prevent changes to the data while still allowing users to inspect,
select and copy it.
- Clicking a cell should select its row without opening an inline editor.
- Right-clicking should open the grid's context menu.
- Selection actions and copying selected rows should remain available.
- A **Copy cell value** action should copy the complete underlying value, even when the displayed
text is shortened.
Long values must remain accessible for viewing and copying after the inline editor is removed — the
pop-out value viewer stays reachable from the keyboard, and *Copy cell value* takes the stored value,
not the shortened display string.
## Cause
All of it is in `TableView`:
- `editSelected` calls `edit(...)` on a left click and only checks `table.isEnabled()`; nothing
consults `readonly`. On a read-only grid the editor has nothing to edit.
- Four menu items are switched off where they are created, with `setEnabled(!readonly)`:
*Select all rows*, *Clear selection*, *Filtered selection* and *Copy selected lines to clipboard*.
None of them changes the table — `setFilter()` ends in `table.setSelection(...)`, `clipSelected()`
reads.
- `clipSelected()` copies whole rows with a header line; there is no single-cell copy.
The result grid built by `DatabaseResultsPanel` shows all three at once: it is read-only, and it
uses `setShortenDisplayedValues(true)`, so long values are displayed shortened. That is why a
single-cell copy has to take the stored value rather than the display string.
## Scope of the fix
One class — `TableView.java` — plus one message key:
1. `editSelected`: when `readonly`, select the row and return.
2. Drop the `!readonly` gate on the four menu items.
3. Add *Copy cell value* beside *Copy selected lines to clipboard*, using `getCellValue` for the
stored value.
Happy to open the PR if the approach looks right. The one point worth an opinion is whether to
suppress the inline editor on read-only grids, or to keep it and give the grid's menu precedence over
it.
### Issue Priority
Priority: 3
### Issue Component
Component: Hop Gui
Contributor guide
Research direction
Start in TableView.java and reproduce the issue through Database perspective → SQL tab → run a query with a long text value. Inspect the read-only handling in editSelected, the four context-menu actions, and clipSelected, along with the message key. Done means read-only grids allow row selection, context-menu actions, and complete single-cell copying while preserving access to long values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100