OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 74 → Rev 86

/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/labels.xml
File deleted
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/menu/MenuTranslationItemEditor.java
9,8 → 9,11
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
 
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.modules.extensionbuilder.menu.mainmenu.MenuDescriptor;
import org.openconcerto.modules.extensionbuilder.translation.LocaleSelector;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.group.Item;
99,8 → 102,47
 
initUIFrom(item);
 
textTranslation1.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
 
@Override
public void changedUpdate(DocumentEvent e) {
extension.setMenuTranslation(item.getId(), textTranslation1.getText(), comboLang1.getLocale());
extension.setChanged();
}
});
textTranslation2.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
 
@Override
public void changedUpdate(DocumentEvent e) {
extension.setMenuTranslation(item.getId(), textTranslation2.getText(), comboLang2.getLocale());
extension.setChanged();
}
});
 
}
 
private void initUIFrom(Item item) {
 
final LayoutHints localHint = item.getLocalHint();
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ModuleResources_fr.properties
1,2 → 1,2
name=Builder
name=Extension Builder
description=Outil de création de modules simples
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MenuItemEditor.java
110,14 → 110,50
int type = cb.getSelectedIndex();
if (type == 0) {
comboActionChoice.setModel(new DefaultComboBoxModel(componentIds));
 
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
desc.setType(MenuDescriptor.CREATE);
desc.setListId(null);
if (componentIds.size() > 0) {
comboActionChoice.setSelectedIndex(0);
desc.setComponentId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
}
extension.setChanged();
} else {
comboActionChoice.setModel(new DefaultComboBoxModel(listIds));
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
desc.setType(MenuDescriptor.LIST);
if (listIds.size() > 0) {
comboActionChoice.setSelectedIndex(0);
desc.setListId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setListId(null);
}
desc.setComponentId(null);
extension.setChanged();
}
 
}
});
comboActionChoice.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
if (desc.getType() == MenuDescriptor.CREATE) {
desc.setComponentId(comboActionChoice.getSelectedItem().toString());
} else if (desc.getType() == MenuDescriptor.LIST) {
desc.setListId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
desc.setListId(null);
}
}
});
 
}
shownInMenu.addActionListener(new ActionListener() {
 
@Override
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionBuilderModule.java
2,7 → 2,6
 
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
10,11 → 9,10
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.erp.config.MainFrame;
import org.openconcerto.erp.config.MenuManager;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.DBContext;
26,7 → 24,6
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.utils.i18n.TranslationManager;
 
public final class ExtensionBuilderModule extends AbstractModule {
 
50,12 → 47,26
 
@Override
protected void setupComponents(ComponentsContext ctxt) {
// ctxt.putAdditionalField("CLIENT", "ID_FIDELITY_CARD");
 
}
 
@Override
protected void setupMenu(MenuContext ctxt) {
ctxt.addMenuItem(new AbstractAction("Gestionnaire d'extensions") {
 
@Override
public void actionPerformed(ActionEvent e) {
Log.get().info("Opening Extension Builder frame");
JFrame f = new JFrame("OpenConcerto Extension Builder - création simplifiée d'extensions");
f.setSize(800, 600);
f.setContentPane(new ExtensionListPanel(ExtensionBuilderModule.this));
f.setLocationRelativeTo(null);
FrameUtil.show(f);
}
}, "menu.extension");
 
// Start extensions...
// TODO merge extensions in ModuleManager
final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
final DBSystemRoot systemRoot = root.getDBSystemRoot();
 
75,20 → 86,7
e.importFromXML(row.get("XML"));
this.extensions.add(e);
}
 
ctxt.addMenuItem(new AbstractAction("Gestionnaire d'extensions") {
 
@Override
public void actionPerformed(ActionEvent e) {
Log.get().info("Opening Extension Builder frame");
JFrame f = new JFrame("OpenConcerto Extension Builder - création simplifiée d'extensions");
f.setSize(800, 600);
f.setContentPane(new ExtensionListPanel(ExtensionBuilderModule.this));
f.setLocationRelativeTo(null);
FrameUtil.show(f);
}
}, "menu.extension");
 
Log.get().info("setupMenu");
// Start previously started extensions
for (Extension extension : extensions) {
if (extension.isAutoStart()) {
100,6 → 98,7
}
}
}
Log.get().info("setupMenu done");
}
 
@Override
111,7 → 110,7
for (Extension extension : extensions) {
if (extension.isAutoStart()) {
try {
extension.start(root);
extension.start(root, true);
} catch (Throwable e) {
JOptionPane.showMessageDialog(new JFrame(), "Impossible de démarrer l'extension " + extension.getName() + "\n" + e.getMessage());
e.printStackTrace();
118,7 → 117,8
}
}
}
 
Log.get().info("Starting Extension Builder done");
System.err.println("Starting Extension Builder done, action for test1:" + MenuManager.getInstance().getActionForId("test1") + " " + MenuManager.getInstance());
}
 
