OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 139 → Rev 181

/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/LocaleSelector.java
36,10 → 36,10
}
 
Collections.sort(langs);
comboLang = new JComboBox(langs);
this.add(comboLang);
comboCountry = new JComboBox();
this.add(comboCountry);
this.comboLang = new JComboBox(langs);
this.add(this.comboLang);
this.comboCountry = new JComboBox();
this.add(this.comboCountry);
 
try {
this.setLocale(Locale.getDefault());
46,36 → 46,36
} catch (Exception e) {
System.err.println("LocaleSelector warning: unable to set current language");
}
comboLang.addActionListener(new ActionListener() {
this.comboLang.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
if (interactive) {
lang = comboLang.getSelectedItem().toString();
if (LocaleSelector.this.interactive) {
LocaleSelector.this.lang = LocaleSelector.this.comboLang.getSelectedItem().toString();
updateCountryFromLang();
country = comboCountry.getSelectedItem().toString();
LocaleSelector.this.country = LocaleSelector.this.comboCountry.getSelectedItem().toString();
fireActionPerformed();
}
}
 
});
comboCountry.addActionListener(new ActionListener() {
this.comboCountry.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
if (interactive) {
country = comboCountry.getSelectedItem().toString();
if (LocaleSelector.this.interactive) {
LocaleSelector.this.country = LocaleSelector.this.comboCountry.getSelectedItem().toString();
fireActionPerformed();
}
}
 
});
final int minWidth = comboLang.getPreferredSize().width * 2;
final int minHeight = comboLang.getPreferredSize().height;
comboLang.setMinimumSize(new Dimension(minWidth, minHeight));
comboLang.setPreferredSize(new Dimension(minWidth, minHeight));
comboCountry.setMinimumSize(new Dimension(minWidth, minHeight));
comboCountry.setPreferredSize(new Dimension(minWidth, minHeight));
final int minWidth = this.comboLang.getPreferredSize().width * 2;
final int minHeight = this.comboLang.getPreferredSize().height;
this.comboLang.setMinimumSize(new Dimension(minWidth, minHeight));
this.comboLang.setPreferredSize(new Dimension(minWidth, minHeight));
this.comboCountry.setMinimumSize(new Dimension(minWidth, minHeight));
this.comboCountry.setPreferredSize(new Dimension(minWidth, minHeight));
}
 
