OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | Rev 180 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
93 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.core.customerrelationship.customer.element;
15
 
142 ilm 16
import org.openconcerto.erp.core.edm.AttachmentAction;
156 ilm 17
import org.openconcerto.erp.core.reports.history.ui.HistoriqueClientFrame;
94 ilm 18
import org.openconcerto.sql.element.GlobalMapper;
93 ilm 19
import org.openconcerto.sql.element.GroupSQLComponent;
20
import org.openconcerto.sql.element.SQLComponent;
144 ilm 21
import org.openconcerto.sql.model.SQLRowAccessor;
22
import org.openconcerto.sql.request.SQLFieldTranslator;
156 ilm 23
import org.openconcerto.sql.view.list.IListe;
142 ilm 24
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
25
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
144 ilm 26
import org.openconcerto.ui.light.LightUIElement;
27
import org.openconcerto.ui.light.LightUILine;
28
import org.openconcerto.ui.light.LightUIPanel;
29
import org.openconcerto.ui.light.SimpleTextLine;
93 ilm 30
 
156 ilm 31
import java.awt.event.ActionEvent;
132 ilm 32
import java.util.List;
33
 
156 ilm 34
import javax.swing.AbstractAction;
35
 
93 ilm 36
public class CustomerSQLElement extends ClientNormalSQLElement {
37
 
38
    public CustomerSQLElement() {
39
        super();
94 ilm 40
        final CustomerGroup group = new CustomerGroup();
41
        GlobalMapper.getInstance().map(CustomerGroup.ID, group);
42
        setDefaultGroup(group);
144 ilm 43
 
142 ilm 44
        PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
45
        actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
46
        getRowActions().add(actionAttachment);
47
 
156 ilm 48
        PredicateRowAction actionHistory = new PredicateRowAction(new AbstractAction("Historique client") {
49
 
50
            @Override
51
            public void actionPerformed(ActionEvent e) {
52
                HistoriqueClientFrame histoFrame = new HistoriqueClientFrame();
53
                int idClient = IListe.get(e).getSelectedId();
54
                histoFrame.selectId(idClient);
55
                histoFrame.setVisible(true);
56
            }
57
        }, true);
58
        actionHistory.setPredicate(IListeEvent.getSingleSelectionPredicate());
59
        getRowActions().add(actionHistory);
60
 
93 ilm 61
    }
62
 
63
    @Override
64
    public SQLComponent createComponent() {
65
        final GroupSQLComponent c = new CustomerSQLComponent(this);
66
        c.startTabGroupAfter("customerrelationship.customer.identifier");
67
        return c;
68
    }
132 ilm 69
 
70
    @Override
71
    protected List<String> getListFields() {
72
        final List<String> fields = super.getListFields();
142 ilm 73
        if (getTable().contains("GROUPE")) {
74
            fields.add("GROUPE");
75
        }
76
        fields.add("SOLDE_COMPTE");
77
        fields.add("REMIND_DATE");
132 ilm 78
        fields.add("OBSOLETE");
79
        return fields;
80
    }
144 ilm 81
 
82
    @Override
83
    protected void fillDataPanel(final String sessionToken, final List<SQLRowAccessor> selection, final LightUIPanel dataPanel) {
84
        final SQLFieldTranslator translator = this.getDirectory().getTranslator();
85
        final SQLRowAccessor sqlRow = selection.get(0);
86
 
87
        final int rowId = sqlRow.getID();
88
        final LightUILine mainLine = new LightUILine();
89
        final LightUIPanel mainLinePanel = new LightUIPanel(dataPanel.getId() + ".main.line." + rowId);
90
        mainLinePanel.setWeightX(1);
91
 
92
        final SimpleTextLine spacer = new SimpleTextLine("", true, LightUIElement.HALIGN_LEFT, 2);
93
        spacer.setMarginBottom(4);
94
 
95
        String name = sqlRow.getString("NOM");
96
 
97
        mainLinePanel.addChild(new SimpleTextLine(name, true, LightUIElement.HALIGN_LEFT));
98
 
99
        final SimpleTextLine titleSituationContact = new SimpleTextLine("Coordonnées du client", true, LightUIElement.HALIGN_LEFT, 2);
100
        titleSituationContact.setMarginTop(10);
101
        mainLinePanel.addChild(titleSituationContact);
102
 
103
        addFieldToPanel("TEL", mainLinePanel, sqlRow, translator, true, "non renseigné");
104
        addFieldToPanel("MAIL", mainLinePanel, sqlRow, translator, true, "non renseigné");
105
 
106
        mainLine.addChild(mainLinePanel);
107
        dataPanel.addChild(mainLine);
108
    }
109
 
93 ilm 110
}