Skip to content

Conversation

@aarnapant-sap
Copy link
Collaborator

Changes Made

Previous flow:

when clicked on copyAction whole row was copied and copied text have to be truncated

New flow:

  • On click user is given option to either copy row or cell (inspired by dataPreview)
  • Supports keyboard ctrl/cmd+c for copy
  • Added PdeTests

Copy link
Collaborator

@shubhamWaghmare-sap shubhamWaghmare-sap left a comment

Choose a reason for hiding this comment

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

Minor refactoring changes.

manager.add(AbapGitView.this.actionCopy);

// Create the sub-menu for Copy
MenuManager copySubMenu = new MenuManager("Copy");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Externalize the string.

Comment on lines 528 to 541
this.actionCopyCell = new Action("Copy Cell") {
@Override
public void run() {
copyCell();
}
};

this.actionCopyRow = new Action("Copy Row") {
@Override
public void run() {
copyRow();
}
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

Externalize both strings.

Comment on lines 765 to 776
final Clipboard clipboard = new Clipboard(this.viewer.getControl().getDisplay());
String textToCopy = null;

TableItem[] selection = this.viewer.getTable().getSelection();
if (selection.length > 0 && this.focusedColumnIndex != -1) {
textToCopy = selection[0].getText(this.focusedColumnIndex);
}

if (textToCopy != null && !textToCopy.isEmpty()) {
clipboard.setContents(new String[] { textToCopy }, new TextTransfer[] { TextTransfer.getInstance() });
}
clipboard.dispose();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copying to clipboard is common in both the copyCell & copyRow methods. Extract the logic as a separate method and use it in the copy methods.

private void copyToClipboard(String textToCopy) {
    if (textToCopy == null || textToCopy.isEmpty()) return;
    
    final Clipboard clipboard = new Clipboard(this.viewer.getControl().getDisplay());
     clipboard.setContents(new String[] { textToCopy }, 
                            new TextTransfer[] { TextTransfer.getInstance() });
     clipboard.dispose();
    }
}

return; // Found the column
}
}
AbapGitView.this.focusedColumnIndex = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Low prio: Can extract -1 as a new constant. Say NO_COLUMN_SELECTED.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can extract the complete logic to find the selected column into a separate method. Easier to understand what's happening via the method name.

table.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
Point pt = new Point(e.x, e.y);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use full variable name wherever possible. i.e. use point instead of pt.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants