OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
147 ilm 1
package org.openconcerto.modules.customersupport;
2
 
3
import java.awt.Dimension;
4
import java.util.ArrayList;
5
import java.util.HashSet;
6
import java.util.List;
7
import java.util.Set;
8
 
9
import javax.swing.JComponent;
10
import javax.swing.JLabel;
11
import javax.swing.JScrollPane;
12
import javax.swing.JTextArea;
13
 
14
import org.openconcerto.erp.core.edm.AttachmentAction;
15
import org.openconcerto.erp.modules.AbstractModule;
16
import org.openconcerto.erp.modules.ModuleElement;
17
import org.openconcerto.sql.element.GroupSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.sql.model.SQLRowValues;
20
import org.openconcerto.sql.users.UserManager;
21
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
22
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
23
import org.openconcerto.ui.JDateTime;
24
 
25
public class CustomerTicketHistorySQLElement extends ModuleElement {
26
 
27
    public CustomerTicketHistorySQLElement(AbstractModule module) {
28
        super(module, Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
29
        PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
30
        actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
31
        getRowActions().add(actionAttachment);
32
    }
33
 
34
    @Override
35
    protected String createCode() {
36
        return "customersupport.ticket.history";
37
    }
38
 
39
    @Override
40
    protected List<String> getListFields() {
41
        final List<String> l = new ArrayList<String>();
42
        l.add("ID_USER_COMMON");
43
        l.add("DATE");
44
        l.add("ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET);
45
        l.add("INFORMATION");
46
        return l;
47
    }
48
 
49
    @Override
50
    protected List<String> getComboFields() {
51
        final List<String> l = new ArrayList<String>();
52
        l.add("DATE");
53
        l.add("INFORMATION");
54
        return l;
55
    }
56
 
57
    @Override
58
    protected String getParentFFName() {
59
        return "ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET;
60
    }
61
 
62
    @Override
63
    public SQLComponent createComponent() {
64
        return new GroupSQLComponent(this, new CustomerTicketSupportHistoryGroup()) {
65
 
66
            @Override
67
            protected Set<String> createRequiredNames() {
68
                final Set<String> s = new HashSet<String>(1);
69
                s.add("ID_USER_COMMON");
70
                s.add("DATE");
71
                return s;
72
            }
73
 
74
            // @Override
75
            // public JComponent getLabel(String id) {
76
            // if (id.equals("customerrelationship.lead.call.content")) {
77
            // return new JLabelBold("Description de l'appel téléphonique");
78
            // } else if (id.equals("customerrelationship.lead.call.next")) {
79
            // return new JLabelBold("Suite à donner");
80
            // }
81
            // return super.getLabel(id);
82
            // }
83
 
84
            @Override
85
            public JComponent createEditor(String id) {
86
                if (id.equals("INFORMATION")) {
87
                    final JTextArea jTextArea = new JTextArea();
88
                    jTextArea.setFont(new JLabel().getFont());
89
                    jTextArea.setMinimumSize(new Dimension(200, 150));
90
                    jTextArea.setPreferredSize(new Dimension(200, 150));
91
                    return new JScrollPane(jTextArea);
92
                } else if (id.equals("DATE")) {
93
                    return new JDateTime(true);
94
                }
95
                return super.createEditor(id);
96
            }
97
 
98
            @Override
99
            protected SQLRowValues createDefaults() {
100
                SQLRowValues rowVals = new SQLRowValues(getTable());
101
                final int idUser = UserManager.getInstance().getCurrentUser().getId();
102
                rowVals.put("ID_USER_COMMON", idUser);
103
                return rowVals;
104
            }
105
 
106
        };
107
    }
108
 
109
}