OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 74 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
74 ilm 1
package org.openconcerto.modules.extensionbuilder.table;
2
 
3
import java.util.ArrayList;
4
import java.util.List;
5
 
6
import javax.swing.event.ChangeEvent;
7
import javax.swing.event.ChangeListener;
8
 
9
import org.openconcerto.modules.extensionbuilder.Extension;
10
import org.openconcerto.ui.DefaultListModel;
11
 
12
public class ModifiedTableListModel extends DefaultListModel implements ChangeListener {
13
    private final Extension extension;
14
 
15
    ModifiedTableListModel(Extension extension) {
16
        this.extension = extension;
17
        addContent(extension);
18
        extension.addChangeListener(this);
19
    }
20
 
21
    private void addContent(Extension extension) {
22
        final List<TableDescritor> modifyTableList = extension.getModifyTableList();
23
        final ArrayList<TableDescritor> newList = new ArrayList<TableDescritor>(modifyTableList.size());
24
        for (TableDescritor tableDescritor : modifyTableList) {
25
            if (tableDescritor.getFields().size() > 0) {
26
                newList.add(tableDescritor);
27
            }
28
        }
29
        this.addAll(newList);
30
    }
31
 
32
    @Override
33
    public void stateChanged(ChangeEvent e) {
34
        this.clear();
181 ilm 35
        addContent(this.extension);
74 ilm 36
        this.fireContentsChanged(this, 0, this.getSize());
37
    }
38
 
39
}