Line 16... |
Line 16... |
16 |
*/
|
16 |
*/
|
17 |
package org.openconcerto.erp.panel;
|
17 |
package org.openconcerto.erp.panel;
|
18 |
|
18 |
|
19 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
19 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
20 |
import org.openconcerto.erp.preferences.GenerationDocGlobalPreferencePanel;
|
20 |
import org.openconcerto.erp.preferences.GenerationDocGlobalPreferencePanel;
|
- |
|
21 |
import org.openconcerto.erp.utils.TM;
|
21 |
import org.openconcerto.sql.Configuration;
|
22 |
import org.openconcerto.sql.Configuration;
|
22 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
23 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
23 |
import org.openconcerto.sql.element.SQLElement;
|
24 |
import org.openconcerto.sql.element.SQLElement;
|
24 |
import org.openconcerto.sql.model.SQLSelect;
|
25 |
import org.openconcerto.sql.model.SQLSelect;
|
25 |
import org.openconcerto.sql.model.SQLTable;
|
26 |
import org.openconcerto.sql.model.SQLTable;
|
Line 36... |
Line 37... |
36 |
import javax.swing.JLabel;
|
37 |
import javax.swing.JLabel;
|
37 |
import javax.swing.JPanel;
|
38 |
import javax.swing.JPanel;
|
38 |
|
39 |
|
39 |
public class PanelOOSQLComponent extends JPanel {
|
40 |
public class PanelOOSQLComponent extends JPanel {
|
40 |
|
41 |
|
41 |
private final JCheckBox checkImpression = new JCheckBox("Imprimer");
|
42 |
private final JCheckBox checkImpression = new JCheckBox(TM.tr("PanelOOSQLComponent.print")); //$NON-NLS-1$
|
42 |
private final JCheckBox checkVisu = new JCheckBox("Visualiser");
|
43 |
private final JCheckBox checkVisu = new JCheckBox(TM.tr("PanelOOSQLComponent.view")); //$NON-NLS-1$
|
43 |
private final JCheckBox checkAbo = new JCheckBox("Créer l'abonnement associé");
|
44 |
private final JCheckBox checkAbo = new JCheckBox(TM.tr("PanelOOSQLComponent.createSubscription")); //$NON-NLS-1$
|
44 |
|
45 |
|
45 |
public PanelOOSQLComponent(final BaseSQLComponent comp) {
|
46 |
public PanelOOSQLComponent(final BaseSQLComponent comp) {
|
46 |
super(new GridBagLayout());
|
47 |
super(new GridBagLayout());
|
47 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
48 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
48 |
c.gridx = GridBagConstraints.RELATIVE;
|
49 |
c.gridx = GridBagConstraints.RELATIVE;
|
49 |
this.setOpaque(false);
|
50 |
this.setOpaque(false);
|
50 |
|
51 |
|
51 |
final SQLTable tableComp = comp.getElement().getTable();
|
52 |
final SQLTable tableComp = comp.getElement().getTable();
|
52 |
if (tableComp.getName().equals("SAISIE_VENTE_FACTURE") && tableComp.getDBRoot().contains("ABONNEMENT")) {
|
53 |
if (tableComp.getName().equals("SAISIE_VENTE_FACTURE") && tableComp.getDBRoot().contains("ABONNEMENT")) { //$NON-NLS-1$ //$NON-NLS-2$
|
53 |
this.checkAbo.setOpaque(false);
|
54 |
this.checkAbo.setOpaque(false);
|
54 |
this.add(this.checkAbo, c);
|
55 |
this.add(this.checkAbo, c);
|
55 |
}
|
56 |
}
|
56 |
|
57 |
|
57 |
SQLPreferences prefs = SQLPreferences.getMemCached(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete());
|
58 |
SQLPreferences prefs = SQLPreferences.getMemCached(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete());
|
58 |
if (prefs.getBoolean(GenerationDocGlobalPreferencePanel.MULTIMOD, false)) {
|
59 |
if (prefs.getBoolean(GenerationDocGlobalPreferencePanel.MULTIMOD, false)) {
|
59 |
|
60 |
|
60 |
if (tableComp.getFieldsName().contains("ID_MODELE")) {
|
61 |
if (tableComp.getFieldsName().contains("ID_MODELE")) { //$NON-NLS-1$
|
61 |
String labelFor = comp.getLabelFor("ID_MODELE");
|
62 |
String labelFor = comp.getLabelFor("ID_MODELE"); //$NON-NLS-1$
|
62 |
if (labelFor == null || labelFor.trim().length() == 0) {
|
63 |
if (labelFor == null || labelFor.trim().length() == 0) {
|
63 |
labelFor = "Modéles";
|
64 |
labelFor = "Modéles"; //$NON-NLS-1$
|
64 |
}
|
65 |
}
|
65 |
JLabel labelModele = new JLabel(labelFor);
|
66 |
JLabel labelModele = new JLabel(labelFor);
|
66 |
ElementComboBox boxModele = new ElementComboBox(true, 25);
|
67 |
ElementComboBox boxModele = new ElementComboBox(true, 25);
|
67 |
SQLElement modeleElement = Configuration.getInstance().getDirectory().getElement("MODELE");
|
68 |
SQLElement modeleElement = Configuration.getInstance().getDirectory().getElement("MODELE"); //$NON-NLS-1$
|
68 |
boxModele.init(modeleElement, modeleElement.getComboRequest(true));
|
69 |
boxModele.init(modeleElement, modeleElement.getComboRequest(true));
|
69 |
comp.addView(boxModele, "ID_MODELE");
|
70 |
comp.addView(boxModele, "ID_MODELE"); //$NON-NLS-1$
|
70 |
boxModele.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
71 |
boxModele.getRequest().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
71 |
|
72 |
|
72 |
@Override
|
73 |
@Override
|
73 |
public SQLSelect transformChecked(SQLSelect input) {
|
74 |
public SQLSelect transformChecked(SQLSelect input) {
|
74 |
SQLTable table = Configuration.getInstance().getDirectory().getElement("TYPE_MODELE").getTable();
|
75 |
SQLTable table = Configuration.getInstance().getDirectory().getElement("TYPE_MODELE").getTable(); //$NON-NLS-1$
|
75 |
Where w = new Where(input.getAlias(table.getField("TABLE")), "=", tableComp.getName());
|
76 |
Where w = new Where(input.getAlias(table.getField("TABLE")), "=", tableComp.getName()); //$NON-NLS-1$ //$NON-NLS-2$
|
76 |
input.setWhere(w);
|
77 |
input.setWhere(w);
|
77 |
return input;
|
78 |
return input;
|
78 |
}
|
79 |
}
|
79 |
});
|
80 |
});
|
80 |
this.add(labelModele, c);
|
81 |
this.add(labelModele, c);
|
81 |
DefaultGridBagConstraints.lockMinimumSize(boxModele);
|
82 |
DefaultGridBagConstraints.lockMinimumSize(boxModele);
|
82 |
this.add(boxModele, c);
|
83 |
this.add(boxModele, c);
|
83 |
} else {
|
84 |
} else {
|
84 |
System.err.println("Impossible d'ajouter la combo pour le choix des modèles car le champ ID_MODELE n'est pas présent dans la table " + tableComp.getName());
|
85 |
System.err.println(TM.tr("PanelOOSQLComponent.missingField", tableComp.getName())); //$NON-NLS-1$
|
85 |
Thread.dumpStack();
|
86 |
Thread.dumpStack();
|
86 |
}
|
87 |
}
|
87 |
}
|
88 |
}
|
88 |
this.checkImpression.setOpaque(false);
|
89 |
this.checkImpression.setOpaque(false);
|
89 |
this.checkVisu.setOpaque(false);
|
90 |
this.checkVisu.setOpaque(false);
|