Add right-click copy with column headers to result tables - #1
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a right-click context menu to query result tables to support copying data as TSV including a header row, improving spreadsheet paste workflows while keeping existing Ctrl+C behavior intact.
Changes:
- Attach a JTable context menu with “Copy (with header)” and “Copy selection (with header)” actions.
- Implement TSV export logic that prepends column headers and sanitizes cell content.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+128
to
+140
| myJTable.addMouseListener(new MouseAdapter() { | ||
| public void mousePressed(MouseEvent e) { | ||
| maybeShowPopup(e); | ||
| } | ||
| public void mouseReleased(MouseEvent e) { | ||
| maybeShowPopup(e); | ||
| } | ||
| private void maybeShowPopup(MouseEvent e) { | ||
| if(e.isPopupTrigger()) { | ||
| popupMenu.show(e.getComponent(), e.getX(), e.getY()); | ||
| } | ||
| } | ||
| }); |
Comment on lines
+122
to
+126
| copySelectionItem.addActionListener(new ActionListener() { | ||
| public void actionPerformed(ActionEvent e) { | ||
| copyWithHeader(true); | ||
| } | ||
| }); |
| for(int j = 0; j < colsToCopy.length; j++) { | ||
| Object value = myJTable.getValueAt(rowsToCopy[i], colsToCopy[j]); | ||
| if(value != null) { | ||
| stringBuffer.append(value.toString().replaceAll("[\t\r\n]", " ")); |
|
looks good to me. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a right-click context menu to query result tables with two entries:
Both copy as tab separated values with the column names as the first row, so the result pastes into Excel with the year columns intact.
The existing Ctrl+C behavior is unchanged.