@Override
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ModuleResources.properties
1,2 → 1,2
name=Builder
name=Extension Builder
description=Tool for simple modules creation
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/FieldDescSelector.java
153,6 → 153,7
}
 
public void setMainTable(String table) {
this.listDescriptor.setMainTable(table);
treeModel.fillFromTable(table);
listModel.removeAllElements();
for (ColumnDescriptor d : this.listDescriptor.getColumns()) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListDescriptor.java
47,4 → 47,8
public int getColumnCount() {
return this.columns.size();
}
 
public void removeAllColumns() {
this.columns.clear();
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/CreateListListModel.java
14,7 → 14,6
CreateListListModel(Extension extension) {
this.extension = extension;
addContent();
extension.addChangeListener(this);
}
 
private void addContent() {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListCreatePanel.java
18,7 → 18,7
 
private FieldDescSelector panel;
 
public ListCreatePanel(ListDescriptor n, Extension extension) {
public ListCreatePanel(final ListDescriptor n, final Extension extension) {
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridwidth = 2;
53,8 → 53,9
 
@Override
public void actionPerformed(ActionEvent e) {
n.removeAllColumns();
panel.setMainTable((String) comboTable.getSelectedItem());
 
extension.setChanged();
}
});
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableModifyPanel.java
47,7 → 47,7
this.add(new JLabel("Structure actuelle dans la base de données"), c);
 
c.gridy++;
TableModifyInfoPanel info = new TableModifyInfoPanel(t, desc, leftPanel);
TableModifyInfoPanel info = new TableModifyInfoPanel(extension, t, desc, leftPanel);
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(new JScrollPane(info), c);
88,7 → 88,7
private void addField(final TableDescritor desc, final JPanel p, GridBagConstraints c, final FieldDescriptor field) {
c.weightx = 1;
c.gridx = 0;
final FieldDescriptorEditor editor = new FieldDescriptorEditor(field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(extension, field);
p.add(editor, c);
 
c.gridx++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/FieldDescriptorEditor.java
17,12 → 17,13
import javax.swing.event.DocumentListener;
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.ui.DefaultGridBagConstraints;
 
public class FieldDescriptorEditor extends JPanel implements ActionListener, DocumentListener {
public class FieldDescriptorEditor extends JPanel implements ActionListener {
final JComboBox comboType;
private JTextField textName;
private JTextField fieldName;
private JLabel labelOption;
private JTextField textOption;
private String[] types = { "Texte", "Nombre entier", "Nombre décimal", "Booléen", "Date", "Heure", "Date et heure", "Référence" };
33,9 → 34,20
private static final String[] vDate = { "vide", "jour actuel" };
private static final String[] vTime = { "vide", "heure actuelle" };
private static final String[] vDateTime = { "vide", "date actuelle" };
private static final int TYPE_STRING = 0;
private static final int TYPE_INTEGER = 1;
private static final int TYPE_DECIMAL = 2;
private static final int TYPE_BOOLEAN = 3;
private static final int TYPE_DATE = 4;
private static final int TYPE_TIME = 5;
private static final int TYPE_DATE_TIME = 6;
private static final int TYPE_REF = 7;
 
FieldDescriptor fd;
private Extension extension;
 
FieldDescriptorEditor(FieldDescriptor fd) {
FieldDescriptorEditor(Extension extension, FieldDescriptor fd) {
this.extension = extension;
this.fd = fd;
this.setLayout(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
49,8 → 61,8
this.add(new JLabel("Nom"), c);
c.gridx++;
c.weightx = 1;
textName = new JTextField(10);
this.add(textName, c);
fieldName = new JTextField(10);
this.add(fieldName, c);
c.weightx = 0;
c.gridx++;
labelOption = new JLabel("Longeur max");
65,31 → 77,160
 
updateFrom(fd);
comboType.addActionListener(this);
fieldName.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
fieldNameModified();
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
fieldNameModified();
 
}
 
@Override
public void changedUpdate(DocumentEvent e) {
fieldNameModified();
 
}
});
comboOption.addActionListener(this);
textOption.getDocument().addDocumentListener(this);
textOption.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
fieldOptionModified();
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
fieldOptionModified();
 
}
 
@Override
public void changedUpdate(DocumentEvent e) {
fieldOptionModified();
 
}
});
}
 
protected void fieldNameModified() {
final String text = this.fieldName.getText();
if (text.trim().length() > 0) {
this.fd.setName(text);
}
extension.setChanged();
 
}
 
protected void fieldOptionModified() {
String text = this.textOption.getText();
if (text.trim().length() > 0) {
 
switch (this.comboType.getSelectedIndex()) {
 
case TYPE_STRING:
fd.setLength(text);
fd.setDefaultValue(null);
fd.setForeignTable(null);
fd.setLink(null);
break;
case TYPE_INTEGER:
fd.setLength(null);
try {
int i = Integer.parseInt(text);
fd.setDefaultValue(text);
} catch (Exception e) {
fd.setDefaultValue("0");
}
fd.setForeignTable(null);
fd.setLink(null);
case TYPE_DECIMAL:
fd.setLength(null);
try {
text = text.replace(',', '.');
float i = Float.parseFloat(text);
fd.setDefaultValue(text);
} catch (Exception e) {
fd.setDefaultValue("0");
}
fd.setForeignTable(null);
fd.setLink(null);
break;
 
}
extension.setChanged();
 
}
}
 
protected void comboOptionModified() {
final int index = comboOption.getSelectedIndex();
 
switch (this.comboType.getSelectedIndex()) {
 
case TYPE_BOOLEAN:
fd.setLength(null);
if (index == 0) {
fd.setDefaultValue("true");
} else {
fd.setDefaultValue("false");
}
fd.setForeignTable(null);
fd.setLink(null);
break;
case TYPE_DATE:
case TYPE_TIME:
case TYPE_DATE_TIME:
fd.setLength(null);
if (index == 0) {
fd.setDefaultValue(null);
} else {
fd.setDefaultValue("now");
}
fd.setForeignTable(null);
fd.setLink(null);
break;
case TYPE_REF:
fd.setLength(null);
fd.setDefaultValue(null);
fd.setDefaultValue("now");
fd.setForeignTable(comboOption.getSelectedItem().toString());
fd.setLink(null);
break;
 
}
extension.setChanged();
 
}
 
private void updateFrom(FieldDescriptor fd) {
if (fd.getType().equals("string")) {
comboType.setSelectedIndex(0);
comboType.setSelectedIndex(TYPE_STRING);
labelOption.setText("Longueur max");
textOption.setVisible(true);
textOption.setText(fd.getLength());
comboOption.setVisible(false);
} else if (fd.getType().equals("integer")) {
comboType.setSelectedIndex(1);
comboType.setSelectedIndex(TYPE_INTEGER);
labelOption.setText("Valeur par défaut");
textOption.setVisible(true);
textOption.setText(fd.getDefaultValue());
comboOption.setVisible(false);
} else if (fd.getType().equals("decimal")) {
comboType.setSelectedIndex(2);
comboType.setSelectedIndex(TYPE_DECIMAL);
labelOption.setText("Valeur par défaut");
textOption.setVisible(true);
textOption.setText(fd.getDefaultValue());
comboOption.setVisible(false);
} else if (fd.getType().equals("boolean")) {
comboType.setSelectedIndex(3);
comboType.setSelectedIndex(TYPE_BOOLEAN);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
101,7 → 242,7
}
 
} else if (fd.getType().equals("date")) {
comboType.setSelectedIndex(4);
comboType.setSelectedIndex(TYPE_DATE);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
112,29 → 253,29
comboOption.setSelectedIndex(1);
}
} else if (fd.getType().equals("time")) {
comboType.setSelectedIndex(5);
comboType.setSelectedIndex(TYPE_TIME);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vTime));
if (!fd.getDefaultValue().equals("now")) {
if (fd.getDefaultValue() == null || !fd.getDefaultValue().equals("now")) {
comboOption.setSelectedIndex(0);
} else {
comboOption.setSelectedIndex(1);
}
} else if (fd.getType().equals("dateAndTime")) {
comboType.setSelectedIndex(6);
comboType.setSelectedIndex(TYPE_DATE_TIME);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vDateTime));
if (!fd.getDefaultValue().equals("now")) {
if (fd.getDefaultValue() == null || !fd.getDefaultValue().equals("now")) {
comboOption.setSelectedIndex(0);
} else {
comboOption.setSelectedIndex(1);
}
} else if (fd.getType().equals("ref")) {
comboType.setSelectedIndex(7);
comboType.setSelectedIndex(TYPE_REF);
labelOption.setText("Table");
textOption.setVisible(false);
comboOption.setVisible(true);
144,7 → 285,7
} else {
throw new IllegalArgumentException("Unknow type " + fd.getType());
}
textName.setText(fd.getName().trim());
fieldName.setText(fd.getName().trim());
 
}
 
