180 |
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.customerrelationship.customer.element;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.sql.element.ElementSQLObject;
|
|
|
17 |
import org.openconcerto.sql.element.GroupSQLComponent;
|
|
|
18 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
19 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
20 |
import org.openconcerto.sql.model.DBRoot;
|
|
|
21 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
22 |
import org.openconcerto.ui.JLabelBold;
|
|
|
23 |
import org.openconcerto.ui.group.Group;
|
|
|
24 |
|
|
|
25 |
import java.util.ArrayList;
|
|
|
26 |
import java.util.HashSet;
|
|
|
27 |
import java.util.List;
|
|
|
28 |
import java.util.Set;
|
|
|
29 |
|
|
|
30 |
import javax.swing.JComponent;
|
|
|
31 |
import javax.swing.JLabel;
|
|
|
32 |
|
|
|
33 |
public class AgenceSQLElement extends SQLElement {
|
|
|
34 |
|
|
|
35 |
public AgenceSQLElement(DBRoot root) {
|
|
|
36 |
super(root.findTable("AGENCE"));
|
|
|
37 |
// TODO Auto-generated constructor stub
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
@Override
|
|
|
41 |
protected List<String> getListFields() {
|
|
|
42 |
List<String> list = new ArrayList<>(2);
|
|
|
43 |
|
|
|
44 |
list.add("DESIGNATION");
|
|
|
45 |
list.add("ID_CLIENT");
|
|
|
46 |
list.add("ID_ADRESSE");
|
|
|
47 |
return list;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
@Override
|
|
|
51 |
public Group getGroupForCreation() {
|
|
|
52 |
// TODO Auto-generated method stub
|
|
|
53 |
return super.getGroupForCreation();
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
@Override
|
|
|
57 |
protected SQLComponent createComponent() {
|
|
|
58 |
return new GroupSQLComponent(this, new AgenceGroup(this.getCode())) {
|
|
|
59 |
|
|
|
60 |
@Override
|
|
|
61 |
public JComponent createEditor(String id) {
|
|
|
62 |
if (id.equals("customerrelationship.customer.agency.address")) {
|
|
|
63 |
org.openconcerto.sql.element.ElementSQLObject c = (ElementSQLObject) super.createEditor(id);
|
|
|
64 |
c.setRequired(true);
|
|
|
65 |
return c;
|
|
|
66 |
}
|
|
|
67 |
if (id.equals("customerrelationship.customer.agency.customer")) {
|
|
|
68 |
ElementComboBox compClient = new ElementComboBox();
|
|
|
69 |
compClient.setVisible(false);
|
|
|
70 |
|
|
|
71 |
return compClient;
|
|
|
72 |
}
|
|
|
73 |
return super.createEditor(id);
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
@Override
|
|
|
77 |
protected Set<String> createRequiredNames() {
|
|
|
78 |
final Set<String> required = new HashSet<>();
|
|
|
79 |
required.add("customerrelationship.customer.agency.designation");
|
|
|
80 |
return required;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
@Override
|
|
|
84 |
public JComponent createLabel(String id) {
|
|
|
85 |
if (id.equals("customerrelationship.customer.agency.customer")) {
|
|
|
86 |
JLabel label = new JLabel();
|
|
|
87 |
label.setVisible(false);
|
|
|
88 |
return label;
|
|
|
89 |
}
|
|
|
90 |
if (id.equals("customerrelationship.customer.agency.grp1")) {
|
|
|
91 |
JLabel label = new JLabel();
|
|
|
92 |
label.setVisible(false);
|
|
|
93 |
return label;
|
|
|
94 |
} else if (id.equals("customerrelationship.customer.agency.address")) {
|
|
|
95 |
return new JLabelBold("Adresse de l'agence");
|
|
|
96 |
} else {
|
|
|
97 |
return super.createLabel(id);
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
};
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
@Override
|
|
|
104 |
protected String createCode() {
|
|
|
105 |
return "customerrelationship.customer.agency";
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
}
|