OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 86 | Rev 153 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86 Rev 139
Line 58... Line 58...
58
import org.openconcerto.sql.model.SQLRowAccessor;
58
import org.openconcerto.sql.model.SQLRowAccessor;
59
import org.openconcerto.sql.model.SQLRowValues;
59
import org.openconcerto.sql.model.SQLRowValues;
60
import org.openconcerto.sql.model.SQLTable;
60
import org.openconcerto.sql.model.SQLTable;
61
import org.openconcerto.sql.model.graph.PathBuilder;
61
import org.openconcerto.sql.model.graph.PathBuilder;
62
import org.openconcerto.sql.request.ListSQLRequest;
62
import org.openconcerto.sql.request.ListSQLRequest;
-
 
63
import org.openconcerto.sql.request.RowItemDesc;
63
import org.openconcerto.sql.utils.AlterTable;
64
import org.openconcerto.sql.utils.AlterTable;
64
import org.openconcerto.sql.utils.ChangeTable;
65
import org.openconcerto.sql.utils.ChangeTable;
65
import org.openconcerto.sql.utils.SQLCreateTable;
66
import org.openconcerto.sql.utils.SQLCreateTable;
66
import org.openconcerto.sql.view.EditFrame;
67
import org.openconcerto.sql.view.EditFrame;
67
import org.openconcerto.sql.view.EditPanel;
68
import org.openconcerto.sql.view.EditPanel;
Line 213... Line 214...
213
                        if (t == null) {
214
                        if (t == null) {
214
                            throw new IllegalStateException("No table  " + n.getTable());
215
                            throw new IllegalStateException("No table  " + n.getTable());
215
                        }
216
                        }
216
                        final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
217
                        final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
217
 
218
 
218
                        final GroupSQLComponent gComponent = new GroupSQLComponent(element, n.getGroup());
219
                        final GroupSQLComponent gComponent = new GroupSQLComponent(element, n.getGroup()) {
-
 
220
                            public RowItemDesc getRIVDescForId(final String id) {
-
 
221
                                return super.getRIVDescForId(t.getName() + "." + id);
-
 
222
                            }
-
 
223
 
-
 
224
                        };
219
                        editFrame.setTitle(EditFrame.getCreateMessage(element));
225
                        editFrame.setTitle(EditFrame.getCreateMessage(element));
220
                        editFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
226
                        editFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
221
                        editFrame.pack();
227
                        editFrame.pack();
222
 
228
 
223
                        return editFrame;
229
                        return editFrame;
224
 
230
 
225
                    }
231
                    }
226
                }, element.getId(), true);
232
                }, element.getId(), true);
227
 
233
 
228
            } else if (element.getType().equals(MenuDescriptor.LIST)) {
234
            } else if (element.getType().equals(MenuDescriptor.LIST)) {
-
 
235
                if (element.getListId() != null) {
229
                menuAndActions.putAction(new CreateFrameAbstractAction() {
236
                    menuAndActions.putAction(new CreateFrameAbstractAction() {
230
 
237
 
231
                    @Override
238
                        @Override
232
                    public JFrame createFrame() {
239
                        public JFrame createFrame() {
233
                        final String componentId = element.getListId();
240
                            final String componentId = element.getListId();
-
 
241
                            if (componentId == null) {
-
 
242
                                throw new IllegalStateException("null ListId for MenuDescriptor " + element.getId());
-
 
243
                            }
234
                        final ListDescriptor listDesc = getCreateListFromId(componentId);
244
                            final ListDescriptor listDesc = getCreateListFromId(componentId);
235
                        if (listDesc == null) {
245
                            if (listDesc == null) {
236
                            throw new IllegalStateException("No ListDescriptor  " + componentId);
246
                                throw new IllegalStateException("No ListDescriptor  " + componentId);
237
                        }
247
                            }
238
                        final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(listDesc.getMainTable());
248
                            final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(listDesc.getMainTable());
239
                        if (t == null) {
249
                            if (t == null) {
240
                            throw new IllegalStateException("No table  " + listDesc.getMainTable());
250
                                throw new IllegalStateException("No table  " + listDesc.getMainTable());
241
                        }
251
                            }
242
                        final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
252
                            final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
243
                        final ListSQLRequest req = new ListSQLRequest(element.getTable(), Collections.EMPTY_LIST);
253
                            final ListSQLRequest req = new ListSQLRequest(element.getTable(), new ArrayList<String>(0));
244
                        final SQLTableModelSourceOnline source = new SQLTableModelSourceOnline(req);
254
                            final SQLTableModelSourceOnline source = new SQLTableModelSourceOnline(req, element);
245
                        final List<SQLTableModelColumn> cols = new ArrayList<SQLTableModelColumn>();
255
                            final List<SQLTableModelColumn> cols = new ArrayList<SQLTableModelColumn>();
246
                        for (ColumnDescriptor cDesc : listDesc.getColumns()) {
256
                            for (ColumnDescriptor cDesc : listDesc.getColumns()) {
247
                            final String fieldspath = cDesc.getFieldsPaths();
257
                                final String fieldspath = cDesc.getFieldsPaths();
248
                            final String[] paths = fieldspath.split(",");
258
                                final String[] paths = fieldspath.split(",");
249
                            final Set<FieldPath> fps = new LinkedHashSet<FieldPath>();
259
                                final Set<FieldPath> fps = new LinkedHashSet<FieldPath>();
Line 289... Line 299...
289
                        editFrame.pack();
299
                            editFrame.pack();
290
                        return editFrame;
300
                            return editFrame;
291
 
301
 
292
                    }
302
                        }
293
                }, element.getId(), true);
303
                    }, element.getId(), true);
-
 
304
                }
294
            } else if (element.getType().equals(MenuDescriptor.LIST)) {
305
            } else if (element.getType().equals(MenuDescriptor.LIST)) {
295
                // No action to register
306
                // No action to register
296
            } else {
307
            } else {
297
                Log.get().warning("unknown type " + element.getType());
308
                Log.get().warning("unknown type " + element.getType());
298
            }
309
            }
Line 1443... Line 1454...
1443
            this.menuTranslations.add(mTranslation);
1454
            this.menuTranslations.add(mTranslation);
1444
        }
