OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
74 ilm 1
package org.openconcerto.modules.extensionbuilder.list;
2
 
3
import java.util.List;
4
 
5
import javax.swing.event.ChangeEvent;
6
import javax.swing.event.ChangeListener;
7
 
8
import org.openconcerto.modules.extensionbuilder.Extension;
9
import org.openconcerto.ui.DefaultListModel;
10
 
11
public class CreateListListModel extends DefaultListModel implements ChangeListener {
12
    private final Extension extension;
13
 
14
    CreateListListModel(Extension extension) {
15
        this.extension = extension;
16
        addContent();
17
    }
18
 
19
    private void addContent() {
181 ilm 20
        this.addAll(this.extension.getCreateListList());
74 ilm 21
    }
22
 
23
    @Override
24
    public void stateChanged(ChangeEvent e) {
25
        this.clear();
26
        addContent();
27
    }
28
 
29
    public void addNewList() {
30
        final ListDescriptor l = new ListDescriptor("liste " + (this.getSize() + 1));
181 ilm 31
        final List<String> allKnownTableNames = this.extension.getAllKnownTableNames();
74 ilm 32
        final String mainTable = allKnownTableNames.get(0);
33
        l.setMainTable(mainTable);
34
        this.addElement(l);
181 ilm 35
        this.extension.addCreateList(l);
74 ilm 36
    }
37
 
38
}