Line 11... |
Line 11... |
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.action;
|
14 |
package org.openconcerto.erp.action;
|
15 |
|
15 |
|
- |
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
- |
|
17 |
import org.openconcerto.erp.utils.TM;
|
16 |
import org.openconcerto.sql.Configuration;
|
18 |
import org.openconcerto.sql.Configuration;
|
17 |
import org.openconcerto.sql.PropsConfiguration;
|
19 |
import org.openconcerto.sql.PropsConfiguration;
|
18 |
import org.openconcerto.sql.element.SQLElement;
|
20 |
import org.openconcerto.sql.element.SQLElement;
|
19 |
import org.openconcerto.sql.ui.light.LightUIFrameProvider;
|
21 |
import org.openconcerto.sql.ui.light.LightUIFrameProvider;
|
20 |
import org.openconcerto.sql.users.UserManager;
|
22 |
import org.openconcerto.sql.users.UserManager;
|
Line 33... |
Line 35... |
33 |
import org.openconcerto.ui.light.LightUIPanel;
|
35 |
import org.openconcerto.ui.light.LightUIPanel;
|
34 |
import org.openconcerto.ui.light.LightUITable;
|
36 |
import org.openconcerto.ui.light.LightUITable;
|
35 |
import org.openconcerto.ui.light.ListToolbarLine;
|
37 |
import org.openconcerto.ui.light.ListToolbarLine;
|
36 |
import org.openconcerto.ui.light.RowSelectionSpec;
|
38 |
import org.openconcerto.ui.light.RowSelectionSpec;
|
37 |
import org.openconcerto.ui.light.TableSpec;
|
39 |
import org.openconcerto.ui.light.TableSpec;
|
- |
|
40 |
import org.openconcerto.utils.StringUtils;
|
- |
|
41 |
import org.openconcerto.utils.i18n.MessageArgs;
|
- |
|
42 |
import org.openconcerto.utils.i18n.NounClass;
|
- |
|
43 |
import org.openconcerto.utils.i18n.TM.MissingMode;
|
38 |
import org.openconcerto.utils.i18n.TranslationManager;
|
44 |
import org.openconcerto.utils.i18n.TranslationManager;
|
39 |
|
45 |
|
40 |
import java.util.ArrayList;
|
46 |
import java.util.ArrayList;
|
41 |
import java.util.Collection;
|
47 |
import java.util.Collection;
|
42 |
import java.util.Iterator;
|
48 |
import java.util.Iterator;
|
43 |
import java.util.List;
|
49 |
import java.util.List;
|
44 |
|
50 |
|
- |
|
51 |
import javax.swing.JFrame;
|
- |
|
52 |
|
45 |
import org.jdom2.Document;
|
53 |
import org.jdom2.Document;
|
46 |
import org.jdom2.input.DOMBuilder;
|
54 |
import org.jdom2.input.DOMBuilder;
|
47 |
|
55 |
|
48 |
public abstract class CreateListFrameAbstractAction extends CreateFrameAbstractAction implements LightUIFrameProvider {
|
56 |
public abstract class CreateListFrameAbstractAction<E extends SQLElement, F extends JFrame> extends GenericElementFrameAction<E, F> implements LightUIFrameProvider {
|
- |
|
57 |
|
- |
|
58 |
private static final String TRANSLATION_KEY = "listMenuItem.name";
|
- |
|
59 |
private static final String[] TRANSLATION_KEY_ARRAY = new String[] { TRANSLATION_KEY };
|
- |
|
60 |
|
- |
|
61 |
private final ComptaPropsConfiguration conf;
|
- |
|
62 |
|
- |
|
63 |
protected CreateListFrameAbstractAction(final ComptaPropsConfiguration conf, final Class<? extends E> clazz) {
|
- |
|
64 |
super(conf.getDirectory().getElement(clazz));
|
- |
|
65 |
this.conf = conf;
|
- |
|
66 |
// TODO use conf to find TM
|
- |
|
67 |
final NounClass nounClass = this.getElem().getName().getNounClass();
|
- |
|
68 |
final String[] translationKeys = nounClass == null ? TRANSLATION_KEY_ARRAY : new String[] { TRANSLATION_KEY + '.' + nounClass.getName(), TRANSLATION_KEY };
|
- |
|
69 |
this.putValue(NAME, StringUtils.firstUp(TM.getTM().translateFirst(MissingMode.NULL, MessageArgs.create("elem", this.getElem().getName()), translationKeys)));
|
- |
|
70 |
}
|
- |
|
71 |
|
- |
|
72 |
public final ComptaPropsConfiguration getConf() {
|
- |
|
73 |
return this.conf;
|
- |
|
74 |
}
|
- |
|
75 |
|
- |
|
76 |
@Override
|
49 |
abstract public String getTableName();
|
77 |
protected void initFrame(F frame) {
|
- |
|
78 |
super.initFrame(frame);
|
- |
|
79 |
CreateFrameAbstractAction.initFrame(frame, this, getConf(), true);
|
- |
|
80 |
}
|
50 |
|
81 |
|
51 |
@Override
|
82 |
@Override
|
52 |
public LightUIFrame getUIFrame(PropsConfiguration configuration) {
|
83 |
public LightUIFrame getUIFrame(PropsConfiguration configuration) {
|
53 |
// Get SQLElement
|
84 |
// Get SQLElement
|
54 |
SQLElement element = configuration.getDirectory().getElement(getTableName());
|
85 |
SQLElement element = getElem();
|
55 |
final String elementCode = element.getCode();
|
86 |
final String elementCode = element.getCode();
|
56 |
|
87 |
|
57 |
// Title of frame should be the element code with .title
|
88 |
// Title of frame should be the element code with .title
|
58 |
final String frameTitle = TranslationManager.getInstance().getTranslationForItem(elementCode + ".title");
|
89 |
final String frameTitle = TranslationManager.getInstance().getTranslationForItem(elementCode + ".title");
|
59 |
|
90 |
|