OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

package org.openconcerto.modules.extensionbuilder.list;

import java.util.List;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.ui.DefaultListModel;

public class CreateListListModel extends DefaultListModel implements ChangeListener {
    private final Extension extension;

    CreateListListModel(Extension extension) {
        this.extension = extension;
        addContent();
    }

    private void addContent() {
        this.addAll(this.extension.getCreateListList());
    }

    @Override
    public void stateChanged(ChangeEvent e) {
        this.clear();
        addContent();
    }

    public void addNewList() {
        final ListDescriptor l = new ListDescriptor("liste " + (this.getSize() + 1));
        final List<String> allKnownTableNames = this.extension.getAllKnownTableNames();
        final String mainTable = allKnownTableNames.get(0);
        l.setMainTable(mainTable);
        this.addElement(l);
        this.extension.addCreateList(l);
    }

}