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 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
Line 23... Line 23...
23
import org.openconcerto.sql.model.SQLRowValues;
23
import org.openconcerto.sql.model.SQLRowValues;
24
import org.openconcerto.sql.model.SQLRowValues.ForeignCopyMode;
24
import org.openconcerto.sql.model.SQLRowValues.ForeignCopyMode;
25
import org.openconcerto.sql.model.SQLTable;
25
import org.openconcerto.sql.model.SQLTable;
26
import org.openconcerto.sql.model.graph.Path;
26
import org.openconcerto.sql.model.graph.Path;
27
import org.openconcerto.sql.request.BaseFillSQLRequest;
27
import org.openconcerto.sql.request.BaseFillSQLRequest;
-
 
28
import org.openconcerto.sql.request.ComboSQLRequest.KeepMode;
28
import org.openconcerto.sql.request.ListSQLRequest;
29
import org.openconcerto.sql.request.ListSQLRequest;
29
import org.openconcerto.utils.cc.IClosure;
30
import org.openconcerto.utils.cc.IClosure;
30
import org.openconcerto.utils.change.ListChangeIndex;
31
import org.openconcerto.utils.change.ListChangeIndex;
31
import org.openconcerto.utils.change.ListChangeRecorder;
32
import org.openconcerto.utils.change.ListChangeRecorder;
32
 
33
 
Line 116... Line 117...
116
 
117
 
117
    public SQLElement getElem() {
118
    public SQLElement getElem() {
118
        return this.elem;
119
        return this.elem;
119
    }
120
    }
120
 
121
 
-
 
122
    protected abstract KeepMode getKeepMode();
-
 
123
 
121
    // lazy initialization since this method calls colsChanged() which subclasses overload and
124
    // lazy initialization since this method calls colsChanged() which subclasses overload and
122
    // they need their own attribute that aren't set yet since super() must be the first statement.
125
    // they need their own attribute that aren't set yet since super() must be the first statement.
123
    public void init() {
126
    public void init() {
124
        assert SwingUtilities.isEventDispatchThread();
127
        assert SwingUtilities.isEventDispatchThread();
125
        if (this.inited == null)
128
        if (this.inited == null)
126
            return;
129
            return;
127
 
130
 
128
        final SQLRowValues graph = this.inited;
131
        final SQLRowValues graph = this.inited;
129
 
132
 
-
 
133
        final boolean moreDebugCols = this.getKeepMode() == KeepMode.GRAPH;
130
        graph.walkFields(new IClosure<FieldPath>() {
134
        graph.walkFields(new IClosure<FieldPath>() {
131
            @Override
135
            @Override
132
            public void executeChecked(final FieldPath input) {
136
            public void executeChecked(final FieldPath input) {
133
                final SQLField f = input.getField();
137
                final SQLField f = input.getField();
134
                if (f.getTable().getLocalContentFields().contains(f)) {
138
                if (f.getTable().getLocalContentFields().contains(f)) {
135
                    final SQLTableModelColumnPath col = new SQLTableModelColumnPath(input, null, getElem().getDirectory());
139
                    final SQLTableModelColumnPath col = new SQLTableModelColumnPath(input, null, getElem().getDirectory());
136
                    SQLTableModelSource.this.cols.add(col);
140
                    SQLTableModelSource.this.cols.add(col);
137
                } else
141
                } else if (moreDebugCols) {
138
                    SQLTableModelSource.this.debugCols.add(new SQLTableModelColumnPath(input.getPath(), f.getName(), f.toString()) {
142
                    SQLTableModelSource.this.debugCols.add(new SQLTableModelColumnPath(input.getPath(), f.getName(), f.toString()) {
139
                        // don't show the rowValues since it's very verbose (and all content fields
143
                        // don't show the rowValues since it's very verbose (and all content fields
140
                        // are already displayed as normal columns) and unsortable
144
                        // are already displayed as normal columns) and unsortable
141
                        @Override
145
                        @Override
142
                        protected Object show_(SQLRowAccessor r) {
146
                        protected Object show_(SQLRowAccessor r) {
143
                            final Object res = super.show_(r);
147
                            final Object res = super.show_(r);
144
                            return res instanceof SQLRowValues ? ((SQLRowValues) res).getID() : res;
148
                            return res instanceof SQLRowValues ? ((SQLRowValues) res).getID() : res;
145
                        }
149
                        }
146
                    });
150
                    });
147
            }
151
                }
-
 
152
            }
148
        }, true);
153
        }, true);
149
 
154
 
-
 
155
        if (moreDebugCols)
150
        this.debugCols.add(new DebugRow(getPrimaryTable()));
156
            this.debugCols.add(new DebugRow(getPrimaryTable()));
151
        final SQLField orderField = getPrimaryTable().getOrderField();
157
        final SQLField orderField = getPrimaryTable().getOrderField();
152
        if (orderField != null)
158
        if (orderField != null)
153
            this.debugCols.add(new SQLTableModelColumnPath(Path.get(getPrimaryTable()), orderField.getName(), "Order"));
159
            this.debugCols.add(new SQLTableModelColumnPath(Path.get(getPrimaryTable()), orderField.getName(), "Order"));
154
        this.debugCols.add(new SQLTableModelColumnPath(Path.get(getPrimaryTable()), getPrimaryTable().getKey().getName(), "PrimaryKey"));
160
        this.debugCols.add(new SQLTableModelColumnPath(Path.get(getPrimaryTable()), getPrimaryTable().getKey().getName(), "PrimaryKey"));