OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 65 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65 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 22... Line 22...
22
import javax.swing.ListModel;
22
import javax.swing.ListModel;
23
import javax.swing.event.ListDataEvent;
23
import javax.swing.event.ListDataEvent;
24
import javax.swing.event.ListDataListener;
24
import javax.swing.event.ListDataListener;
25
 
25
 
26
public class ArticleModel implements ListModel {
26
public class ArticleModel implements ListModel {
27
    private final List<Article> items = new ArrayList<Article>();
27
    private final List<Article> items = new ArrayList<>();
28
 
28
 
29
    private List<ListDataListener> listeners = new ArrayList<ListDataListener>();
29
    private List<ListDataListener> listeners = new ArrayList<>();
30
 
30
 
31
    private Categorie categorie;
31
    private Categorie categorie;
32
 
32
 
33
    @Override
33
    @Override
34
    public void addListDataListener(ListDataListener l) {
34
    public void addListDataListener(ListDataListener l) {
Line 57... Line 57...
57
            this.items.addAll(c.getArticles());
57
            this.items.addAll(c.getArticles());
58
        }
58
        }
59
        fire();
59
        fire();
60
    }
60
    }
61
 
61
 
-
 
62
    public void setArticles(List<Article> list) {
-
 
63
        this.items.addAll(list);
-
 
64
        fire();
-
 
65
    }
-
 
66
 
62
    private void fire() {
67
    private void fire() {
63
        for (ListDataListener l : listeners) {
68
        for (ListDataListener l : listeners) {
64
            l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.listeners.size()));
69
            l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.listeners.size()));
65
        }
70
        }
66
    }
71
    }