1455
        }
1445
        mTranslation.setLabel(text);
1456
        mTranslation.setLabel(text);
1446
 
1457
 
1447
    }
1458
    }
-
 
1459
 
-
 
1460
    private TableTranslation getTableTranslation(String tableName, Locale locale) {
-
 
1461
        TableTranslation tTranslation = null;
-
 
1462
        for (TableTranslation mTr : this.tableTranslations) {
-
 
1463
            if (mTr.getTableName().equals(tableName) && mTr.getLocale().equals(locale.toString())) {
-
 
1464
                tTranslation = mTr;
-
 
1465
                break;
-
 
1466
            }
-
 
1467
        }
-
 
1468
        if (tTranslation == null) {
-
 
1469
            tTranslation = new TableTranslation(locale.toString(), tableName);
-
 
1470
            this.tableTranslations.add(tTranslation);
-
 
1471
        }
-
 
1472
        return tTranslation;
-
 
1473
    }
-
 
1474
 
-
 
1475
    public void setTableSingularTranslation(String tableName, Locale locale, String text) {
-
 
1476
        TableTranslation mTranslation = getTableTranslation(tableName, locale);
-
 
1477
        mTranslation.setSingular(text);
-
 
1478
 
-
 
1479
    }
-
 
1480
 
-
 
1481
    public void setTablePluralTranslation(String tableName, Locale locale, String text) {
-
 
1482
        TableTranslation mTranslation = getTableTranslation(tableName, locale);
-
 
1483
        mTranslation.setPlural(text);
-
 
1484
 
-
 
1485
    }
-
 
1486
 
-
 
1487
    public void setFieldTranslation(String tableName, String fieldName, Locale locale, String text) {
-
 
1488
        System.err.println("Extension.setFieldTranslation()" + tableName + " " + fieldName + " " + locale + " : " + text);
-
 
1489
        FieldTranslation fTranslation = null;
-
 
1490
        for (FieldTranslation mTr : this.fieldTranslations) {
-
 
1491
            if (mTr.getTableName().equals(tableName) && mTr.getFieldName().equals(fieldName) && mTr.getLocale().equals(locale.toString())) {
-
 
1492
                fTranslation = mTr;
-
 
1493
                break;
-
 
1494
            }
-
 
1495
        }
-
 
1496
        if (fTranslation == null) {
-
 
1497
            fTranslation = new FieldTranslation(locale.toString(), tableName, fieldName);
-
 
1498
            this.fieldTranslations.add(fTranslation);
-
 
1499
        }
-
 
1500
        fTranslation.setLabel(text);
-
 
1501
 
-
 
1502
    }
1448
}
1503
}