175,31 → 316,9
updateFrom(fd);
}
} else if (e.getSource() == this.comboOption) {
// TODO combo -> FieldDescriptor
comboOptionModified();
}
 
}
 
private void updateText(DocumentEvent e) {
// TODO text -> FieldDescriptor
 
}
 
@Override
public void insertUpdate(DocumentEvent e) {
updateText(e);
 
}
 
@Override
public void removeUpdate(DocumentEvent e) {
updateText(e);
 
}
 
@Override
public void changedUpdate(DocumentEvent e) {
updateText(e);
 
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableCreatePanel.java
70,7 → 70,7
 
c.weightx = 1;
c.gridx = 0;
final FieldDescriptorEditor editor = new FieldDescriptorEditor(field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(extension, field);
p.add(editor, c);
 
c.gridx++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableModifyInfoPanel.java
24,6 → 24,7
 
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.modules.extensionbuilder.ClickableLabel;
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLTable;
33,9 → 34,12
import org.openconcerto.utils.Tuple2;
 
public class TableModifyInfoPanel extends JPanel implements Scrollable {
private Extension extension;
 
// TODO: tooltip sur un champs pour indiquer quelles extensions l'utilisent
 
public TableModifyInfoPanel(SQLTable t, final TableDescritor desc, final TableModifyLeftPanel leftPanel) {
public TableModifyInfoPanel(Extension extension, SQLTable t, final TableDescritor desc, final TableModifyLeftPanel leftPanel) {
this.extension = extension;
this.setLayout(new GridBagLayout());
this.setBackground(Color.WHITE);
GridBagConstraints c = new DefaultGridBagConstraints();
172,7 → 176,7
private void addField(final TableDescritor desc, final JPanel p, GridBagConstraints c, final FieldDescriptor field) {
c.weightx = 1;
c.gridx = 0;
final FieldDescriptorEditor editor = new FieldDescriptorEditor(field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(extension, field);
p.add(editor, c);
 
c.gridx++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/labels_fr.xml
New file
0,0 → 1,4
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
</ROOT>
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionInfoPanel.java
126,7 → 126,6
 
}
});
saveButton.setEnabled(extension.isNotSaved());
panel.add(saveButton);
// TODO: a mettre en clic droit sur la liste gauche
final JButton exportButton = new JButton("Exporter");
252,7 → 251,7
public void run() {
final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
try {
extension.start(root);
extension.start(root, false);
} catch (SQLException e1) {
e1.printStackTrace();
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/Extension.java
14,6 → 14,7
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.logging.Level;
 
57,7 → 58,7
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ChangeTable;
80,6 → 81,7
import org.openconcerto.ui.group.modifier.AddItemModifier;
import org.openconcerto.ui.group.modifier.MoveToGroupModifier;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.i18n.TranslationManager;
 
public class Extension {
 
141,7 → 143,7
return autoStart;
}
 
public void start(DBRoot root) throws SQLException {
public void start(DBRoot root, boolean inModuleStart) throws SQLException {
 
// Ensure that database is configured
boolean databaseOk = setupDatabase(root);
150,9 → 152,13
return;
}
// Register translations
 
registerTranslations();
// Create menus
setupMenu();
if (!inModuleStart) {
final MenuAndActions copy = MenuManager.getInstance().copyMenuAndActions();
registerMenuActions(copy);
MenuManager.getInstance().setMenuAndActions(copy);
}
Log.get().info("Extension " + this.getName() + " started");
this.isStarted = true;
this.autoStart = true;
159,18 → 165,50
fireChanged();
}
 
private void setupMenu() {
private void registerTranslations() {
final String locale = Locale.getDefault().toString();
for (MenuTranslation mTranslation : this.menuTranslations) {
if (locale.equals(mTranslation.getLocale())) {
TranslationManager.getInstance().setTranslationForMenu(mTranslation.getId(), mTranslation.getLabel());
}
}
for (ActionTranslation mTranslation : this.actionTranslations) {
if (locale.equals(mTranslation.getLocale())) {
TranslationManager.getInstance().setTranslationForAction(mTranslation.getId(), mTranslation.getLabel());
}
}
for (FieldTranslation mTranslation : this.fieldTranslations) {
if (locale.equals(mTranslation.getLocale())) {
TranslationManager.getInstance().setTranslationForItem(mTranslation.getTableName() + "." + mTranslation.getFieldName(), mTranslation.getLabel());
}
}
for (TableTranslation mTranslation : this.tableTranslations) {
if (locale.equals(mTranslation.getLocale())) {
// FIXME voir avec Sylvain
}
}
}
 
private void registerMenuActions(MenuAndActions menuAndActions) {
// register actions
for (final MenuDescriptor element : getCreateMenuList()) {
if (element.getType().equals(MenuDescriptor.CREATE)) {
MenuManager.getInstance().registerAction(element.getId(), new CreateFrameAbstractAction() {
Log.get().info("Registering action for menu creation id:'" + element.getId() + "'");
 
menuAndActions.putAction(new CreateFrameAbstractAction() {
 
@Override
public JFrame createFrame() {
 
JFrame editFrame = new JFrame();
String componentId = element.getComponentId();
if (componentId == null) {
throw new IllegalStateException("No ComponentId for menu " + element.getId());
}
ComponentDescritor n = getCreateComponentFromId(componentId);
if (n == null) {
throw new IllegalStateException("No ComponentDescritor for " + componentId);
}
final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
if (t == null) {
throw new IllegalStateException("No table " + n.getTable());
185,10 → 223,10
return editFrame;
 
}
});
}, element.getId(), true);
 
} else if (element.getType().equals(MenuDescriptor.LIST)) {
MenuManager.getInstance().registerAction(element.getId(), new CreateFrameAbstractAction() {
menuAndActions.putAction(new CreateFrameAbstractAction() {
 
@Override
public JFrame createFrame() {
212,13 → 250,14
for (int i = 0; i < paths.length; i++) {
// LOCAL, id_batiment.id_site.nom
final SQLName name = SQLName.parse(paths[i].trim());
final Path p = new Path(element.getTable());
 
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, name.getName());
final FieldPath fp = new FieldPath(p.build(), name.getName());
fps.add(fp);
 
}
251,7 → 290,7
return editFrame;
 
}
});
}, element.getId(), true);
} else if (element.getType().equals(MenuDescriptor.LIST)) {
// No action to register
} else {
259,12 → 298,14
}
}
 
final MenuAndActions copy = MenuManager.getInstance().copyMenuAndActions();
// create group
final Group group = copy.getGroup();
initMenuGroup(group);
MenuManager.getInstance().setMenuAndActions(copy);
 
// System.err.println("****" + MenuManager.getInstance().getActionForId("test1"));
//
// final MenuAndActions copy = MenuManager.getInstance().copyMenuAndActions();
// // create group
// final Group group = copy.getGroup();
initMenuGroup(menuAndActions.getGroup());
// MenuManager.getInstance().setMenuAndActions(copy);
// System.err.println("*******" + MenuManager.getInstance().getActionForId("test1"));
}
 
public void initMenuGroup(final Group group) {
460,6 → 501,7
this.isStarted = false;
this.autoStart = false;
Log.get().info("Extension " + this.getName() + " stopped");
// TODO : remove menu changes
fireChanged();
}
 
1331,7 → 1373,7
public void setupMenu(MenuContext ctxt) {
final Group group = ctxt.getMenuAndActions().getGroup();
initMenuGroup(group);
 
registerMenuActions(ctxt.getMenuAndActions());
}
 
public void removeRemoveMenuForId(String id) {
1386,4 → 1428,21
}
 
}
 
public void setMenuTranslation(String id, String text, Locale locale) {
MenuTranslation mTranslation = null;
for (MenuTranslation mTr : this.menuTranslations) {
if (mTr.getId().equals(id) && mTr.getLocale().equals(locale.toString())) {
mTranslation = mTr;
break;
}
 
}
if (mTranslation == null) {
mTranslation = new MenuTranslation(locale.toString(), id);
this.menuTranslations.add(mTranslation);
}
mTranslation.setLabel(text);
 
}
}