Skip to content

Add right-click copy with column headers to result tables - #1

Merged
d3y419 merged 2 commits into
masterfrom
copy-with-header
Aug 1, 2026
Merged

Add right-click copy with column headers to result tables#1
d3y419 merged 2 commits into
masterfrom
copy-with-header

Conversation

@jiheunha

Copy link
Copy Markdown
Member

Adds a right-click context menu to query result tables with two entries:

  • Copy (with header): copies the whole table
  • Copy selection (with header): copies the selected cells

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.

@jiheunha
jiheunha requested a review from d3y419 July 29, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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]", " "));
@d3y419

d3y419 commented Aug 1, 2026

Copy link
Copy Markdown

looks good to me.

@d3y419
d3y419 merged commit f5189e3 into master Aug 1, 2026
1 check passed
@d3y419
d3y419 deleted the copy-with-header branch August 1, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants