OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 152 → Rev 153

/trunk/jOpenCalendar/src/org/jopencalendar/ui/DatePickerPanel.java
57,7 → 57,13
this.setLayout(new BorderLayout(2, 2));
JPanel navigator = new JPanel();
navigator.setLayout(new BorderLayout());
bLeft = new JButton(new ImageIcon(this.getClass().getResource("left.png")));
String leftFileName = "left.png";
String rightFileName = "right.png";
if (this.getFont().getSize() > 16) {
leftFileName = "left_2x.png";
rightFileName = "right_2x.png";
}
bLeft = new JButton(new ImageIcon(this.getClass().getResource(leftFileName)));
configureButton(bLeft);
 
navigator.add(bLeft, BorderLayout.WEST);
64,7 → 70,8
title = new JLabel("...", SwingConstants.CENTER);
title.setFont(title.getFont().deriveFont(Font.BOLD));
navigator.add(title, BorderLayout.CENTER);
bRight = new JButton(new ImageIcon(this.getClass().getResource("right.png")));
 
bRight = new JButton(new ImageIcon(this.getClass().getResource(rightFileName)));
configureButton(bRight);
navigator.add(bRight, BorderLayout.EAST);
this.add(navigator, BorderLayout.NORTH);
93,7 → 100,9
j = 1;
}
String d = dateFormatSymbols[j];
dayPanel.add(new JLabel(d, SwingConstants.RIGHT));
final JLabel lDay = new JLabel(d, SwingConstants.RIGHT);
lDay.setMinimumSize(new Dimension(lDay.getPreferredSize().width, lDay.getPreferredSize().width));
dayPanel.add(lDay);
}
 
//
180,7 → 189,7
}
 
private void configureButton(final JButton button) {
int buttonSize = 28;
int buttonSize = button.getIcon().getIconWidth() + 8;
button.setMinimumSize(new Dimension(buttonSize, buttonSize));
button.setPreferredSize(new Dimension(buttonSize, buttonSize));
button.setFocusPainted(false);
345,14 → 354,17
 
@Override
public void mouseReleased(MouseEvent e) {
// Nothing
}
 
@Override
public void mouseEntered(MouseEvent e) {
// Nothing
}
 
@Override
public void mouseExited(MouseEvent e) {
// Nothing
}
 
}
/trunk/jOpenCalendar/src/org/jopencalendar/ui/left_2x.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/left_2x.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/jOpenCalendar/src/org/jopencalendar/ui/DatePicker.java
81,102 → 81,19
this.add(spacer);
}
 
final ImageIcon icon = new ImageIcon(this.getClass().getResource("calendar.png"));
String iconFileName = "calendar.png";
if (getFont().getSize() > 16) {
iconFileName = "calendar_2x.png";
}
final ImageIcon icon = new ImageIcon(this.getClass().getResource(iconFileName));
button = new JButton(new AbstractAction(null, icon) {
 
@Override
public void actionPerformed(ActionEvent e) {
final JComponent source = (JComponent) e.getSource();
 
if (text != null) {
// if the button isn't focusable, no FOCUS_LOST will occur and the text won't
// get
// committed (or reverted). So act as if the user requested a commit, so that
// invalidEdit() can be called (usually causing a beep).
if (!source.isFocusable()) {
for (final Action a : text.getActions()) {
final String name = (String) a.getValue(Action.NAME);
if (JTextField.notifyAction.equals(name))
a.actionPerformed(new ActionEvent(text, e.getID(), null));
calendarButtonPressed(e);
}
}
 
// if after trying to commit, the value is invalid then don't show the popup
if (!text.isEditValid())
return;
}
if (dialog == null) {
final JDialog d = new JDialog(SwingUtilities.getWindowAncestor(DatePicker.this));
pickerPanel = new DatePickerPanel();
 
d.setContentPane(pickerPanel);
d.setUndecorated(true);
pickerPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
d.setSize(330, 270);
 
pickerPanel.addPropertyChangeListener(DatePickerPanel.TIME_IN_MILLIS, new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!DatePicker.this.isEditable())
return;
final Long millis = (Long) evt.getNewValue();
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(millis);
setDate(c.getTime());
if (dialog != null) {
dialog.dispose();
dialog = null;
}
fireActionPerformed();
}
 
});
d.addWindowFocusListener(new WindowFocusListener() {
 
public void windowGainedFocus(WindowEvent e) {
// do nothing
}
 
public void windowLostFocus(WindowEvent e) {
if (dialog != null) {
final Window oppositeWindow = e.getOppositeWindow();
if (oppositeWindow != null && SwingUtilities.isDescendingFrom(oppositeWindow, dialog)) {
return;
}
dialog.dispose();
dialog = null;
}
dialogLostFocusTime = System.currentTimeMillis();
}
 
});
dialog = d;
}
// Set picker panel date
final Calendar calendar = Calendar.getInstance();
if (date != null) {
calendar.setTime(date);
pickerPanel.setSelectedDate(calendar);
} else {
pickerPanel.setSelectedDate(null);
}
// Show dialog
final int x = source.getLocation().x;
final int y = source.getLocation().y + source.getHeight();
Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, DatePicker.this);
p = adjustPopupLocationToFitScreen(p.x, p.y, dialog.getSize(), source.getSize());
dialog.setLocation(p.x, p.y);
final long time = System.currentTimeMillis() - dialogLostFocusTime;
if (time > RELEASE_TIME_MS) {
dialog.setVisible(true);
} else {
dialogLostFocusTime = System.currentTimeMillis() - RELEASE_TIME_MS;
}
}
 
});
button.setContentAreaFilled(false);
button.setOpaque(false);
button.setFocusable(false);
345,7 → 262,98
}
}
 
