OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 162 → Rev 181

/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/MenuMainPanel.java
7,7 → 7,6
 
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.modules.extensionbuilder.menu.mainmenu.MainMenuPanel;
import org.openconcerto.modules.extensionbuilder.meu.actions.ActionMainPanel;
 
public class MenuMainPanel extends JPanel {
final MainMenuPanel mainMenuPanel;
15,9 → 14,10
public MenuMainPanel(Extension extension) {
this.setLayout(new GridLayout(1, 1));
JTabbedPane tab = new JTabbedPane();
mainMenuPanel = new MainMenuPanel(extension);
tab.addTab("Menu principal", mainMenuPanel);
tab.addTab("Actions contextuelles", new ActionMainPanel(extension));
this.mainMenuPanel = new MainMenuPanel(extension);
tab.addTab("Menu principal", this.mainMenuPanel);
// TODO : terminer la gestion des actions
// tab.addTab("Actions contextuelles", new ActionMainPanel(extension));
this.add(tab);
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MenuItemTreeModel.java
64,7 → 64,7
depth++;
final ActivableMutableTreeNode newChild = new ActivableMutableTreeNode(item);
newChild.setActive(isActive(item.getId()));
if (showAll || newChild.isActive()) {
if (this.showAll || newChild.isActive()) {
node.add(newChild);
}
if (item instanceof Group) {
81,7 → 81,7
}
 
private boolean isActive(String id) {
List<MenuDescriptor> l = extension.getRemoveMenuList();
List<MenuDescriptor> l = this.extension.getRemoveMenuList();
for (MenuDescriptor menuDescriptor : l) {
if (menuDescriptor.getId().equals(id)) {
return false;
108,11 → 108,11
 
public void setActive(boolean active, String id) {
if (active) {
extension.removeRemoveMenuForId(id);
this.extension.removeRemoveMenuForId(id);
} else {
extension.addRemoveMenu(new MenuDescriptor(id));
this.extension.addRemoveMenu(new MenuDescriptor(id));
}
extension.setChanged();
this.extension.setChanged();
 
DefaultMutableTreeNode n = getNode(id);
if (n != null) {
137,9 → 137,9
public void insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index) {
Item it = (Item) ((DefaultMutableTreeNode) newChild).getUserObject();
Group g = (Group) ((DefaultMutableTreeNode) parent).getUserObject();
extension.moveMenuItem(it.getId(), g.getId());
this.extension.moveMenuItem(it.getId(), g.getId());
super.insertNodeInto(newChild, parent, index);
extension.setChanged();
this.extension.setChanged();
}
 
@SuppressWarnings("rawtypes")
158,8 → 158,8
}
}
 
extension.renameMenuItem(previousId, newId);
extension.setChanged();
this.extension.renameMenuItem(previousId, newId);
this.extension.setChanged();
 
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MenuItemEditor.java
59,9 → 59,9
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.gridwidth = 2;
textId = new JTextField();
this.textId = new JTextField();
 
this.add(textId, c);
this.add(this.textId, c);
c.gridy++;
 
c.gridwidth = 1;
72,13 → 72,13
c.gridx++;
 
c.fill = GridBagConstraints.HORIZONTAL;
comboActionType = new JComboBox();
this.comboActionType = new JComboBox();
 
this.add(comboActionType, c);
this.add(this.comboActionType, c);
c.gridx++;
c.weightx = 1;
comboActionChoice = new JComboBox();
this.add(comboActionChoice, c);
this.comboActionChoice = new JComboBox();
this.add(this.comboActionChoice, c);
 
c.gridy++;
}
87,9 → 87,9
c.gridx = 1;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
shownInMenu = new JCheckBox("Afficher dans le menu");
this.shownInMenu = new JCheckBox("Afficher dans le menu");
 
this.add(shownInMenu, c);
this.add(this.shownInMenu, c);
 
JPanel spacer = new JPanel();
c.gridx = 1;
100,9 → 100,9
initUIFrom(item.getId());
 
// Listeners
if (!isEditingGroup) {
if (!this.isEditingGroup) {
// comboActionType
comboActionType.addActionListener(new ActionListener() {
this.comboActionType.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
110,14 → 110,14
int type = cb.getSelectedIndex();
if (type == 0) {
// Saisie
comboActionChoice.setModel(new DefaultComboBoxModel(componentIds));
MenuItemEditor.this.comboActionChoice.setModel(new DefaultComboBoxModel(MenuItemEditor.this.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());
if (MenuItemEditor.this.componentIds.size() > 0) {
MenuItemEditor.this.comboActionChoice.setSelectedIndex(0);
desc.setComponentId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
}
124,12 → 124,12
extension.setChanged();
} else {
// Liste
comboActionChoice.setModel(new DefaultComboBoxModel(listIds));
MenuItemEditor.this.comboActionChoice.setModel(new DefaultComboBoxModel(MenuItemEditor.this.listIds));
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
desc.setType(MenuDescriptor.LIST);
if (listIds.size() > 0) {
comboActionChoice.setSelectedIndex(0);
desc.setListId(comboActionChoice.getSelectedItem().toString());
if (MenuItemEditor.this.listIds.size() > 0) {
MenuItemEditor.this.comboActionChoice.setSelectedIndex(0);
desc.setListId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
} else {
desc.setListId(null);
}
139,15 → 139,15
 
}
});
comboActionChoice.addActionListener(new ActionListener() {
this.comboActionChoice.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
if (desc.getType().equals(MenuDescriptor.CREATE)) {
desc.setComponentId(comboActionChoice.getSelectedItem().toString());
desc.setComponentId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
} else if (desc.getType().equals(MenuDescriptor.LIST)) {
desc.setListId(comboActionChoice.getSelectedItem().toString());
desc.setListId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
desc.setListId(null);
156,13 → 156,13
});
 
}
shownInMenu.addActionListener(new ActionListener() {
this.shownInMenu.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final boolean selected = shownInMenu.isSelected();
final boolean selected = MenuItemEditor.this.shownInMenu.isSelected();
 
treeModel.setActive(selected, item.getId());
MenuItemEditor.this.treeModel.setActive(selected, item.getId());
}
});
 
169,11 → 169,11
}
 
private void initUIFrom(String itemId) {
boolean hasCreated = extension.getCreateMenuItemFromId(itemId) != null;
textId.setEnabled(hasCreated);
previousId = itemId;
boolean hasCreated = this.extension.getCreateMenuItemFromId(itemId) != null;
this.textId.setEnabled(hasCreated);
this.previousId = itemId;
if (hasCreated) {
textId.getDocument().addDocumentListener(new DocumentListener() {
this.textId.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
187,12 → 187,12
 
@Override
public void changedUpdate(DocumentEvent e) {
String t = textId.getText();
String t = MenuItemEditor.this.textId.getText();
System.err.println("MenuItemEditor.initUIFrom(...).new DocumentListener() {...}.changedUpdate()" + t);
 
if (!previousId.equals(t)) {
treeModel.renameMenuItem(previousId, t);
previousId = t;
if (!MenuItemEditor.this.previousId.equals(t)) {
MenuItemEditor.this.treeModel.renameMenuItem(MenuItemEditor.this.previousId, t);
MenuItemEditor.this.previousId = t;
 
}
}
199,59 → 199,59
});
}
 
shownInMenu.setSelected(extension.getRemoveMenuItemFromId(itemId) == null);
if (textId != null) {
textId.setText(itemId);
this.shownInMenu.setSelected(this.extension.getRemoveMenuItemFromId(itemId) == null);
if (this.textId != null) {
this.textId.setText(itemId);
}
if (!isEditingGroup) {
comboActionType.setEnabled(true);
comboActionChoice.setEnabled(true);
if (!this.isEditingGroup) {
this.comboActionType.setEnabled(true);
this.comboActionChoice.setEnabled(true);
final Action actionForId = MenuManager.getInstance().getActionForId(itemId);
if (hasCreated) {
MenuDescriptor desc = extension.getCreateMenuItemFromId(itemId);
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie", "Liste" }));
MenuDescriptor desc = this.extension.getCreateMenuItemFromId(itemId);
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie", "Liste" }));
//
final List<ComponentDescritor> compDescList = extension.getCreateComponentList();
componentIds = new Vector<String>(compDescList.size());
final List<ComponentDescritor> compDescList = this.extension.getCreateComponentList();
this.componentIds = new Vector<String>(compDescList.size());
for (ComponentDescritor componentDescritor : compDescList) {
final String id = componentDescritor.getId();
if (id != null) {
componentIds.add(id);
this.componentIds.add(id);
}
}
 
Collections.sort(componentIds);
Collections.sort(this.componentIds);
 
final List<ListDescriptor> listDescList = extension.getCreateListList();
listIds = new Vector<>(listDescList.size());
final List<ListDescriptor> listDescList = this.extension.getCreateListList();
this.listIds = new Vector<>(listDescList.size());
for (ListDescriptor listDescritor : listDescList) {
final String id = listDescritor.getId();
if (id != null) {
listIds.add(id);
this.listIds.add(id);
}
}
 
Collections.sort(listIds);
Collections.sort(this.listIds);
//
 
String type = desc.getType();
if (type.equals(MenuDescriptor.CREATE)) {
final String componentId = desc.getComponentId();
if (!componentIds.contains(componentId) && componentId != null) {
componentIds.add(componentId);
if (!this.componentIds.contains(componentId) && componentId != null) {
this.componentIds.add(componentId);
}
comboActionType.setSelectedIndex(0);
comboActionChoice.setModel(new DefaultComboBoxModel(componentIds));
comboActionChoice.setSelectedItem(componentId);
this.comboActionType.setSelectedIndex(0);
this.comboActionChoice.setModel(new DefaultComboBoxModel(this.componentIds));
this.comboActionChoice.setSelectedItem(componentId);
 
} else if (type.equals(MenuDescriptor.LIST)) {
final String listId = desc.getListId();
if (!listIds.contains(listId) && listId != null) {
listIds.add(listId);
if (!this.listIds.contains(listId) && listId != null) {
this.listIds.add(listId);
}
comboActionType.setSelectedIndex(1);
comboActionChoice.setModel(new DefaultComboBoxModel(listIds));
comboActionChoice.setSelectedItem(listId);
this.comboActionType.setSelectedIndex(1);
this.comboActionChoice.setModel(new DefaultComboBoxModel(this.listIds));
this.comboActionChoice.setSelectedItem(listId);
 
} else {
throw new IllegalArgumentException("Unknown type " + type);
263,14 → 263,14
JFrame frame = a.createFrame();
if (frame != null) {
if (frame instanceof EditFrame) {
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie" }));
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie" }));
} else if (frame instanceof IListFrame) {
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Liste" }));
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Liste" }));
} else {
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Autre" }));
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Autre" }));
}
 
comboActionChoice.setModel(new DefaultComboBoxModel(new String[] { frame.getTitle() }));
this.comboActionChoice.setModel(new DefaultComboBoxModel(new String[] { frame.getTitle() }));
} else {
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Autre" }));
comboActionChoice.setModel(new DefaultComboBoxModel(new String[] { actionForId.getClass().getName() }));
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MainMenuGroupEditor.java
49,20 → 49,20
}
 
public void fillModel() {
newModel.fillFromDescriptor(extension);
tree.setModel(newModel);
this.newModel.fillFromDescriptor(this.extension);
this.tree.setModel(this.newModel);
expand();
 
}
 
private void expand() {
tree.expandRow(0);
this.tree.expandRow(0);
 
final List<MenuDescriptor> m = new ArrayList<MenuDescriptor>();
m.addAll(extension.getCreateMenuList());
m.addAll(extension.getRemoveMenuList());
m.addAll(this.extension.getCreateMenuList());
m.addAll(this.extension.getRemoveMenuList());
for (MenuDescriptor menuDescriptor : m) {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) tree.getModel().getRoot();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) this.tree.getModel().getRoot();
@SuppressWarnings("unchecked")
final Enumeration<DefaultMutableTreeNode> e = root.depthFirstEnumeration();
while (e.hasMoreElements()) {
72,7 → 72,7
final String nodeLabel = ((Item) userObject).getId();
if (nodeLabel != null && nodeLabel.equals(menuDescriptor.getId())) {
final TreePath path = new TreePath(((DefaultMutableTreeNode) node.getParent()).getPath());
tree.expandPath(path);
this.tree.expandPath(path);
}
}
}
92,11 → 92,11
c.insets = new Insets(2, 2, 2, 0);
 
panel.add(new JLabel("Menus"), c);
newModel = new MenuItemTreeModel();
tree = new ReorderableJTree();
tree.setModel(newModel);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
this.newModel = new MenuItemTreeModel();
this.tree = new ReorderableJTree();
this.tree.setModel(this.newModel);
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
 
final DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer() {
@Override
109,7 → 109,7
final JLabel r = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (tr.getUserObject() instanceof Item) {
final String id = ((Item) tr.getUserObject()).getId();
if (extension.getCreateMenuItemFromId(id) != null) {
if (MainMenuGroupEditor.this.extension.getCreateMenuItemFromId(id) != null) {
r.setForeground(new Color(50, 80, 150));
}
}
116,13 → 116,16
if (!tr.isActive()) {
r.setForeground(Color.LIGHT_GRAY);
}
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;
170,13 → 173,13
removeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
final TreePath selectionPath = MainMenuGroupEditor.this.tree.getSelectionPath();
if (selectionPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
if (node.getUserObject() != null) {
String idToDelete = ((Item) node.getUserObject()).getId();
extension.removeCreateMenuForId(idToDelete);
extension.setChanged();
MainMenuGroupEditor.this.extension.removeCreateMenuForId(idToDelete);
MainMenuGroupEditor.this.extension.setChanged();
fillModel();
}
 
187,21 → 190,21
 
@Override
public void actionPerformed(ActionEvent e) {
newModel.setShowAll(hideCheckbox.isSelected());
newModel.fillFromDescriptor(extension);
MainMenuGroupEditor.this.newModel.setShowAll(hideCheckbox.isSelected());
MainMenuGroupEditor.this.newModel.fillFromDescriptor(MainMenuGroupEditor.this.extension);
}
 
});
tree.addTreeSelectionListener(new TreeSelectionListener() {
this.tree.addTreeSelectionListener(new TreeSelectionListener() {
 
@Override
public void valueChanged(TreeSelectionEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
final TreePath selectionPath = MainMenuGroupEditor.this.tree.getSelectionPath();
if (selectionPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
if (node.getUserObject() != null) {
String selectedId = ((Item) node.getUserObject()).getId();
removeButton.setEnabled(extension.getCreateMenuItemFromId(selectedId) != null);
removeButton.setEnabled(MainMenuGroupEditor.this.extension.getCreateMenuItemFromId(selectedId) != null);
}
} else {
removeButton.setEnabled(false);
209,26 → 212,26
 
}
});
tree.addMouseListener(new MouseAdapter() {
this.tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
newModel.toggleActive(tree.getSelectionPath());
MainMenuGroupEditor.this.newModel.toggleActive(MainMenuGroupEditor.this.tree.getSelectionPath());
}
}
 
@Override
public void mousePressed(MouseEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
final TreePath selectionPath = MainMenuGroupEditor.this.tree.getSelectionPath();
if (selectionPath == null) {
setRightPanel(new JPanel());
} else {
Item i = (Item) ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject();
setRightPanel(new MenuItemEditor(newModel, i, extension));
setRightPanel(new MenuItemEditor(MainMenuGroupEditor.this.newModel, i, MainMenuGroupEditor.this.extension));
}
}
});
tree.getModel().addTreeModelListener(new TreeModelListener() {
this.tree.getModel().addTreeModelListener(new TreeModelListener() {
 
@Override
public void treeStructureChanged(TreeModelEvent e) {
257,13 → 260,13
}
 
protected void addNewGroup() {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (this.tree.getModel().getRoot())).getFirstChild();
DefaultMutableTreeNode node = root;
if (node.getChildCount() > 0) {
node = (DefaultMutableTreeNode) node.getFirstChild();
}
if (tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (this.tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
}
if (node != root) {
final String newGroupId = "group" + node.getParent().getChildCount() + 1;
274,23 → 277,23
final MenuDescriptor desc = new MenuDescriptor(newGroupId);
desc.setType(MenuDescriptor.GROUP);
desc.setInsertInMenu(((Item) parent.getUserObject()).getId());
extension.addCreateMenu(desc);
extension.setChanged();
this.extension.addCreateMenu(desc);
this.extension.setChanged();
 
newModel.reload();
tree.setSelectionPath(new TreePath(newModel.getPathToRoot(newNode)));
this.newModel.reload();
this.tree.setSelectionPath(new TreePath(this.newModel.getPathToRoot(newNode)));
}
extension.setChanged();
this.extension.setChanged();
}
 
protected void addNewItem() {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (this.tree.getModel().getRoot())).getFirstChild();
DefaultMutableTreeNode node = root;
if (node.getChildCount() > 0) {
node = (DefaultMutableTreeNode) node.getFirstChild();
}
if (tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (this.tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
}
if (node != root) {
final String newActionId = "action" + node.getParent().getChildCount() + 1;
300,10 → 303,10
final MenuDescriptor desc = new MenuDescriptor(newActionId);
desc.setType(MenuDescriptor.CREATE);
desc.setInsertInMenu(((Item) parent.getUserObject()).getId());
extension.addCreateMenu(desc);
extension.setChanged();
newModel.reload();
tree.setSelectionPath(new TreePath(newModel.getPathToRoot(newNode)));
this.extension.addCreateMenu(desc);
this.extension.setChanged();
this.newModel.reload();
this.tree.setSelectionPath(new TreePath(this.newModel.getPathToRoot(newNode)));
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MenuDescriptor.java
16,7 → 16,7
}
 
public String getId() {
return id;
return this.id;
}
 
public void setId(String id) {
24,7 → 24,7
}
 
public String getListId() {
return listId;
return this.listId;
}
 
public void setListId(String listId) {
32,7 → 32,7
}
 
public String getComponentId() {
return componentId;
return this.componentId;
}
 
public void setComponentId(String componentId) {
44,7 → 44,7
* @return "list" or "create"
* */
public String getType() {
return type;
return this.type;
}
 
public void setType(String type) {
52,7 → 52,7
}
 
public String getInsertInMenu() {
return insertInMenu;
return this.insertInMenu;
}
 
public void setInsertInMenu(String insertInMenu) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/MenuCreateMainPanel.java
9,12 → 9,12
 
public MenuCreateMainPanel(Extension extension) {
super(extension);
split.setDividerLocation(0.5D);
this.split.setDividerLocation(0.5D);
}
 
@Override
public JComponent createLeftComponent() {
return new MenuListPanel(extension, this);
return new MenuListPanel(this.extension, this);
}
 
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionListPanel.java
18,10 → 18,10
}
this.extensionBuilderModule = extensionBuilderModule;
this.setLayout(new GridLayout(1, 1));
newLeftComponent = new ExtensionMainListPanel(this);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, rPanel);
this.newLeftComponent = new ExtensionMainListPanel(this);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.newLeftComponent, this.rPanel);
this.add(this.split);
newLeftComponent.fill();
this.newLeftComponent.fill();
}
 
public void setRightPanel(JComponent p) {
32,11 → 32,11
}
 
public ExtensionBuilderModule getExtensionBuilderModule() {
return extensionBuilderModule;
return this.extensionBuilderModule;
}
 
public void modelChanged() {
newLeftComponent.modelChanged();
this.newLeftComponent.modelChanged();
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionBuilderModule.java
89,7 → 89,7
}
Log.get().info("setupMenu");
// Start previously started extensions
for (Extension extension : extensions) {
for (Extension extension : this.extensions) {
if (extension.isAutoStart()) {
try {
extension.setupMenu(ctxt);
108,7 → 108,7
final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
 
// Start previously started extensions
for (Extension extension : extensions) {
for (Extension extension : this.extensions) {
if (extension.isAutoStart()) {
try {
extension.start(root, true);
124,7 → 124,7
 
@Override
protected void stop() {
for (Extension extension : extensions) {
for (Extension extension : this.extensions) {
extension.stop();
}
this.extensions.clear();
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionListModel.java
17,7 → 17,7
}
 
public void fill(final EditableListPanel list) {
addAll(moduleListPanel.getExtensionBuilderModule().getExtensions());
addAll(this.moduleListPanel.getExtensionBuilderModule().getExtensions());
final int size = this.getSize();
if (size > 0) {
final Object firstElement = firstElement();
39,7 → 39,7
@Override
public void addElement(Object obj) {
final Extension e = (Extension) obj;
moduleListPanel.getExtensionBuilderModule().add(e);
this.moduleListPanel.getExtensionBuilderModule().add(e);
e.addChangeListener(this);
super.addElement(obj);
}
49,7 → 49,7
final Extension extenstion = (Extension) obj;
final int answer = JOptionPane.showConfirmDialog(new JFrame(), "Voulez vous vraiment supprimer l'extension " + extenstion.getName() + " ?", "Suppression", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.OK_OPTION) {
moduleListPanel.getExtensionBuilderModule().remove(extenstion);
this.moduleListPanel.getExtensionBuilderModule().remove(extenstion);
extenstion.removeChangeListener(this);
return super.removeElement(obj);
}
58,7 → 58,7
 
@Override
public void stateChanged(ChangeEvent e) {
moduleListPanel.modelChanged();
this.moduleListPanel.modelChanged();
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListDescriptor.java
15,7 → 15,7
}
 
public String getId() {
return id;
return this.id;
}
 
public void setId(String id) {
27,11 → 27,11
}
 
public String getMainTable() {
return mainTable;
return this.mainTable;
}
 
public List<ColumnDescriptor> getColumns() {
return columns;
return this.columns;
}
 
@Override
51,4 → 51,8
public void removeAllColumns() {
this.columns.clear();
}
 
public void remove(ColumnDescriptor c) {
this.columns.remove(c);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ColumnDescriptor.java
15,14 → 15,14
}
 
public String getId() {
return id;
return this.id;
}
 
public String getFieldsPaths() {
String r = "";
final int size = fieldPaths.size();
final int size = this.fieldPaths.size();
for (int i = 0; i < size; i++) {
String fieldPath = fieldPaths.get(i);
String fieldPath = this.fieldPaths.get(i);
if (i != 0) {
r += ",";
}
33,14 → 33,14
 
public void setFieldsPaths(String paths) {
final List<String> l = StringUtils.fastSplit(paths, ',');
fieldPaths.clear();
this.fieldPaths.clear();
for (String string : l) {
fieldPaths.add(string.trim());
this.fieldPaths.add(string.trim());
}
}
 
public String getStyle() {
return style;
return this.style;
}
 
public void setStyle(String style) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/CreateListListModel.java
17,7 → 17,7
}
 
private void addContent() {
this.addAll(extension.getCreateListList());
this.addAll(this.extension.getCreateListList());
}
 
@Override
28,11 → 28,11
 
public void addNewList() {
final ListDescriptor l = new ListDescriptor("liste " + (this.getSize() + 1));
final List<String> allKnownTableNames = extension.getAllKnownTableNames();
final List<String> allKnownTableNames = this.extension.getAllKnownTableNames();
final String mainTable = allKnownTableNames.get(0);
l.setMainTable(mainTable);
this.addElement(l);
extension.addCreateList(l);
this.extension.addCreateList(l);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListCreatePanel.java
38,16 → 38,16
c.weighty = 1;
c.gridwidth = 2;
c.fill = GridBagConstraints.BOTH;
panel = new FieldDescSelector(n, extension);
this.panel = new FieldDescSelector(n, extension);
final String mainTable = n.getMainTable();
if (mainTable == null && comboTable.getModel().getSize() > 0) {
comboTable.setSelectedIndex(0);
panel.setMainTable((String) comboTable.getModel().getElementAt(0));
this.panel.setMainTable((String) comboTable.getModel().getElementAt(0));
} else {
comboTable.setSelectedItem(mainTable);
panel.setMainTable(mainTable);
this.panel.setMainTable(mainTable);
}
this.add(panel, c);
this.add(this.panel, c);
 
comboTable.addActionListener(new ActionListener() {
 
54,7 → 54,7
@Override
public void actionPerformed(ActionEvent e) {
n.removeAllColumns();
panel.setMainTable((String) comboTable.getSelectedItem());
ListCreatePanel.this.panel.setMainTable((String) comboTable.getSelectedItem());
extension.setChanged();
}
});
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/FieldDescSelector.java
9,6 → 9,7
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
 
import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
46,8 → 47,8
// Col 0
c.gridx = 0;
c.gridy++;
treeModel = new FieldTreeModel(extension);
this.tree = new JTree(treeModel) {
this.treeModel = new FieldTreeModel(extension);
this.tree = new JTree(this.treeModel) {
@Override
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
61,19 → 62,19
return " " + d.getName();
}
};
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
final DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();
 
treeRenderer.setLeafIcon(null);
treeRenderer.setOpenIcon(new ImageIcon(this.getClass().getResource("ref.png")));
treeRenderer.setClosedIcon(new ImageIcon(this.getClass().getResource("ref.png")));
tree.setCellRenderer(treeRenderer);
this.tree.setCellRenderer(treeRenderer);
c.gridheight = 2;
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(new JScrollPane(tree), c);
this.add(new JScrollPane(this.tree), c);
// Col 1
c.gridx = 1;
c.gridheight = 1;
93,7 → 94,7
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
listModel = new DefaultListModel() {
this.listModel = new DefaultListModel() {
@Override
public void addElement(Object obj) {
if (!(obj instanceof ColumnDescriptor)) {
103,9 → 104,9
}
 
};
list = new ReorderableJList();
list.setModel(listModel);
list.setCellRenderer(new DefaultListCellRenderer() {
this.list = new ReorderableJList();
this.list.setModel(this.listModel);
this.list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
ColumnDescriptor f = (ColumnDescriptor) value;
113,9 → 114,9
return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
}
});
this.add(new JScrollPane(list), c);
this.add(new JScrollPane(this.list), c);
// Listeners
tree.addMouseListener(new MouseAdapter() {
this.tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
140,7 → 141,7
 
}
});
list.addKeyListener(new KeyAdapter() {
this.list.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
154,8 → 155,8
 
public void setMainTable(String table) {
this.listDescriptor.setMainTable(table);
treeModel.fillFromTable(table);
listModel.removeAllElements();
this.treeModel.fillFromTable(table);
this.listModel.removeAllElements();
for (ColumnDescriptor d : this.listDescriptor.getColumns()) {
this.listModel.addElement(d);
}
162,18 → 163,24
}
 
private void deleteSelectedInList() {
Object[] vals = list.getSelectedValues();
if (vals == null)
List<Object> vals = this.list.getSelectedValuesList();
if (vals.isEmpty())
return;
for (int i = 0; i < vals.length; i++) {
Object object = vals[i];
this.listModel.removeElement(object);
for (Object object : vals) {
boolean b = this.listModel.removeElement(object);
if (!b) {
throw new IllegalStateException("cannot remove " + object + " from list model " + this.listModel);
}
list.clearSelection();
if (object instanceof ColumnDescriptor) {
ColumnDescriptor c = (ColumnDescriptor) object;
this.listDescriptor.remove(c);
}
}
this.list.clearSelection();
}
 
private void addTreeSelectionToList() {
final TreePath[] paths = tree.getSelectionPaths();
final TreePath[] paths = this.tree.getSelectionPaths();
if (paths == null)
return;
for (int i = 0; i < paths.length; i++) {
203,10 → 210,10
if (d != null && root != null) {
boolean add = true;
final String extendedLabel = root.getPath();
final int size = listModel.getSize();
final int size = this.listModel.getSize();
// Check if already in the list
for (int j = 0; j < size; j++) {
if (((ColumnDescriptor) listModel.getElementAt(j)).getFieldsPaths().contains(extendedLabel)) {
if (((ColumnDescriptor) this.listModel.getElementAt(j)).getFieldsPaths().contains(extendedLabel)) {
add = false;
break;
}
214,12 → 221,12
if (add) {
final ColumnDescriptor colDesc = new ColumnDescriptor(root.getPath());
colDesc.setFieldsPaths(root.getPath());
listModel.addElement(colDesc);
listDescriptor.add(colDesc);
this.listModel.addElement(colDesc);
this.listDescriptor.add(colDesc);
}
}
}
tree.clearSelection();
this.tree.clearSelection();
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/FieldTreeModel.java
80,7 → 80,7
newChild.setAllowsChildren(false);
}
}
this.setRoot(root);
this.setRoot(this.root);
}
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListCreateMainPanel.java
13,7 → 13,7
 
@Override
public JComponent createLeftComponent() {
return new ListListPanel(extension, this);
return new ListListPanel(this.extension, this);
}
 
public void select(ListDescriptor listDescriptor) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/EditableListPanel.java
43,9 → 43,9
if (title != null) {
this.add(new JLabel(title), c);
}
list = new JList(dataModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane comp2 = new JScrollPane(list);
this.list = new JList(dataModel);
this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane comp2 = new JScrollPane(this.list);
comp2.setMinimumSize(new Dimension(150, 150));
comp2.setPreferredSize(new Dimension(150, 150));
c.weighty = 1;
64,15 → 64,15
this.add(addButton, c);
c.gridy++;
if (canRename) {
renameButton = new JButton("Renommer");
this.add(renameButton, c);
renameButton.setEnabled(false);
renameButton.addActionListener(new ActionListener() {
this.renameButton = new JButton("Renommer");
this.add(this.renameButton, c);
this.renameButton.setEnabled(false);
this.renameButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
if (list.getSelectedValue() != null) {
renameItem(list.getSelectedValue());
if (EditableListPanel.this.list.getSelectedValue() != null) {
renameItem(EditableListPanel.this.list.getSelectedValue());
}
}
 
80,9 → 80,9
c.gridy++;
}
 
removeButton = new JButton("Supprimer");
removeButton.setEnabled(false);
this.add(removeButton, c);
this.removeButton = new JButton("Supprimer");
this.removeButton.setEnabled(false);
this.add(this.removeButton, c);
 
// init
 
98,25 → 98,25
 
});
 
removeButton.addActionListener(new ActionListener() {
this.removeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (list.getSelectedValue() != null) {
removeItem(list.getSelectedValue());
if (EditableListPanel.this.list.getSelectedValue() != null) {
removeItem(EditableListPanel.this.list.getSelectedValue());
}
}
});
}
list.addListSelectionListener(new ListSelectionListener() {
this.list.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
final Object selectedValue = list.getSelectedValue();
if (removeButton != null) {
removeButton.setEnabled(selectedValue != null);
final Object selectedValue = EditableListPanel.this.list.getSelectedValue();
if (EditableListPanel.this.removeButton != null) {
EditableListPanel.this.removeButton.setEnabled(selectedValue != null);
}
if (renameButton != null) {
renameButton.setEnabled(selectedValue != null);
if (EditableListPanel.this.renameButton != null) {
EditableListPanel.this.renameButton.setEnabled(selectedValue != null);
}
if (!e.getValueIsAdjusting() && selectedValue != null) {
 
136,7 → 136,7
* Select an item in the list
* */
public void selectItem(Object item) {
list.setSelectedValue(item, true);
this.list.setSelectedValue(item, true);
}
 
/**
162,7 → 162,7
public abstract void itemSelected(Object item);
 
public void reload() {
list.invalidate();
list.repaint();
this.list.invalidate();
this.list.repaint();
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListListPanel.java
21,7 → 21,7
 
@Override
public void addNewItem() {
((CreateListListModel) dataModel).addNewList();
((CreateListListModel) this.dataModel).addNewList();
}
 
@Override
36,8 → 36,8
 
@Override
public void removeItem(Object item) {
((CreateListListModel) dataModel).removeElement(item);
extension.removeCreateList((ListDescriptor) item);
((CreateListListModel) this.dataModel).removeElement(item);
this.extension.removeCreateList((ListDescriptor) item);
}
 
@Override
44,10 → 44,10
public void itemSelected(Object item) {
if (item != null) {
ListDescriptor n = (ListDescriptor) item;
final ListCreatePanel p = new ListCreatePanel(n, extension);
tableInfoPanel.setRightPanel(p);
final ListCreatePanel p = new ListCreatePanel(n, this.extension);
this.tableInfoPanel.setRightPanel(p);
} else {
tableInfoPanel.setRightPanel(new JPanel());
this.tableInfoPanel.setRightPanel(new JPanel());
}
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/AbstractSplittedPanel.java
15,14 → 15,14
this.extension = extension;
this.setLayout(new GridLayout(1, 1));
this.setOpaque(false);
leftComponent = createLeftComponent();
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, new JPanel());
this.add(split);
this.leftComponent = createLeftComponent();
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.leftComponent, new JPanel());
this.add(this.split);
}
 
public void setRightPanel(JComponent p) {
this.invalidate();
split.setRightComponent(p);
this.split.setRightComponent(p);
this.revalidate();
this.repaint();
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionMainListPanel.java
22,6 → 22,7
this.moduleListPanel = moduleListPanel;
this.list.setFixedCellHeight(new JLabel("A").getPreferredSize().height + 8);
this.list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, ((Extension) value).getName(), index, isSelected, cellHasFocus);
Extension e = (Extension) value;
35,13 → 36,13
}
 
public void fill() {
((ExtensionListModel) dataModel).fill(this);
((ExtensionListModel) this.dataModel).fill(this);
 
}
 
@Override
public void addNewItem() {
((ExtensionListModel) dataModel).addNewModule();
((ExtensionListModel) this.dataModel).addNewModule();
}
 
@Override
56,22 → 57,22
 
@Override
public void removeItem(Object item) {
((ExtensionListModel) dataModel).removeElement(item);
((ExtensionListModel) this.dataModel).removeElement(item);
}
 
@Override
public void itemSelected(Object item) {
if (item != null) {
final ExtensionInfoPanel p = new ExtensionInfoPanel((Extension) item, moduleListPanel);
moduleListPanel.setRightPanel(p);
final ExtensionInfoPanel p = new ExtensionInfoPanel((Extension) item, this.moduleListPanel);
this.moduleListPanel.setRightPanel(p);
} else {
moduleListPanel.setRightPanel(new JPanel());
this.moduleListPanel.setRightPanel(new JPanel());
}
 
}
 
public void modelChanged() {
list.invalidate();
list.repaint();
this.list.invalidate();
this.list.repaint();
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/meu/actions/ActionListPanel.java
15,14 → 15,14
 
public class ActionListPanel extends EditableListPanel {
 
private ActionMainPanel tableTranslationPanel;
private ActionMainPanel actionPanel;
private Extension extension;
 
public ActionListPanel(Extension extension, ActionMainPanel tableTranslationPanel) {
super(new AllKnownActionsListModel(extension), "Actions", "", true, true);
public ActionListPanel(Extension extension, ActionMainPanel actionPanel) {
super(new AllKnownActionsListModel(extension), "Actions", "Ajouter une action", true, true);
this.extension = extension;
this.tableTranslationPanel = tableTranslationPanel;
list.setCellRenderer(new DefaultListCellRenderer() {
this.actionPanel = actionPanel;
this.list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
value = ((ActionDescriptor) value).getId();
33,9 → 33,16
 
@Override
public void addNewItem() {
((AllKnownActionsListModel) this.dataModel).addAction();
}
 
@Override
public void removeItem(Object item) {
((AllKnownActionsListModel) this.dataModel).removeElement(item);
this.extension.removeCreateAction((ActionDescriptor) item);
}
 
@Override
public void renameItem(Object item) {
final ActionDescriptor e = (ActionDescriptor) item;
final Window w = SwingUtilities.windowForComponent(this);
42,19 → 49,16
final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la liste", JOptionPane.PLAIN_MESSAGE, null, null, e.getId());
if ((s != null) && (s.length() > 0)) {
e.setId(s);
reload();
}
}
 
@Override
public void removeItem(Object item) {
}
 
@Override
public void itemSelected(Object item) {
if (item != null) {
tableTranslationPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, extension)));
this.actionPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, this.extension)));
} else {
tableTranslationPanel.setRightPanel(new JPanel());
this.actionPanel.setRightPanel(new JPanel());
}
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/meu/actions/ActionDescriptor.java
3,9 → 3,9
public class ActionDescriptor {
 
private String id;
private String location; // header, popup, both
private String table;
private String componentId;
private String location = LOCATION_HEADER_POPUP; // header, popup, both
private String table = "";
private String componentId = "";
public static final String LOCATION_HEADER = "header";
public static final String LOCATION_POPUP = "popup";
public static final String LOCATION_HEADER_POPUP = "header,popup";
15,7 → 15,7
}
 
public String getId() {
return id;
return this.id;
}
 
public void setId(String id) {
23,7 → 23,7
}
 
public String getLocation() {
return location;
return this.location;
}
 
public void setLocation(String location) {
31,7 → 31,7
}
 
public String getTable() {
return table;
return this.table;
}
 
public void setTable(String table) {
39,7 → 39,7
}
 
public String getComponentId() {
return componentId;
return this.componentId;
}
 
public void setComponentId(String componentId) {
46,4 → 46,11
this.componentId = componentId;
}
 
@Override
public boolean equals(Object obj) {
if (obj instanceof ActionDescriptor) {
return this.id.equals(((ActionDescriptor) obj).id);
}
return super.equals(obj);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/meu/actions/ActionMainPanel.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/meu/actions/ActionItemEditor.java
44,8 → 44,8
 
c.weightx = 1;
 
textId = new JTextField();
this.add(textId, c);
this.textId = new JTextField();
this.add(this.textId, c);
 
//
final List<ComponentDescritor> l = extension.getCreateComponentList();
63,16 → 63,18
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel("Composant", SwingConstants.RIGHT), c);
c.gridx++;
comboComponent = new JComboBox(v);
comboComponent.setRenderer(new DefaultListCellRenderer() {
this.comboComponent = new JComboBox(v);
this.comboComponent.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value != null) {
value = ((ComponentDescritor) value).getId();
}
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
c.fill = GridBagConstraints.NONE;
this.add(comboComponent, c);
this.add(this.comboComponent, c);
 
c.gridx = 0;
c.gridy++;
81,9 → 83,9
this.add(new JLabel("Table", SwingConstants.RIGHT), c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
textTable = new JTextField(30);
textTable.setEnabled(false);
this.add(textTable, c);
this.textTable = new JTextField(30);
this.textTable.setEnabled(false);
this.add(this.textTable, c);
// Location
c.gridx = 0;
c.gridy++;
92,8 → 94,8
this.add(new JLabel("Emplacement", SwingConstants.RIGHT), c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
comboLocation = new JComboBox(new String[] { "Bouton et clic droit", "clic droit uniquement", "bouton uniquement" });
this.add(comboLocation, c);
this.comboLocation = new JComboBox(new String[] { "Bouton et clic droit", "clic droit uniquement", "bouton uniquement" });
this.add(this.comboLocation, c);
c.gridy++;
c.weighty = 1;
this.add(new JPanel(), c);
100,25 → 102,25
 
initUIFrom(actionDescriptor);
 
comboComponent.addActionListener(new ActionListener() {
this.comboComponent.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final ComponentDescritor componentDescritor = getComponentDescritor(comboComponent.getSelectedItem().toString());
final ComponentDescritor componentDescritor = getComponentDescritor(ActionItemEditor.this.comboComponent.getSelectedItem().toString());
if (componentDescritor != null) {
textTable.setText(componentDescritor.getTable());
ActionItemEditor.this.textTable.setText(componentDescritor.getTable());
actionDescriptor.setComponentId(componentDescritor.getId());
actionDescriptor.setTable(componentDescritor.getTable());
} else {
textTable.setText("");
ActionItemEditor.this.textTable.setText("");
}
}
});
comboLocation.addActionListener(new ActionListener() {
this.comboLocation.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
int index = comboLocation.getSelectedIndex();
int index = ActionItemEditor.this.comboLocation.getSelectedIndex();
if (index == 0) {
actionDescriptor.setLocation(ActionDescriptor.LOCATION_HEADER_POPUP);
} else if (index == 1) {
129,7 → 131,7
 
}
});
textId.getDocument().addDocumentListener(new DocumentListener() {
this.textId.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
145,7 → 147,7
 
@Override
public void changedUpdate(DocumentEvent e) {
actionDescriptor.setId(textId.getText());
actionDescriptor.setId(ActionItemEditor.this.textId.getText());
}
});
 
153,24 → 155,24
 
private void initUIFrom(ActionDescriptor item) {
 
textId.setText(item.getId());
this.textId.setText(item.getId());
final ComponentDescritor componentDescritor = getComponentDescritor(item.getComponentId());
if (componentDescritor != null) {
comboComponent.setSelectedItem(componentDescritor);
this.comboComponent.setSelectedItem(componentDescritor);
}
textTable.setText(item.getTable());
this.textTable.setText(item.getTable());
String loc = item.getLocation();
if (loc.equals(ActionDescriptor.LOCATION_HEADER_POPUP)) {
comboLocation.setSelectedIndex(0);
this.comboLocation.setSelectedIndex(0);
} else if (loc.equals(ActionDescriptor.LOCATION_HEADER)) {
comboLocation.setSelectedIndex(2);
this.comboLocation.setSelectedIndex(2);
} else {
comboLocation.setSelectedIndex(1);
this.comboLocation.setSelectedIndex(1);
}
}
 
private ComponentDescritor getComponentDescritor(String componentId) {
List<ComponentDescritor> l = extension.getCreateComponentList();
List<ComponentDescritor> l = this.extension.getCreateComponentList();
for (ComponentDescritor componentDescritor : l) {
if (componentDescritor.getId().equals(componentId)) {
return componentDescritor;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/meu/actions/AllKnownActionsListModel.java
6,9 → 6,18
import org.openconcerto.ui.DefaultListModel;
 
public class AllKnownActionsListModel extends DefaultListModel {
private final Extension extension;
 
public AllKnownActionsListModel(Extension module) {
List<ActionDescriptor> l = module.getActionDescriptors();
public AllKnownActionsListModel(Extension extension) {
final List<ActionDescriptor> l = extension.getActionDescriptors();
this.addAll(l);
this.extension = extension;
}
 
public void addAction() {
final ActionDescriptor obj = new ActionDescriptor("Action_" + this.size());
this.addElement(obj);
this.extension.addCreateAction(obj);
 
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableListPanel.java
23,7 → 23,7
 
@Override
public void addNewItem() {
((CreateTableListModel) dataModel).addNewTable();
((CreateTableListModel) this.dataModel).addNewTable();
}
 
@Override
30,7 → 30,7
public void renameItem(Object item) {
final TableDescritor e = (TableDescritor) item;
final Window w = SwingUtilities.windowForComponent(this);
final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la liste", JOptionPane.PLAIN_MESSAGE, null, null, e.getName());
final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la table", JOptionPane.PLAIN_MESSAGE, null, null, e.getName());
if ((s != null) && (s.length() > 0)) {
e.setName(s);
}
38,8 → 38,8
 
@Override
public void removeItem(Object item) {
((CreateTableListModel) dataModel).removeElement(item);
extension.removeCreateTable((TableDescritor) item);
((CreateTableListModel) this.dataModel).removeElement(item);
this.extension.removeCreateTable((TableDescritor) item);
}
 
@Override
47,10 → 47,10
if (item != null) {
TableDescritor n = (TableDescritor) item;
System.out.println("TableListPanel..valueChanged():" + n);
final TableCreatePanel p = new TableCreatePanel(n, extension);
tableInfoPanel.setRightPanel(new JScrollPane(p));
final TableCreatePanel p = new TableCreatePanel(n, this.extension);
this.tableInfoPanel.setRightPanel(new JScrollPane(p));
} else {
tableInfoPanel.setRightPanel(new JPanel());
this.tableInfoPanel.setRightPanel(new JPanel());
}
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/ModifiedTableListModel.java
32,7 → 32,7
@Override
public void stateChanged(ChangeEvent e) {
this.clear();
addContent(extension);
addContent(this.extension);
this.fireContentsChanged(this, 0, this.getSize());
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableDescritor.java
36,9 → 36,9
// Create elements
ComptaPropsConfiguration conf = ComptaPropsConfiguration.getInstanceCompta();
DBRoot root = conf.getRootSociete();
if (conf.getDirectory().getElement(name) == null) {
final SQLTable table = root.getTable(name);
final SQLElement e = new SQLElement("ext." + name, "ext." + name, table) {
if (conf.getDirectory().getElement(this.name) == null) {
final SQLTable table = root.getTable(this.name);
final SQLElement e = new SQLElement("ext." + this.name, "ext." + this.name, table) {
 
@Override
protected List<String> getListFields() {
60,6 → 60,7
l.add("NOM");
} else {
ListDescriptor listDesc = null;
l.clear();
for (ListDescriptor listDescriptor : ext.getCreateListList()) {
if (listDescriptor.getMainTable().equals(getTable().getName())) {
listDesc = listDescriptor;
66,6 → 67,7
break;
}
}
if (listDesc != null) {
for (ColumnDescriptor string : listDesc.getColumns()) {
if (!string.getFieldsPaths().contains(".")) {
l.add(string.getFieldsPaths());
73,6 → 75,12
}
}
}
if (l.isEmpty()) {
if (!getTable().getContentFields().isEmpty()) {
l.add(new ArrayList<>(getTable().getContentFields()).get(0).getName());
}
}
}
return l;
}
 
101,7 → 109,7
return new ExtensionGroupSQLComponent(this, cDescriptor.getGroup());
}
}
JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + name);
JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + TableDescritor.this.name);
return null;
}
};
111,7 → 119,7
}
 
public String getName() {
return name;
return this.name;
}
 
public void setName(String name) {
119,22 → 127,22
}
 
public List<FieldDescriptor> getFields() {
return fields;
return this.fields;
}
 
public void add(FieldDescriptor f) {
fields.add(f);
this.fields.add(f);
 
}
 
public void remove(FieldDescriptor field) {
fields.remove(field);
this.fields.remove(field);
 
}
 
@Override
public String toString() {
return name;
return this.name;
}
 
public void sortFields() {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableMainPanel.java
14,14 → 14,14
public TableMainPanel(Extension extension) {
this.setLayout(new GridLayout(1, 1));
JTabbedPane tab = new JTabbedPane();
component = new TableCreateMainPanel(extension);
tab.addTab("Tables créées par l'extension", component);
this.component = new TableCreateMainPanel(extension);
tab.addTab("Tables créées par l'extension", this.component);
tab.addTab("Tables modifiées", new TableModifyMainPanel(extension));
this.add(tab);
}
 
public void select(TableDescritor tableDescriptor) {
component.select(tableDescriptor);
this.component.select(tableDescriptor);
 
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableModifyPanel.java
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(extension, field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(this.extension, field);
p.add(editor, c);
 
c.gridx++;
104,7 → 104,7
p.remove(editor);
p.remove(close);
p.revalidate();
extension.setChanged();
TableModifyPanel.this.extension.setChanged();
}
});
c.gridy++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/FieldDescriptor.java
39,14 → 39,14
@Override
public String toString() {
String string = this.table + " " + this.name + " type:" + this.type + " default:" + this.defaultValue + " l:" + this.length + " t:" + this.foreignTable;
if (link != null) {
string += " => " + link.toString();
if (this.link != null) {
string += " => " + this.link.toString();
}
return string;
}
 
public String getName() {
return name;
return this.name;
}
 
public void setName(String name) {
54,7 → 54,7
}
 
public String getType() {
return type;
return this.type;
}
 
public void setType(String type) {
62,7 → 62,7
}
 
public String getDefaultValue() {
return defaultValue;
return this.defaultValue;
}
 
public void setDefaultValue(String defaultValue) {
70,7 → 70,7
}
 
public String getLength() {
return length;
return this.length;
}
 
public void setLength(String length) {
78,7 → 78,7
}
 
public String getTable() {
return table;
return this.table;
}
 
public void setLink(FieldDescriptor fieldDescriptor) {
86,7 → 86,7
}
 
public FieldDescriptor getLink() {
return link;
return this.link;
}
 
public void setForeignTable(String foreignTable) {
94,7 → 94,7
}
 
public String getForeignTable() {
return foreignTable;
return this.foreignTable;
}
 
public String getExtendedLabel() {
111,8 → 111,8
public boolean equals(Object obj) {
if (obj instanceof FieldDescriptor) {
FieldDescriptor f = (FieldDescriptor) obj;
if (getTable().equals(f.getTable()) && getName().equals(f.getTable())) {
return getLink() != null && getLink().equals(f.getLink());
if (getTable().equals(f.getTable()) && getName().equals(f.getName())) {
return (getLink() == null && f.getLink() == null) || (getLink() != null && getLink().equals(f.getLink()));
} else {
return false;
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableModifyMainPanel.java
14,13 → 14,13
public TableModifyMainPanel(Extension extension) {
this.setLayout(new GridLayout(1, 1));
final TableModifyLeftPanel newLeftComponent = new TableModifyLeftPanel(extension, this);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, new JPanel());
this.add(split);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, new JPanel());
this.add(this.split);
}
 
public void setRightPanel(JComponent p) {
this.invalidate();
split.setRightComponent(p);
this.split.setRightComponent(p);
this.revalidate();
this.repaint();
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/CreateTableListModel.java
30,18 → 30,18
// FIXME: ensure table does not exists
final TableDescritor obj = new TableDescritor("TABLE_" + this.size());
this.addElement(obj);
extension.addCreateTable(obj);
this.extension.addCreateTable(obj);
}
 
@Override
public boolean removeElement(Object obj) {
extension.removeCreateTable((TableDescritor) obj);
this.extension.removeCreateTable((TableDescritor) obj);
return super.removeElement(obj);
}
 
@Override
public void stateChanged(ChangeEvent e) {
this.loadContent(extension);
this.loadContent(this.extension);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/ElementDescriptor.java
10,15 → 10,15
}
 
public String getId() {
return id;
return this.id;
}
 
public String getTableName() {
return tableName;
return this.tableName;
}
 
@Override
public String toString() {
return "ElementDescriptor id: " + id + " table: " + tableName;
return "ElementDescriptor id: " + this.id + " table: " + this.tableName;
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/FieldDescriptorEditor.java
1,16 → 1,22
package org.openconcerto.modules.extensionbuilder.table;
 
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.Vector;
 
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
54,30 → 60,30
this.add(new JLabel("Type"), c);
c.gridx++;
 
comboType = new JComboBox(types);
comboType.setOpaque(false);
this.add(comboType, c);
this.comboType = new JComboBox(this.types);
this.comboType.setOpaque(false);
this.add(this.comboType, c);
c.gridx++;
this.add(new JLabel("Nom"), c);
c.gridx++;
c.weightx = 1;
fieldName = new JTextField(10);
this.add(fieldName, c);
this.fieldName = new JTextField(10);
this.add(this.fieldName, c);
c.weightx = 0;
c.gridx++;
labelOption = new JLabel("Longeur max");
this.add(labelOption, c);
this.labelOption = new JLabel("Longeur max");
this.add(this.labelOption, c);
c.gridx++;
textOption = new JTextField(6);
this.textOption = new JTextField(6);
c.gridx++;
this.add(textOption, c);
comboOption = new JComboBox();
this.add(this.textOption, c);
this.comboOption = new JComboBox();
 
this.add(comboOption, c);
this.add(this.comboOption, c);
 
updateFrom(fd);
comboType.addActionListener(this);
fieldName.getDocument().addDocumentListener(new DocumentListener() {
this.comboType.addActionListener(this);
this.fieldName.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
97,8 → 103,8
 
}
});
comboOption.addActionListener(this);
textOption.getDocument().addDocumentListener(new DocumentListener() {
this.comboOption.addActionListener(this);
this.textOption.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
125,7 → 131,7
if (text.trim().length() > 0) {
this.fd.setName(text);
}
extension.setChanged();
this.extension.setChanged();
 
}
 
136,128 → 142,127
switch (this.comboType.getSelectedIndex()) {
 
case TYPE_STRING:
fd.setLength(text);
fd.setDefaultValue(null);
fd.setForeignTable(null);
fd.setLink(null);
this.fd.setLength(text);
this.fd.setDefaultValue(null);
this.fd.setForeignTable(null);
this.fd.setLink(null);
break;
case TYPE_INTEGER:
fd.setLength(null);
this.fd.setLength(null);
try {
int i = Integer.parseInt(text);
fd.setDefaultValue(text);
this.fd.setDefaultValue(text);
} catch (Exception e) {
fd.setDefaultValue("0");
this.fd.setDefaultValue("0");
}
fd.setForeignTable(null);
fd.setLink(null);
this.fd.setForeignTable(null);
this.fd.setLink(null);
case TYPE_DECIMAL:
fd.setLength(null);
this.fd.setLength(null);
try {
text = text.replace(',', '.');
float i = Float.parseFloat(text);
fd.setDefaultValue(text);
this.fd.setDefaultValue(text);
} catch (Exception e) {
fd.setDefaultValue("0");
this.fd.setDefaultValue("0");
}
fd.setForeignTable(null);
fd.setLink(null);
this.fd.setForeignTable(null);
this.fd.setLink(null);
break;
 
}
extension.setChanged();
this.extension.setChanged();
 
}
}
 
protected void comboOptionModified() {
final int index = comboOption.getSelectedIndex();
final int index = this.comboOption.getSelectedIndex();
 
switch (this.comboType.getSelectedIndex()) {
 
case TYPE_BOOLEAN:
fd.setLength(null);
this.fd.setLength(null);
if (index == 0) {
fd.setDefaultValue("true");
this.fd.setDefaultValue("true");
} else {
fd.setDefaultValue("false");
this.fd.setDefaultValue("false");
}
fd.setForeignTable(null);
fd.setLink(null);
this.fd.setForeignTable(null);
this.fd.setLink(null);
break;
case TYPE_DATE:
case TYPE_TIME:
case TYPE_DATE_TIME:
fd.setLength(null);
this.fd.setLength(null);
if (index == 0) {
fd.setDefaultValue(null);
this.fd.setDefaultValue(null);
} else {
fd.setDefaultValue("now");
this.fd.setDefaultValue("now");
}
fd.setForeignTable(null);
fd.setLink(null);
this.fd.setForeignTable(null);
this.fd.setLink(null);
break;
case TYPE_REF:
fd.setLength(null);
fd.setDefaultValue(null);
fd.setDefaultValue("now");
fd.setForeignTable(comboOption.getSelectedItem().toString());
fd.setLink(null);
this.fd.setLength(null);
this.fd.setDefaultValue(null);
this.fd.setForeignTable(this.comboOption.getSelectedItem().toString());
this.fd.setLink(null);
break;
 
}
extension.setChanged();
this.extension.setChanged();
 
}
 
private void updateFrom(FieldDescriptor fd) {
if (fd.getType().equals("string")) {
comboType.setSelectedIndex(TYPE_STRING);
labelOption.setText("Longueur max");
textOption.setVisible(true);
textOption.setText(fd.getLength());
comboOption.setVisible(false);
this.comboType.setSelectedIndex(TYPE_STRING);
this.labelOption.setText("Longueur max");
this.textOption.setVisible(true);
this.textOption.setText(fd.getLength());
this.comboOption.setVisible(false);
} else if (fd.getType().equals("integer")) {
comboType.setSelectedIndex(TYPE_INTEGER);
labelOption.setText("Valeur par défaut");
textOption.setVisible(true);
textOption.setText(fd.getDefaultValue());
comboOption.setVisible(false);
this.comboType.setSelectedIndex(TYPE_INTEGER);
this.labelOption.setText("Valeur par défaut");
this.textOption.setVisible(true);
this.textOption.setText(fd.getDefaultValue());
this.comboOption.setVisible(false);
} else if (fd.getType().equals("decimal")) {
comboType.setSelectedIndex(TYPE_DECIMAL);
labelOption.setText("Valeur par défaut");
textOption.setVisible(true);
textOption.setText(fd.getDefaultValue());
comboOption.setVisible(false);
this.comboType.setSelectedIndex(TYPE_DECIMAL);
this.labelOption.setText("Valeur par défaut");
this.textOption.setVisible(true);
this.textOption.setText(fd.getDefaultValue());
this.comboOption.setVisible(false);
} else if (fd.getType().equals("boolean")) {
comboType.setSelectedIndex(TYPE_BOOLEAN);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vBoolean));
this.comboType.setSelectedIndex(TYPE_BOOLEAN);
this.labelOption.setText("Valeur par défaut");
this.textOption.setVisible(false);
this.comboOption.setVisible(true);
this.comboOption.setModel(new DefaultComboBoxModel(vBoolean));
if (fd.getDefaultValue().equals("true")) {
comboOption.setSelectedIndex(0);
this.comboOption.setSelectedIndex(0);
} else {
comboOption.setSelectedIndex(1);
this.comboOption.setSelectedIndex(1);
}
 
} else if (fd.getType().equals("date")) {
comboType.setSelectedIndex(TYPE_DATE);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vDate));
this.comboType.setSelectedIndex(TYPE_DATE);
this.labelOption.setText("Valeur par défaut");
this.textOption.setVisible(false);
this.comboOption.setVisible(true);
this.comboOption.setModel(new DefaultComboBoxModel(vDate));
if (fd.getDefaultValue() == null || !fd.getDefaultValue().equals("now")) {
comboOption.setSelectedIndex(0);
this.comboOption.setSelectedIndex(0);
} else {
comboOption.setSelectedIndex(1);
this.comboOption.setSelectedIndex(1);
}
} else if (fd.getType().equals("time")) {
comboType.setSelectedIndex(TYPE_TIME);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vTime));
this.comboType.setSelectedIndex(TYPE_TIME);
this.labelOption.setText("Valeur par défaut");
this.textOption.setVisible(false);
this.comboOption.setVisible(true);
this.comboOption.setModel(new DefaultComboBoxModel(vTime));
if (fd.getDefaultValue() == null || !fd.getDefaultValue().equals("now")) {
comboOption.setSelectedIndex(0);
} else {
279,8 → 284,27
labelOption.setText("Table");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(getTables()));
final Vector<String> tables = new Vector<String>();
tables.addAll(Arrays.asList(getTables()));
String tableName = fd.getForeignTable();
if (!tables.contains(tableName)) {
tables.add(tableName);
}
comboOption.setModel(new DefaultComboBoxModel<String>(tables));
comboOption.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value.toString().trim().isEmpty()) {
value = "!! non renseignée !!";
}
DefaultListCellRenderer r = (DefaultListCellRenderer) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (!tables.contains(value)) {
r.setForeground(Color.RED);
}
return r;
}
 
});
comboOption.setSelectedItem(tableName);
} else {
throw new IllegalArgumentException("Unknow type " + fd.getType());
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableModifyLeftPanel.java
53,24 → 53,24
 
private JComponent createModifiedTableList(final Extension extension) {
final ModifiedTableListModel dataModel = new ModifiedTableListModel(extension);
listTableModified = new JList(dataModel);
listTableModified.addListSelectionListener(new ListSelectionListener() {
this.listTableModified = new JList(dataModel);
this.listTableModified.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
final TableDescritor tableDesc = (TableDescritor) listTableModified.getSelectedValue();
final TableDescritor tableDesc = (TableDescritor) TableModifyLeftPanel.this.listTableModified.getSelectedValue();
if (tableDesc != null) {
System.out.println("TableModifyLeftPanel.createModifiedTableList.valueChanged():" + tableDesc);
final TableModifyPanel p = new TableModifyPanel(extension.getSQLTable(tableDesc), tableDesc, extension, TableModifyLeftPanel.this);
tableModifyMainPanel.setRightPanel(p);
listTableAll.clearSelection();
TableModifyLeftPanel.this.tableModifyMainPanel.setRightPanel(p);
TableModifyLeftPanel.this.listTableAll.clearSelection();
}
}
 
}
});
final JScrollPane comp2 = new JScrollPane(listTableModified);
final JScrollPane comp2 = new JScrollPane(this.listTableModified);
comp2.setMinimumSize(new Dimension(250, 150));
comp2.setPreferredSize(new Dimension(250, 150));
return comp2;
78,25 → 78,25
 
private JComponent createAllTableList(final Extension extension) {
final AllTableListModel dataModel = new AllTableListModel(extension);
listTableAll = new JList(dataModel);
listTableAll.addListSelectionListener(new ListSelectionListener() {
this.listTableAll = new JList(dataModel);
this.listTableAll.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
final SQLTable table = (SQLTable) listTableAll.getSelectedValue();
final SQLTable table = (SQLTable) TableModifyLeftPanel.this.listTableAll.getSelectedValue();
if (table != null) {
System.out.println("TableModifyLeftPanel.createAllTableList.valueChanged():" + table);
final TableModifyPanel p = new TableModifyPanel(table, extension.getOrCreateTableDescritor(table.getName()), extension, TableModifyLeftPanel.this);
tableModifyMainPanel.setRightPanel(p);
listTableModified.clearSelection();
TableModifyLeftPanel.this.tableModifyMainPanel.setRightPanel(p);
TableModifyLeftPanel.this.listTableModified.clearSelection();
}
}
 
}
});
listTableAll.setCellRenderer(new SQLTableListCellRenderer());
final JScrollPane comp2 = new JScrollPane(listTableAll);
this.listTableAll.setCellRenderer(new SQLTableListCellRenderer());
final JScrollPane comp2 = new JScrollPane(this.listTableAll);
comp2.setMinimumSize(new Dimension(150, 150));
comp2.setPreferredSize(new Dimension(150, 150));
return comp2;
105,11 → 105,11
public void selectTable(String tableName) {
System.out.println("TableModifyLeftPanel.selectTable():" + tableName);
if (tableName != null) {
TableDescritor tableDesc = extension.getOrCreateTableDescritor(tableName);
final TableModifyPanel p = new TableModifyPanel(extension.getSQLTable(tableDesc), tableDesc, extension, TableModifyLeftPanel.this);
tableModifyMainPanel.setRightPanel(p);
listTableAll.clearSelection();
listTableModified.clearSelection();
TableDescritor tableDesc = this.extension.getOrCreateTableDescritor(tableName);
final TableModifyPanel p = new TableModifyPanel(this.extension.getSQLTable(tableDesc), tableDesc, this.extension, TableModifyLeftPanel.this);
this.tableModifyMainPanel.setRightPanel(p);
this.listTableAll.clearSelection();
this.listTableModified.clearSelection();
}
}
 
/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(extension, field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(this.extension, field);
p.add(editor, c);
 
c.gridx++;
86,7 → 86,7
p.remove(editor);
p.remove(close);
p.revalidate();
extension.setChanged();
TableCreatePanel.this.extension.setChanged();
}
});
c.gridy++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableModifyInfoPanel.java
176,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(extension, field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(this.extension, field);
p.add(editor, c);
 
c.gridx++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableCreateMainPanel.java
12,11 → 12,11
}
 
public void select(TableDescritor tableDescriptor) {
((TableListPanel) leftComponent).selectItem(tableDescriptor);
((TableListPanel) this.leftComponent).selectItem(tableDescriptor);
}
 
@Override
public JComponent createLeftComponent() {
return new TableListPanel(extension, this);
return new TableListPanel(this.extension, this);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionInfoPanel.java
113,16 → 113,16
final JButton startButton = new JButton("Démarrer");
 
panel.add(startButton);
startButton.setEnabled(!extension.isStarted());
startButton.setEnabled(!this.extension.isStarted());
final JButton stopButton = new JButton("Arrêter");
panel.add(stopButton);
stopButton.setEnabled(extension.isStarted());
stopButton.setEnabled(this.extension.isStarted());
final JButton saveButton = new JButton("Enregister");
saveButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
extension.save();
ExtensionInfoPanel.this.extension.save();
 
}
});
137,10 → 137,10
 
@Override
public void actionPerformed(ActionEvent e) {
String xml = extension.toXML();
String xml = ExtensionInfoPanel.this.extension.toXML();
System.out.println(xml);
FileDialog fDialog = new FileDialog(new JFrame(), "Export", FileDialog.SAVE);
fDialog.setFile(extension.getName() + ".ocext");
fDialog.setFile(ExtensionInfoPanel.this.extension.getName() + ".ocext");
fDialog.setVisible(true);
String fileName = fDialog.getFile();
if (fileName != null) {
225,17 → 225,17
 
}
// Create extension from XML
extension.stop();
ExtensionInfoPanel.this.extension.stop();
if (!xml.isEmpty()) {
if (!extension.isEmpty()) {
if (!ExtensionInfoPanel.this.extension.isEmpty()) {
int result = JOptionPane.showConfirmDialog(ExtensionInfoPanel.this, "Attention l'extension actuelle sera écrasée.\nContinuer l'importation?");
if (result != JOptionPane.YES_OPTION) {
return;
}
}
extension.clearAll();
extension.importFromXML(xml);
extension.setChanged();
ExtensionInfoPanel.this.extension.clearAll();
ExtensionInfoPanel.this.extension.importFromXML(xml);
ExtensionInfoPanel.this.extension.setChanged();
}
 
}
251,11 → 251,25
public void run() {
final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
try {
extension.start(root, false);
} catch (SQLException e1) {
e1.printStackTrace();
ExtensionInfoPanel.this.extension.start(root, false);
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_EMPTY);
}
});
} catch (SQLException e) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_BLINK);
}
});
ExceptionHandler.handle("Start error", e);
}
}
}).start();
}
});
267,8 → 281,27
new Thread(new Runnable() {
@Override
public void run() {
extension.stop();
try {
ExtensionInfoPanel.this.extension.stop();
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_EMPTY);
}
});
} catch (Exception e) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_BLINK);
}
});
ExceptionHandler.handle("Stop error", e);
}
 
}
}).start();
}
});
334,7 → 367,7
// --------- UI
panel.add(new JLabelBold("Interfaces de saisie"), c);
c.gridy++;
List<ComponentDescritor> createComponentList = extension.getCreateComponentList();
List<ComponentDescritor> createComponentList = this.extension.getCreateComponentList();
if (createComponentList.size() > 0) {
String components = "";
for (int i = 0; i < createComponentList.size(); i++) {
363,7 → 396,7
// --------- LIST
panel.add(new JLabelBold("Listes"), c);
c.gridy++;
List<ListDescriptor> createListList = extension.getCreateListList();
List<ListDescriptor> createListList = this.extension.getCreateListList();
if (createListList.size() > 0) {
String components = "";
for (int i = 0; i < createListList.size(); i++) {
391,9 → 424,9
// --------- MENUS
panel.add(new JLabelBold("Menus et actions"), c);
c.gridy++;
final int actionCount = extension.getActionDescriptors().size();
final int menuCount = extension.getCreateMenuList().size();
final int menuCount2 = extension.getRemoveMenuList().size();
final int actionCount = this.extension.getActionDescriptors().size();
final int menuCount = this.extension.getCreateMenuList().size();
final int menuCount2 = this.extension.getRemoveMenuList().size();
if (actionCount > 0) {
if (actionCount > 1)
panel.add(new JLabel(actionCount + " actions"), c);
427,9 → 460,9
panel.add(new JLabelBold("Traductions et renommage de labels"), c);
c.gridy++;
 
int actionTranslationCount = extension.getActionTranslations().size();
int menuTranslationCount = extension.getMenuTranslations().size();
int fieldTranslationCount = extension.getFieldTranslations().size();
int actionTranslationCount = this.extension.getActionTranslations().size();
int menuTranslationCount = this.extension.getMenuTranslations().size();
int fieldTranslationCount = this.extension.getFieldTranslations().size();
if (fieldTranslationCount > 0) {
if (fieldTranslationCount > 1)
panel.add(new JLabel(fieldTranslationCount + " traductions de champs"), c);
504,32 → 537,32
}
 
private void openTableEditor() {
final TableMainPanel contentPane = new TableMainPanel(extension);
openEditor(frameTableEditor, contentPane, "Tables dans la base de données");
final TableMainPanel contentPane = new TableMainPanel(this.extension);
openEditor(this.frameTableEditor, contentPane, "Tables dans la base de données");
 
}
 
private void openListEditor() {
final ListCreateMainPanel contentPane = new ListCreateMainPanel(extension);
openEditor(frameListEditor, contentPane, "Listes personnalisées");
final ListCreateMainPanel contentPane = new ListCreateMainPanel(this.extension);
openEditor(this.frameListEditor, contentPane, "Listes personnalisées");
 
}
 
protected void openComponentEditor() {
final ComponentCreateMainPanel contentPane = new ComponentCreateMainPanel(extension);
openEditor(frameListEditor, contentPane, "Interfaces personnalisées");
final ComponentCreateMainPanel contentPane = new ComponentCreateMainPanel(this.extension);
openEditor(this.frameListEditor, contentPane, "Interfaces personnalisées");
 
}
 
protected void openMenuEditor() {
final MenuMainPanel contentPane = new MenuMainPanel(extension);
openEditor(frameMenuEditor, contentPane, "Menus et actions");
final MenuMainPanel contentPane = new MenuMainPanel(this.extension);
openEditor(this.frameMenuEditor, contentPane, "Menus et actions");
 
}
 
protected void openTranslationEditor() {
final TranslationMainPanel contentPane = new TranslationMainPanel(extension);
openEditor(frameTranslationEditor, contentPane, "Traductions");
final TranslationMainPanel contentPane = new TranslationMainPanel(this.extension);
openEditor(this.frameTranslationEditor, contentPane, "Traductions");
 
}
 
536,7 → 569,7
private void openEditor(JFrame frame, JPanel mainPanel, String title) {
if (frame == null) {
frame = new JFrame();
frame.setTitle(extension.getName() + " - " + title);
frame.setTitle(this.extension.getName() + " - " + title);
frame.setContentPane(mainPanel);
frame.setMinimumSize(new Dimension(796, 560));
frame.pack();
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ClickableLabel.java
25,7 → 25,7
 
public void paint(Graphics g) {
super.paint(g);
if (mouseOver) {
if (this.mouseOver) {
Rectangle r = g.getClipBounds();
final int y1 = r.height - getFontMetrics(getFont()).getDescent() + 1;
g.drawLine(0, y1, getFontMetrics(getFont()).stringWidth(getText()), y1);
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/Extension.java
91,22 → 91,22
public class Extension {
 
// Descriptors of the extension
private List<ElementDescriptor> elementList = new ArrayList<ElementDescriptor>();
private List<TableDescritor> createTableList = new ArrayList<TableDescritor>();
private List<TableDescritor> modifyTableList = new ArrayList<TableDescritor>();
private List<ListDescriptor> createListList = new ArrayList<ListDescriptor>();
private List<TableTranslation> tableTranslations = new ArrayList<TableTranslation>();
private List<FieldTranslation> fieldTranslations = new ArrayList<FieldTranslation>();
private List<MenuTranslation> menuTranslations = new ArrayList<MenuTranslation>();
private List<ActionTranslation> actionTranslations = new ArrayList<ActionTranslation>();
private List<ComponentDescritor> createComponentList = new ArrayList<ComponentDescritor>();
private List<ComponentDescritor> modifyComponentList = new ArrayList<ComponentDescritor>();
private List<MenuDescriptor> createMenuList = new ArrayList<MenuDescriptor>();
private List<MenuDescriptor> removeMenuList = new ArrayList<MenuDescriptor>();
private List<ActionDescriptor> createActionList = new ArrayList<ActionDescriptor>();
private List<ElementDescriptor> elementList = new ArrayList<>();
private List<TableDescritor> createTableList = new ArrayList<>();
private List<TableDescritor> modifyTableList = new ArrayList<>();
private List<ListDescriptor> createListList = new ArrayList<>();
private List<TableTranslation> tableTranslations = new ArrayList<>();
private List<FieldTranslation> fieldTranslations = new ArrayList<>();
private List<MenuTranslation> menuTranslations = new ArrayList<>();
private List<ActionTranslation> actionTranslations = new ArrayList<>();
private List<ComponentDescritor> createComponentList = new ArrayList<>();
private List<ComponentDescritor> modifyComponentList = new ArrayList<>();
private List<MenuDescriptor> createMenuList = new ArrayList<>();
private List<MenuDescriptor> removeMenuList = new ArrayList<>();
private List<ActionDescriptor> createActionList = new ArrayList<>();
 
// Listeners
private List<ChangeListener> listeners = new ArrayList<ChangeListener>();
private List<ChangeListener> listeners = new ArrayList<>();
 
private String name;
private boolean notSaved;
119,24 → 119,24
}
 
public void clearAll() {
elementList.clear();
createTableList.clear();
modifyTableList.clear();
createListList.clear();
tableTranslations.clear();
fieldTranslations.clear();
menuTranslations.clear();
actionTranslations.clear();
createComponentList.clear();
modifyComponentList.clear();
createMenuList.clear();
removeMenuList.clear();
createActionList.clear();
listeners.clear();
this.elementList.clear();
this.createTableList.clear();
this.modifyTableList.clear();
this.createListList.clear();
this.tableTranslations.clear();
this.fieldTranslations.clear();
this.menuTranslations.clear();
this.actionTranslations.clear();
this.createComponentList.clear();
this.modifyComponentList.clear();
this.createMenuList.clear();
this.removeMenuList.clear();
this.createActionList.clear();
this.listeners.clear();
 
notSaved = true;
autoStart = false;
isStarted = false;
this.notSaved = true;
this.autoStart = false;
this.isStarted = false;
 
}
 
145,7 → 145,7
}
 
public boolean isAutoStart() {
return autoStart;
return this.autoStart;
}
 
public void start(DBRoot root, boolean inModuleStart) throws SQLException {
156,14 → 156,13
Log.get().severe("Extension " + this.getName() + " not started due to database error");
return;
}
// Register translations
registerTranslations(root);
// Create menus
if (!inModuleStart) {
final MenuAndActions copy = MenuManager.getInstance().copyMenuAndActions();
registerMenuActions(copy);
// Register translations before setting menu
registerTranslations(root);
MenuManager.getInstance().setMenuAndActions(copy);
}
 
Log.get().info("Extension " + this.getName() + " started");
this.isStarted = true;
this.autoStart = true;
282,21 → 281,14
}
}, menuDescriptor.getId(), true);
}
} else if (menuDescriptor.getType().equals(MenuDescriptor.LIST)) {
// No action to register
} else if (menuDescriptor.getType().equals(MenuDescriptor.GROUP)) {
// TODO
} else {
Log.get().warning("unknown type " + menuDescriptor.getType());
}
}
 
// 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 SQLTableModelSourceOnline createSource(SQLElement element, ListSQLRequest req, ListDescriptor listDesc) {
305,7 → 297,7
for (ColumnDescriptor cDesc : listDesc.getColumns()) {
final String fieldspath = cDesc.getFieldsPaths();
final String[] paths = fieldspath.split(",");
final Set<FieldPath> fps = new LinkedHashSet<FieldPath>();
final Set<FieldPath> fps = new LinkedHashSet<>();
for (int i = 0; i < paths.length; i++) {
// LOCAL, id_batiment.id_site.nom
final SQLName name = SQLName.parse(paths[i].trim());
417,13 → 409,13
}
 
private boolean setupDatabase(DBRoot root) throws SQLException {
List<ChangeTable<?>> changesToApply = new ArrayList<ChangeTable<?>>();
List<SQLCreateTable> createToApply = new ArrayList<SQLCreateTable>();
List<ChangeTable<?>> changesToApply = new ArrayList<>();
List<SQLCreateTable> createToApply = new ArrayList<>();
// Create fields and tables if needed
final List<TableDescritor> t = new ArrayList<TableDescritor>();
final List<TableDescritor> t = new ArrayList<>();
t.addAll(this.createTableList);
t.addAll(this.modifyTableList);
Set<String> tableNames = new HashSet<String>();
Set<String> tableNames = new HashSet<>();
for (TableDescritor tDesc : t) {
String tableName = tDesc.getName();
tableNames.add(tableName);
483,7 → 475,6
createTable.addDateAndTimeColumn(fieldName);
} else if (type.equals(FieldDescriptor.TYPE_REF)) {
// created later
mustAdd = false;
}
mustAdd = true;
} else {
520,6 → 511,11
final SQLField f = (table == null) ? null : table.getFieldRaw(fDesc.getName());
if (f == null && fDesc.getType().equals(FieldDescriptor.TYPE_REF)) {
final String fTableName = fDesc.getForeignTable();
if (fTableName == null || fTableName.isEmpty()) {
JOptionPane.showMessageDialog(new JFrame(),
"L'extension ne peut pas s'installer car le champs référence " + fDesc.getName() + " de la table " + tDesc.getName() + " ne définit pas de table étrangère");
return false;
} else {
final SQLTable fTable = root.getTable(fTableName);
if (fTable != null) {
final AlterTable mTable = new AlterTable(table);
532,6 → 528,7
}
}
}
}
// Create foreign keys
if (!changesToApply.isEmpty()) {
for (String change : ChangeTable.cat(changesToApply)) {
558,7 → 555,7
}
 
public String getName() {
return name;
return this.name;
}
 
@SuppressWarnings("unchecked")
593,7 → 590,7
FieldDescriptor f = createFieldDescriptorFrom(name, field);
tDesc.add(f);
}
if (tDesc.getFields().size() > 0) {
if (!tDesc.getFields().isEmpty()) {
if (type.equals("create")) {
this.createTableList.add(tDesc);
} else if (type.equals("modify")) {
657,7 → 654,7
listDesc.setMainTable(mainTable);
final List<Element> columns = eList.getChildren("column");
for (Element field : columns) {
ColumnDescriptor f = createColumnDescriptorFrom(mainTable, field);
ColumnDescriptor f = createColumnDescriptorFrom(field);
listDesc.add(f);
}
if (listDesc.getColumnCount() > 0) {
756,7 → 753,7
e.printStackTrace();
}
}
notSaved = false;
this.notSaved = false;
 
fireChanged();
}
824,20 → 821,20
rootElement.addContent(eTable);
}
// Translations
final HashSet<String> locales = new HashSet<String>();
for (Translation tr : tableTranslations) {
final HashSet<String> locales = new HashSet<>();
for (Translation tr : this.tableTranslations) {
locales.add(tr.getLocale());
}
for (Translation tr : fieldTranslations) {
for (Translation tr : this.fieldTranslations) {
locales.add(tr.getLocale());
}
for (Translation tr : menuTranslations) {
for (Translation tr : this.menuTranslations) {
locales.add(tr.getLocale());
}
for (Translation tr : actionTranslations) {
for (Translation tr : this.actionTranslations) {
locales.add(tr.getLocale());
}
final List<String> lLocales = new ArrayList<String>(locales);
final List<String> lLocales = new ArrayList<>(locales);
Collections.sort(lLocales);
for (String locale : lLocales) {
final Element eTranslation = new Element("translation");
844,7 → 841,7
eTranslation.setAttribute("locale", locale);
rootElement.addContent(eTranslation);
// Tables
for (TableTranslation tTranslation : tableTranslations) {
for (TableTranslation tTranslation : this.tableTranslations) {
if (tTranslation.getLocale().equals(locale)) {
final Element eTable = new Element("element");
eTable.setAttribute("refid", tTranslation.getTableName());
856,7 → 853,7
if (plural != null && !plural.isEmpty()) {
eTable.setAttribute("plural", plural);
}
for (FieldTranslation fTranslation : fieldTranslations) {
for (FieldTranslation fTranslation : this.fieldTranslations) {
// Fields
if (fTranslation.getLocale().equals(locale) && fTranslation.getTableName().equals(tTranslation.getTableName())) {
final Element eField = new Element("item");
873,7 → 870,7
}
}
// Menus
for (MenuTranslation tMenu : menuTranslations) {
for (MenuTranslation tMenu : this.menuTranslations) {
if (tMenu.getLocale().equals(locale)) {
final Element eMenu = new Element("menu");
eMenu.setAttribute("refid", tMenu.getId());
883,7 → 880,7
}
 
// Actions
for (ActionTranslation tAction : actionTranslations) {
for (ActionTranslation tAction : this.actionTranslations) {
if (tAction.getLocale().equals(locale)) {
final Element eMenu = new Element("action");
eMenu.setAttribute("refid", tAction.getId());
1076,7 → 1073,7
return f;
}
 
private ColumnDescriptor createColumnDescriptorFrom(String table, Element field) {
private ColumnDescriptor createColumnDescriptorFrom(Element field) {
final ColumnDescriptor f = new ColumnDescriptor(field.getAttributeValue("id"));
f.setFieldsPaths(field.getAttributeValue("fields"));
f.setStyle(field.getAttributeValue("style"));
1084,7 → 1081,7
}
 
private void fireChanged() {
for (ChangeListener listener : listeners) {
for (ChangeListener listener : this.listeners) {
listener.stateChanged(new ChangeEvent(this));
}
 
1091,7 → 1088,7
}
 
public List<TableDescritor> getCreateTableList() {
return createTableList;
return this.createTableList;
}
 
public void addCreateTable(TableDescritor value) {
1105,11 → 1102,11
}
 
public List<TableDescritor> getModifyTableList() {
return modifyTableList;
return this.modifyTableList;
}
 
public List<ListDescriptor> getCreateListList() {
return createListList;
return this.createListList;
}
 
public ListDescriptor getCreateListFromId(String id) {
1154,8 → 1151,7
 
public SQLTable getSQLTable(TableDescritor tableDesc) {
try {
SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(tableDesc.getName());
return t;
return ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(tableDesc.getName());
} catch (Exception e) {
return null;
}
1207,8 → 1203,8
}
 
public List<String> getAllKnownTableNames() {
final List<String> l = new ArrayList<String>();
final Set<String> s = new HashSet<String>();
final List<String> l = new ArrayList<>();
final Set<String> s = new HashSet<>();
for (SQLTable t : AllTableListModel.getAllDatabaseTables()) {
s.add(t.getName());
}
1240,7 → 1236,7
}
 
public List<String> getTranslatedFieldOfTable(String tableName) {
final List<String> l = new ArrayList<String>();
final List<String> l = new ArrayList<>();
for (FieldTranslation tr : this.fieldTranslations) {
if (tr.getTableName().equals(tableName)) {
l.add(tr.getFieldName());
1281,7 → 1277,7
}
 
public List<MenuDescriptor> getCreateMenuList() {
return createMenuList;
return this.createMenuList;
}
 
public void addCreateMenu(MenuDescriptor desc) {
1298,7 → 1294,7
}
 
public List<MenuDescriptor> getRemoveMenuList() {
return removeMenuList;
return this.removeMenuList;
}
 
public void addRemoveMenu(MenuDescriptor desc) {
1307,7 → 1303,7
}
 
public List<String> getAllKnownFieldName(String tableName) {
final Set<String> l = new HashSet<String>();
final Set<String> l = new HashSet<>();
// fields created in the extension
 
final List<TableDescritor> desc = getCreateTableList();
1332,11 → 1328,11
}
}
 
return new ArrayList<String>(l);
return new ArrayList<>(l);
}
 
public List<String> getAllKnownActionNames() {
ArrayList<String> s = new ArrayList<String>();
final Set<String> s = new HashSet<>();
Collection<SQLElement> elements = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElements();
for (SQLElement element : elements) {
Collection<IListeAction> actions = element.getRowActions();
1349,12 → 1345,13
}
}
}
Collections.sort(s);
return s;
final List<String> list = new ArrayList<>(s);
Collections.sort(list);
return list;
}
 
public List<String> getActionNames() {
ArrayList<String> s = new ArrayList<String>();
ArrayList<String> s = new ArrayList<>();
for (ActionDescriptor action : this.createActionList) {
s.add(action.getId());
}
1373,9 → 1370,20
return this.createActionList;
}
 
public void addCreateAction(ActionDescriptor obj) {
this.createActionList.add(obj);
setChanged();
}
 
public void removeCreateAction(ActionDescriptor obj) {
this.createActionList.remove(obj);
setChanged();
}
 
public boolean isEmpty() {
return createTableList.isEmpty() && modifyTableList.isEmpty() && createListList.isEmpty() && tableTranslations.isEmpty() && fieldTranslations.isEmpty() && menuTranslations.isEmpty()
&& actionTranslations.isEmpty() && createComponentList.isEmpty() && modifyComponentList.isEmpty() && createMenuList.isEmpty() && removeMenuList.isEmpty() && createActionList.isEmpty();
return this.createTableList.isEmpty() && this.modifyTableList.isEmpty() && this.createListList.isEmpty() && this.tableTranslations.isEmpty() && this.fieldTranslations.isEmpty()
&& this.menuTranslations.isEmpty() && this.actionTranslations.isEmpty() && this.createComponentList.isEmpty() && this.modifyComponentList.isEmpty() && this.createMenuList.isEmpty()
&& this.removeMenuList.isEmpty() && this.createActionList.isEmpty();
}
 
public String getTableNameForElementId(String id) {
1397,15 → 1405,24
}
 
public List<MenuTranslation> getMenuTranslations() {
return menuTranslations;
return this.menuTranslations;
}
 
public MenuTranslation getMenuTranslation(String menuId, String locale) {
for (MenuTranslation tr : this.menuTranslations) {
if (tr.getId().equals(menuId) && tr.getLocale().equals(locale)) {
return tr;
}
}
return null;
}
 
public List<ActionTranslation> getActionTranslations() {
return actionTranslations;
return this.actionTranslations;
}
 
public List<FieldTranslation> getFieldTranslations() {
return fieldTranslations;
return this.fieldTranslations;
}
 
public void removeChangeListener(ChangeListener listener) {
1429,10 → 1446,10
}
 
public void removeRemoveMenuForId(String id) {
for (int i = removeMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = removeMenuList.get(i);
for (int i = this.removeMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = this.removeMenuList.get(i);
if (m.getId().equals(id)) {
removeMenuList.remove(i);
this.removeMenuList.remove(i);
}
}
 
1439,10 → 1456,10
}
 
public void removeCreateMenuForId(String id) {
for (int i = createMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = createMenuList.get(i);
for (int i = this.createMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = this.createMenuList.get(i);
if (m.getId().equals(id)) {
createMenuList.remove(i);
this.createMenuList.remove(i);
}
}
 
1449,7 → 1466,7
}
 
public MenuDescriptor getRemoveMenuItemFromId(String itemId) {
for (MenuDescriptor m : removeMenuList) {
for (MenuDescriptor m : this.removeMenuList) {
if (m.getId().equals(itemId)) {
return m;
}
1459,9 → 1476,9
 
public void renameMenuItem(String previousId, String newId) {
if (!previousId.equals(newId)) {
final List<MenuDescriptor> descs = new ArrayList<MenuDescriptor>(createMenuList.size() + removeMenuList.size());
descs.addAll(createMenuList);
descs.addAll(removeMenuList);
final List<MenuDescriptor> descs = new ArrayList<>(this.createMenuList.size() + this.removeMenuList.size());
descs.addAll(this.createMenuList);
descs.addAll(this.removeMenuList);
for (MenuDescriptor m : descs) {
if (m.getId().equals(previousId)) {
m.setId(newId);
1473,7 → 1490,7
}
 
public void moveMenuItem(String itemId, String parentId) {
for (MenuDescriptor m : createMenuList) {
for (MenuDescriptor m : this.createMenuList) {
if (m.getId().equals(itemId)) {
m.setInsertInMenu(parentId);
}
1540,4 → 1557,5
fTranslation.setLabel(text);
 
}
 
}
/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());
}
 
}
/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/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/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/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/component/ActivableMutableTreeNode.java
14,7 → 14,7
}
 
public boolean isActive() {
return active;
return this.active;
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentCreateMainPanel.java
9,12 → 9,12
 
public ComponentCreateMainPanel(Extension extension) {
super(extension);
split.setDividerLocation(0.5D);
this.split.setDividerLocation(0.5D);
}
 
@Override
public JComponent createLeftComponent() {
return new ComponentListPanel(extension, this);
return new ComponentListPanel(this.extension, this);
}
 
public void select(ComponentDescritor listDescriptor) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/GroupDescritor.java
23,7 → 23,7
}
 
public String getId() {
return id;
return this.id;
}
 
public void setId(String id) {
31,7 → 31,7
}
 
public Group getGroup() {
return group;
return this.group;
}
 
@Override
40,7 → 40,7
}
 
public boolean containsGroupId(String gId) {
return containsGroup(group, gId);
return containsGroup(this.group, gId);
}
 
private boolean containsGroup(Item item, String gId) {
61,7 → 61,7
}
 
public Item getItemFromId(String id) {
return getItemFromId(group, id);
return getItemFromId(this.group, id);
}
 
private Item getItemFromId(Item item, String gId) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/GroupTreeModel.java
19,7 → 19,7
}
 
public void setShowAll(boolean b) {
if (b != showAll) {
if (b != this.showAll) {
this.showAll = b;
System.err.println("GroupTreeModel.setShowAll()" + b);
reload();
68,7 → 68,7
final ActivableMutableTreeNode newChild = new ActivableMutableTreeNode(item);
 
newChild.setActive(n.containsGroupId(item.getId()));
if (showAll || newChild.isActive()) {
if (this.showAll || newChild.isActive()) {
node.add(newChild);
}
if (item instanceof Group) {
102,7 → 102,7
this.componentDescriptor.removeGroup(item);
}
reload(n);
componentDescriptor.fireGroupChanged();
this.componentDescriptor.fireGroupChanged();
}
 
@Override
109,7 → 109,7
protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children) {
// To update preview while reordering
super.fireTreeNodesInserted(source, path, childIndices, children);
componentDescriptor.fireGroupChanged();
this.componentDescriptor.fireGroupChanged();
}
 
@Override
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentListPanel.java
22,7 → 22,7
 
@Override
public void addNewItem() {
((CreateComponentListModel) dataModel).addComponentList();
((CreateComponentListModel) this.dataModel).addComponentList();
}
 
@Override
39,8 → 39,8
 
@Override
public void removeItem(Object item) {
((CreateComponentListModel) dataModel).removeElement(item);
extension.removeCreateComponent((ComponentDescritor) item);
((CreateComponentListModel) this.dataModel).removeElement(item);
this.extension.removeCreateComponent((ComponentDescritor) item);
}
 
@Override
47,10 → 47,10
public void itemSelected(Object item) {
if (item != null) {
ComponentDescritor n = (ComponentDescritor) item;
final ComponentCreatePanel p = new ComponentCreatePanel(n, extension);
tableInfoPanel.setRightPanel(p);
final ComponentCreatePanel p = new ComponentCreatePanel(n, this.extension);
this.tableInfoPanel.setRightPanel(p);
} else {
tableInfoPanel.setRightPanel(new JPanel());
this.tableInfoPanel.setRightPanel(new JPanel());
}
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentDescritor.java
16,7 → 16,7
}
 
public String getTable() {
return table;
return this.table;
}
 
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/CreateComponentListModel.java
22,13 → 22,13
@Override
public void stateChanged(ChangeEvent e) {
this.clear();
addContent(extension);
addContent(this.extension);
}
 
public void addComponentList() {
final ComponentDescritor l = new ComponentDescritor("Interface de saisie " + (this.getSize() + 1));
this.addElement(l);
extension.addCreateComponent(l);
this.extension.addCreateComponent(l);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/GroupEditor.java
61,8 → 61,8
c.insets = new Insets(2, 2, 2, 0);
 
panel.add(new JLabelBold("Champs et groupes"), c);
newModel = new ItemTreeModel();
tree = new ReorderableJTree() {
this.newModel = new ItemTreeModel();
this.tree = new ReorderableJTree() {
@Override
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
76,10 → 76,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) {
97,8 → 97,8
};
 
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;
139,7 → 139,7
showHideButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newModel.toggleActive(tree.getSelectionPath());
GroupEditor.this.newModel.toggleActive(GroupEditor.this.tree.getSelectionPath());
}
});
 
147,36 → 147,36
 
@Override
public void actionPerformed(ActionEvent e) {
newModel.setShowAll(hideCheckbox.isSelected());
setMainTable(n.getTable());
GroupEditor.this.newModel.setShowAll(hideCheckbox.isSelected());
setMainTable(GroupEditor.this.n.getTable());
setRightPanel(new JPanel());
}
});
 
tree.addTreeSelectionListener(new TreeSelectionListener() {
this.tree.addTreeSelectionListener(new TreeSelectionListener() {
 
@Override
public void valueChanged(TreeSelectionEvent e) {
final Object selectedValue = tree.getSelectionPath();
final Object selectedValue = GroupEditor.this.tree.getSelectionPath();
showHideButton.setEnabled((selectedValue != null));
}
});
tree.addMouseListener(new MouseAdapter() {
this.tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
newModel.toggleActive(tree.getSelectionPath());
GroupEditor.this.newModel.toggleActive(GroupEditor.this.tree.getSelectionPath());
}
}
 
@Override
public void mousePressed(MouseEvent e) {
final TreePath selectionPath = tree.getSelectionPath();
final TreePath selectionPath = GroupEditor.this.tree.getSelectionPath();
if (selectionPath == null) {
setRightPanel(new JPanel());
} else {
Item i = (Item) ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject();
setRightPanel(new ItemEditor(i, n));
setRightPanel(new ItemEditor(i, GroupEditor.this.n));
}
}
});
184,31 → 184,31
}
 
protected void addNewGroup() {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (this.tree.getModel().getRoot())).getFirstChild();
DefaultMutableTreeNode node = root;
if (node.getChildCount() > 0) {
node = (DefaultMutableTreeNode) node.getFirstChild();
}
if (tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (this.tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
}
if (node != root) {
DefaultMutableTreeNode newNode = new ActivableMutableTreeNode(new Group("group" + node.getParent().getChildCount() + 1));
final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();
parent.insert(newNode, parent.getIndex(node));
newModel.reload();
tree.setSelectionPath(new TreePath(newModel.getPathToRoot(newNode)));
this.newModel.reload();
this.tree.setSelectionPath(new TreePath(this.newModel.getPathToRoot(newNode)));
}
 
}
 
public void setMainTable(String table) {
n.setTable(table);
this.n.setTable(table);
 
initGroupFromTable(extension.getAllKnownFieldName(table));
newModel.fillFromGroup(n, this.tableGroup);
initGroupFromTable(this.extension.getAllKnownFieldName(table));
this.newModel.fillFromGroup(this.n, this.tableGroup);
 
tree.expandRow(0);
this.tree.expandRow(0);
}
 
public void initGroupFromTable(List<String> fields) {
215,9 → 215,9
System.out.println("GroupEditor.initGroupFromTable()");
System.out.println("GroupEditor.initGroupFromTable Component group");
 
this.tableGroup = new Group(n.getId());
this.tableGroup = new Group(this.n.getId());
for (String field : fields) {
Item i = n.getItemFromId(field);
Item i = this.n.getItemFromId(field);
Item newItem = new Item(field);
 
if (i != null) {
232,11 → 232,11
 
public Group getFilteredGroup() {
// Parcours du Tree
Group filteredGroup = new Group(n.getId());
if (n.getTable() == null) {
throw new IllegalStateException("Not table defined for " + n);
Group filteredGroup = new Group(this.n.getId());
if (this.n.getTable() == null) {
throw new IllegalStateException("Not table defined for " + this.n);
}
walk(newModel, filteredGroup, newModel.getRoot());
walk(this.newModel, filteredGroup, this.newModel.getRoot());
filteredGroup = (Group) filteredGroup.getItem(0);
 
return filteredGroup;
256,7 → 256,7
} else {
final Item item = new Item(userObject.getId());
item.setLocalHint(new LayoutHints(userObject.getLocalHint()));
final SQLTable table = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
final SQLTable table = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(this.n.getTable());
if (table.contains(userObject.getId())) {
SQLField field = table.getField(userObject.getId());
if (!field.isPrimaryKey() && !field.getName().endsWith("ORDRE") && !field.getName().endsWith("ARCHIVE")) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ItemEditor.java
47,8 → 47,8
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
textId = new JTextField(30);
this.add(textId, c);
this.textId = new JTextField(30);
this.add(this.textId, c);
c.gridy++;
} else {
// Label du champs
77,8 → 77,8
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
comboType = new JComboBox(new String[] { "normal", "large", "très large" });
this.add(comboType, c);
this.comboType = new JComboBox(new String[] { "normal", "large", "très large" });
this.add(this.comboType, c);
c.gridy++;
}
c.gridx = 0;
92,9 → 92,9
this.add(labelSep, c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
checkSeparated = new JCheckBox();
this.checkSeparated = new JCheckBox();
c.weightx = 1;
this.add(checkSeparated, c);
this.add(this.checkSeparated, c);
c.gridx = 0;
c.gridy++;
if (!this.isEditingGroup) {
104,9 → 104,9
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
checkLabel = new JCheckBox();
this.checkLabel = new JCheckBox();
 
this.add(checkLabel, c);
this.add(this.checkLabel, c);
 
c.gridy++;
 
117,8 → 117,8
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
checkFillH = new JCheckBox();
this.add(checkFillH, c);
this.checkFillH = new JCheckBox();
this.add(this.checkFillH, c);
c.gridy++;
}
 
129,8 → 129,8
initUIFrom(item);
 
// Listeners
if (isEditingGroup) {
textId.getDocument().addDocumentListener(new DocumentListener() {
if (this.isEditingGroup) {
this.textId.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
146,44 → 146,44
 
@Override
public void changedUpdate(DocumentEvent e) {
item.setId(textId.getText());
item.setId(ItemEditor.this.textId.getText());
component.fireGroupChanged();
 
}
});
}
checkSeparated.addActionListener(new ActionListener() {
this.checkSeparated.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
item.setLocalHint(item.getLocalHint().getBuilder().setSeparated(checkSeparated.isSelected()).build());
item.setLocalHint(item.getLocalHint().getBuilder().setSeparated(ItemEditor.this.checkSeparated.isSelected()).build());
component.fireGroupChanged();
}
});
 
if (!isEditingGroup) {
checkLabel.addActionListener(new ActionListener() {
if (!this.isEditingGroup) {
this.checkLabel.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
item.setLocalHint(item.getLocalHint().getBuilder().setShowLabel(checkLabel.isSelected()).build());
item.setLocalHint(item.getLocalHint().getBuilder().setShowLabel(ItemEditor.this.checkLabel.isSelected()).build());
component.fireGroupChanged();
}
});
checkFillH.addActionListener(new ActionListener() {
this.checkFillH.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
item.setLocalHint(item.getLocalHint().getBuilder().setFillHeight(checkFillH.isSelected()).build());
item.setLocalHint(item.getLocalHint().getBuilder().setFillHeight(ItemEditor.this.checkFillH.isSelected()).build());
component.fireGroupChanged();
}
});
 
comboType.addActionListener(new ActionListener() {
this.comboType.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
int i = comboType.getSelectedIndex();
int i = ItemEditor.this.comboType.getSelectedIndex();
final LayoutHintsBuilder h = item.getLocalHint().getBuilder();
if (i == 0) {
h.setFillWidth(false);
208,20 → 208,20
 
final LayoutHints localHint = item.getLocalHint();
 
checkSeparated.setSelected(localHint.isSeparated());
this.checkSeparated.setSelected(localHint.isSeparated());
 
if (!isEditingGroup) {
if (!this.isEditingGroup) {
if (localHint.fillWidth() && localHint.largeWidth()) {
comboType.setSelectedIndex(2);
this.comboType.setSelectedIndex(2);
} else if (localHint.fillWidth()) {
comboType.setSelectedIndex(1);
this.comboType.setSelectedIndex(1);
} else {
comboType.setSelectedIndex(0);
this.comboType.setSelectedIndex(0);
}
checkFillH.setSelected(localHint.fillHeight());
checkLabel.setSelected(localHint.showLabel());
this.checkFillH.setSelected(localHint.fillHeight());
this.checkLabel.setSelected(localHint.showLabel());
} else {
textId.setText(item.getId());
this.textId.setText(item.getId());
 
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentCreatePanel.java
58,16 → 58,16
c.gridwidth = 2;
c.fill = GridBagConstraints.BOTH;
 
panel = new GroupEditor(n, extension);
this.panel = new GroupEditor(n, extension);
final String mainTable = n.getTable();
if (mainTable == null && comboTable.getModel().getSize() > 0) {
comboTable.setSelectedIndex(0);
panel.setMainTable((String) comboTable.getModel().getElementAt(0));
this.panel.setMainTable((String) comboTable.getModel().getElementAt(0));
} else {
comboTable.setSelectedItem(mainTable);
panel.setMainTable(mainTable);
this.panel.setMainTable(mainTable);
}
this.add(panel, c);
this.add(this.panel, c);
 
final JButton previewButton = new JButton("Prévisualiser");
c.gridy++;
82,7 → 82,7
 
@Override
public void actionPerformed(ActionEvent e) {
panel.setMainTable((String) comboTable.getSelectedItem());
ComponentCreatePanel.this.panel.setMainTable((String) comboTable.getSelectedItem());
 
}
});
96,7 → 96,7
JOptionPane.showMessageDialog(ComponentCreatePanel.this, "La table doit être créée avant de pouvoir prévisualiser.");
return;
}
final Group group = panel.getFilteredGroup();
final Group group = ComponentCreatePanel.this.panel.getFilteredGroup();
 
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
if (element == null) {
103,17 → 103,17
Log.get().warning("No element for table: " + t.getName());
}
final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
oldGroup = group;
if (previewFrame == null || !previewFrame.isVisible()) {
previewFrame = new JFrame();
previewFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
previewFrame.setTitle("Preview: " + group.getId());
ComponentCreatePanel.this.oldGroup = group;
if (ComponentCreatePanel.this.previewFrame == null || !ComponentCreatePanel.this.previewFrame.isVisible()) {
ComponentCreatePanel.this.previewFrame = new JFrame();
ComponentCreatePanel.this.previewFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
ComponentCreatePanel.this.previewFrame.setTitle("Preview: " + group.getId());
}
final EditPanel panel = new EditPanel(gComponent, EditMode.CREATION);
previewFrame.setContentPane(panel);
previewFrame.pack();
if (!previewFrame.isVisible()) {
FrameUtil.show(previewFrame);
ComponentCreatePanel.this.previewFrame.setContentPane(panel);
ComponentCreatePanel.this.previewFrame.pack();
if (!ComponentCreatePanel.this.previewFrame.isVisible()) {
FrameUtil.show(ComponentCreatePanel.this.previewFrame);
}
 
};
123,15 → 123,15
 
@Override
public void stateChanged(ChangeEvent e) {
if (previewFrame == null || !previewFrame.isVisible()) {
if (ComponentCreatePanel.this.previewFrame == null || !ComponentCreatePanel.this.previewFrame.isVisible()) {
return;
}
final Group group = panel.getFilteredGroup();
if (group.equalsDesc(oldGroup)) {
final Group group = ComponentCreatePanel.this.panel.getFilteredGroup();
if (group.equalsDesc(ComponentCreatePanel.this.oldGroup)) {
// Avoid refresh when group doesn't change
return;
}
oldGroup = group;
ComponentCreatePanel.this.oldGroup = group;
final SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(n.getTable());
if (t == null) {
return;
138,10 → 138,10
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
previewFrame.pack();
if (!previewFrame.isVisible()) {
FrameUtil.show(previewFrame);
ComponentCreatePanel.this.previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
ComponentCreatePanel.this.previewFrame.pack();
if (!ComponentCreatePanel.this.previewFrame.isVisible()) {
FrameUtil.show(ComponentCreatePanel.this.previewFrame);
}
 
}