OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | Rev 144 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
94 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.ui.light;
15
 
142 ilm 16
import org.openconcerto.utils.NumberUtils;
132 ilm 17
import org.openconcerto.utils.io.JSONConverter;
18
 
19
import java.awt.event.ActionEvent;
20
import java.awt.event.ActionListener;
21
import java.util.ArrayList;
94 ilm 22
import java.util.List;
23
 
142 ilm 24
import javax.xml.parsers.ParserConfigurationException;
25
 
26
import org.jdom2.Document;
27
import org.jdom2.Element;
28
 
132 ilm 29
import net.minidev.json.JSONArray;
94 ilm 30
import net.minidev.json.JSONObject;
31
 
142 ilm 32
public class LightUITable extends LightUserControlContainer {
33
 
34
    public static final int DEFAULT_LINE_HEIGHT = 40;
35
 
36
    private static final String LINE_PER_ROW = "line-per-row";
37
    private static final String TABLE_SPEC = "table-spec";
38
    private static final String ALLOW_SELECTION = "allow-selection";
39
    private static final String ALLOW_MULTI_SELECTION = "allow-multi-selection";
40
    private static final String DYNAMIC_LOAD = "dynamic-load";
41
    private static final String AUTO_SELECT_FIRST_LINE = "auto-select-first-line";
132 ilm 42
    private Boolean dynamicLoad = false;
43
    private Boolean allowSelection = false;
142 ilm 44
    private Boolean allowMultiSelection = false;
45
    private Boolean autoSelectFirstLine = true;
94 ilm 46
    private TableSpec tableSpec = null;
47
 
132 ilm 48
    private List<ActionListener> selectionListeners = new ArrayList<ActionListener>();
49
 
50
    // Nombre de ligne à afficher par Row
51
    private int linePerRow = 1;
52
 
142 ilm 53
    private int lineHeight = DEFAULT_LINE_HEIGHT;
54
 
94 ilm 55
    // Init from json constructor
56
    public LightUITable(final JSONObject json) {
132 ilm 57
        super(json);
94 ilm 58
    }
132 ilm 59
 
94 ilm 60
    // Clone constructor
61
    public LightUITable(final LightUITable tableElement) {
62
        super(tableElement);
63
        this.tableSpec = tableElement.tableSpec;
132 ilm 64
        this.allowSelection = tableElement.allowSelection;
94 ilm 65
    }
132 ilm 66
 
94 ilm 67
    public LightUITable(final String id) {
132 ilm 68
        super(id);
94 ilm 69
        this.setType(LightUIElement.TYPE_TABLE);
132 ilm 70
 
71
        this.setWeightX(1);
94 ilm 72
        this.setFillWidth(true);
73
 
142 ilm 74
        final RowSelectionSpec selection = new RowSelectionSpec(this.getId());
75
        final ColumnsSpec columnsSpec = new ColumnsSpec(this.getId(), new ArrayList<ColumnSpec>(), new ArrayList<String>(), new ArrayList<String>());
76
        final TableSpec tableSpec = new TableSpec(this.getId(), selection, columnsSpec);
77
        tableSpec.setContent(new TableContent(this.getId()));
132 ilm 78
 
142 ilm 79
        this.setTableSpec(tableSpec);
132 ilm 80
    }
81
 
82
    @Override
83
    public void setId(final String id) {
84
        super.setId(id);
85
 
142 ilm 86
        if (this.tableSpec != null) {
87
            this.tableSpec.setId(id);
132 ilm 88
 
142 ilm 89
            if (this.tableSpec.getSelection() != null) {
90
                this.tableSpec.getSelection().setTableId(id);
91
            }
92
 
93
            if (this.tableSpec.getContent() != null) {
94
                this.tableSpec.getContent().setTableId(id);
95
            }
96
        }
132 ilm 97
    }
98
 
142 ilm 99
    public final void setLinePerRow(int linePerRow) {
132 ilm 100
        this.linePerRow = linePerRow;
101
    }
102
 
142 ilm 103
    public final int getLinePerRow() {
132 ilm 104
        return this.linePerRow;
105
    }
106
 
142 ilm 107
    public final void setLineHeight(int lineHeight) {
108
        this.lineHeight = lineHeight;
109
    }
110
 
111
    public final int getLineHeight() {
112
        return this.lineHeight;
113
    }
114
 
115
    public final TableSpec getTableSpec() {
94 ilm 116
        return this.tableSpec;
117
    }
118
 
142 ilm 119
    public final void setTableSpec(final TableSpec tableSpec) {
94 ilm 120
        this.tableSpec = tableSpec;
121
    }
132 ilm 122
 
142 ilm 123
    public final Boolean isAllowSelection() {
132 ilm 124
        return this.allowSelection;
125
    }
126
 
142 ilm 127
    public final void setAllowSelection(final boolean allowSelection) {
132 ilm 128
        this.allowSelection = allowSelection;
129
    }
130
 
142 ilm 131
    public final Boolean isAllowMultiSelection() {
132
        return this.allowMultiSelection;
133
    }
134
 
135
    public final void setAllowMultiSelection(final boolean allowMultiSelection) {
136
        this.allowMultiSelection = allowMultiSelection;
137
    }
138
 
139
    public final Boolean isDynamicLoad() {
132 ilm 140
        return this.dynamicLoad;
141
    }
142
 
142 ilm 143
    public final void setDynamicLoad(final boolean dynamicLoad) {
132 ilm 144
        this.dynamicLoad = dynamicLoad;
145
    }
146
 
142 ilm 147
    public final Boolean isAutoSelectFirstLine() {
148
        return this.autoSelectFirstLine;
94 ilm 149
    }
132 ilm 150
 
142 ilm 151
    public final void setAutoSelectFirstLine(final boolean autoSelectFirstLine) {
152
        this.autoSelectFirstLine = autoSelectFirstLine;
94 ilm 153
    }
132 ilm 154
 
142 ilm 155
    public final Row removeRow(final int index) {
156
        return this.tableSpec.getContent().removeRow(index);
157
    }
158
 
159
    public final boolean removeRow(final Row row) {
160
        final TableContent content = this.getTableSpec().getContent();
161
        return content.removeRow(row);
162
    }
163
 
164
    public final boolean hasRow() {
165
        return (this.tableSpec != null && this.tableSpec.getContent() != null && this.tableSpec.getContent().getRowsCount() > 0);
166
    }
167
 
168
    public final Row getRow(final int index) {
169
        return this.getTableSpec().getContent().getRow(index);
170
    }
171
 
172
    public Row getRowById(final Number rowId) {
173
        final int size = this.getTableSpec().getContent().getRowsCount();
174
        for (int i = 0; i < size; i++) {
175
            final Row row = this.getRow(i);
176
            if (NumberUtils.areNumericallyEqual(row.getId(), rowId)) {
177
                return row;
178
            } else {
179
                System.err.println("LightUITable.getSelectedRows() - Null selectedRow");
180
            }
181
        }
182
        return null;
183
    }
184
 
185
    public final Row setRow(final int index, final Row row) {
186
        return this.getTableSpec().getContent().setRow(index, row);
187
    }
188
 
189
    public final boolean addRow(final Row row) {
190
        return this.getTableSpec().getContent().addRow(row);
191
    }
192
 
193
    public final int getRowsCount() {
194
        return this.getTableSpec().getContent().getRowsCount();
195
    }
196
 
197
    public final void clearRows() {
198
        this.getTableSpec().getContent().clearRows();
199
    }
200
 
201
    /**
202
     * Get Ids of SQLRowAccessor store in selected rows
203
     *
204
     * @return The list of selected DB Ids
205
     */
206
    public final List<Number> getSelectedIds() {
207
        return this.getTableSpec().getSelection().getIds();
208
    }
209
 
210
    public final Number getFirstSelectedId() {
211
        final List<Number> selectedIds = this.getTableSpec().getSelection().getIds();
212
        if (selectedIds.isEmpty()) {
213
            return null;
214
        } else {
215
            return selectedIds.get(0);
216
        }
217
    }
218
 
219
    public final void setSelectedIds(final List<Number> selectedIds, final boolean fire) {
220
        this.getTableSpec().getSelection().setIds(selectedIds);
221
        if (fire) {
222
            this.fireSelectionChange();
223
        }
224
    }
225
 
226
    public final void clearSelection(final boolean fire) {
227
        this.getTableSpec().getSelection().getIds().clear();
228
        if (fire) {
229
            this.fireSelectionChange();
230
        }
231
    }
232
 
233
    public final List<Row> getSelectedRows() {
234
        final List<Row> selectedRows = new ArrayList<Row>();
235
 
236
        if (this.getTableSpec().getSelection() != null) {
237
            final List<Number> selectedIds = this.getSelectedIds();
238
            for (final Number selectedId : selectedIds) {
239
                final Row selectedRow = this.getRowById(selectedId);
240
                if (selectedRow != null) {
241
                    selectedRows.add(selectedRow);
242
                }
243
            }
244
        }
245
 
246
        return selectedRows;
247
    }
248
 
249
    public final boolean replaceChild(final LightUIElement pChild) {
132 ilm 250
        pChild.setReadOnly(this.isReadOnly());
251
 
142 ilm 252
        for (int i = 0; i < this.getRowsCount(); i++) {
253
            final Row tableRow = this.getTableSpec().getContent().getRow(i);
132 ilm 254
            final List<Object> tableRowValues = tableRow.getValues();
255
            final int tableRowValuesCount = tableRowValues.size();
256
 
257
            for (int j = 0; j < tableRowValuesCount; j++) {
258
                final Object tableRowValue = tableRowValues.get(j);
259
                if (tableRowValue instanceof LightUIElement) {
260
                    final LightUIElement child = (LightUIElement) tableRowValue;
261
 
262
                    if (child.getId().equals(pChild.getId())) {
263
                        tableRowValues.set(i, pChild);
264
                        child.setParent(this);
265
                        return true;
266
                    }
267
                    if (child instanceof LightUIContainer) {
268
                        if (((LightUIContainer) child).replaceChild(pChild)) {
269
                            return true;
270
                        }
271
                    }
272
                    if (child instanceof LightUITable) {
273
                        if (((LightUITable) child).replaceChild(pChild)) {
274
                            return true;
275
                        }
276
                    }
277
                }
278
            }
279
        }
280
        return false;
281
    }
282
 
142 ilm 283
    public final LightUIElement findElement(final String searchParam, final boolean byUUID) {
132 ilm 284
        return this.findElement(searchParam, byUUID, LightUIElement.class);
285
    }
286
 
142 ilm 287
    public final <T extends LightUIElement> T findElement(final String searchParam, final boolean byUUID, final Class<T> objectClass) {
288
        if (this.hasRow()) {
289
 
290
            for (int i = 0; i < this.getRowsCount(); i++) {
291
                final Row row = this.getRow(i);
292
                final List<Object> rowValues = row.getValues();
293
                for (final Object value : rowValues) {
294
                    if (value instanceof LightUIContainer) {
295
                        final LightUIContainer panel = (LightUIContainer) value;
296
                        final T element = panel.findChild(searchParam, byUUID, objectClass);
297
                        if (element != null) {
298
                            return element;
299
                        }
300
                    } else if (value instanceof LightUIElement) {
301
                        final LightUIElement element = (LightUIElement) value;
302
                        if (byUUID) {
303
                            if (element.getUUID().equals(searchParam)) {
304
                                if (objectClass.isAssignableFrom(element.getClass())) {
305
                                    return objectClass.cast(element);
306
                                } else {
307
                                    throw new IllegalArgumentException(
308
                                            "Element found at is not an instance of " + objectClass.getName() + ", element class: " + element.getClass().getName() + " element ID: " + element.getId());
94 ilm 309
                                }
142 ilm 310
                            }
311
                        } else {
312
                            if (element.getId().equals(searchParam)) {
313
                                if (objectClass.isAssignableFrom(element.getClass())) {
314
                                    return objectClass.cast(element);
132 ilm 315
                                } else {
142 ilm 316
                                    throw new IllegalArgumentException(
317
                                            "Element found at is not an instance of " + objectClass.getName() + ", element class: " + element.getClass().getName() + " element ID: " + element.getId());
132 ilm 318
                                }
142 ilm 319
                            }
320
                        }
132 ilm 321
 
142 ilm 322
                        if (element instanceof LightUITable) {
323
                            final T resultElement = ((LightUITable) element).findElement(searchParam, byUUID, objectClass);
324
                            if (resultElement != null) {
325
                                return resultElement;
94 ilm 326
                            }
327
                        }
328
                    }
329
                }
330
            }
331
        } else {
142 ilm 332
            System.out.println("LightUITable.getElementById() - No rows for table: " + this.getId());
94 ilm 333
        }
334
        return null;
335
    }
336
 
142 ilm 337
    public <T extends LightUIElement> List<T> findChildren(final Class<T> expectedClass, final boolean recursively) {
338
        final List<T> result = new ArrayList<T>();
339
 
340
        if (this.hasRow()) {
341
            final int size = this.getRowsCount();
342
            for (int i = 0; i < size; i++) {
343
                final Row row = this.getRow(i);
344
                final List<Object> rowValues = row.getValues();
345
                for (final Object value : rowValues) {
346
                    if (recursively) {
347
                        if (value instanceof LightUIContainer) {
348
                            result.addAll(((LightUIContainer) value).findChildren(expectedClass, recursively));
349
                        } else if (value instanceof LightUITable) {
350
                            result.addAll(((LightUITable) value).findChildren(expectedClass, recursively));
351
                        }
352
                    }
353
                    if (expectedClass.isAssignableFrom(value.getClass())) {
354
                        result.add(expectedClass.cast(value));
355
                    }
356
                }
357
            }
358
        } else {
359
            System.out.println("LightUITable.getElementById() - No rows for table: " + this.getId());
360
        }
361
 
362
        return result;
363
    }
364
 
365
    public final void addSelectionListener(final ActionListener selectionListener) {
132 ilm 366
        this.selectionListeners.add(selectionListener);
367
    }
368
 
142 ilm 369
    public final void removeSelectionListeners() {
132 ilm 370
        this.selectionListeners.clear();
371
    }
372
 
142 ilm 373
    public final void fireSelectionChange() {
132 ilm 374
        for (final ActionListener listener : this.selectionListeners) {
375
            listener.actionPerformed(new ActionEvent(this, 1, "selection"));
376
        }
377
    }
378
 
142 ilm 379
    // TODO: garder l'ordre des colonnes invisibles
380
    /**
381
     * Create columns preferences with the current ColumnsSpec
382
     *
383
     * @return XML document with columns preferences
384
     */
385
    public final Document createXmlPreferences(final Document userPrefs, final ColumnsSpec columnsSpec) throws ParserConfigurationException {
386
 
387
        final Element rootElement = new Element("list");
388
        final Document xmlConf = new Document();
389
 
390
        final int columnSpecCount = columnsSpec.getColumnCount();
391
        final List<String> visibleIds = new ArrayList<String>();
392
        for (int i = 0; i < columnSpecCount; i++) {
393
            final ColumnSpec columnSpec = columnsSpec.getColumn(i);
394
            final Element xmlColumn = this.createXmlColumn(columnSpec.getId(), columnSpec.getMaxWidth(), columnSpec.getMinWidth(), columnSpec.getWidth());
395
            rootElement.addContent(xmlColumn);
396
            visibleIds.add(columnSpec.getId());
397
        }
398
 
399
        final Element rootUserPrefs = userPrefs.getRootElement();
400
        final List<Element> xmlColumns = rootUserPrefs.getChildren();
401
        final int columnsSize = xmlColumns.size();
402
        for (int i = 0; i < columnsSize; i++) {
403
            final Element xmlColumn = xmlColumns.get(i);
404
            final String columnId = xmlColumn.getAttribute("id").getValue();
405
            if (!visibleIds.contains(columnId)) {
406
                final int maxWidth = Integer.parseInt(xmlColumn.getAttribute("max-width").getValue());
407
                final int minWidth = Integer.parseInt(xmlColumn.getAttribute("min-width").getValue());
408
                final int width = Integer.parseInt(xmlColumn.getAttribute("width").getValue());
409
                final Element newXmlColumn = this.createXmlColumn(columnId, maxWidth, minWidth, width);
410
                rootElement.addContent(newXmlColumn);
411
            }
412
        }
413
        xmlConf.setRootElement(rootElement);
414
        return xmlConf;
415
    }
416
 
417
    /**
418
     * Create default columns preferences from the SQLTableModelLinesSourceOnline
419
     *
420
     * @return XML document with columns preferences
421
     */
422
    public Document createDefaultXmlPreferences() {
423
        final Element rootElement = new Element("list");
424
 
425
        if (this.getTableSpec() != null && this.getTableSpec().getColumns() != null) {
426
            final int sqlColumnsCount = this.getTableSpec().getColumns().getColumnCount();
427
            for (int i = 0; i < sqlColumnsCount; i++) {
428
                final ColumnSpec column = this.getTableSpec().getColumns().getColumn(i);
429
                final String columnId = column.getId();
430
                final Element columnElement = this.createXmlColumn(columnId, column.getMaxWidth(), column.getMinWidth(), column.getWidth());
431
                rootElement.addContent(columnElement);
432
            }
433
        }
434
        final Document xmlConf = new Document(rootElement);
435
 
436
        return xmlConf;
437
    }
438
 
439
    protected final Element createXmlColumn(final String columnId, final double maxWidth, final double minWidth, final double width) {
440
        final Element columnElement = new Element("column");
441
        columnElement.setAttribute("id", columnId);
442
        columnElement.setAttribute("max-width", String.valueOf(maxWidth));
443
        columnElement.setAttribute("min-width", String.valueOf(minWidth));
444
        columnElement.setAttribute("width", String.valueOf(width));
445
        return columnElement;
446
    }
447
 
132 ilm 448
    @Override
449
    public void setReadOnly(final boolean readOnly) {
450
        super.setReadOnly(readOnly);
142 ilm 451
 
452
        if (this.hasRow()) {
453
            final int size = this.getRowsCount();
454
            for (int i = 0; i < size; i++) {
455
                final Row row = this.getRow(i);
132 ilm 456
                final List<Object> values = row.getValues();
457
                for (final Object value : values) {
458
                    if (value != null && value instanceof LightUIElement) {
459
                        ((LightUIElement) value).setReadOnly(readOnly);
460
                    }
461
                }
462
            }
463
        }
464
    }
465
 
466
    @Override
467
    public JSONToLightUIConvertor getConvertor() {
468
        return new JSONToLightUIConvertor() {
469
            @Override
470
            public LightUIElement convert(final JSONObject json) {
471
                return new LightUITable(json);
472
            }
473
        };
474
    }
475
 
476
    @Override
142 ilm 477
    public void _setValueFromContext(final Object value) {
132 ilm 478
        if (value != null) {
479
            final JSONArray jsonContext = (JSONArray) JSONConverter.getObjectFromJSON(value, JSONArray.class);
480
            final ColumnsSpec columnsSpec = this.getTableSpec().getColumns();
481
            final int columnsCount = columnsSpec.getColumnCount();
482
 
483
            final List<Integer> editorsIndex = new ArrayList<Integer>();
484
 
485
            for (int i = 0; i < columnsCount; i++) {
486
                final ColumnSpec columnSpec = columnsSpec.getColumn(i);
487
                if (columnSpec.getEditor() != null) {
488
                    editorsIndex.add(i);
489
                }
490
            }
491
 
142 ilm 492
            if (this.hasRow()) {
493
                final int size = this.getRowsCount();
494
                if (jsonContext.size() != size) {
495
                    System.err.println("LightUITable.setValueFromContext() - Incorrect line count in JSON");
496
                } else {
497
 
498
                    for (int i = 0; i < size; i++) {
499
                        final Row row = this.getRow(i);
500
                        final JSONObject jsonLineContext = (JSONObject) JSONConverter.getObjectFromJSON(jsonContext.get(i), JSONObject.class);
501
                        final Number rowId = JSONConverter.getParameterFromJSON(jsonLineContext, "row.id", Number.class);
502
                        final String rowExtendId = (String) JSONConverter.getParameterFromJSON(jsonLineContext, "row.extend.id", String.class);
503
                        if (NumberUtils.areNumericallyEqual(rowId, row.getId()) && (row.getExtendId() == null || (row.getExtendId() != null && rowExtendId.equals(row.getExtendId())))) {
504
                            if (row.isFillWidth()) {
505
                                if (!row.getValues().isEmpty() && row.getValues().get(0) instanceof LightUserControl) {
506
                                    final LightUIElement element = (LightUIElement) row.getValues().get(0);
507
                                    if (element instanceof LightUserControl) {
508
                                        if (jsonLineContext.containsKey(element.getUUID())) {
509
                                            ((LightUserControl) element)._setValueFromContext(jsonLineContext.get(element.getUUID()));
510
                                        } else {
511
                                            System.out.println("LightUITable.setValueFromContext() - Unable to find element : id - " + element.getId() + " uuid - " + element.getUUID());
512
                                            System.out.println("LightUITable.setValueFromContext() - In JSON                : " + jsonLineContext.toJSONString());
513
                                        }
514
                                    }
515
                                }
516
                            } else {
517
                                for (int k = 0; k < editorsIndex.size(); k++) {
518
                                    final Object objEditor = row.getValues().get(editorsIndex.get(k));
519
                                    if (!(objEditor instanceof LightUserControl)) {
520
                                        throw new IllegalArgumentException("Impossible to find editor for row: " + rowId.toString() + " at position: " + String.valueOf(k));
521
                                    }
522
                                    final LightUIElement editor = (LightUIElement) objEditor;
523
 
524
                                    if (editor instanceof LightUserControl && jsonLineContext.containsKey(editor.getUUID())) {
525
                                        ((LightUserControl) editor)._setValueFromContext(jsonLineContext.get(editor.getUUID()));
132 ilm 526
                                    } else {
142 ilm 527
                                        throw new IllegalArgumentException(
528
                                                "Impossible to find value for editor: " + editor.getId() + " for row: " + rowId.toString() + " at position: " + String.valueOf(k));
132 ilm 529
                                    }
530
                                }
531
                            }
532
                        } else {
142 ilm 533
                            throw new IllegalArgumentException("Impossible to find row: " + rowId.toString());
132 ilm 534
                        }
535
                    }
536
                }
537
            }
538
        }
539
    }
540
 
541
    @Override
94 ilm 542
    public LightUIElement clone() {
543
        return new LightUITable(this);
544
    }
132 ilm 545
 
94 ilm 546
    @Override
547
    public JSONObject toJSON() {
548
        final JSONObject json = super.toJSON();
132 ilm 549
        if (this.allowSelection) {
142 ilm 550
            json.put(ALLOW_SELECTION, true);
132 ilm 551
        }
142 ilm 552
        if (this.allowMultiSelection) {
553
            json.put(ALLOW_MULTI_SELECTION, true);
554
        }
132 ilm 555
        if (this.dynamicLoad) {
142 ilm 556
            json.put(DYNAMIC_LOAD, true);
132 ilm 557
        }
142 ilm 558
        if (!this.autoSelectFirstLine) {
559
            json.put(AUTO_SELECT_FIRST_LINE, false);
94 ilm 560
        }
132 ilm 561
        if (this.tableSpec != null) {
142 ilm 562
            json.put(TABLE_SPEC, this.tableSpec.toJSON());
94 ilm 563
        }
142 ilm 564
 
565
        json.put(LINE_PER_ROW, this.linePerRow);
94 ilm 566
        return json;
567
    }
568
 
569
    @Override
570
    public void fromJSON(final JSONObject json) {
571
        super.fromJSON(json);
142 ilm 572
        this.allowSelection = JSONConverter.getParameterFromJSON(json, ALLOW_SELECTION, Boolean.class, false);
573
        this.allowSelection = JSONConverter.getParameterFromJSON(json, ALLOW_MULTI_SELECTION, Boolean.class, false);
574
        this.dynamicLoad = JSONConverter.getParameterFromJSON(json, DYNAMIC_LOAD, Boolean.class, false);
575
        this.autoSelectFirstLine = JSONConverter.getParameterFromJSON(json, AUTO_SELECT_FIRST_LINE, Boolean.class, true);
576
        this.linePerRow = JSONConverter.getParameterFromJSON(json, LINE_PER_ROW, Integer.class);
132 ilm 577
 
142 ilm 578
        final JSONObject jsonRawContent = (JSONObject) JSONConverter.getParameterFromJSON(json, TABLE_SPEC, JSONObject.class);
132 ilm 579
 
94 ilm 580
        if (jsonRawContent != null) {
581
            this.tableSpec = new TableSpec(jsonRawContent);
582
        }
583
    }
142 ilm 584
 
585
    @Override
586
    public void destroy() {
587
        super.destroy();
588
        this.selectionListeners.clear();
589
    }
94 ilm 590
}