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.GridBagConstraints;
3
import java.awt.GridBagConstraints;
4
import java.awt.event.ActionEvent;
4
import java.awt.event.ActionEvent;
5
import java.util.ArrayList;
5
import java.util.ArrayList;
6
import java.util.Arrays;
6
import java.util.Arrays;
7
import java.util.HashSet;
7
import java.util.HashSet;
8
import java.util.List;
8
import java.util.List;
9
import java.util.Set;
9
import java.util.Set;
10
 
10
 
11
import javax.swing.AbstractAction;
11
import javax.swing.AbstractAction;
12
 
12
 
13
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
13
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
14
import org.openconcerto.erp.core.common.ui.PanelFrame;
14
import org.openconcerto.erp.core.common.ui.PanelFrame;
-
 
15
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
15
import org.openconcerto.erp.modules.AbstractModule;
16
import org.openconcerto.erp.modules.AbstractModule;
16
import org.openconcerto.erp.modules.ModuleElement;
17
import org.openconcerto.erp.modules.ModuleElement;
17
import org.openconcerto.sql.element.GlobalMapper;
18
import org.openconcerto.sql.element.GlobalMapper;
18
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.sql.element.SQLElement;
20
import org.openconcerto.sql.element.SQLElement;
20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.sql.view.EditFrame;
22
import org.openconcerto.sql.view.EditFrame;
22
import org.openconcerto.sql.view.EditPanel.EditMode;
23
import org.openconcerto.sql.view.EditPanel.EditMode;
23
import org.openconcerto.sql.view.IListFrame;
24
import org.openconcerto.sql.view.IListFrame;
24
import org.openconcerto.sql.view.ListeAddPanel;
25
import org.openconcerto.sql.view.ListeAddPanel;
25
import org.openconcerto.sql.view.list.IListe;
26
import org.openconcerto.sql.view.list.IListe;
26
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
27
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
27
import org.openconcerto.sql.view.list.RowAction;
28
import org.openconcerto.sql.view.list.RowAction;
28
import org.openconcerto.ui.DefaultGridBagConstraints;
29
import org.openconcerto.ui.DefaultGridBagConstraints;
29
import org.openconcerto.ui.FrameUtil;
30
import org.openconcerto.ui.FrameUtil;
30
import org.openconcerto.ui.group.Group;
31
import org.openconcerto.ui.group.Group;
31
import org.openconcerto.utils.ListMap;
32
import org.openconcerto.utils.ListMap;
32
 
33
 
