OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 138 → Rev 139

/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/Extension.java
60,6 → 60,7
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ChangeTable;
import org.openconcerto.sql.utils.SQLCreateTable;
215,7 → 216,12
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
 
final GroupSQLComponent gComponent = new GroupSQLComponent(element, n.getGroup());
final GroupSQLComponent gComponent = new GroupSQLComponent(element, n.getGroup()) {
public RowItemDesc getRIVDescForId(final String id) {
return super.getRIVDescForId(t.getName() + "." + id);
}
 
};
editFrame.setTitle(EditFrame.getCreateMessage(element));
editFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
editFrame.pack();
226,11 → 232,15
}, element.getId(), true);
 
} else if (element.getType().equals(MenuDescriptor.LIST)) {
if (element.getListId() != null) {
menuAndActions.putAction(new CreateFrameAbstractAction() {
 
@Override
public JFrame createFrame() {
final String componentId = element.getListId();
if (componentId == null) {
throw new IllegalStateException("null ListId for MenuDescriptor " + element.getId());
}
final ListDescriptor listDesc = getCreateListFromId(componentId);
if (listDesc == null) {
throw new IllegalStateException("No ListDescriptor " + componentId);
240,8 → 250,8
throw new IllegalStateException("No table " + listDesc.getMainTable());
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
final ListSQLRequest req = new ListSQLRequest(element.getTable(), Collections.EMPTY_LIST);
final SQLTableModelSourceOnline source = new SQLTableModelSourceOnline(req);
final ListSQLRequest req = new ListSQLRequest(element.getTable(), new ArrayList<String>(0));
final SQLTableModelSourceOnline source = new SQLTableModelSourceOnline(req, element);
final List<SQLTableModelColumn> cols = new ArrayList<SQLTableModelColumn>();
for (ColumnDescriptor cDesc : listDesc.getColumns()) {
final String fieldspath = cDesc.getFieldsPaths();
291,6 → 301,7
 
}
}, element.getId(), true);
}
} else if (element.getType().equals(MenuDescriptor.LIST)) {
// No action to register
} else {
1445,4 → 1456,48
mTranslation.setLabel(text);
 
}
 
private TableTranslation getTableTranslation(String tableName, Locale locale) {
TableTranslation tTranslation = null;
for (TableTranslation mTr : this.tableTranslations) {
if (mTr.getTableName().equals(tableName) && mTr.getLocale().equals(locale.toString())) {
tTranslation = mTr;
break;
}
}
if (tTranslation == null) {
tTranslation = new TableTranslation(locale.toString(), tableName);
this.tableTranslations.add(tTranslation);
}
return tTranslation;
}
 
public void setTableSingularTranslation(String tableName, Locale locale, String text) {
TableTranslation mTranslation = getTableTranslation(tableName, locale);
mTranslation.setSingular(text);
 
}
 
public void setTablePluralTranslation(String tableName, Locale locale, String text) {
TableTranslation mTranslation = getTableTranslation(tableName, locale);
mTranslation.setPlural(text);
 
}
 
public void setFieldTranslation(String tableName, String fieldName, Locale locale, String text) {
System.err.println("Extension.setFieldTranslation()" + tableName + " " + fieldName + " " + locale + " : " + text);
FieldTranslation fTranslation = null;
for (FieldTranslation mTr : this.fieldTranslations) {
if (mTr.getTableName().equals(tableName) && mTr.getFieldName().equals(fieldName) && mTr.getLocale().equals(locale.toString())) {
fTranslation = mTr;
break;
}
}
if (fTranslation == null) {
fTranslation = new FieldTranslation(locale.toString(), tableName, fieldName);
this.fieldTranslations.add(fTranslation);
}
fTranslation.setLabel(text);
 
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/TableTranslationEditorPanel.java
19,6 → 19,7
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
 
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.modules.extensionbuilder.translation.LocaleSelector;
33,6 → 34,7
final JTextField textPlural2 = new JTextField();
private Map<String, JTextField> map1 = new HashMap<String, JTextField>();
private Map<String, JTextField> map2 = new HashMap<String, JTextField>();
private Map<JTextField, String> fieldsMap = new HashMap<JTextField, String>();
 
TableTranslationEditorPanel(final Extension extension, final String tableName) {
this.setLayout(new GridBagLayout());
121,10 → 123,12
c.gridx++;
final JTextField t1 = new JTextField();
map1.put(fName, t1);
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.add(t2, c);
c.gridy++;
152,8 → 156,62
updateUIFrom(extension, tableName, null, comboLang2.getLocale());
}
});
 
this.textSingular1.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setTableSingularTranslation(tableName, comboLang1.getLocale(), text);
}
 
});
this.textSingular2.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setTableSingularTranslation(tableName, comboLang2.getLocale(), text);
}
 
});
this.textPlural1.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setTablePluralTranslation(tableName, comboLang1.getLocale(), text);
}
 
});
this.textPlural2.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setTablePluralTranslation(tableName, comboLang2.getLocale(), text);
}
 
});
for (final JTextField textField : map1.values()) {
textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang1.getLocale(), text);
}
 
});
}
for (final JTextField textField : map2.values()) {
textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang2.getLocale(), text);
}
 
});
}
 
}
 
