OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 65 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65 Rev 156
Line 15... Line 15...
15
 
15
 
16
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
16
import org.openconcerto.sql.sqlobject.ITextWithCompletion;
17
import org.openconcerto.ui.TextAreaTableCellEditor;
17
import org.openconcerto.ui.TextAreaTableCellEditor;
18
import org.openconcerto.utils.checks.ValidState;
18
import org.openconcerto.utils.checks.ValidState;
19
 
19
 
-
 
20
import java.awt.Component;
-
 
21
 
20
import javax.swing.JOptionPane;
22
import javax.swing.JOptionPane;
21
import javax.swing.JTable;
23
import javax.swing.JTable;
22
import javax.swing.SwingUtilities;
24
import javax.swing.SwingUtilities;
23
 
25
 
24
public class TextTableCellEditorWithCompletion extends TextAreaTableCellEditor {
26
public class TextTableCellEditorWithCompletion extends TextAreaTableCellEditor {
Line 54... Line 56...
54
    @Override
56
    @Override
55
    public boolean stopCellEditing() {
57
    public boolean stopCellEditing() {
56
 
58
 
57
        this.textWithCompl.hidePopup();
59
        this.textWithCompl.hidePopup();
58
        if (!getValidState().isValid()) {
60
        if (!getValidState().isValid()) {
-
 
61
            final Component root = SwingUtilities.getRoot(TextTableCellEditorWithCompletion.this.getTextArea());
59
            JOptionPane.showMessageDialog(SwingUtilities.getRoot(this.getTextArea()), getValidState().getValidationText());
62
            final String validationText = getValidState().getValidationText();
-
 
63
            // JOptionPane dans invokeLater pour éviter une boucle avec notre listener sur le focus
-
 
64
            // de la table qui stoppe
-
 
65
            // l'édition
-
 
66
            SwingUtilities.invokeLater(new Runnable() {
-
 
67
                @Override
-
 
68
                public void run() {
-
 
69
                    JOptionPane.showMessageDialog(root, validationText);
-
 
70
                }
-
 
71
            });
60
            return false;
72
            return false;
61
        } else {
73
        } else {
62
            return super.stopCellEditing();
74
            return super.stopCellEditing();
63
        }
75
        }
64
    }
76
    }
65
    
77
 
66
 
78
    @Override
67
    public void setLimitedSize(int nbChar) {
79
    public void setLimitedSize(int nbChar) {
68
        this.textWithCompl.setLimitedSize(nbChar);
80
        this.textWithCompl.setLimitedSize(nbChar);
69
    }
81
    }
70
 
82
 
71
    public ValidState getValidState() {
83
    public ValidState getValidState() {
72
        return validStateChecker.getValidState(this.textWithCompl.getText());
84
        return validStateChecker.getValidState(this.textWithCompl.getText());
73
    }
85
    }
74
 
86
 
75
}
87
}
76
 
-
 
77
 
-