OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 94 Rev 174
Line 18... Line 18...
18
import org.openconcerto.sql.model.SQLRowValues;
18
import org.openconcerto.sql.model.SQLRowValues;
19
import org.openconcerto.sql.model.SQLTable.ListenerAndConfig;
19
import org.openconcerto.sql.model.SQLTable.ListenerAndConfig;
20
import org.openconcerto.sql.model.SQLTableEvent;
20
import org.openconcerto.sql.model.SQLTableEvent;
21
import org.openconcerto.sql.model.SQLTableEvent.Mode;
21
import org.openconcerto.sql.model.SQLTableEvent.Mode;
22
import org.openconcerto.sql.model.SQLTableModifiedListener;
22
import org.openconcerto.sql.model.SQLTableModifiedListener;
-
 
23
import org.openconcerto.sql.request.ComboSQLRequest;
23
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
24
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
24
 
25
 
25
import java.awt.Component;
26
import java.awt.Component;
26
import java.util.HashMap;
27
import java.util.HashMap;
27
import java.util.List;
28
import java.util.List;
Line 35... Line 36...
35
 
36
 
36
    private String lastStringValue;
37
    private String lastStringValue;
37
    private Object toSelect;
38
    private Object toSelect;
38
    private boolean isLoading = false;
39
    private boolean isLoading = false;
39
    private final SQLElement el;
40
    private final SQLElement el;
-
 
41
    private final List<String> fields;
40
    private JTable t;
42
    private JTable t;
41
    static private final Map<SQLElement, Map<Integer, IComboSelectionItem>> cacheMap = new HashMap<SQLElement, Map<Integer, IComboSelectionItem>>();
43
    static private final Map<SQLElement, Map<Integer, IComboSelectionItem>> cacheMap = new HashMap<SQLElement, Map<Integer, IComboSelectionItem>>();
42
 
44
 
43
    public KeyTableCellRenderer(final SQLElement el) {
45
    public KeyTableCellRenderer(final SQLElement el) {
-
 
46
        this(el, null);
-
 
47
    }
-
 
48
 
-
 
49
    public KeyTableCellRenderer(final SQLElement el, final List<String> fields) {
44
        super();
50
        super();
45
        this.el = el;
51
        this.el = el;
46
 
-
 
-
 
52
        this.fields = fields;
47
        if (cacheMap.get(this.el) == null) {
53
        if (cacheMap.get(this.el) == null) {
48
            loadCacheAsynchronous();
54
            loadCacheAsynchronous();
49
        }
55
        }
50
    }
56
    }
51
 
57
 
Line 105... Line 111...
105
    private void loadCacheAsynchronous() {
111
    private void loadCacheAsynchronous() {
106
        this.isLoading = true;
112
        this.isLoading = true;
107
        Configuration.getInstance().getNonInteractiveSQLExecutor().execute(new Runnable() {
113
        Configuration.getInstance().getNonInteractiveSQLExecutor().execute(new Runnable() {
108
            public void run() {
114
            public void run() {
109
 
115
 
-
 
116
                final ComboSQLRequest comboRequest = KeyTableCellRenderer.this.fields == null || KeyTableCellRenderer.this.fields.isEmpty() ? KeyTableCellRenderer.this.el.getComboRequest()
-
 
117
                        : KeyTableCellRenderer.this.el.createComboRequest(KeyTableCellRenderer.this.fields, null);
110
                List<IComboSelectionItem> items = KeyTableCellRenderer.this.el.getComboRequest().getComboItems();
118
                List<IComboSelectionItem> items = comboRequest.getComboItems();
111
                final Map<Integer, IComboSelectionItem> m = new HashMap<Integer, IComboSelectionItem>();
119
                final Map<Integer, IComboSelectionItem> m = new HashMap<Integer, IComboSelectionItem>();
112
                for (IComboSelectionItem comboSelectionItem : items) {
120
                for (IComboSelectionItem comboSelectionItem : items) {
113
                    m.put(comboSelectionItem.getId(), comboSelectionItem);
121
                    m.put(comboSelectionItem.getId(), comboSelectionItem);
114
                }
122
                }
115
                cacheMap.put(KeyTableCellRenderer.this.el, m);
123
                cacheMap.put(KeyTableCellRenderer.this.el, m);