static public final boolean equals(Object o1, Object o2) {
private void calendarButtonPressed(ActionEvent e) {
final JComponent source = (JComponent) e.getSource();
 
if (text != null) {
// if the button isn't focusable, no FOCUS_LOST will occur and the text won't
// get
// committed (or reverted). So act as if the user requested a commit, so that
// invalidEdit() can be called (usually causing a beep).
if (!source.isFocusable()) {
for (final Action a : text.getActions()) {
final String name = (String) a.getValue(Action.NAME);
if (JTextField.notifyAction.equals(name))
a.actionPerformed(new ActionEvent(text, e.getID(), null));
}
}
 
// if after trying to commit, the value is invalid then don't show the popup
if (!text.isEditValid())
return;
}
if (dialog == null) {
final JDialog d = new JDialog(SwingUtilities.getWindowAncestor(DatePicker.this));
pickerPanel = new DatePickerPanel();
 
d.setContentPane(pickerPanel);
d.setUndecorated(true);
pickerPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY));
d.pack();
 
pickerPanel.addPropertyChangeListener(DatePickerPanel.TIME_IN_MILLIS, new PropertyChangeListener() {
 
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!DatePicker.this.isEditable())
return;
final Long millis = (Long) evt.getNewValue();
final Calendar c = Calendar.getInstance();
c.setTimeInMillis(millis);
setDate(c.getTime());
if (dialog != null) {
dialog.dispose();
dialog = null;
}
fireActionPerformed();
}
 
});
d.addWindowFocusListener(new WindowFocusListener() {
 
public void windowGainedFocus(WindowEvent e) {
// do nothing
}
 
public void windowLostFocus(WindowEvent e) {
if (dialog != null) {
final Window oppositeWindow = e.getOppositeWindow();
if (oppositeWindow != null && SwingUtilities.isDescendingFrom(oppositeWindow, dialog)) {
return;
}
dialog.dispose();
dialog = null;
}
dialogLostFocusTime = System.currentTimeMillis();
}
 
});
dialog = d;
}
// Set picker panel date
final Calendar calendar = Calendar.getInstance();
if (date != null) {
calendar.setTime(date);
pickerPanel.setSelectedDate(calendar);
} else {
pickerPanel.setSelectedDate(null);
}
// Show dialog
final int x = source.getLocation().x;
final int y = source.getLocation().y + source.getHeight();
Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, DatePicker.this);
p = adjustPopupLocationToFitScreen(p.x, p.y, dialog.getSize(), source.getSize());
dialog.setLocation(p.x, p.y);
final long time = System.currentTimeMillis() - dialogLostFocusTime;
if (time > RELEASE_TIME_MS) {
dialog.setVisible(true);
} else {
dialogLostFocusTime = System.currentTimeMillis() - RELEASE_TIME_MS;
}
}
 