private void updateCountryFromLang() {
84,7 → 84,7
Locale[] l = Locale.getAvailableLocales();
for (int i = 0; i < l.length; i++) {
Locale lo = (Locale) l[i];
if (lo.getLanguage().equals(lang)) {
if (lo.getLanguage().equals(this.lang)) {
countries.add(lo.getCountry());
}
}
92,16 → 92,16
if (countries.isEmpty()) {
countries.add("");
}
comboCountry.setModel(new DefaultComboBoxModel(countries));
this.comboCountry.setModel(new DefaultComboBoxModel(countries));
}
 
public Locale getLocale() {
Locale[] l = Locale.getAvailableLocales();
if (country != null) {
if (this.country != null) {
 
for (int i = 0; i < l.length; i++) {
Locale lo = (Locale) l[i];
if (lo.getLanguage().equals(lang) && lo.getCountry().equals(country)) {
if (lo.getLanguage().equals(this.lang) && lo.getCountry().equals(this.country)) {
return lo;
}
}
108,7 → 108,7
}
for (int i = 0; i < l.length; i++) {
Locale lo = (Locale) l[i];
if (lo.getLanguage().equals(lang)) {
if (lo.getLanguage().equals(this.lang)) {
return lo;
}
}
126,9 → 126,9
this.lang = l.getLanguage();
this.country = l.getCountry();
System.err.println("LocaleSelector.setLocale() " + this.lang + " " + this.country);
this.comboLang.setSelectedItem(lang);
this.comboLang.setSelectedItem(this.lang);
updateCountryFromLang();
this.comboCountry.setSelectedItem(country);
this.comboCountry.setSelectedItem(this.country);
this.interactive = true;
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/TableTranslationEditorPanel.java
64,13 → 64,13
c.fill = GridBagConstraints.BOTH;
final JSeparator sep = new JSeparator(JSeparator.VERTICAL);
this.add(sep, c);
hideableComponents.add(sep);
this.hideableComponents.add(sep);
c.gridheight = 1;
c.weightx = 1;
c.gridx++;
c.fill = GridBagConstraints.NONE;
final LocaleSelector comboLang2 = new LocaleSelector();
hideableComponents.add(comboLang2);
this.hideableComponents.add(comboLang2);
comboLang2.setLocale(Locale.ENGLISH);
this.add(comboLang2, c);
// Singular
81,10 → 81,10
this.add(new JLabel("Singulier", SwingConstants.RIGHT), c);
c.gridx++;
 
this.add(textSingular1, c);
this.add(this.textSingular1, c);
c.gridx += 2;
hideableComponents.add(textSingular2);
this.add(textSingular2, c);
this.hideableComponents.add(this.textSingular2);
this.add(this.textSingular2, c);
 
// Plural
c.gridx = 0;
92,10 → 92,10
c.weightx = 0;
this.add(new JLabel("Pluriel", SwingConstants.RIGHT), c);
c.gridx++;
this.add(textPlural1, c);
this.add(this.textPlural1, c);
c.gridx += 2;
hideableComponents.add(textPlural2);
this.add(textPlural2, c);
this.hideableComponents.add(this.textPlural2);
this.add(this.textPlural2, c);
 
// Fields
c.gridx = 0;
111,7 → 111,7
c.gridx = 2;
c.fill = GridBagConstraints.BOTH;
final JSeparator sep2 = new JSeparator(JSeparator.VERTICAL);
hideableComponents.add(sep2);
this.hideableComponents.add(sep2);
this.add(sep2, c);
 
c.fill = GridBagConstraints.HORIZONTAL;
122,14 → 122,14
this.add(new JLabel(fName, SwingConstants.RIGHT), c);
c.gridx++;
final JTextField t1 = new JTextField();
map1.put(fName, t1);
fieldsMap.put(t1, fName);
this.map1.put(fName, t1);
this.fieldsMap.put(t1, fName);
this.add(t1, c);
c.gridx += 2;
final JTextField t2 = new JTextField();
hideableComponents.add(t2);
fieldsMap.put(t2, fName);
map2.put(fName, t2);
this.hideableComponents.add(t2);
this.fieldsMap.put(t2, fName);
this.map2.put(fName, t2);
this.add(t2, c);
c.gridy++;
}
189,22 → 189,22
}
 
});
for (final JTextField textField : map1.values()) {
for (final JTextField textField : this.map1.values()) {
textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang1.getLocale(), text);
extension.setFieldTranslation(tableName, TableTranslationEditorPanel.this.fieldsMap.get(textField), comboLang1.getLocale(), text);
}
 
});
}
for (final JTextField textField : map2.values()) {
for (final JTextField textField : this.map2.values()) {
textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang2.getLocale(), text);
extension.setFieldTranslation(tableName, TableTranslationEditorPanel.this.fieldsMap.get(textField), comboLang2.getLocale(), text);
}
 
});
215,11 → 215,11
private void updateUIFrom(Extension extension, String tableName, Object l1, Object l2) {
if (l1 != null) {
final String lang = l1.toString();
updateUI(extension, tableName, lang, textSingular1, textPlural1, map1);
updateUI(extension, tableName, lang, this.textSingular1, this.textPlural1, this.map1);
}
if (l2 != null) {
final String lang = l2.toString();
updateUI(extension, tableName, lang, textSingular2, textPlural2, map2);
updateUI(extension, tableName, lang, this.textSingular2, this.textPlural2, this.map2);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/FieldTranslation.java
21,19 → 21,19
}
 
public String getTableName() {
return tableName;
return this.tableName;
}
 
public String getFieldName() {
return fieldName;
return this.fieldName;
}
 
public String getLabel() {
return label;
return this.label;
}
 
public String getDocumentation() {
return documentation;
return this.documentation;
}
 
public void setDocumentation(String documentation) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/TableTranslation.java
14,7 → 14,7
}
 
public String getTableName() {
return tableName;
return this.tableName;
}
 
public void setSingular(String singular) {
22,7 → 22,7
}
 
public String getSingular() {
return singular;
return this.singular;
}
 
