OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 144 Rev 149
Line 333... Line 333...
333
        // and they only are modified by the EDT, our executing thread too
333
        // and they only are modified by the EDT, our executing thread too
334
        boolean res = true;
334
        boolean res = true;
335
        if (!this.completing) {
335
        if (!this.completing) {
336
            this.completing = true;
336
            this.completing = true;
337
            // ne completer que si le texte fait plus de 2 char et n'est pas que des chiffres
337
            // ne completer que si le texte fait plus de 2 char et n'est pas que des chiffres
338
            if (originalText.length() > 2 && !DIGIT_PATTERN.matcher(originalText).matches()) {
338
            if (canComplete(originalText)) {
339
                String completion = this.getCompletion(originalText);
339
                String completion = this.getCompletion(originalText);
340
                if (completion != null && !originalText.trim().equalsIgnoreCase(completion.trim())) {
340
                if (completion != null && !originalText.trim().equalsIgnoreCase(completion.trim())) {
341
                    fb.replace(0, fb.getDocument().getLength(), completion, null);
341
                    fb.replace(0, fb.getDocument().getLength(), completion, null);
342
                    // we handled the modification
342
                    // we handled the modification
343
                    res = false;
343
                    res = false;
Line 349... Line 349...
349
        }
349
        }
350
        return res;
350
        return res;
351
    }
351
    }
352
 
352
 
353
    /**
353
    /**
-
 
354
     * hook to activate or not complete for a given text
-
 
355
     * 
-
 
356
     * @return true if completion must occur
-
 
357
     */
-
 
358
    public boolean canComplete(final String originalText) {
-
 
359
        return originalText.length() > 2 && !DIGIT_PATTERN.matcher(originalText).matches();
-
 
360
    }
-
 
361
 
-
 
362
    /**
354
     * Recherche si on peut completer la string avec les items de completion
363
     * Recherche si on peut completer la string avec les items de completion
355
     * 
364
     * 
356
     * @param string the start
365
     * @param string the start
357
     * @return <code>null</code> si pas trouve, sinon le mot complet
366
     * @return <code>null</code> si pas trouve, sinon le mot complet
358
     */
367
     */
Line 567... Line 576...
567
            return this.getCurrentValue();
576
            return this.getCurrentValue();
568
    }
577
    }
569
 
578
 
570
    public String getCurrentValue() {
579
    public String getCurrentValue() {
571
        // this.getSelectedItem() renvoie vide quand on tape du texte sans sélection
580
        // this.getSelectedItem() renvoie vide quand on tape du texte sans sélection
-
 
581
        final Object res;
-
 
582
        if (this.isLocked()) {
-
 
583
            res = this.getSelectedItem();
-
 
584
        } else {
572
        return (String) (this.isLocked() ? this.getSelectedItem() : this.getEditor().getItem());
585
            final ComboBoxEditor editor = this.getEditor();
-
 
586
            // as documented in the constructor, the editor can sometimes be null
-
 
587
            res = editor == null ? null : editor.getItem();
-
 
588
        }
-
 
589
        return (String) res;
573
    }
590
    }
574
 
591
 
575
    public JComponent getComp() {
592
    public JComponent getComp() {
576
        return this;
593
        return this;
577
    }
594
    }