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