private void updateUIFrom(Extension extension, String tableName, Object l1, Object l2) {
if (l1 != null) {
final String lang = l1.toString();
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/SimpleDocumentListener.java
New file
0,0 → 1,32
package org.openconcerto.modules.extensionbuilder.translation.field;
 
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
 
public abstract class SimpleDocumentListener implements DocumentListener {
 
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void changedUpdate(DocumentEvent e) {
try {
changedUpdate(e, e.getDocument().getText(0, e.getDocument().getLength()));
} catch (BadLocationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
 
public abstract void changedUpdate(DocumentEvent e, String text);
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentCreatePanel.java
22,6 → 22,7
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.sql.view.EditPanel;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.ui.DefaultGridBagConstraints;
100,7 → 101,12
if (element == null) {
Log.get().warning("No element for table: " + t.getName());
}
final GroupSQLComponent gComponent = new GroupSQLComponent(element, group);
final GroupSQLComponent gComponent = new GroupSQLComponent(element, group) {
public RowItemDesc getRIVDescForId(final String id) {
return super.getRIVDescForId(t.getName() + "." + id);
}
 
};
oldGroup = group;
if (previewFrame == null || !previewFrame.isVisible()) {
previewFrame = new JFrame();
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MenuItemEditor.java
212,8 → 212,11
final List<ComponentDescritor> compDescList = extension.getCreateComponentList();
componentIds = new Vector<String>(compDescList.size());
for (ComponentDescritor componentDescritor : compDescList) {
componentIds.add(componentDescritor.getId());
final String id = componentDescritor.getId();
if (id != null) {
componentIds.add(id);
}
}
 
Collections.sort(componentIds);
 
220,8 → 223,11
final List<ListDescriptor> listDescList = extension.getCreateListList();
listIds = new Vector<String>(listDescList.size());
for (ListDescriptor listDescritor : listDescList) {
listIds.add(listDescritor.getId());
final String id = listDescritor.getId();
if (id != null) {
listIds.add(id);
}
}
 
Collections.sort(listIds);
//
229,7 → 235,7
String type = desc.getType();
if (type.equals(MenuDescriptor.CREATE)) {
final String componentId = desc.getComponentId();
if (!componentIds.contains(componentId)) {
if (!componentIds.contains(componentId) && componentId != null) {
componentIds.add(componentId);
}
comboActionType.setSelectedIndex(0);
238,7 → 244,7
 
} else if (type.equals(MenuDescriptor.LIST)) {
final String listId = desc.getListId();
if (!listIds.contains(listId)) {
if (!listIds.contains(listId) && listId != null) {
listIds.add(listId);
}
comboActionType.setSelectedIndex(1);