OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
156 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.erp.action;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.sql.element.SQLElement;
18
import org.openconcerto.sql.view.IListFrame;
19
import org.openconcerto.sql.view.IListPanel;
20
import org.openconcerto.sql.view.ListeAddPanel;
21
import org.openconcerto.sql.view.list.IListe;
22
import org.openconcerto.sql.view.list.SQLTableModelSource;
23
 
24
public abstract class CreateIListFrameAbstractAction<E extends SQLElement> extends CreateListFrameAbstractAction<E, IListFrame> {
25
 
26
    protected CreateIListFrameAbstractAction(final ComptaPropsConfiguration conf, final Class<? extends E> clazz) {
27
        super(conf, clazz);
28
    }
29
 
174 ilm 30
    protected CreateIListFrameAbstractAction(final ComptaPropsConfiguration conf, final E elem) {
31
        super(conf, elem);
32
    }
33
 
156 ilm 34
    protected SQLTableModelSource createTableSource() {
35
        return this.getElem().createTableSource();
36
    }
37
 
38
    protected String getPanelVariant() {
39
        return null;
40
    }
41
 
42
    protected IListPanel instantiateListPanel(final SQLTableModelSource tableSource, String panelVariant) {
43
        return new ListeAddPanel(tableSource.getElem(), new IListe(tableSource), panelVariant);
44
    }
45
 
46
    protected final IListPanel createListPanel() {
47
        final SQLTableModelSource tableSource = this.createTableSource();
48
        if (tableSource.getElem() != this.getElem())
49
            throw new IllegalStateException("Element mismatch");
50
        final IListPanel res = this.instantiateListPanel(tableSource, this.getPanelVariant());
51
        if (res.getListe().getSource() != tableSource)
52
            throw new IllegalStateException("Source mismatch");
53
        return res;
54
    }
55
 
56
    @Override
57
    protected final IListFrame instantiateFrame() {
58
        return new IListFrame(createListPanel());
59
    }
60
}