OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Comparer les révisions

Ignorer les espaces blanc Révision 138 → Révision 139

/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,7 → 212,10
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,7 → 223,10
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);
/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,71 → 232,76
}, element.getId(), true);
 
} else if (element.getType().equals(MenuDescriptor.LIST)) {
menuAndActions.putAction(new CreateFrameAbstractAction() {
if (element.getListId() != null) {
menuAndActions.putAction(new CreateFrameAbstractAction() {
 
@Override
public JFrame createFrame() {
final String componentId = element.getListId();
final ListDescriptor listDesc = getCreateListFromId(componentId);
if (listDesc == null) {
throw new IllegalStateException("No ListDescriptor " + componentId);
}
final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(listDesc.getMainTable());
if (t == null) {
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 List<SQLTableModelColumn> cols = new ArrayList<SQLTableModelColumn>();
for (ColumnDescriptor cDesc : listDesc.getColumns()) {
final String fieldspath = cDesc.getFieldsPaths();
final String[] paths = fieldspath.split(",");
final Set<FieldPath> fps = new LinkedHashSet<FieldPath>();
for (int i = 0; i < paths.length; i++) {
// LOCAL, id_batiment.id_site.nom
final SQLName name = SQLName.parse(paths[i].trim());
@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);
}
final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(listDesc.getMainTable());
if (t == null) {
throw new IllegalStateException("No table " + listDesc.getMainTable());
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
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();
final String[] paths = fieldspath.split(",");
final Set<FieldPath> fps = new LinkedHashSet<FieldPath>();
for (int i = 0; i < paths.length; i++) {
// LOCAL, id_batiment.id_site.nom
final SQLName name = SQLName.parse(paths[i].trim());
 
final PathBuilder p = new PathBuilder(element.getTable());
final int stop = name.getItemCount() - 1;
for (int j = 0; j < stop; j++) {
String it = name.getItem(j);
p.addForeignField(it);
final PathBuilder p = new PathBuilder(element.getTable());
final int stop = name.getItemCount() - 1;
for (int j = 0; j < stop; j++) {
String it = name.getItem(j);
p.addForeignField(it);
}
final FieldPath fp = new FieldPath(p.build(), name.getName());
fps.add(fp);
 
}
final FieldPath fp = new FieldPath(p.build(), name.getName());
fps.add(fp);
cols.add(new BaseSQLTableModelColumn(cDesc.getId(), String.class) {
 
}
cols.add(new BaseSQLTableModelColumn(cDesc.getId(), String.class) {
@Override
protected Object show_(SQLRowAccessor r) {
final List<String> l = new ArrayList<String>();
for (final FieldPath fp : fps) {
final String string = fp.getString((SQLRowValues) r);
if (string != null)
l.add(string);
}
return CollectionUtils.join(l, " ");
}
 
@Override
protected Object show_(SQLRowAccessor r) {
final List<String> l = new ArrayList<String>();
for (final FieldPath fp : fps) {
final String string = fp.getString((SQLRowValues) r);
if (string != null)
l.add(string);
@Override
public Set<FieldPath> getPaths() {
return fps;
}
return CollectionUtils.join(l, " ");
}
});
 
@Override
public Set<FieldPath> getPaths() {
return fps;
}
});
}
 
}
source.getColumns().addAll(cols);
 
source.getColumns().addAll(cols);
final IListe list = new IListe(source);
final IListFrame editFrame = new IListFrame(new ListeAddPanel(element, list));
editFrame.pack();
return editFrame;
 
final IListe list = new IListe(source);
final IListFrame editFrame = new IListFrame(new ListeAddPanel(element, list));
editFrame.pack();
return editFrame;
 
}
}, element.getId(), true);
}
}, 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,6 → 156,60
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) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/SimpleDocumentListener.java
Nouveau fichier
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);
}