33
public class CustomerSupportTicketSQLElement extends ModuleElement {
34
public class CustomerSupportTicketSQLElement extends ModuleElement {
34
 
35
 
35
    public CustomerSupportTicketSQLElement(final AbstractModule module) {
36
    public CustomerSupportTicketSQLElement(final AbstractModule module) {
36
        super(module, Module.TABLE_CUSTOMER_SUPPORT_TICKET);
37
        super(module, Module.TABLE_CUSTOMER_SUPPORT_TICKET);
37
        this.setL18nLocation(CustomerSupportTicketSQLElement.class);
-
 
38
 
38
 
39
        // Suivi
39
        // Suivi
40
        final RowAction.PredicateRowAction addSuiviAction = new RowAction.PredicateRowAction(new AbstractAction("Suivi du ticket") {
40
        final RowAction.PredicateRowAction addSuiviAction = new RowAction.PredicateRowAction(new AbstractAction("Suivi du ticket") {
41
 
41
 
42
            @Override
42
            @Override
43
            public void actionPerformed(ActionEvent e) {
43
            public void actionPerformed(ActionEvent e) {
44
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
44
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
45
                SuiviTicketPanel panel = new SuiviTicketPanel(sRow);
45
                SuiviTicketPanel panel = new SuiviTicketPanel(sRow);
46
                PanelFrame frame = new PanelFrame(panel, "Suivi ticket client");
46
                PanelFrame frame = new PanelFrame(panel, "Suivi ticket client");
47
                frame.setSize(800, 600);
47
                frame.setSize(800, 600);
48
                FrameUtil.show(frame);
48
                FrameUtil.show(frame);
49
            }
49
            }
50
        }, true) {
50
        }, true) {
51
        };
51
        };
52
        addSuiviAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
52
        addSuiviAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
53
        getRowActions().add(addSuiviAction);
53
        getRowActions().add(addSuiviAction);
54
 
54
 
55
        // Suivi
55
        // Suivi
56
        final RowAction.PredicateRowAction detailsAction = new RowAction.PredicateRowAction(new AbstractAction("Détails client") {
56
        final RowAction.PredicateRowAction detailsAction = new RowAction.PredicateRowAction(new AbstractAction("Détails client") {
57
 
57
 
58
            @Override
58
            @Override
59
            public void actionPerformed(ActionEvent e) {
59
            public void actionPerformed(ActionEvent e) {
60
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
60
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
61
                EditFrame frame = new EditFrame(getForeignElement("ID_CLIENT"), EditMode.READONLY);
61
                EditFrame frame = new EditFrame(getForeignElement("ID_CLIENT"), EditMode.READONLY);
62
                frame.selectionId(sRow.getForeignID("ID_CLIENT"));
62
                frame.selectionId(sRow.getForeignID("ID_CLIENT"));
63
                frame.pack();
63
                frame.pack();
64
                FrameUtil.show(frame);
64
                FrameUtil.show(frame);
65
            }
65
            }
66
        }, true) {
66
        }, true) {
67
        };
67
        };
68
        detailsAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
68
        detailsAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
69
        getRowActions().add(detailsAction);
69
        getRowActions().add(detailsAction);
70
 
70
 
71
        // Histo
71
        // Histo
72
        final RowAction.PredicateRowAction addHistoriqueAction = new RowAction.PredicateRowAction(new AbstractAction("Historique des interventions sur tickets") {
72
        final RowAction.PredicateRowAction addHistoriqueAction = new RowAction.PredicateRowAction(new AbstractAction("Historique des interventions sur tickets") {
73
 
73
 
74
            @Override
74
            @Override
75
            public void actionPerformed(ActionEvent e) {
75
            public void actionPerformed(ActionEvent e) {
76
                final SQLElement elementHisto = getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
76
                final SQLElement elementHisto = getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
77
                final ListeAddPanel panel = new ListeAddPanel(elementHisto);
77
                final ListeAddPanel panel = new ListeAddPanel(elementHisto);
78
                IListFrame frame = new IListFrame(panel);
78
                IListFrame frame = new IListFrame(panel);
79
 
79
 
80
                IListFilterDatePanel panelDate = new IListFilterDatePanel(panel.getListe(), elementHisto.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap());
80
                IListFilterDatePanel panelDate = new IListFilterDatePanel(panel.getListe(), elementHisto.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap());
81
                GridBagConstraints c = new DefaultGridBagConstraints();
81
                GridBagConstraints c = new DefaultGridBagConstraints();
82
                c.gridy = 1;
82
                c.gridy = 1;
83
                c.gridwidth = GridBagConstraints.REMAINDER;
83
                c.gridwidth = GridBagConstraints.REMAINDER;
84
                c.weightx = 1;
84
                c.weightx = 1;
85
                c.weighty = 0;
85
                c.weighty = 0;
86
                c.gridy++;
86
                c.gridy++;
87
                panel.add(panelDate, c);
87
                panel.add(panelDate, c);
88
                FrameUtil.show(frame);
88
                FrameUtil.show(frame);
89
            }
89
            }
90
        }, true) {
90
        }, true) {
91
        };
91
        };
92
        addHistoriqueAction.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
92
        addHistoriqueAction.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
93
        getRowActions().add(addHistoriqueAction);
93
        getRowActions().add(addHistoriqueAction);
94
 
94
 
-
 
95
        MouseSheetXmlListeListener l = new MouseSheetXmlListeListener(CustomerSupportTicketSheetXML.class);
-
 
96
 
-
 
97
        getRowActions().addAll(l.getRowActions());
95
    }
98
    }
96
 
99
 
97
    @Override
100
    @Override
98
    public Set<String> getReadOnlyFields() {
101
    public Set<String> getReadOnlyFields() {
99
        Set<String> s = new HashSet<String>();
102
        Set<String> s = new HashSet<String>();
100
        s.add("NUMBER");
103
        s.add("NUMBER");
101
        return s;
104
        return s;
102
    }
105
    }
103
 
106
 
104
    @Override
107
    @Override
105
    protected String createCode() {
108
    protected String createCode() {
106
        return "customersupport.ticket";
109
        return "customersupport.ticket";
107
    }
110
    }
108
 
111
 
109
    @Override
112
    @Override
110
    protected List<String> getListFields() {
113
    protected List<String> getListFields() {
111
        final List<String> l = new ArrayList<String>();
114
        final List<String> l = new ArrayList<String>();
112
        l.add("NUMBER");
115
        l.add("NUMBER");
113
        l.add("DATE");
116
        l.add("DATE");
114
        l.add("LABEL");
117
        l.add("LABEL");
115
        l.add("ID_CLIENT");
118
        l.add("ID_CLIENT");
116
        l.add("STATUS");
119
        l.add("STATUS");
117
        l.add("RATING");
120
        l.add("RATING");
118
        l.add("INFOS");
121
        l.add("INFOS");
119
        l.add("CLOSED_AND_ARCHIVED");
122
        l.add("CLOSED_AND_ARCHIVED");
120
        return l;
123
        return l;
121
    }
124
    }
122
 
125
 
123
    @Override
126
    @Override
124
    protected List<String> getComboFields() {
127
    protected List<String> getComboFields() {
125
        final List<String> l = new ArrayList<String>();
128
        final List<String> l = new ArrayList<String>();
126
        l.add("NUMBER");
129
        l.add("NUMBER");
127
        l.add("DATE");
130
        l.add("DATE");
128
        l.add("ID_CLIENT");
131
        l.add("ID_CLIENT");
129
        l.add("LABEL");
132
        l.add("LABEL");
130
        return l;
133
        return l;
131
    }
134
    }
132
 
135
 
133
    @Override
136
    @Override
134
    public ListMap<String, String> getShowAs() {
137
    public ListMap<String, String> getShowAs() {
135
        ListMap<String, String> map = new ListMap<String, String>();
138
        ListMap<String, String> map = new ListMap<String, String>();
136
        map.put(null, Arrays.asList("NUMBER", "DATE", "ID_CLIENT", "LABEL", "RATING", "STATUS"));
139
        map.put(null, Arrays.asList("NUMBER", "DATE", "ID_CLIENT", "LABEL", "RATING", "STATUS"));
137
        return map;
140
        return map;
138
    }
141
    }
139
 
142
 
140
    @Override
143
    @Override
141
    public SQLComponent createComponent() {
144
    public SQLComponent createComponent() {
142
        final String groupId = this.getCode() + ".default";
145
        final String groupId = this.getCode() + ".default";
143
        final Group group = GlobalMapper.getInstance().getGroup(groupId);
146
        final Group group = GlobalMapper.getInstance().getGroup(groupId);
144
        if (group == null) {
147
        if (group == null) {
145
            throw new IllegalStateException("No group found for id " + groupId);
148
            throw new IllegalStateException("No group found for id " + groupId);
146
        }
149
        }
147
        return createComponent(group);
150
        return createComponent(group);
148
    }
151
    }
149
 
152
 
150
    protected SQLComponent createComponent(final Group group) {
153
    protected SQLComponent createComponent(final Group group) {
151
        return new CustomerSupportTicketSQLComponent(this, group);
154
        return new CustomerSupportTicketSQLComponent(this, group);
152
    }
155
    }
153
}
156
}