OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 61 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
21 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
 /*
15
 * Créé le 11 oct. 2011
16
 */
17
package org.openconcerto.erp.panel;
18
 
19
import org.openconcerto.erp.preferences.TemplateNXProps;
20
import org.openconcerto.erp.preferences.TemplatePreferencePanel;
21
import org.openconcerto.sql.Configuration;
22
import org.openconcerto.sql.element.BaseSQLComponent;
23
import org.openconcerto.sql.model.SQLSelect;
24
import org.openconcerto.sql.model.SQLTable;
25
import org.openconcerto.sql.model.Where;
26
import org.openconcerto.sql.sqlobject.ElementComboBox;
27
import org.openconcerto.ui.DefaultGridBagConstraints;
28
import org.openconcerto.utils.cc.ITransformer;
29
 
30
import java.awt.GridBagConstraints;
31
import java.awt.GridBagLayout;
32
 
33
import javax.swing.JCheckBox;
34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
36
 
37
public class PanelOOSQLComponent extends JPanel {
38
 
39
    private final JCheckBox checkImpression = new JCheckBox("Imprimer");
40
    private final JCheckBox checkVisu = new JCheckBox("Visualiser");
41
 
42
    public PanelOOSQLComponent(final BaseSQLComponent comp) {
43
        super(new GridBagLayout());
44
        GridBagConstraints c = new DefaultGridBagConstraints();
45
        c.gridx = GridBagConstraints.RELATIVE;
46
        this.setOpaque(false);
47
 
48
        if (TemplateNXProps.getInstance().getBooleanValue(TemplatePreferencePanel.MULTIMOD, false)) {
49
            if (comp.getElement().getTable().getFieldsName().contains("ID_MODELE")) {
50
                JLabel labelModele = new JLabel(comp.getLabelFor("ID_MODELE"));
51
                ElementComboBox boxModele = new ElementComboBox();
52
                comp.addView(boxModele, "ID_MODELE");
53
                boxModele.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
54
 
55
                    @Override
56
                    public SQLSelect transformChecked(SQLSelect input) {
57
                        SQLTable table = Configuration.getInstance().getDirectory().getElement("TYPE_MODELE").getTable();
58
                        Where w = new Where(table.getField("TABLE"), "=", comp.getElement().getTable().getName());
59
                        input.setWhere(w);
60
                        System.err.println(input.asString());
61
                        return input;
62
                    }
63
                });
64
                this.add(labelModele, c);
65
                this.add(boxModele, c);
66
            } else {
67
                System.err.println("Impossible d'ajouter la combo pour le choix des modèles car le champ ID_MODELE n'est pas présent dans la table " + comp.getElement().getTable().getName());
68
                Thread.dumpStack();
69
            }
70
        }
71
        this.add(this.checkImpression, c);
72
        this.add(this.checkVisu, c);
73
    }
74
 
75
    public boolean isVisualisationSelected() {
76
        return this.checkVisu.isSelected();
77
    }
78
 
79
    public boolean isImpressionSelected() {
80
        return this.checkImpression.isSelected();
81
    }
82
 
83
}