17 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.sql.view.list;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.sql.model.SQLTableEvent;
|
|
|
17 |
import org.openconcerto.sql.model.graph.Path;
|
|
|
18 |
import org.openconcerto.utils.CollectionMap;
|
|
|
19 |
|
|
|
20 |
import java.util.Collection;
|
|
|
21 |
|
|
|
22 |
final class UpdateOneRunnable extends AbstractUpdateOneRunnable {
|
|
|
23 |
private final SQLTableEvent evt;
|
|
|
24 |
|
|
|
25 |
public UpdateOneRunnable(ITableModel model, SQLTableEvent evt) {
|
73 |
ilm |
26 |
super(model, evt.getRow());
|
17 |
ilm |
27 |
this.evt = evt;
|
|
|
28 |
}
|
|
|
29 |
|
73 |
ilm |
30 |
@Override
|
17 |
ilm |
31 |
public void run() {
|
|
|
32 |
if (this.getTable() == this.getReq().getParent().getPrimaryTable()) {
|
|
|
33 |
final ListSQLLine line = this.getReq().get(this.getID());
|
73 |
ilm |
34 |
// handle deleted rows (i.e. line == null) by using this.getID(), must be done before
|
|
|
35 |
// finding lines
|
17 |
ilm |
36 |
if (line == null)
|
|
|
37 |
this.getReq().fireLineChanged(this.getID(), line, null);
|
73 |
ilm |
38 |
final CollectionMap<Path, ListSQLLine> affectedPaths = this.getAffectedPaths();
|
|
|
39 |
// the line should be in the list (since SQLTableModelLinesSource.get()
|
|
|
40 |
// returned it), so if not yet part of the list add it.
|
|
|
41 |
if (line != null && affectedPaths.getNonNull(new Path(getTable())).isEmpty())
|
|
|
42 |
line.clearCache();
|
|
|
43 |
// then, update affectedPaths (it's not because the changed table is the primary
|
|
|
44 |
// table, that it's not also referenced, e.g. CIRCUIT.ORIGINE)
|
|
|
45 |
updateLines(affectedPaths);
|
17 |
ilm |
46 |
} else {
|
|
|
47 |
// eg CONTACT[3] has changed
|
|
|
48 |
updateLines(this.getAffectedPaths());
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
@Override
|
|
|
53 |
protected Collection<String> getModifedFields() {
|
|
|
54 |
return this.evt.getFieldNames();
|
|
|
55 |
}
|
|
|
56 |
}
|