OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 86 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
74 ilm 1
package org.openconcerto.modules.extensionbuilder.translation.menu;
2
 
3
import java.awt.GridBagConstraints;
4
import java.awt.GridBagLayout;
5
import java.util.Locale;
6
 
7
import javax.swing.JLabel;
8
import javax.swing.JPanel;
9
import javax.swing.JSeparator;
10
import javax.swing.JTextField;
11
import javax.swing.SwingConstants;
12
 
13
import org.openconcerto.modules.extensionbuilder.Extension;
14
import org.openconcerto.modules.extensionbuilder.translation.LocaleSelector;
15
import org.openconcerto.ui.DefaultGridBagConstraints;
16
import org.openconcerto.ui.group.Item;
17
import org.openconcerto.ui.group.LayoutHints;
18
 
19
public class MenuTranslationItemEditor extends JPanel {
20
 
21
    final Extension extension;
22
    private JTextField textId;
23
    private JTextField textTranslation1;
24
    private JTextField textTranslation2;
25
 
26
    public MenuTranslationItemEditor(final Item item, final Extension extension) {
27
        this.extension = extension;
28
        this.setLayout(new GridBagLayout());
29
        GridBagConstraints c = new DefaultGridBagConstraints();
30
 
31
        c.weightx = 0;
32
        c.fill = GridBagConstraints.HORIZONTAL;
33
        this.add(new JLabel("Identifiant", SwingConstants.RIGHT), c);
34
        c.gridx++;
35
        c.fill = GridBagConstraints.HORIZONTAL;
36
        c.weightx = 1;
37
        c.gridwidth = 3;
38
        textId = new JTextField();
39
        this.add(textId, c);
40
 
41
        // Language selector
42
        c.gridx = 0;
43
        c.gridy++;
44
        c.weightx = 0;
45
        c.gridwidth = 1;
46
        c.fill = GridBagConstraints.HORIZONTAL;
47
        this.add(new JLabel("Langue et pays", SwingConstants.RIGHT), c);
48
        final String[] isoLanguages = Locale.getISOLanguages();
49
        System.out.println(isoLanguages.length);
50
 
51
        final LocaleSelector comboLang1 = new LocaleSelector();
52
 
53
        c.weightx = 1;
54
        c.gridx++;
55
        c.fill = GridBagConstraints.NONE;
56
        this.add(comboLang1, c);
57
        c.weightx = 0;
58
        c.gridx++;
59
        c.gridheight = 2;
60
        c.fill = GridBagConstraints.BOTH;
61
        final JSeparator sep = new JSeparator(JSeparator.VERTICAL);
62
        this.add(sep, c);
63
 
64
        c.gridheight = 1;
65
        c.weightx = 1;
66
        c.gridx++;
67
        c.fill = GridBagConstraints.NONE;
68
        final LocaleSelector comboLang2 = new LocaleSelector();
69
 
70
        comboLang2.setLocale(Locale.ENGLISH);
71
        this.add(comboLang2, c);
72
        // Traduction
73
        c.gridx = 0;
74
        c.gridy++;
75
 
76
        c.gridwidth = 1;
77
 
78
        c.weightx = 0;
79
        c.fill = GridBagConstraints.HORIZONTAL;
80
        this.add(new JLabel("Traduction", SwingConstants.RIGHT), c);
81
        c.gridx++;
82
 
83
        c.weightx = 1;
84
 
85
        textTranslation1 = new JTextField(20);
86
 
87
        this.add(textTranslation1, c);
88
 
89
        c.gridx += 2;
90
        c.fill = GridBagConstraints.HORIZONTAL;
91
 
92
        c.weightx = 1;
93
        textTranslation2 = new JTextField(20);
94
        this.add(textTranslation2, c);
95
 
96
        c.gridy++;
97
        c.weighty = 1;
98
        this.add(new JPanel(), c);
99
 
100
        initUIFrom(item);
101
 
102
    }
103
 
104
    private void initUIFrom(Item item) {
105
 
106
        final LayoutHints localHint = item.getLocalHint();
107
        System.out.println("ItemEditor.initUIFrom:" + item + " " + localHint);
108
        textId.setEnabled(false);
109
        if (textId != null) {
110
            textId.setText(item.getId());
111
        }
112
 
113
    }
114
}