OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 142 Rev 151
Line 22... Line 22...
22
 
22
 
23
import java.beans.PropertyChangeEvent;
23
import java.beans.PropertyChangeEvent;
24
import java.beans.PropertyChangeListener;
24
import java.beans.PropertyChangeListener;
25
import java.sql.SQLException;
25
import java.sql.SQLException;
26
import java.util.ArrayList;
26
import java.util.ArrayList;
-
 
27
import java.util.Comparator;
27
import java.util.List;
28
import java.util.List;
28
import java.util.concurrent.Future;
29
import java.util.concurrent.Future;
29
 
30
 
30
// use SQLRowValues to allow graph
31
// use SQLRowValues to allow graph
31
public abstract class SQLTableModelLinesSource {
32
public abstract class SQLTableModelLinesSource {
32
 
33
 
33
    private final ITableModel model;
34
    private final ITableModel model;
-
 
35
    private final PropertyChangeListener reqListener;
34
    private final List<PropertyChangeListener> listeners;
36
    private final List<PropertyChangeListener> listeners;
35
    private IPredicate<SQLRowValues> filter;
37
    private IPredicate<SQLRowValues> filter;
36
 
38
 
37
    {
39
    {
38
        this.listeners = new ArrayList<PropertyChangeListener>();
40
        this.listeners = new ArrayList<PropertyChangeListener>();
39
        this.filter = null;
41
        this.filter = null;
40
    }
42
    }
41
 
43
 
42
    protected SQLTableModelLinesSource(final ITableModel model) {
44
    protected SQLTableModelLinesSource(final ITableModel model) {
43
        this.model = model;
45
        this.model = model;
-
 
46
        this.reqListener = new PropertyChangeListener() {
-
 
47
            @Override
-
 
48
            public void propertyChange(PropertyChangeEvent evt) {
-
 
49
                fireChanged(evt);
-
 
50
            }
-
 
51
        };
-
 
52
    }
-
 
53
 
-
 
54
    void live() {
-
 
55
        this.getParent().getReq().addWhereListener(this.reqListener);
44
    }
56
    }
45
 
57
 
46
    void die() {
58
    void die() {
-
 
59
        this.getParent().getReq().rmWhereListener(this.reqListener);
47
    }
60
    }
48
 
61
 
49
    public final ITableModel getModel() {
62
    public final ITableModel getModel() {
50
        return this.model;
63
        return this.model;
51
    }
64
    }
Line 65... Line 78...
65
     * @return if not {@link Value#hasValue()} the event should be ignored, otherwise the new value
78
     * @return if not {@link Value#hasValue()} the event should be ignored, otherwise the new value
66
     *         for the passed ID, <code>null</code> if it is not part of this.
79
     *         for the passed ID, <code>null</code> if it is not part of this.
67
     */
80
     */
68
    public abstract Value<ListSQLLine> get(final int id);
81
    public abstract Value<ListSQLLine> get(final int id);
69
 
82
 
-
 
83
    /**
-
 
84
     * Implementations should only use state of the parameters, so that this method can be
-
 
85
     * thread-safe (it is called both by the {@link UpdateQueue} and by the EDT in
-
 
86
     * {@link ITableModel}). This implementation order lines like the source {@link ListSQLRequest
-
 
87
     * request}.
-
 
88
     * 
-
 
89
     * @param l1 the first line.
-
 
90
     * @param l2 the second line.
-
 
91
     * @return a negative integer, zero, or a positive integer as this object is less than, equal
-
 
92
     *         to, or greater than the specified object.
-
 
93
     * @see Comparator#compare(Object, Object)
-
 
94
     */
70
    public abstract int compare(ListSQLLine l1, ListSQLLine l2);
95
    public int compare(ListSQLLine l1, ListSQLLine l2) {
-
 
96
        return ListSQLLine.compareLikeRequest(l1, l2);
-
 
97
    }
-
 
98
 
-
 
99
    public boolean isCellEditable(ListSQLLine line, int colIndex, SQLTableModelColumn col) {
-
 
100
        return true;
-
 
101
    }
71
 
102
 
72
    public abstract Future<?> moveBy(final List<? extends SQLRowAccessor> rows, final int inc);
103
    public abstract Future<?> moveBy(final List<? extends SQLRowAccessor> rows, final int inc);
73
 
104
 
74
    // take IDs :
105
    // take IDs :
75
    // 1. no need to protect rows from modifications, just copy IDs
106
    // 1. no need to protect rows from modifications, just copy IDs