Line 21... |
Line 21... |
21 |
import org.openconcerto.sql.request.RowItemDesc;
|
21 |
import org.openconcerto.sql.request.RowItemDesc;
|
22 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
22 |
import org.openconcerto.sql.view.EditPanel.EditMode;
|
23 |
import org.openconcerto.ui.group.Group;
|
23 |
import org.openconcerto.ui.group.Group;
|
24 |
import org.openconcerto.ui.group.Item;
|
24 |
import org.openconcerto.ui.group.Item;
|
25 |
import org.openconcerto.ui.group.LayoutHints;
|
25 |
import org.openconcerto.ui.group.LayoutHints;
|
26 |
import org.openconcerto.ui.light.CustomEditorProvider;
|
- |
|
27 |
import org.openconcerto.ui.light.LightUIAutoCompleteComboBox;
|
26 |
import org.openconcerto.ui.light.LightUIAutoCompleteComboBox;
|
28 |
import org.openconcerto.ui.light.LightUICheckBox;
|
27 |
import org.openconcerto.ui.light.LightUICheckBox;
|
29 |
import org.openconcerto.ui.light.LightUIDate;
|
28 |
import org.openconcerto.ui.light.LightUIDate;
|
30 |
import org.openconcerto.ui.light.LightUIElement;
|
29 |
import org.openconcerto.ui.light.LightUIElement;
|
31 |
import org.openconcerto.ui.light.LightUIFrame;
|
30 |
import org.openconcerto.ui.light.LightUIFrame;
|
Line 41... |
Line 40... |
41 |
import java.math.BigDecimal;
|
40 |
import java.math.BigDecimal;
|
42 |
import java.math.BigInteger;
|
41 |
import java.math.BigInteger;
|
43 |
import java.sql.Timestamp;
|
42 |
import java.sql.Timestamp;
|
44 |
import java.util.Date;
|
43 |
import java.util.Date;
|
45 |
import java.util.HashMap;
|
44 |
import java.util.HashMap;
|
- |
|
45 |
import java.util.List;
|
46 |
import java.util.Map;
|
46 |
import java.util.Map;
|
47 |
|
47 |
|
48 |
public class GroupToLightUIConvertor {
|
48 |
public class GroupToLightUIConvertor {
|
49 |
private final int maxColumnCount;
|
49 |
private final int maxColumnCount;
|
50 |
private PropsConfiguration configuration;
|
50 |
private PropsConfiguration configuration;
|
51 |
private FieldMapper mapper;
|
51 |
private FieldMapper mapper;
|
52 |
private Map<String, CustomEditorProvider> customEditorProviders = new HashMap<String, CustomEditorProvider>();
|
52 |
private Map<String, CustomRowEditor> customRowEditors = new HashMap<>();
|
53 |
|
53 |
|
54 |
public GroupToLightUIConvertor(PropsConfiguration conf) {
|
54 |
public GroupToLightUIConvertor(PropsConfiguration conf) {
|
55 |
this(conf, 4);
|
55 |
this(conf, 4);
|
56 |
}
|
56 |
}
|
57 |
|
57 |
|
Line 71... |
Line 71... |
71 |
if (defaultRow == null) {
|
71 |
if (defaultRow == null) {
|
72 |
throw new IllegalArgumentException("Null default SQLRowValues");
|
72 |
throw new IllegalArgumentException("Null default SQLRowValues");
|
73 |
}
|
73 |
}
|
74 |
|
74 |
|
75 |
final SQLElement sqlElement = this.configuration.getDirectory().getElement(defaultRow.getTable());
|
75 |
final SQLElement sqlElement = this.configuration.getDirectory().getElement(defaultRow.getTable());
|
- |
|
76 |
if (sqlElement == null) {
|
- |
|
77 |
throw new IllegalArgumentException("not SQLElement found for default row table : " + defaultRow.getTable().getName());
|
- |
|
78 |
}
|
- |
|
79 |
if (sqlElement.getGroupForCreation() == null) {
|
- |
|
80 |
throw new IllegalArgumentException("no group for creation defined in " + sqlElement.getClass().getName());
|
- |
|
81 |
}
|
- |
|
82 |
if (sqlElement.getGroupForModification() == null) {
|
- |
|
83 |
throw new IllegalArgumentException("no group for creation defined in " + sqlElement.getClass().getName());
|
- |
|
84 |
}
|
76 |
if (!sqlElement.getGroupForCreation().equals(group) && sqlElement.getGroupForModification().equals(group)) {
|
85 |
if (!sqlElement.getGroupForCreation().equals(group) && sqlElement.getGroupForModification().equals(group)) {
|
77 |
throw new IllegalArgumentException("This group isn't attached to this SQLElement, group ID: " + group.getId() + " element code: " + sqlElement.getCode());
|
86 |
throw new IllegalArgumentException("This group isn't attached to this SQLElement, group ID: " + group.getId() + " element code: " + sqlElement.getCode());
|
78 |
}
|
87 |
}
|
79 |
|
88 |
|
80 |
final LightEditFrame editFrame = new LightEditFrame(this.configuration, group, defaultRow.asRowValues(), parentFrame, editMode);
|
89 |
final LightEditFrame editFrame = new LightEditFrame(this.configuration, group, defaultRow.asRowValues(), parentFrame, editMode);
|
Line 311... |
Line 320... |
311 |
}
|
320 |
}
|
312 |
return label;
|
321 |
return label;
|
313 |
}
|
322 |
}
|
314 |
|
323 |
|
315 |
private LightUIElement getCustomEditor(final String id) {
|
324 |
private LightUIElement getCustomEditor(final String id) {
|
- |
|
325 |
if (id == null) {
|
- |
|
326 |
throw new IllegalArgumentException("null id");
|
- |
|
327 |
}
|
316 |
final CustomEditorProvider customEditorProvider = this.customEditorProviders.get(id);
|
328 |
final CustomRowEditor customEditorProvider = this.customRowEditors.get(id);
|
317 |
if (customEditorProvider != null) {
|
329 |
if (customEditorProvider != null) {
|
318 |
final LightUIElement element = customEditorProvider.createUIElement(id);
|
330 |
final LightUIElement element = customEditorProvider.createUIElement();
|
319 |
if (element.getId() == null) {
|
331 |
if (element.getId() == null) {
|
320 |
throw new IllegalStateException("Null id for custom editor for id: " + id);
|
332 |
throw new IllegalStateException("Null id for custom editor for id: " + id + " element : " + element);
|
321 |
}
|
333 |
}
|
322 |
return element;
|
334 |
return element;
|
323 |
}
|
335 |
}
|
324 |
return null;
|
336 |
return null;
|
325 |
}
|
337 |
}
|
326 |
|
338 |
|
327 |
public void putCustomEditorProvider(final String id, final CustomEditorProvider provider) {
|
339 |
public void putCustomEditorProvider(final CustomRowEditor e) {
|
328 |
this.customEditorProviders.put(id, provider);
|
340 |
this.customRowEditors.put(e.getItemId(), e);
|
329 |
}
|
341 |
}
|
330 |
|
342 |
|
331 |
public void putAllCustomEditorProvider(final Map<String, CustomEditorProvider> map) {
|
343 |
public void putAllCustomEditorProvider(final List<CustomRowEditor> editors) {
|
- |
|
344 |
for (CustomRowEditor e : editors)
|
332 |
this.customEditorProviders.putAll(map);
|
345 |
this.customRowEditors.put(e.getItemId(), e);
|
333 |
}
|
346 |
}
|
334 |
}
|
347 |
}
|