public void setPlural(String plural) {
30,6 → 30,6
}
 
public String getPlural() {
return plural;
return this.plural;
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/TableTranslationPanel.java
10,20 → 10,20
 
public TableTranslationPanel(Extension extension) {
super(extension);
split.setDividerLocation(250);
this.split.setDividerLocation(250);
}
 
public void setRightPanel(JComponent p) {
super.setRightPanel(p);
split.setDividerLocation(250);
this.split.setDividerLocation(250);
}
 
@Override
public JComponent createLeftComponent() {
return new AllTableListPanel(extension, this);
return new AllTableListPanel(this.extension, this);
}
 
public void select(TableDescritor tableDescriptor) {
((AllTableListPanel) leftComponent).selectItem(tableDescriptor);
((AllTableListPanel) this.leftComponent).selectItem(tableDescriptor);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/AllTableListPanel.java
32,9 → 32,9
@Override
public void itemSelected(Object item) {
if (item != null) {
tableTranslationPanel.setRightPanel(new JScrollPane(new TableTranslationEditorPanel(extension, (String) item)));
this.tableTranslationPanel.setRightPanel(new JScrollPane(new TableTranslationEditorPanel(this.extension, (String) item)));
} else {
tableTranslationPanel.setRightPanel(new JPanel());
this.tableTranslationPanel.setRightPanel(new JPanel());
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/menu/MenuTranslation.java
13,7 → 13,7
}
 
public String getId() {
return id;
return this.id;
}
 
public void setLabel(String label) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/menu/MenuTranslationPanel.java
36,9 → 36,9
}
 
public void fillModel() {
newModel.fillFromDescriptor(extension);
tree.setModel(newModel);
tree.expandRow(0);
this.newModel.fillFromDescriptor(this.extension);
this.tree.setModel(this.newModel);
this.tree.expandRow(0);
}
 
@Override
54,8 → 54,8
c.insets = new Insets(2, 2, 2, 0);
 
panel.add(new JLabel("Menus"), c);
newModel = new MenuItemTreeModel();
tree = new JTree() {
this.newModel = new MenuItemTreeModel();
this.tree = new JTree() {
@Override
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
69,10 → 69,10
return userObject.toString();
}
};
tree.setModel(newModel);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.expandRow(0);
this.tree.setModel(this.newModel);
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
this.tree.expandRow(0);
final DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
85,13 → 85,16
if (tr.getUserObject() instanceof Item) {
r.setText(((Item) tr.getUserObject()).getId());
}
if (sel) {
r.setForeground(Color.WHITE);
}
return r;
}
};
 
treeRenderer.setLeafIcon(null);
tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(tree);
this.tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(this.tree);
comp2.setMinimumSize(new Dimension(250, 150));
comp2.setPreferredSize(new Dimension(250, 150));
c.weighty = 1;
101,16 → 104,16
 
// init
 
