Menu

#10 SSDataGrid::DefaultEditor::stopCellEditing missing return?

SwingSet 3.0.0
closed-fixed
None
5
2020-12-10
2020-08-06
Ernie Rael
No

While browsing, I came across something suspicious. Seems like should be

return super.stopCellEditing

Maybe not a bug. Here's the context

        public boolean stopCellEditing() {
            String s = (String) super.getCellEditorValue();

            if (s.trim().equals("")) {
                if (this.constructor.getDeclaringClass() == String.class) {
                    this.value = s;
                }
                super.stopCellEditing();
            }

Discussion

  • Brian E. Pangburn

    • assigned_to: Brian E. Pangburn
    • Group: SwingSet 0.5.0-alpha --> SwingSet 3.0.0
     
  • Brian E. Pangburn

    Committed fix from Prasanth Pasala:

        @Override
        public boolean stopCellEditing() {
    
            String s = (String) super.getCellEditorValue();
    
            if (s.trim().equals("")) {
                if (this.constructor.getDeclaringClass() == String.class) {
                    this.value = s;
                }
            } else {
                try {
                    this.value = this.constructor.newInstance(new Object[] { s });
                } catch (Exception e) {
                    // DRAW A RED BORDER IF THE VALUE OBJECT CAN'T BE CREATED.
                    // PROBABLY THE DATA ENTERED IS NOT RIGHT (STRING IN NUMBER FIELD OR VICE-VERSA)
                    ((JComponent) getComponent()).setBorder(new LineBorder(Color.red));
                    return false;
                }
            }
    
            return super.stopCellEditing();
    
        }
    
     
  • Ernie Rael

    Ernie Rael - 2020-08-06

    I guess with the database being reponsible for white space handling (don't take my word for it, I'm just guessing)

    this.value = s; // may have whitespace characters
    

    is not that different from

    this.value = "";
    
     
  • Brian E. Pangburn

    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB