OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 147 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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