tree.addMouseListener(new MouseAdapter() {
this.tree.addMouseListener(new MouseAdapter() {
 
@Override
public void mousePressed(MouseEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
final TreePath selectionPath = MenuTranslationPanel.this.tree.getSelectionPath();
if (selectionPath == null) {
setRightPanel(new JPanel());
} else {
Item i = (Item) ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject();
setRightPanel(new MenuTranslationItemEditor(i, extension));
setRightPanel(new MenuTranslationItemEditor(i, MenuTranslationPanel.this.extension));
}
}
});
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/menu/MenuTranslationItemEditor.java
2,6 → 2,8
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
 
import javax.swing.JLabel;
24,6 → 26,8
private JTextField textId;
private JTextField textTranslation1;
private JTextField textTranslation2;
final LocaleSelector comboLang1;
final LocaleSelector comboLang2;
 
public MenuTranslationItemEditor(final Item item, final Extension extension) {
this.extension = extension;
37,8 → 41,8
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.gridwidth = 3;
textId = new JTextField();
this.add(textId, c);
this.textId = new JTextField();
this.add(this.textId, c);
 
// Language selector
c.gridx = 0;
50,7 → 54,7
final String[] isoLanguages = Locale.getISOLanguages();
System.out.println(isoLanguages.length);
 
final LocaleSelector comboLang1 = new LocaleSelector();
comboLang1 = new LocaleSelector();
 
c.weightx = 1;
c.gridx++;
67,7 → 71,7
c.weightx = 1;
c.gridx++;
c.fill = GridBagConstraints.NONE;
final LocaleSelector comboLang2 = new LocaleSelector();
comboLang2 = new LocaleSelector();
 
comboLang2.setLocale(Locale.ENGLISH);
this.add(comboLang2, c);
84,16 → 88,16
 
c.weightx = 1;
 
textTranslation1 = new JTextField(20);
this.textTranslation1 = new JTextField(20);
 
this.add(textTranslation1, c);
this.add(this.textTranslation1, c);
 
c.gridx += 2;
c.fill = GridBagConstraints.HORIZONTAL;
 
c.weightx = 1;
textTranslation2 = new JTextField(20);
this.add(textTranslation2, c);
this.textTranslation2 = new JTextField(20);
this.add(this.textTranslation2, c);
 
c.gridy++;
c.weighty = 1;
101,7 → 105,7
 
initUIFrom(item);
 
textTranslation1.getDocument().addDocumentListener(new DocumentListener() {
this.textTranslation1.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
116,11 → 120,11
 
@Override
public void changedUpdate(DocumentEvent e) {
extension.setMenuTranslation(item.getId(), textTranslation1.getText(), comboLang1.getLocale());
extension.setMenuTranslation(item.getId(), MenuTranslationItemEditor.this.textTranslation1.getText(), comboLang1.getLocale());
extension.setChanged();
}
});
textTranslation2.getDocument().addDocumentListener(new DocumentListener() {
this.textTranslation2.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
135,21 → 139,56
 
@Override
public void changedUpdate(DocumentEvent e) {
extension.setMenuTranslation(item.getId(), textTranslation2.getText(), comboLang2.getLocale());
extension.setMenuTranslation(item.getId(), MenuTranslationItemEditor.this.textTranslation2.getText(), comboLang2.getLocale());
extension.setChanged();
}
});
comboLang1.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
MenuTranslation t = extension.getMenuTranslation(textId.getText(), comboLang1.getLocale().toString());
if (t != null) {
textTranslation1.setText(t.getLabel());
} else {
textTranslation1.setText("");
}
}
});
comboLang2.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
MenuTranslation t = extension.getMenuTranslation(textId.getText(), comboLang2.getLocale().toString());
if (t != null) {
textTranslation2.setText(t.getLabel());
} else {
textTranslation2.setText("");
}
}
});
 
}
 
private void initUIFrom(Item item) {
 
final LayoutHints localHint = item.getLocalHint();
System.out.println("ItemEditor.initUIFrom:" + item + " " + localHint);
textId.setEnabled(false);
if (textId != null) {
textId.setText(item.getId());
this.textId.setEnabled(false);
if (this.textId != null) {
this.textId.setText(item.getId());
}
 
MenuTranslation t = extension.getMenuTranslation(textId.getText(), comboLang1.getLocale().toString());
if (t != null) {
textTranslation1.setText(t.getLabel());
} else {
textTranslation1.setText("");
}
t = extension.getMenuTranslation(textId.getText(), comboLang2.getLocale().toString());
if (t != null) {
textTranslation2.setText(t.getLabel());
} else {
textTranslation2.setText("");
}
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/action/ActionTranslation.java
13,11 → 13,11
}
 
public String getId() {
return id;
return this.id;
}
 
public String getLabel() {
return label;
return this.label;
}
 
public void setLabel(String label) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/action/ActionTranslationPanel.java
13,6 → 13,6
 
@Override
public JComponent createLeftComponent() {
return new ActionListPanel(extension, this);
return new ActionListPanel(this.extension, this);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/action/ActionListPanel.java
36,9 → 36,9
@Override
public void itemSelected(Object item) {
if (item != null) {
tableTranslationPanel.setRightPanel(new JScrollPane(new MenuTranslationItemEditor(new Item(item.toString()), extension)));
this.tableTranslationPanel.setRightPanel(new JScrollPane(new MenuTranslationItemEditor(new Item(item.toString()), this.extension)));
} else {
tableTranslationPanel.setRightPanel(new JPanel());
this.tableTranslationPanel.setRightPanel(new JPanel());
}
 
}