OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 139 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 139 Rev 181
Line 62... Line 62...
62
        c.gridx++;
62
        c.gridx++;
63
        c.gridheight = 3;
63
        c.gridheight = 3;
64
        c.fill = GridBagConstraints.BOTH;
64
        c.fill = GridBagConstraints.BOTH;
65
        final JSeparator sep = new JSeparator(JSeparator.VERTICAL);
65
        final JSeparator sep = new JSeparator(JSeparator.VERTICAL);
66
        this.add(sep, c);
66
        this.add(sep, c);
67
        hideableComponents.add(sep);
67
        this.hideableComponents.add(sep);
68
        c.gridheight = 1;
68
        c.gridheight = 1;
69
        c.weightx = 1;
69
        c.weightx = 1;
70
        c.gridx++;
70
        c.gridx++;
71
        c.fill = GridBagConstraints.NONE;
71
        c.fill = GridBagConstraints.NONE;
72
        final LocaleSelector comboLang2 = new LocaleSelector();
72
        final LocaleSelector comboLang2 = new LocaleSelector();
73
        hideableComponents.add(comboLang2);
73
        this.hideableComponents.add(comboLang2);
74
        comboLang2.setLocale(Locale.ENGLISH);
74
        comboLang2.setLocale(Locale.ENGLISH);
75
        this.add(comboLang2, c);
75
        this.add(comboLang2, c);
76
        // Singular
76
        // Singular
77
        c.gridx = 0;
77
        c.gridx = 0;
78
        c.gridy++;
78
        c.gridy++;
79
        c.weightx = 0;
79
        c.weightx = 0;
80
        c.fill = GridBagConstraints.HORIZONTAL;
80
        c.fill = GridBagConstraints.HORIZONTAL;
81
        this.add(new JLabel("Singulier", SwingConstants.RIGHT), c);
81
        this.add(new JLabel("Singulier", SwingConstants.RIGHT), c);
82
        c.gridx++;
82
        c.gridx++;
83
 
83
 
84
        this.add(textSingular1, c);
84
        this.add(this.textSingular1, c);
85
        c.gridx += 2;
85
        c.gridx += 2;
86
        hideableComponents.add(textSingular2);
86
        this.hideableComponents.add(this.textSingular2);
87
        this.add(textSingular2, c);
87
        this.add(this.textSingular2, c);
88
 
88
 
89
        // Plural
89
        // Plural
90
        c.gridx = 0;
90
        c.gridx = 0;
91
        c.gridy++;
91
        c.gridy++;
92
        c.weightx = 0;
92
        c.weightx = 0;
93
        this.add(new JLabel("Pluriel", SwingConstants.RIGHT), c);
93
        this.add(new JLabel("Pluriel", SwingConstants.RIGHT), c);
94
        c.gridx++;
94
        c.gridx++;
95
        this.add(textPlural1, c);
95
        this.add(this.textPlural1, c);
96
        c.gridx += 2;
96
        c.gridx += 2;
97
        hideableComponents.add(textPlural2);
97
        this.hideableComponents.add(this.textPlural2);
98
        this.add(textPlural2, c);
98
        this.add(this.textPlural2, c);
99
 
99
 
100
        // Fields
100
        // Fields
101
        c.gridx = 0;
101
        c.gridx = 0;
102
        c.gridy++;
102
        c.gridy++;
103
        c.gridwidth = 2;
103
        c.gridwidth = 2;
Line 109... Line 109...
109
        c.gridy++;
109
        c.gridy++;
110
        c.gridheight = fieldsName.size();
110
        c.gridheight = fieldsName.size();
111
        c.gridx = 2;
111
        c.gridx = 2;
112
        c.fill = GridBagConstraints.BOTH;
112
        c.fill = GridBagConstraints.BOTH;
113
        final JSeparator sep2 = new JSeparator(JSeparator.VERTICAL);
113
        final JSeparator sep2 = new JSeparator(JSeparator.VERTICAL);
114
        hideableComponents.add(sep2);
114
        this.hideableComponents.add(sep2);
115
        this.add(sep2, c);
115
        this.add(sep2, c);
116
 
116
 
117
        c.fill = GridBagConstraints.HORIZONTAL;
117
        c.fill = GridBagConstraints.HORIZONTAL;
118
        c.gridheight = 1;
118
        c.gridheight = 1;