public static final boolean equals(Object o1, Object o2) {
if (o1 == null && o2 == null)
return true;
if (o1 == null || o2 == null)
/trunk/jOpenCalendar/src/org/jopencalendar/ui/calendar.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/calendar_2x.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/calendar_2x.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/jOpenCalendar/src/org/jopencalendar/ui/right_2x.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/jOpenCalendar/src/org/jopencalendar/ui/right_2x.png
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableDescritor.java
11,13 → 11,18
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.modules.extensionbuilder.ExtensionGroupSQLComponent;
import org.openconcerto.modules.extensionbuilder.component.ComponentDescritor;
import org.openconcerto.modules.extensionbuilder.menu.mainmenu.MenuDescriptor;
import org.openconcerto.modules.extensionbuilder.list.ListDescriptor;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
 
public class TableDescritor {
private String name;
42,14 → 47,28
}
 
@Override
protected SQLTableModelSourceOnline instantiateTableSourceOnline(ListSQLRequest req) {
ListDescriptor listDesc = null;
for (ListDescriptor listDescriptor : ext.getCreateListList()) {
if (listDescriptor.getMainTable().equals(getTable().getName())) {
listDesc = listDescriptor;
break;
}
}
if (listDesc != null) {
return ext.createSource(this, req, listDesc);
} else {
return super.instantiateTableSourceOnline(req);
}
 
}
 
@Override
protected SQLComponent createComponent() {
 
for (final ComponentDescritor cDescriptor : ext.getCreateComponentList()) {
if (cDescriptor.getTable().equals(table.getTable().getName())) {
 
final GroupSQLComponent gComponent = new GroupSQLComponent(this, cDescriptor.getGroup());
return gComponent;
 
return new ExtensionGroupSQLComponent(this, cDescriptor.getGroup());
}
}
JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + name);
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/Extension.java
61,6 → 61,7
import org.openconcerto.sql.model.graph.PathBuilder;
import org.openconcerto.sql.request.ListSQLRequest;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ChangeTable;
import org.openconcerto.sql.utils.SQLCreateTable;
82,6 → 83,10
import org.openconcerto.ui.group.modifier.AddItemModifier;
import org.openconcerto.ui.group.modifier.MoveToGroupModifier;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.i18n.Grammar;
import org.openconcerto.utils.i18n.Grammar_fr;
import org.openconcerto.utils.i18n.NounClass;
import org.openconcerto.utils.i18n.Phrase;
import org.openconcerto.utils.i18n.TranslationManager;
 
public class Extension {
153,7 → 158,7
return;
}
// Register translations
registerTranslations();
registerTranslations(root);
// Create menus
if (!inModuleStart) {
final MenuAndActions copy = MenuManager.getInstance().copyMenuAndActions();
166,7 → 171,7
fireChanged();
}
 
private void registerTranslations() {
private void registerTranslations(DBRoot root) {
final String locale = Locale.getDefault().toString();
for (MenuTranslation mTranslation : this.menuTranslations) {
if (locale.equals(mTranslation.getLocale())) {
181,20 → 186,43
for (FieldTranslation mTranslation : this.fieldTranslations) {
if (locale.equals(mTranslation.getLocale())) {
TranslationManager.getInstance().setTranslationForItem(mTranslation.getTableName() + "." + mTranslation.getFieldName(), mTranslation.getLabel());
// TODO: getDescFor SQLFieldTranslator
}
}
for (TableTranslation mTranslation : this.tableTranslations) {
if (locale.equals(mTranslation.getLocale())) {
// FIXME voir avec Sylvain
// FIXME voir avec Sylvain, impossible pour l'instant
SQLElement e = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(mTranslation.getTableName());
e.setDefaultName(createPhrase(mTranslation.getSingular(), mTranslation.getPlural()));
}
}
}
 
private static Phrase createPhrase(String singular, String plural) {
final NounClass nounClass;
final String base;
if (singular.startsWith("une ")) {
nounClass = NounClass.FEMININE;
base = singular.substring(4);
} else if (singular.startsWith("un ")) {
nounClass = NounClass.MASCULINE;
base = singular.substring(3);
} else {
nounClass = null;
base = singular;
}
final Phrase res = new Phrase(Grammar_fr.getInstance(), base, nounClass);
if (nounClass != null)
res.putVariant(Grammar.INDEFINITE_ARTICLE_SINGULAR, singular);
res.putVariant(Grammar.PLURAL, plural);
return res;
}
 
private void registerMenuActions(MenuAndActions menuAndActions) {
// register actions
for (final MenuDescriptor element : getCreateMenuList()) {
if (element.getType().equals(MenuDescriptor.CREATE)) {
Log.get().info("Registering action for menu creation id:'" + element.getId() + "'");
for (final MenuDescriptor menuDescriptor : getCreateMenuList()) {
if (menuDescriptor.getType().equals(MenuDescriptor.CREATE)) {
Log.get().info("Registering action for menu creation id:'" + menuDescriptor.getId() + "'");
 
menuAndActions.putAction(new CreateFrameAbstractAction() {
 
202,9 → 230,9
public JFrame createFrame() {
 
JFrame editFrame = new JFrame();
String componentId = element.getComponentId();
String componentId = menuDescriptor.getComponentId();
if (componentId == null) {
throw new IllegalStateException("No ComponentId for menu " + element.getId());
throw new IllegalStateException("No ComponentId for menu " + menuDescriptor.getId());
}
ComponentDescritor n = getCreateComponentFromId(componentId);
if (n == null) {
216,30 → 244,24
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
 
final GroupSQLComponent gComponent = new GroupSQLComponent(element, n.getGroup()) {
public RowItemDesc getRIVDescForId(final String id) {
return super.getRIVDescForId(t.getName() + "." + id);
}
 
};
final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, n.getGroup());
editFrame.setTitle(EditFrame.getCreateMessage(element));
editFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
editFrame.pack();
 
return editFrame;
 
}
}, element.getId(), true);
}, menuDescriptor.getId(), true);
 
} else if (element.getType().equals(MenuDescriptor.LIST)) {
if (element.getListId() != null) {
} else if (menuDescriptor.getType().equals(MenuDescriptor.LIST)) {
if (menuDescriptor.getListId() != null) {
menuAndActions.putAction(new CreateFrameAbstractAction() {
 
@Override
public JFrame createFrame() {
final String componentId = element.getListId();
final String componentId = menuDescriptor.getListId();
if (componentId == null) {
throw new IllegalStateException("null ListId for MenuDescriptor " + element.getId());
throw new IllegalStateException("null ListId for MenuDescriptor " + menuDescriptor.getId());
}
final ListDescriptor listDesc = getCreateListFromId(componentId);
if (listDesc == null) {
251,8 → 273,36
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
final ListSQLRequest req = new ListSQLRequest(element.getTable(), new ArrayList<String>(0));
SQLTableModelSourceOnline source = createSource(element, req, listDesc);
 
final IListe list = new IListe(source);
final IListFrame editFrame = new IListFrame(new ListeAddPanel(element, list));
editFrame.pack();
return editFrame;
 
}
}, menuDescriptor.getId(), true);
}
} else if (menuDescriptor.getType().equals(MenuDescriptor.LIST)) {
// No action to register
} 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) {
final SQLTableModelSourceOnline source = new SQLTableModelSourceOnline(req, element);
final List<SQLTableModelColumn> cols = new ArrayList<SQLTableModelColumn>();
final List<SQLTableModelColumn> cols = new ArrayList<>();
for (ColumnDescriptor cDesc : listDesc.getColumns()) {
final String fieldspath = cDesc.getFieldsPaths();
final String[] paths = fieldspath.split(",");
271,11 → 321,23
fps.add(fp);
 
}
cols.add(new BaseSQLTableModelColumn(cDesc.getId(), String.class) {
String columnName = cDesc.getId();
if (!columnName.contains(".")) {
columnName = element.getTable().getTable().getName() + "." + columnName;
}
String tranlatedName = TranslationManager.getInstance().getTranslationForItem(columnName);
if (tranlatedName == null) {
tranlatedName = SQLFieldTranslator.getDefaultDesc(fps.iterator().next().getField()).getTitleLabel();
}
if (tranlatedName == null) {
tranlatedName = cDesc.getId();
}
 
cols.add(new BaseSQLTableModelColumn(tranlatedName, String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
final List<String> l = new ArrayList<String>();
final List<String> l = new ArrayList<>();
for (final FieldPath fp : fps) {
final String string = fp.getString((SQLRowValues) r);
if (string != null)
293,32 → 355,9
}
 
source.getColumns().addAll(cols);
 
final IListe list = new IListe(source);
final IListFrame editFrame = new IListFrame(new ListeAddPanel(element, list));
editFrame.pack();
return editFrame;
 
return source;
}
}, element.getId(), true);
}
} else if (element.getType().equals(MenuDescriptor.LIST)) {
// No action to register
} else {
Log.get().warning("unknown type " + element.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 void initMenuGroup(final Group group) {
for (MenuDescriptor element : getCreateMenuList()) {
if (element.getType().equals(MenuDescriptor.GROUP)) {
1137,14 → 1176,14
public void save() {
String xml = this.toXML();
System.out.println(xml);
// delete old version
deleteFromDB();
// insert new version
final SQLTable extensionTable = getExtensionTable();
SQLRowValues v = new SQLRowValues(extensionTable);
v.put("IDENTIFIER", this.getName());
v.put("XML", this.toXML());
v.put("XML", xml);
try {
// delete old version
deleteFromDB();
v.insert();
this.notSaved = false;
} catch (SQLException e) {
1485,7 → 1524,6
}
 
public void setFieldTranslation(String tableName, String fieldName, Locale locale, String text) {
System.err.println("Extension.setFieldTranslation()" + tableName + " " + fieldName + " " + locale + " : " + text);
FieldTranslation fTranslation = null;
for (FieldTranslation mTr : this.fieldTranslations) {
if (mTr.getTableName().equals(tableName) && mTr.getFieldName().equals(fieldName) && mTr.getLocale().equals(locale.toString())) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentCreatePanel.java
18,6 → 18,7
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Log;
import org.openconcerto.modules.extensionbuilder.Extension;
import org.openconcerto.modules.extensionbuilder.ExtensionGroupSQLComponent;
import org.openconcerto.modules.extensionbuilder.list.AllTablesComboBoxModel;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
101,12 → 102,7
if (element == null) {
Log.get().warning("No element for table: " + t.getName());
}
final GroupSQLComponent gComponent = new GroupSQLComponent(element, group) {
public RowItemDesc getRIVDescForId(final String id) {
return super.getRIVDescForId(t.getName() + "." + id);
}
 
};
final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
oldGroup = group;
if (previewFrame == null || !previewFrame.isVisible()) {
previewFrame = new JFrame();
141,9 → 137,7
return;
}
final SQLElement element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
 
final GroupSQLComponent gComponent = new GroupSQLComponent(element, group);
 
final GroupSQLComponent gComponent = new ExtensionGroupSQLComponent(element, group);
previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
previewFrame.pack();
if (!previewFrame.isVisible()) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MenuItemEditor.java
109,6 → 109,7
JComboBox cb = (JComboBox) e.getSource();
int type = cb.getSelectedIndex();
if (type == 0) {
// Saisie
comboActionChoice.setModel(new DefaultComboBoxModel(componentIds));
 
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
122,6 → 123,7
}
extension.setChanged();
} else {
// Liste
comboActionChoice.setModel(new DefaultComboBoxModel(listIds));
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
desc.setType(MenuDescriptor.LIST);
142,9 → 144,9
@Override
public void actionPerformed(ActionEvent e) {
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
if (desc.getType() == MenuDescriptor.CREATE) {
if (desc.getType().equals(MenuDescriptor.CREATE)) {
desc.setComponentId(comboActionChoice.getSelectedItem().toString());
} else if (desc.getType() == MenuDescriptor.LIST) {
} else if (desc.getType().equals(MenuDescriptor.LIST)) {
desc.setListId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
221,7 → 223,7
Collections.sort(componentIds);
 
final List<ListDescriptor> listDescList = extension.getCreateListList();
listIds = new Vector<String>(listDescList.size());
listIds = new Vector<>(listDescList.size());
for (ListDescriptor listDescritor : listDescList) {
final String id = listDescritor.getId();
if (id != null) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionBuilderModule.java
2,6 → 2,7
 
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
36,7 → 37,7
}
 
@Override
protected void install(DBContext ctxt) {
protected void install(DBContext ctxt) throws SQLException, IOException {
super.install(ctxt);
if (ctxt.getRoot().getTable(TABLE_NAME) == null) {
final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_NAME);
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionGroupSQLComponent.java
New file
0,0 → 1,20
package org.openconcerto.modules.extensionbuilder;
 
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.request.RowItemDesc;
import org.openconcerto.ui.group.Group;
 
public class ExtensionGroupSQLComponent extends GroupSQLComponent {
 
public ExtensionGroupSQLComponent(SQLElement element, Group group) {
super(element, group);
}
 
@Override
public RowItemDesc getRIVDescForId(final String id) {
return super.getRIVDescForId(getTable().getName() + "." + id);
 
}
 
}
/trunk/Modules/Module Extension Builder/.settings/org.eclipse.jdt.core.prefs
File deleted
/trunk/Modules/Module Extension Builder/.classpath
1,7 → 1,7
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Extension Builder/module.properties
2,5 → 2,5
id=org.openconcerto.modules.extensionbuilder
entryPoint=ExtensionBuilderModule
# \p{Digit}(\.\p{Digit}+)?
version=1.0
version=1.1
contact=ILM Informatique
/trunk/Modules/Module Google Docs/src/org/openconcerto/modules/google/docs/Module.java
1,6 → 1,7
package org.openconcerto.modules.google.docs;
 
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
 
24,7 → 25,7
}
 
@Override
protected void install(DBContext ctxt) {
protected void install(DBContext ctxt) throws SQLException, IOException {
super.install(ctxt);
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/Module.java
47,7 → 47,7
}
 
@Override
protected void install(DBContext ctxt) {
protected void install(DBContext ctxt) throws SQLException, IOException {
super.install(ctxt);
// TODO use version to upgrade
if (ctxt.getRoot().getTable(TABLE_CUSTOMER_SUPPORT_TICKET) == null) {
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/ModuleOperation.java
4,6 → 4,7
 
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
129,7 → 130,7
}
 
@Override
protected void install(DBContext ctxt) {
protected void install(DBContext ctxt) throws SQLException, IOException {
super.install(ctxt);
if (ctxt.getRoot().getTable(TABLE_SITE) == null) {
final SQLCreateTable createTableSite = ctxt.getCreateTable(TABLE_SITE);
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationExportPanel.java
9,6 → 9,7
import java.awt.event.ActionListener;
import java.io.File;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
34,8 → 35,11
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
 
import org.jdom2.Document;
import org.jdom2.Element;
import org.jopencalendar.model.JCalendarItem;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.generationDoc.TemplateManager;
45,6 → 49,7
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.FieldMapper;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
56,6 → 61,7
import org.openconcerto.ui.date.DateRangePlannerPanel;
import org.openconcerto.utils.CollectionMap2.Mode;
import org.openconcerto.utils.CompareUtils;
import org.openconcerto.utils.DecimalUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.StreamUtils;
213,9 → 219,14
}
 
static private final class Planner implements Comparable<Planner> {
 
static private final BigDecimal MS_PER_HOUR = BigDecimal.valueOf(1000 * 3600);
 
private final String uid;
private final String xml;
private Date rangeStart;
private Date startTime;
private BigDecimal hours;
 
protected Planner(String uid, String xml) {
super();
228,21 → 239,44
}
 
public final String getDescription() {
return DateRangePlannerPanel.getDescriptionFromXML(this.xml);
return DateRangePlannerPanel.getDescriptionFromXML(this.xml, false);
}
 
public final Date getRangeStart() {
if (this.rangeStart == null) {
parse();
}
return this.rangeStart;
}
 
protected void parse() {
try {
final Document doc = JDOM2Utils.parseStringDocument(this.xml);
this.rangeStart = new Date(Long.valueOf(doc.getRootElement().getChild("range").getAttributeValue("start")));
 
final Element scheduleElem = doc.getRootElement().getChild("schedule");
this.startTime = new Date(Long.valueOf(scheduleElem.getAttributeValue("start")));
final long endTime = Long.valueOf(scheduleElem.getAttributeValue("end"));
this.hours = DecimalUtils.round(BigDecimal.valueOf(endTime - this.startTime.getTime()).divide(MS_PER_HOUR, DecimalUtils.HIGH_PRECISION), 5);
} catch (Exception e) {
throw new IllegalStateException("couldn't get start for " + this.xml, e);
}
}
return this.rangeStart;
 
public final Date getStartTime() {
if (this.startTime == null) {
parse();
}
return this.startTime;
}
 
public final BigDecimal getHours() {
if (this.hours == null) {
parse();
}
return this.hours;
}
 
@Override
public int hashCode() {
final int prime = 31;
286,10 → 320,8
final SQLRowValues valSite = new SQLRowValues(root.getTable(ModuleOperation.TABLE_SITE));
valSite.putNulls("NAME", "COMMENT");
 
final SQLRowValues userVals = valOperation.putRowValues("ID_USER_COMMON").putNulls("NOM");
 
valOperation.putRowValues("ID_USER_COMMON").putNulls("NOM", "PRENOM");
// valOperation.put("ID_CALENDAR_ITEM_GROUP", valsCalendarItemsGroup);
valOperation.put("ID_USER_COMMON", userVals);
valOperation.put("ID_SITE", valSite);
valOperation.putNulls("STATUS", "DESCRIPTION", "TYPE", "PLANNER_XML", "PLANNER_UID");
 
302,6 → 334,12
operationsByPlanner.add(new Planner(d.getString("PLANNER_UID"), d.getString("PLANNER_XML")), d);
}
final List<Entry<Planner, List<SQLRowValues>>> items = new ArrayList<>(operationsByPlanner.entrySet());
final DatatypeFactory dataTypeFactory;
try {
dataTypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new IllegalStateException(e);
}
 
TableModel model = new AbstractTableModel() {
 
312,7 → 350,7
 
@Override
public int getColumnCount() {
return 5;
return 7;
}
 
@Override
324,10 → 362,16
final SQLRowValues i = rows.getValue().get(0);
switch (columnIndex) {
case 0:
return dataTypeFactory.newDurationDayTime(planner.getStartTime().getTime());
 
case 1:
return planner.getHours();
 
case 2:
// Plannif
return planner.getDescription();
 
case 1:
case 3:
// Employé
final ListMap<Integer, SQLRowValues> operationsByUserID = new ListMap<>();
for (final SQLRowValues r : rows.getValue()) {
349,7 → 393,8
while (listIter.hasNext()) {
final Entry<Integer, List<SQLRowValues>> element = listIter.next();
final SQLRowValues operationR = element.getValue().get(0);
sb.append(operationR.getForeign("ID_USER_COMMON").getString("NOM"));
final SQLRowAccessor userR = operationR.getForeign("ID_USER_COMMON");
sb.append(userR.getString("PRENOM") + " " + userR.getString("NOM"));
if (listIter.previousIndex() > 0) {
sb.append(" (");
sb.append(element.getValue().size());
360,15 → 405,15
}
}
return sb.toString();
case 2:
case 4:
// Nature
final String type = i.getString("TYPE");
return type;
case 3:
case 5:
// Chantier
final String siteName = i.getForeign("ID_SITE").getString("NAME");
return siteName;
case 4:
case 6:
// Description
final String desc = i.getString("DESCRIPTION");
return desc;
/trunk/Modules/Module Badge/module.properties
1,5 → 1,5
# [\p{Alnum}_.]{3,}
id=org.openconcerto.modules.badge
# \p{Digit}(\.\p{Digit}+)?
version=1.0
version=1.1
contact=ILM Informatique
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/labels.xml
File deleted
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/ModuleResources.properties
1,2 → 1,2
name=Badge
description=Adds
name=Access badge
description=Adds a list of members and their RFID badges.
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/AdherentSQLElement.java
16,7 → 16,6
 
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.sql.element.BaseSQLComponent;
import org.openconcerto.sql.element.ElementSQLObject;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.ElementComboBox;
32,12 → 31,13
}
 
@Override
public boolean isPrivate() {
return true;
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("PRENOM");
l.add("TEL");
l.add("MAIL");
l.add("ID_PLAGE_HORAIRE");
l.add("DATE_VALIDITE_INSCRIPTION");
l.add("NUMERO_CARTE");
48,19 → 48,11
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NOM");
l.add("PRENOM");
l.add("NUMERO_CARTE");
return l;
}
 
@Override
protected List<String> getPrivateFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_ADRESSE");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, getComboFields());
}
89,67 → 81,6
 
c.weightx = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(new TitledSeparator("Informations personnelles", true), c);
 
c.gridy++;
c.weightx = 0;
c.gridwidth = 1;
JTextField nom = new JTextField();
this.add(getJLabelFor("NOM"), c);
c.gridx++;
c.weightx = 1;
this.add(nom, c);
this.addView(nom, "NOM", REQ);
 
c.gridx++;
c.weightx = 0;
JTextField prenom = new JTextField();
this.add(getJLabelFor("PRENOM"), c);
c.gridx++;
c.weightx = 1;
this.add(prenom, c);
this.addView(prenom, "PRENOM", REQ);
 
c.gridy++;
c.gridx = 0;
c.weightx = 0;
JDate dateNaissance = new JDate();
this.add(getJLabelFor("DATE_NAISSANCE"), c);
c.gridx++;
this.add(dateNaissance, c);
this.addView(dateNaissance, "DATE_NAISSANCE");
 
c.gridy++;
c.gridx = 0;
JTextField tel = new JTextField();
c.weightx = 0;
this.add(getJLabelFor("TEL"), c);
c.gridx++;
c.weightx = 1;
this.add(tel, c);
this.addView(tel, "TEL");
 
c.gridx++;
c.weightx = 0;
JTextField mail = new JTextField();
this.add(getJLabelFor("MAIL"), c);
c.gridx++;
c.weightx = 1;
this.add(mail, c);
this.addView(mail, "MAIL");
 
c.gridy++;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
final ElementSQLObject view = (ElementSQLObject) this.getView("ID_ADRESSE");
 
this.add(view, c);
 
c.gridy++;
c.gridx = 0;
c.weightx = 1;
c.insets = new Insets(15, 3, 2, 2);
this.add(new TitledSeparator("Gestion des entrées", true), c);
 
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/translation_fr.xml
New file
0,0 → 1,3
<translation lang="fr">
<item id="customerrelationship.customer.adherent" label="Accès par badge" />
</translation>
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/Module.java
3,15 → 3,22
import java.awt.Component;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.Normalizer;
import java.text.Normalizer.Form;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
import javax.swing.Action;
import javax.swing.Icon;
23,8 → 30,11
import org.openconcerto.erp.action.PreferencesAction;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.config.MainFrame;
import org.openconcerto.erp.core.common.element.AdresseSQLElement;
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.DBContext;
34,6 → 44,7
import org.openconcerto.erp.modules.ModulePackager;
import org.openconcerto.erp.modules.ModulePreferencePanel;
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
import org.openconcerto.erp.modules.ModuleVersion;
import org.openconcerto.erp.modules.RuntimeModuleFactory;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLComponent;
41,25 → 52,35
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.SQLName;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSyntax;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.sql.view.FileDropHandler;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.PrefType;
import org.openconcerto.utils.StringUtils;
import org.openconcerto.utils.cc.IClosure;
 
public final class Module extends AbstractModule {
 
private static final String CLIENT_ADH_FIELDNAME = "ID_ADHERENT";
private static final Pattern FIRST_NAME_PATTERN = Pattern.compile("([^0-9]*)([0-9]*).*");
public static final boolean HAS_CODE_IN_FIRST_NAME = Boolean.getBoolean("adherent.hasCodeInFirstName");
 
public Module(ModuleFactory f) throws IOException {
super(f);
 
66,10 → 87,14
}
 
@Override
protected void install(DBContext ctxt) {
protected void install(final DBContext ctxt) throws SQLException, IOException {
super.install(ctxt);
final AdresseSQLElement addrElem = ctxt.getElementDirectory().getElement(AdresseSQLElement.class);
 
if (!ctxt.getTablesPreviouslyCreated().contains("ENTREE")) {
final ModuleVersion dbVersion = ctxt.getLastInstalledVersion() == null ? ModuleVersion.MIN : ctxt.getLastInstalledVersion();
if (dbVersion.getMerged() > this.getFactory().getVersion().getMerged())
throw new IllegalStateException("Cannot downgrade from " + dbVersion + " to " + this.getFactory());
if (dbVersion.getMerged() < ModuleVersion.getMerged(1, 0)) {
// ENTREE
final SQLCreateTable createTableEntree = ctxt.getCreateTable("ENTREE");
createTableEntree.addDateAndTimeColumn("DATE");
77,8 → 102,7
createTableEntree.addVarCharColumn("ADHERENT", 512);
createTableEntree.addVarCharColumn("MOTIF", 2048);
createTableEntree.addColumn("ACCEPTE", "boolean");
}
if (!ctxt.getTablesPreviouslyCreated().contains("PLAGE_HORAIRE")) {
 
// PLAGE
final SQLCreateTable createTablePlage = ctxt.getCreateTable("PLAGE_HORAIRE");
createTablePlage.addVarCharColumn("NOM", 256);
129,9 → 153,7
createTablePlage.addColumn("FIN_3_VENDREDI", "time");
createTablePlage.addColumn("FIN_3_SAMEDI", "time");
createTablePlage.addColumn("FIN_3_DIMANCHE", "time");
}
 
if (!ctxt.getTablesPreviouslyCreated().contains("ADHERENT")) {
// ADHERENT
final SQLCreateTable createTable = ctxt.getCreateTable("ADHERENT");
 
147,11 → 169,133
createTable.addColumn("DATE_VALIDITE_INSCRIPTION", "date");
createTable.addColumn("DATE_NAISSANCE", "date");
 
createTable.addForeignColumn("ID_ADRESSE", Configuration.getInstance().getRoot().findTable("ADRESSE"));
createTable.addForeignColumn("ID_ADRESSE", addrElem.getTable());
createTable.addForeignColumn("ID_PLAGE_HORAIRE", new SQLName("PLAGE_HORAIRE"), SQLSyntax.ID_NAME, null);
}
// at least v1.0
 
if (dbVersion.getMerged() < ModuleVersion.getMerged(1, 1)) {
// migrate from non-private
final SQLTable adhT = ctxt.getRoot().getTable("ADHERENT");
final CustomerSQLElement clientElem = ctxt.getElementDirectory().getElement(CustomerSQLElement.class);
final SQLTable clientT = clientElem.getTable();
ctxt.getAlterTable(clientT.getName()).addForeignColumn(CLIENT_ADH_FIELDNAME, adhT);
// fill new field (no need to do anything in uninstall() since the field will be
// dropped and new clients shouldn't be dropped)
if (adhT.getRowCount(false) > 0) {
ctxt.executeSQL();
this.setupElements(ctxt.getElementDirectory());
// 1. fetch all clients
final ListMap<String, SQLRow> clientByName = new ListMap<>();
final ListMap<String, SQLRow> clientByCode = new ListMap<>();
for (final SQLRowValues clientR : SQLRowValuesListFetcher.create(new SQLRowValues(clientT).putNulls("NOM", "CODE")).fetch()) {
final String normalized = normalize(clientR.getString("NOM"));
clientByName.add(normalized, clientR.asRow());
clientByCode.add(clientR.getString("CODE"), clientR.asRow());
}
// 2. for each ADHERENT, link it to a single matching CLIENT, or create a
// new one. Also fill CLIENT fields with duplicates from ADHERENT.
// créer plutôt plus de clients : si besoin, fusion après coup.
final SQLRowValues adhToFetch = new SQLRowValues(adhT).putNulls("NOM", "PRENOM", "MAIL", "TEL", "DATE_NAISSANCE");
adhToFetch.putRowValues("ID_ADRESSE").setAllToNull();
final Map<SQLRow, SQLRow> updatedClientsAndAdh = new HashMap<>();
 
for (final SQLRowValues adhR : SQLRowValuesListFetcher.create(adhToFetch).fetch(null, true)) {
final String firstName;
final String code;
SQLRow existingClient = null;
if (HAS_CODE_IN_FIRST_NAME) {
final Matcher matcher = FIRST_NAME_PATTERN.matcher(adhR.getString("PRENOM"));
if (!matcher.matches())
throw new IllegalStateException("Couldn't match " + adhR);
firstName = matcher.group(1).trim();
code = matcher.group(2);
} else {
firstName = adhR.getString("PRENOM");
code = null;
}
if (!StringUtils.isEmpty(code)) {
existingClient = getUnique(clientByCode.get(code));
}
final String firstLastName = firstName + " " + adhR.getString("NOM");
if (existingClient == null) {
existingClient = getUnique(clientByName.get(normalize(firstLastName)));
}
final SQLRow newClient;
if (existingClient != null && !updatedClientsAndAdh.containsKey(existingClient)) {
updatedClientsAndAdh.put(existingClient, adhR.asRow());
// TODO use SQLElement.createFetcher()
final SQLRowValues clientToUpdateVals = SQLRowValuesListFetcher.create(clientElem.createGraph()).fetchOne(existingClient.getIDNumber(), true);
// TODO use new UpdateAction(SQLElement.createContext())
final SQLRowValues newVals = fillFields(clientToUpdateVals.deepCopy(), adhR, false, addrElem);
newClient = clientElem.update(clientToUpdateVals, newVals).exec();
} else {
// TODO use Logger
if (existingClient != null) {
System.err.println("While matching " + adhT + ", existing client " + existingClient + " already updated with " + updatedClientsAndAdh.get(existingClient)
+ " so creating new client for " + adhR);
} else {
System.err.println("While matching " + adhT + ", no client found for " + adhR);
}
// create new client row
// TODO use new InsertAction(SQLElement.createContext()) or at least
// SQLElement.insert()
final SQLRowValues vals = fillFields(new SQLRowValues(clientT).put("NOM", firstLastName), adhR, true, addrElem);
if (!StringUtils.isEmpty(code))
vals.put("CODE", code);
newClient = vals.insert();
}
final SQLRowValues contactVals = new SQLRowValues(ctxt.getElementDirectory().getElement(ContactSQLElement.class).getTable());
contactVals.putForeignID("ID_CLIENT", newClient);
contactVals.load(adhR.asRow(), Arrays.asList("NOM", "DATE_NAISSANCE"));
contactVals.put("PRENOM", firstName);
contactVals.put("EMAIL", adhR.getString("MAIL"));
contactVals.insert();
}
 
ctxt.getAlterTable(adhT.getName()).dropColumn("ID_ADRESSE");
}
}
}
 
protected SQLRow getUnique(final List<SQLRow> clientRows) {
return clientRows != null && clientRows.size() == 1 ? clientRows.get(0) : null;
}
 
private final SQLRowValues fillFields(final SQLRowValues clientVals, final SQLRowValues adhVals, final boolean useAdhID, final SQLElement addrElem) {
clientVals.put(CLIENT_ADH_FIELDNAME, useAdhID ? adhVals.getIDNumber() : adhVals.deepCopy());
concatField(clientVals, adhVals, "MAIL");
concatField(clientVals, adhVals, "TEL");
final SQLRowValues adhAddr = (SQLRowValues) adhVals.getNonEmptyForeign("ID_ADRESSE");
if (adhAddr != null && !StringUtils.isEmpty(adhAddr.getString("VILLE"), true)) {
clientVals.put("ID_ADRESSE", addrElem.createCopy(adhAddr, true, null));
}
return clientVals;
}
 
private final void concatField(final SQLRowValues clientVals, final SQLRowValues adhVals, final String fieldName) {
final String adhStr = adhVals.getString(fieldName);
if (StringUtils.isEmpty(adhStr, true))
return;
final String clientStr = clientVals.getString(fieldName);
if (StringUtils.isEmpty(clientStr, true)) {
clientVals.put(fieldName, adhStr);
} else {
clientVals.put(fieldName, clientStr + ", " + adhStr);
}
}
 
static private final Pattern diacriticalPattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
static private final Pattern punctPattern = Pattern.compile("\\p{Punct}+");
static private final Pattern spacePattern = Pattern.compile("\\p{Space}+");
 
// remove punctation, multiple spaces and accents
static private String normalize(final String s) {
final String noMarks = diacriticalPattern.matcher(Normalizer.normalize(s, Form.NFD)).replaceAll("");
final String noPunct = punctPattern.matcher(noMarks).replaceAll("_");
return spacePattern.matcher(noPunct.trim()).replaceAll(" ").toLowerCase();
}
 
@Override
protected void setupElements(SQLElementDirectory dir) {
super.setupElements(dir);
248,6 → 392,9
 
@Override
protected void setupComponents(ComponentsContext ctxt) {
final Group g = new Group("customerrelationship.customer.adherent", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
ctxt.getElement("CLIENT").getDefaultGroup().add(g);
g.addItem(CLIENT_ADH_FIELDNAME, new LayoutHints(true, true, true, true, true, true));
ctxt.addFileDropHandler("ADHERENT", new FileDropHandler() {
 
@Override
268,20 → 415,10
return n.endsWith(".xls") || n.endsWith(".ods");
}
});
 
}
 
@Override
protected void setupMenu(MenuContext ctxt) {
ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des adhérents") {
 
@Override
public JFrame createFrame() {
IListFrame frameAdh = new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("ADHERENT")));
return frameAdh;
}
}, MainFrame.LIST_MENU);
 
ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des entrées") {
 
@Override
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/BadgeListener.java
44,7 → 44,6
import org.openconcerto.sql.preferences.SQLPreferences;
import org.openconcerto.sql.preferences.UserProps;
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.i18n.TranslationManager;
 
60,7 → 59,7
}
 
public void init(String id) {
 
// TODO use HeadlessGestion
TranslationManager.getInstance().addTranslationStreamFromClass(BadgeListener.class);
TranslationManager.getInstance().setLocale(Locale.FRANCE);
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
70,7 → 69,7
}
 
Configuration.setInstance(conf);
UserManager.getInstance().setCurrentUser(2);
conf.getUserManager().setCurrentUserID(2);
 
try {
conf.getBase();
276,6 → 275,7
public boolean isBadgeAllowed(String cardNumber) {
SQLBase base = Configuration.getInstance().getBase();
SQLSelect sel = new SQLSelect(base);
// FIXME use SQLElement
SQLTable tableAdh = Configuration.getInstance().getRoot().findTable("ADHERENT");
sel.addSelectStar(tableAdh);
sel.setWhere(new Where(tableAdh.getField("NUMERO_CARTE"), "=", cardNumber));
282,6 → 282,7
List<SQLRow> list = (List<SQLRow>) base.getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
 
String motif = "";
// FIXME use actual module installed in the DB (MAYBE init() the ModuleManager)
Boolean onlyAdmin = ModuleManager.getInstance().getFactories().get("org.openconcerto.modules.badge").get(new ModuleVersion(1, 0)).getSQLPreferences(tableAdh.getDBRoot())
.getBoolean(Module.ENTREE_PREF, false);
boolean allow = false;
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/labels_fr.xml
New file
0,0 → 1,91
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<TABLE name="ADHERENT">
<FIELD name="NOM" label="Nom" />
<FIELD name="PRENOM" label="Prénom" />
<FIELD name="DATE_NAISSANCE" label="Date de naissance" />
<FIELD name="TEL" label="Téléphone" />
<FIELD name="MAIL" label="E-Mail" />
<FIELD name="ACTIF" label="Actif" />
<FIELD name="ADMIN" label="Toujours autoriser l'entrée" />
<FIELD name="ID_ADRESSE" label="Adresse" />
<FIELD name="ID_PLAGE_HORAIRE" label="Plage horaire" />
<FIELD name="INFOS" label="Informations" />
<FIELD name="DATE_VALIDITE_INSCRIPTION" label="Autorisé jusqu'au" />
<FIELD name="NUMERO_CARTE" label="Numéro de carte" />
</TABLE>
<TABLE name="CLIENT">
<!-- TODO fix showLabel=false,fillWidth=true : fillWidth is ignored. So for now showLabel with a dummy one -->
<FIELD name="ID_ADHERENT" label="." />
</TABLE>
 
<TABLE name="ENTREE">
<FIELD name="DATE" label="Date" />
<FIELD name="ADHERENT" label="Nom de l'adhérent" />
<FIELD name="ACCEPTE" label="Ouverture autorisée" />
<FIELD name="NUMERO_CARTE" label="Numéro de carte" />
<FIELD name="MOTIF" label="motif" />
</TABLE>
 
 
<TABLE name="PLAGE_HORAIRE">
<FIELD name="NOM" label="Nom de la plage" />
<FIELD name="DEBUT_1_LUNDI" label="Début lundi 1" />
<FIELD name="DEBUT_2_LUNDI" label="Début lundi 2" />
<FIELD name="DEBUT_3_LUNDI" label="Début lundi 3" />
<FIELD name="FIN_1_LUNDI" label="Fin lundi 1" />
<FIELD name="FIN_2_LUNDI" label="Fin lundi 2" />
<FIELD name="FIN_3_LUNDI" label="Fin lundi 3" />
 
<FIELD name="DEBUT_1_MARDI" label="Début mardi 1" />
<FIELD name="DEBUT_2_MARDI" label="Début mardi 2" />
<FIELD name="DEBUT_3_MARDI" label="Début mardi 3" />
<FIELD name="FIN_1_MARDI" label="Fin mardi 1" />
<FIELD name="FIN_2_MARDI" label="Fin mardi 2" />
<FIELD name="FIN_3_MARDI" label="Fin mardi 3" />
 
<FIELD name="DEBUT_1_MERC" label="Début mercredi 1" />
<FIELD name="DEBUT_2_MERC" label="Début mercredi 2" />
<FIELD name="DEBUT_3_MERC" label="Début mercredi 3" />
<FIELD name="FIN_1_MERC" label="Fin mercredi 1" />
<FIELD name="FIN_2_MERC" label="Fin mercredi 2" />
<FIELD name="FIN_3_MERC" label="Fin mercredi 3" />
 
<FIELD name="DEBUT_1_JEUDI" label="Début jeudi 1" />
<FIELD name="DEBUT_2_JEUDI" label="Début jeudi 2" />
<FIELD name="DEBUT_3_JEUDI" label="Début jeudi 3" />
<FIELD name="FIN_1_JEUDI" label="Fin jeudi 1" />
<FIELD name="FIN_2_JEUDI" label="Fin jeudi 2" />
<FIELD name="FIN_3_JEUDI" label="Fin jeudi 3" />
 
<FIELD name="DEBUT_1_VEND" label="Début vendredi 1" />
<FIELD name="DEBUT_2_VEND" label="Début vendredi 2" />
<FIELD name="DEBUT_3_VEND" label="Début vendredi 3" />
<FIELD name="FIN_1_VEND" label="Fin vendredi 1" />
<FIELD name="FIN_2_VEND" label="Fin vendredi 2" />
<FIELD name="FIN_3_VEND" label="Fin vendredi 3" />
 
 
<FIELD name="DEBUT_1_SAMEDI" label="Début samedi 1" />
<FIELD name="DEBUT_2_SAMEDI" label="Début samedi 2" />
<FIELD name="DEBUT_3_SAMEDI" label="Début samedi 3" />
<FIELD name="FIN_1_SAMEDI" label="Fin samedi 1" />
<FIELD name="FIN_2_SAMEDI" label="Fin samedi 2" />
<FIELD name="FIN_3_SAMEDI" label="Fin samedi 3" />
 
 
<FIELD name="DEBUT_1_DIM" label="Début dimanche 1" />
<FIELD name="DEBUT_2_DIM" label="Début dimanche 2" />
<FIELD name="DEBUT_3_DIM" label="Début dimanche 3" />
<FIELD name="FIN_1_DIM" label="Fin dimanche 1" />
<FIELD name="FIN_2_DIM" label="Fin dimanche 2" />
<FIELD name="FIN_3_DIM" label="Fin dimanche 3" />
 
 
 
</TABLE>
 
 
</ROOT>
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/ModuleCard.java
1,6 → 1,7
package org.openconcerto.modules.card;
 
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
34,7 → 35,7
}
 
@Override
protected void install(DBContext ctxt) {
protected void install(DBContext ctxt) throws SQLException, IOException {
super.install(ctxt);
// TODO use version to upgrade
if (!ctxt.getTablesPreviouslyCreated().contains(TABLE_NAME)) {