Line 15... |
Line 15... |
15 |
|
15 |
|
16 |
import javax.swing.JLabel;
|
16 |
import javax.swing.JLabel;
|
17 |
import javax.swing.JPanel;
|
17 |
import javax.swing.JPanel;
|
18 |
import javax.swing.JSpinner;
|
18 |
import javax.swing.JSpinner;
|
19 |
import javax.swing.SpinnerNumberModel;
|
19 |
import javax.swing.SpinnerNumberModel;
|
- |
|
20 |
import javax.swing.SwingWorker;
|
20 |
import javax.swing.event.ChangeEvent;
|
21 |
import javax.swing.event.ChangeEvent;
|
21 |
import javax.swing.event.ChangeListener;
|
22 |
import javax.swing.event.ChangeListener;
|
22 |
|
23 |
|
23 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
24 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
24 |
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
|
25 |
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
|
Line 31... |
Line 32... |
31 |
import org.openconcerto.sql.model.Where;
|
32 |
import org.openconcerto.sql.model.Where;
|
32 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
33 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
33 |
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
|
34 |
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
|
34 |
import org.openconcerto.sql.view.IListPanel;
|
35 |
import org.openconcerto.sql.view.IListPanel;
|
35 |
import org.openconcerto.sql.view.list.IListe;
|
36 |
import org.openconcerto.sql.view.list.IListe;
|
36 |
import org.openconcerto.utils.SwingWorker2;
|
- |
|
37 |
import org.openconcerto.utils.cc.ITransformer;
|
37 |
import org.openconcerto.utils.cc.ITransformer;
|
38 |
|
38 |
|
39 |
public class OperationHistoryPanel extends JPanel {
|
39 |
public class OperationHistoryPanel extends JPanel {
|
40 |
OperationHistoryPanel() {
|
40 |
OperationHistoryPanel() {
|
41 |
this.setLayout(new GridLayout(1, 1));
|
41 |
this.setLayout(new GridLayout(1, 1));
|
42 |
final SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
42 |
final SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
|
43 |
final Map<String, List<String>> mapList = new HashMap<String, List<String>>();
|
43 |
final Map<String, List<String>> mapList = new HashMap<>();
|
44 |
mapList.put("Interventions", Arrays.asList("OPERATION"));
|
44 |
mapList.put("Interventions", Arrays.asList("OPERATION"));
|
45 |
|
45 |
|
46 |
final Map<SQLTable, SQLField> map = new HashMap<SQLTable, SQLField>();
|
46 |
final Map<SQLTable, SQLField> map = new HashMap<>();
|
47 |
final ComboSQLRequest comboRequest = JListSQLTablePanel.createComboRequest(Configuration.getInstance().getDirectory().getElement(b.getTable("SITE")), true);
|
47 |
final ComboSQLRequest comboRequest = JListSQLTablePanel.createComboRequest(Configuration.getInstance().getDirectory().getElement(b.getTable("SITE")), true);
|
48 |
|
48 |
|
49 |
JPanel panel = new JPanel();
|
49 |
JPanel panel = new JPanel();
|
50 |
panel.add(new JLabel("Année"));
|
50 |
panel.add(new JLabel("Année"));
|
51 |
int year = Calendar.getInstance().get(Calendar.YEAR);
|
51 |
int year = Calendar.getInstance().get(Calendar.YEAR);
|
Line 71... |
Line 71... |
71 |
@Override
|
71 |
@Override
|
72 |
public void propertyChange(PropertyChangeEvent evt) {
|
72 |
public void propertyChange(PropertyChangeEvent evt) {
|
73 |
final List<SQLRowValues> selectedRows = list.getSelectedRows();
|
73 |
final List<SQLRowValues> selectedRows = list.getSelectedRows();
|
74 |
final IListPanel listePanel = listHistoriquePanel.getListePanel(0);
|
74 |
final IListPanel listePanel = listHistoriquePanel.getListePanel(0);
|
75 |
if (selectedRows != null && !selectedRows.isEmpty()) {
|
75 |
if (selectedRows != null && !selectedRows.isEmpty()) {
|
76 |
final Set<Long> idsCalendarItemGroup = new HashSet<Long>();
|
76 |
final Set<Long> idsCalendarItemGroup = new HashSet<>();
|
77 |
for (SQLRowValues sqlRowValues : selectedRows) {
|
77 |
for (SQLRowValues sqlRowValues : selectedRows) {
|
78 |
idsCalendarItemGroup.add(Long.valueOf(sqlRowValues.getForeign("ID_CALENDAR_ITEM_GROUP").getID()));
|
78 |
idsCalendarItemGroup.add(Long.valueOf(sqlRowValues.getForeign("ID_CALENDAR_ITEM_GROUP").getID()));
|
79 |
}
|
79 |
}
|
80 |
final SQLTable table = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CALENDAR_ITEM");
|
80 |
final SQLTable table = ((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CALENDAR_ITEM");
|
81 |
final SQLField flag = table.getField("FLAGS");
|
81 |
final SQLField flag = table.getField("FLAGS");
|
Line 85... |
Line 85... |
85 |
select.addSelect(group);
|
85 |
select.addSelect(group);
|
86 |
Where where = new Where(group, idsCalendarItemGroup).and(new Where(flag, "LIKE", "%locked%"));
|
86 |
Where where = new Where(group, idsCalendarItemGroup).and(new Where(flag, "LIKE", "%locked%"));
|
87 |
|
87 |
|
88 |
select.setWhere(where);
|
88 |
select.setWhere(where);
|
89 |
|
89 |
|
90 |
final SwingWorker2<Boolean, String> w = new SwingWorker2<Boolean, String>() {
|
90 |
final SwingWorker<Boolean, String> w = new SwingWorker<Boolean, String>() {
|
91 |
|
91 |
|
92 |
@Override
|
92 |
@Override
|
93 |
protected Boolean doInBackground() throws Exception {
|
93 |
protected Boolean doInBackground() throws Exception {
|
94 |
@SuppressWarnings("rawtypes")
|
94 |
@SuppressWarnings("rawtypes")
|
95 |
final List l = b.getDataSource().execute(select.asString());
|
95 |
final List l = b.getDataSource().execute(select.asString());
|
96 |
return l.isEmpty();
|
96 |
return l.isEmpty();
|
97 |
}
|
97 |
}
|
98 |
|
98 |
|
- |
|
99 |
@Override
|
99 |
protected void done() {
|
100 |
protected void done() {
|
100 |
Boolean b;
|
101 |
Boolean b;
|
101 |
try {
|
102 |
try {
|
102 |
b = get();
|
103 |
b = get();
|
103 |
listePanel.setModifyVisible(b);
|
104 |
listePanel.setModifyVisible(b);
|
Line 106... |
Line 107... |
106 |
e.printStackTrace();
|
107 |
e.printStackTrace();
|
107 |
} catch (ExecutionException e) {
|
108 |
} catch (ExecutionException e) {
|
108 |
e.printStackTrace();
|
109 |
e.printStackTrace();
|
109 |
}
|
110 |
}
|
110 |
|
111 |
|
111 |
};
|
112 |
}
|
112 |
};
|
113 |
};
|
113 |
w.execute();
|
114 |
w.execute();
|
114 |
|
115 |
|
115 |
}
|
116 |
}
|
116 |
|
117 |
|