119
        for (String fName : fieldsName) {
119
        for (String fName : fieldsName) {
120
            c.gridx = 0;
120
            c.gridx = 0;
121
            c.weightx = 0;
121
            c.weightx = 0;
122
            this.add(new JLabel(fName, SwingConstants.RIGHT), c);
122
            this.add(new JLabel(fName, SwingConstants.RIGHT), c);
123
            c.gridx++;
123
            c.gridx++;
124
            final JTextField t1 = new JTextField();
124
            final JTextField t1 = new JTextField();
125
            map1.put(fName, t1);
125
            this.map1.put(fName, t1);
126
            fieldsMap.put(t1, fName);
126
            this.fieldsMap.put(t1, fName);
127
            this.add(t1, c);
127
            this.add(t1, c);
128
            c.gridx += 2;
128
            c.gridx += 2;
129
            final JTextField t2 = new JTextField();
129
            final JTextField t2 = new JTextField();
130
            hideableComponents.add(t2);
130
            this.hideableComponents.add(t2);
131
            fieldsMap.put(t2, fName);
131
            this.fieldsMap.put(t2, fName);
132
            map2.put(fName, t2);
132
            this.map2.put(fName, t2);
133
            this.add(t2, c);
133
            this.add(t2, c);
134
            c.gridy++;
134
            c.gridy++;
135
        }
135
        }
136
        c.gridx = 0;
136
        c.gridx = 0;
137
        c.gridy++;
137
        c.gridy++;
Line 187... Line 187...
187
            public void changedUpdate(DocumentEvent e, String text) {
187
            public void changedUpdate(DocumentEvent e, String text) {
188
                extension.setTablePluralTranslation(tableName, comboLang2.getLocale(), text);
188
                extension.setTablePluralTranslation(tableName, comboLang2.getLocale(), text);
189
            }
189
            }
190
 
190
 
191
        });
191
        });
192
        for (final JTextField textField : map1.values()) {
192
        for (final JTextField textField : this.map1.values()) {
193
            textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
193
            textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
194
 
194
 
195
                @Override
195
                @Override
196
                public void changedUpdate(DocumentEvent e, String text) {
196
                public void changedUpdate(DocumentEvent e, String text) {
197
                    extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang1.getLocale(), text);
197
                    extension.setFieldTranslation(tableName, TableTranslationEditorPanel.this.fieldsMap.get(textField), comboLang1.getLocale(), text);
198
                }
198
                }
199
 
199
 
200
            });
200
            });
201
        }
201
        }
202
        for (final JTextField textField : map2.values()) {
202
        for (final JTextField textField : this.map2.values()) {
203
            textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
203
            textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
204
 
204
 
205
                @Override
205
                @Override
206
                public void changedUpdate(DocumentEvent e, String text) {
206
                public void changedUpdate(DocumentEvent e, String text) {
207
                    extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang2.getLocale(), text);
207
                    extension.setFieldTranslation(tableName, TableTranslationEditorPanel.this.fieldsMap.get(textField), comboLang2.getLocale(), text);
208
                }
208
                }
209
 
209
 
210
            });
210
            });
211
        }
211
        }
212
 
212
 
213
    }
213
    }
214
 
214
 
215
    private void updateUIFrom(Extension extension, String tableName, Object l1, Object l2) {
215
    private void updateUIFrom(Extension extension, String tableName, Object l1, Object l2) {
216
        if (l1 != null) {
216
        if (l1 != null) {
217
            final String lang = l1.toString();
217
            final String lang = l1.toString();
218
            updateUI(extension, tableName, lang, textSingular1, textPlural1, map1);
218
            updateUI(extension, tableName, lang, this.textSingular1, this.textPlural1, this.map1);
219
        }
219
        }
220
        if (l2 != null) {
220
        if (l2 != null) {
221
            final String lang = l2.toString();
221
            final String lang = l2.toString();
222
            updateUI(extension, tableName, lang, textSingular2, textPlural2, map2);
222
            updateUI(extension, tableName, lang, this.textSingular2, this.textPlural2, this.map2);
223
        }
223
        }
224
 
224
 
225
    }
225
    }
226
 
226
 
227
    private void updateUI(Extension extension, String tableName, final String lang, JTextField textSingular, JTextField textPlural, Map<String, JTextField> map) {
227
    private void updateUI(Extension extension, String tableName, final String lang, JTextField textSingular, JTextField textPlural, Map<String, JTextField> map) {