18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.sales.invoice.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
|
|
|
17 |
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
|
|
|
18 |
import org.openconcerto.sql.Configuration;
|
|
|
19 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
21 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
22 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
23 |
import org.openconcerto.sql.model.SQLTableListener;
|
|
|
24 |
import org.openconcerto.sql.model.Where;
|
|
|
25 |
import org.openconcerto.sql.request.ListSQLRequest;
|
|
|
26 |
import org.openconcerto.sql.view.EditFrame;
|
|
|
27 |
import org.openconcerto.sql.view.ListeAddPanel;
|
|
|
28 |
import org.openconcerto.sql.view.list.SQLTableModelColumn;
|
|
|
29 |
import org.openconcerto.sql.view.list.SQLTableModelColumnPath;
|
|
|
30 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
|
|
31 |
|
|
|
32 |
import java.awt.event.ActionEvent;
|
|
|
33 |
|
|
|
34 |
import javax.swing.JButton;
|
|
|
35 |
import javax.swing.JTable;
|
|
|
36 |
import javax.swing.SwingUtilities;
|
|
|
37 |
|
|
|
38 |
public class ListPanelEcheancesClients extends ListeAddPanel implements SQLTableListener {
|
|
|
39 |
|
|
|
40 |
// TODO Ajouter une légende dans liste echeance panel pour les couleurs du renderer
|
|
|
41 |
|
|
|
42 |
private EditFrame editFrame;
|
|
|
43 |
private boolean showRegCompta = false;
|
|
|
44 |
|
|
|
45 |
public ListPanelEcheancesClients() {
|
|
|
46 |
|
|
|
47 |
super(Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT"));
|
|
|
48 |
|
|
|
49 |
setListe();
|
|
|
50 |
SQLElement elementEch = Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT");
|
|
|
51 |
elementEch.getTable().addTableListener(this);
|
|
|
52 |
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public JTable getJTable() {
|
|
|
56 |
|
|
|
57 |
return this.getListe().getJTable();
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
public void setShowRegCompta(boolean b) {
|
|
|
61 |
this.showRegCompta = b;
|
|
|
62 |
setListe();
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
protected void handleAction(JButton source, ActionEvent e) {
|
|
|
66 |
if (source == this.buttonModifier) {
|
|
|
67 |
|
|
|
68 |
if (this.editFrame == null) {
|
|
|
69 |
this.editFrame = new EditFrame(this.element, EditFrame.MODIFICATION);
|
|
|
70 |
}
|
|
|
71 |
this.editFrame.selectionId(this.getListe().getSelectedId(), -1);
|
|
|
72 |
this.editFrame.pack();
|
|
|
73 |
this.editFrame.setVisible(true);
|
|
|
74 |
|
|
|
75 |
SQLRow ecritureRow = new EcritureSQLElement().getTable().getRow(this.getListe().getSelectedId());
|
|
|
76 |
|
|
|
77 |
MouvementSQLElement.showSource(ecritureRow.getInt("ID_MOUVEMENT"));
|
|
|
78 |
|
|
|
79 |
} else {
|
|
|
80 |
|
|
|
81 |
super.handleAction(source, e);
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
public void rowAdded(SQLTable table, int id) {
|
|
|
86 |
// TODO Auto-generated method stub
|
|
|
87 |
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public void rowDeleted(SQLTable table, int id) {
|
|
|
91 |
// TODO Auto-generated method stub
|
|
|
92 |
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public void rowModified(SQLTable table, int id) {
|
|
|
96 |
setListe();
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
private void setListe() {
|
|
|
100 |
SwingUtilities.invokeLater(new Runnable() {
|
|
|
101 |
@Override
|
|
|
102 |
public void run() {
|
|
|
103 |
|
|
|
104 |
final SQLElement elementEch = Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT");
|
|
|
105 |
Where wNotRegle = new Where(elementEch.getTable().getField("REGLE"), "=", Boolean.FALSE);
|
|
|
106 |
if (!showRegCompta) {
|
|
|
107 |
wNotRegle = wNotRegle.and(new Where(elementEch.getTable().getField("REG_COMPTA"), "=", Boolean.FALSE));
|
|
|
108 |
}
|
|
|
109 |
ListPanelEcheancesClients.this.setRequest(ListSQLRequest.copy(elementEch.getListRequest(), wNotRegle));
|
|
|
110 |
|
|
|
111 |
// this.buttonAjouter.setVisible(false);
|
|
|
112 |
final ListEcheanceClientRenderer rend = new ListEcheanceClientRenderer();
|
|
|
113 |
for (int i = 0; i < ListPanelEcheancesClients.this.getListe().getJTable().getColumnCount(); i++) {
|
|
|
114 |
if (ListPanelEcheancesClients.this.getListe().getJTable().getColumnClass(i) != Boolean.class) {
|
|
|
115 |
|
|
|
116 |
ListPanelEcheancesClients.this.getListe().getJTable().getColumnModel().getColumn(i).setCellRenderer(rend);
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
// this.getListe().setSQLEditable(false);
|
|
|
120 |
ListPanelEcheancesClients.this.buttonAjouter.setVisible(false);
|
|
|
121 |
ListPanelEcheancesClients.this.buttonEffacer.setVisible(false);
|
|
|
122 |
ListPanelEcheancesClients.this.buttonModifier.setVisible(false);
|
|
|
123 |
|
|
|
124 |
final SQLTableModelSourceOnline src = (SQLTableModelSourceOnline) ListPanelEcheancesClients.this.getListe().getModel().getReq();
|
|
|
125 |
|
|
|
126 |
ListPanelEcheancesClients.this.getListe().setSQLEditable(true);
|
|
|
127 |
|
|
|
128 |
for (SQLTableModelColumn column : src.getColumns()) {
|
|
|
129 |
if (column.getClass().isAssignableFrom(SQLTableModelColumnPath.class)) {
|
|
|
130 |
((SQLTableModelColumnPath) column).setEditable(false);
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
((SQLTableModelColumnPath) src.getColumns(getElement().getTable().getField("INFOS")).iterator().next()).setEditable(true);
|
|
|
135 |
|
|
|
136 |
}
|
|
|
137 |
});
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
@Override
|
|
|
141 |
public SQLComponent getModifComp() {
|
|
|
142 |
// TODO Auto-generated method stub
|
|
|
143 |
return null;
|
|
|
144 |
}
|
|
|
145 |
}
|