OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 181 → Rev 180

/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchField.java
File deleted
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/DateProcessor.java
17,8 → 17,8
private final JDate d = new JDate(true);
private final SQLField field;
 
public DateProcessor(BatchField field) {
this.field = field.getField();
public DateProcessor(SQLField field) {
this.field = field;
this.setLayout(new FlowLayout());
this.add(new JLabel("forcer la date au "));
this.add(d);
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/ReferenceProcessor.java
18,18 → 18,18
 
public class ReferenceProcessor extends JPanel implements BatchProcessor {
 
private final BatchField field;
private final SQLField field;
final SQLElement element;
private ElementComboBox combo;
 
public ReferenceProcessor(BatchField field) {
public ReferenceProcessor(SQLField field) {
this.field = field;
this.element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(field.getField().getForeignTable());
this.element = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(field.getForeignTable());
 
if (element != null) {
this.setLayout(new BorderLayout());
this.add(new JLabel("remplacer par "), BorderLayout.WEST);
combo = new ElementComboBox(true, 10);
combo = new ElementComboBox(true, 200);
combo.setMinimal();
combo.setAddIconVisible(false);
combo.init(element);
36,7 → 36,7
this.add(combo, BorderLayout.CENTER);
} else {
this.setLayout(new FlowLayout());
this.add(new JLabelWarning("No element for table " + field.getField().getTable().getName()));
this.add(new JLabelWarning("No element for table " + field.getTable().getName()));
}
}
 
45,7 → 45,7
 
for (SQLRowAccessor sqlRowAccessor : r) {
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
rowValues.put(field.getField().getName(), combo.getSelectedId());
rowValues.put(field.getName(), combo.getSelectedId());
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BooleanProcessor.java
13,13 → 13,13
import org.openconcerto.ui.VFlowLayout;
 
public class BooleanProcessor extends JPanel implements BatchProcessor {
private final BatchField field;
private final SQLField field;
 
private JRadioButton bTrue;
private JRadioButton bFalse;
private JRadioButton bInvert;
 
public BooleanProcessor(BatchField field) {
public BooleanProcessor(SQLField field) {
this.field = field;
this.setLayout(new VFlowLayout());
bTrue = new JRadioButton("forcer à vrai");
41,7 → 41,7
if (bTrue.isSelected()) {
for (SQLRowAccessor sqlRowAccessor : r) {
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
rowValues.put(field.getField().getName(), Boolean.TRUE);
rowValues.put(field.getName(), Boolean.TRUE);
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
48,7 → 48,7
} else if (bFalse.isSelected()) {
for (SQLRowAccessor sqlRowAccessor : r) {
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
rowValues.put(field.getField().getName(), Boolean.FALSE);
rowValues.put(field.getName(), Boolean.FALSE);
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
55,9 → 55,9
} else if (bInvert.isSelected()) {
for (SQLRowAccessor sqlRowAccessor : r) {
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
final Boolean boolean1 = sqlRowAccessor.asRow().getBoolean(field.getField().getName());
final Boolean boolean1 = sqlRowAccessor.asRow().getBoolean(field.getName());
if (boolean1 != null) {
rowValues.put(field.getField().getName(), boolean1.equals(Boolean.FALSE));
rowValues.put(field.getName(), boolean1.equals(Boolean.FALSE));
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/product/PurchaseProcessor.java
2,14 → 2,14
 
import java.math.BigDecimal;
 
import org.openconcerto.modules.common.batchprocessing.BatchField;
import org.openconcerto.modules.common.batchprocessing.NumberProcessor;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
 
public class PurchaseProcessor extends NumberProcessor {
 
public PurchaseProcessor(BatchField field) {
public PurchaseProcessor(SQLField field) {
super(field);
}
 
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/product/TTCProcessor.java
4,8 → 4,8
 
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.utils.ConvertDevise;
import org.openconcerto.modules.common.batchprocessing.BatchField;
import org.openconcerto.modules.common.batchprocessing.NumberProcessor;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
12,7 → 12,7
 
public class TTCProcessor extends NumberProcessor {
 
public TTCProcessor(BatchField field) {
public TTCProcessor(SQLField field) {
super(field);
}
 
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/product/TVAProcessor.java
4,8 → 4,8
 
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.utils.ConvertDevise;
import org.openconcerto.modules.common.batchprocessing.BatchField;
import org.openconcerto.modules.common.batchprocessing.ReferenceProcessor;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
12,7 → 12,7
 
public class TVAProcessor extends ReferenceProcessor {
 
public TVAProcessor(BatchField field) {
public TVAProcessor(SQLField field) {
super(field);
}
 
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/product/HTProcessor.java
4,8 → 4,8
 
import org.openconcerto.erp.core.finance.tax.model.TaxeCache;
import org.openconcerto.erp.utils.ConvertDevise;
import org.openconcerto.modules.common.batchprocessing.BatchField;
import org.openconcerto.modules.common.batchprocessing.NumberProcessor;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
12,7 → 12,7
 
public class HTProcessor extends NumberProcessor {
 
public HTProcessor(BatchField field) {
public HTProcessor(SQLField field) {
super(field);
}
 
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchDetailPanel.java
22,47 → 22,46
this.setLayout(new VFlowLayout());
}
 
public void setField(BatchField batchField) {
public void setField(SQLField field) {
this.removeAll();
 
SQLField field = batchField.getField();
final SQLType type = field.getType();
final Class<?> javaType = type.getJavaType();
final String fName = field.getName();
if (fName.equals("PV_TTC")) {
final NumberProcessor p = new TTCProcessor(batchField);
final NumberProcessor p = new TTCProcessor(field);
this.add(p);
this.processor = p;
} else if (fName.equals("PV_HT")) {
final NumberProcessor p = new HTProcessor(batchField);
final NumberProcessor p = new HTProcessor(field);
this.add(p);
this.processor = p;
} else if (fName.equals("ID_TAXE")) {
final ReferenceProcessor p = new TVAProcessor(batchField);
final ReferenceProcessor p = new TVAProcessor(field);
this.add(p);
this.processor = p;
} else if (fName.equals("PA_HT")) {
final NumberProcessor p = new PurchaseProcessor(batchField);
final NumberProcessor p = new PurchaseProcessor(field);
this.add(p);
this.processor = p;
} else if (javaType.equals(Boolean.class)) {
final BooleanProcessor p = new BooleanProcessor(batchField);
final BooleanProcessor p = new BooleanProcessor(field);
this.add(p);
this.processor = p;
} else if (field.isKey()) {
final ReferenceProcessor p = new ReferenceProcessor(batchField);
final ReferenceProcessor p = new ReferenceProcessor(field);
this.add(p);
this.processor = p;
} else if (javaType.equals(String.class)) {
final StringProcessor p = new StringProcessor(batchField);
final StringProcessor p = new StringProcessor(field);
this.add(p);
this.processor = p;
} else if (javaType.equals(Date.class)) {
final DateProcessor p = new DateProcessor(batchField);
final DateProcessor p = new DateProcessor(field);
this.add(p);
this.processor = p;
} else if (javaType.equals(BigDecimal.class) || javaType.equals(Float.class) || javaType.equals(Double.class) || javaType.equals(Integer.class) || javaType.equals(Long.class)) {
final NumberProcessor p = new NumberProcessor(batchField);
final NumberProcessor p = new NumberProcessor(field);
this.add(p);
this.processor = p;
}
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/Module.java
2,6 → 2,7
 
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.util.List;
 
8,12 → 9,18
import javax.swing.AbstractAction;
import javax.swing.JFrame;
 
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.erp.modules.ModulePackager;
import org.openconcerto.erp.modules.RuntimeModuleFactory;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRequestLog;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.ui.ConnexionPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
26,7 → 33,7
}
 
@Override
protected void setupComponents(final ComponentsContext ctxt) {
protected void setupComponents(ComponentsContext ctxt) {
 
super.setupComponents(ctxt);
final SQLElement element = ctxt.getElement("ARTICLE");
53,7 → 60,7
 
};
 
f.setContentPane(new BatchEditorPanel(ctxt.getElement("ARTICLE").getDirectory(), rows, filter));
f.setContentPane(new BatchEditorPanel(rows, filter));
f.pack();
f.setMinimumSize(new Dimension(400, 300));
f.setLocationRelativeTo(IListe.get(e));
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/StringProcessor.java
29,8 → 29,8
private JRadioButton bLower;
private JRadioButton bUpper;
 
public StringProcessor(BatchField field) {
this.field = field.getField();
public StringProcessor(SQLField field) {
this.field = field;
 
this.setLayout(new GridBagLayout());
bReplace = new JRadioButton("remplacer par");
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchEditorPanel.java
24,13 → 24,10
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
 
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.request.SQLFieldTranslator;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.JLabelBold;
39,34 → 36,24
 
public class BatchEditorPanel extends JPanel {
 
public BatchEditorPanel(final SQLElementDirectory dir, final List<SQLRowValues> rows, FieldFilter filter) {
SQLFieldTranslator translator = dir.getTranslator();
public BatchEditorPanel(final List<SQLRowValues> rows, FieldFilter filter) {
Configuration conf = PropsConfiguration.getInstance();
final SQLFieldTranslator translator = conf.getTranslator();
Set<SQLField> fields = rows.get(0).getTable().getFields();
List<BatchField> f = new ArrayList<BatchField>();
List<SQLField> f = new ArrayList<SQLField>();
for (SQLField sqlField : fields) {
if (ForbiddenFieldName.isAllowed(sqlField.getName()) && translator.getLabelFor(sqlField) != null) {
if (filter == null || !filter.isFiltered(sqlField)) {
f.add(new BatchField(dir, sqlField, null));
f.add(sqlField);
}
}
}
SQLTable tableTarif = rows.get(0).getTable().getTable("TARIF");
SQLTable tableArticleTarif = rows.get(0).getTable().getTable("ARTICLE_TARIF");
SQLSelect sel = new SQLSelect();
sel.addSelectStar(tableTarif);
List<SQLRow> rowTarif = SQLRowListRSH.execute(sel);
for (SQLRow sqlRow : rowTarif) {
f.add(new BatchField(dir, tableArticleTarif.getField("PV_HT"), sqlRow));
if (tableArticleTarif.contains("POURCENT_REMISE")) {
f.add(new BatchField(dir, tableArticleTarif.getField("POURCENT_REMISE"), sqlRow));
}
}
 
Collections.sort(f, new Comparator<BatchField>() {
Collections.sort(f, new Comparator<SQLField>() {
 
@Override
public int compare(BatchField o1, BatchField o2) {
return o1.getComboName().compareToIgnoreCase(o2.getComboName());
public int compare(SQLField o1, SQLField o2) {
return translator.getLabelFor(o1).compareToIgnoreCase(translator.getLabelFor(o2));
}
});
this.setLayout(new GridBagLayout());
73,11 → 60,11
GridBagConstraints c = new DefaultGridBagConstraints();
this.add(new JLabel("Champ"), c);
 
final JComboBox<BatchField> combo = new JComboBox<BatchField>(f.toArray(new BatchField[1]));
final JComboBox<SQLField> combo = new JComboBox<SQLField>(f.toArray(new SQLField[1]));
combo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String label = ((BatchField) value).getComboName();
String label = translator.getLabelFor(((SQLField) value));
return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
}
});
99,7 → 86,7
c.gridy++;
c.anchor = GridBagConstraints.NORTHWEST;
final BatchDetailPanel comp = new BatchDetailPanel();
comp.setField((BatchField) combo.getSelectedItem());
comp.setField((SQLField) combo.getSelectedItem());
this.add(comp, c);
 
JPanel actions = new JPanel();
121,7 → 108,7
 
@Override
public void itemStateChanged(ItemEvent e) {
comp.setField((BatchField) combo.getSelectedItem());
comp.setField((SQLField) combo.getSelectedItem());
 
}
});
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/NumberProcessor.java
13,7 → 13,7
import javax.swing.JRadioButton;
import javax.swing.JTextField;
 
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.ui.DefaultGridBagConstraints;
20,7 → 20,7
 
public class NumberProcessor extends JPanel implements BatchProcessor {
 
private final BatchField batchfield;
private final SQLField field;
// Editors
final JTextField tReplace = new JTextField();
private JRadioButton bReplace;
30,8 → 30,8
final JTextField tRemove = new JTextField();
private JRadioButton bRemove;
 
public NumberProcessor(BatchField field) {
this.batchfield = field;
public NumberProcessor(SQLField field) {
this.field = field;
 
this.setLayout(new GridBagLayout());
bReplace = new JRadioButton("remplacer par");
110,23 → 110,11
if (bReplace.isSelected()) {
BigDecimal v = new BigDecimal(this.tReplace.getText().trim());
for (SQLRowAccessor sqlRowAccessor : r) {
 
if (batchfield.getForeignLinkRow() != null) {
 
final List<SQLRow> referentRow = batchfield.getReferentRows(sqlRowAccessor);
for (SQLRow sqlRowT : referentRow) {
SQLRowValues rowValues = sqlRowT.createEmptyUpdateRow();
rowValues.put(batchfield.getField().getName(), decimalToFieldType(v));
processBeforeUpdate(sqlRowT, rowValues);
rowValues.update();
}
} else {
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
rowValues.put(batchfield.getField().getName(), decimalToFieldType(v));
rowValues.put(field.getName(), decimalToFieldType(v));
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
}
} else if (bAdd.isSelected()) {
 
String t = this.tAdd.getText().trim();
139,44 → 127,18
BigDecimal v = new BigDecimal(t);
 
for (SQLRowAccessor sqlRowAccessor : r) {
 
if (batchfield.getForeignLinkRow() != null) {
 
final List<SQLRow> referentRow = batchfield.getReferentRows(sqlRowAccessor);
for (SQLRow sqlRowT : referentRow) {
 
SQLRowValues rowValues = sqlRowT.createEmptyUpdateRow();
BigDecimal value = sqlRowT.asRow().getBigDecimal(batchfield.getField().getName());
 
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
final BigDecimal value = sqlRowAccessor.asRow().getBigDecimal(field.getName());
if (value != null) {
if (isPercent) {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.multiply(v.divide(new BigDecimal(100)).add(BigDecimal.ONE))));
rowValues.put(field.getName(), decimalToFieldType(value.multiply(v.divide(new BigDecimal(100)).add(BigDecimal.ONE))));
} else {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.add(v)));
rowValues.put(field.getName(), decimalToFieldType(value.add(v)));
}
processBeforeUpdate(sqlRowT, rowValues);
rowValues.update();
}
}
} else {
 
final SQLRowValues rowValues;
final BigDecimal value;
 
rowValues = sqlRowAccessor.createEmptyUpdateRow();
value = sqlRowAccessor.asRow().getBigDecimal(batchfield.getField().getName());
 
if (value != null) {
if (isPercent) {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.multiply(v.divide(new BigDecimal(100)).add(BigDecimal.ONE))));
} else {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.add(v)));
}
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
}
}
} else if (bRemove.isSelected()) {
String t = this.tRemove.getText().trim();
boolean isPercent = false;
187,35 → 149,15
 
BigDecimal v = new BigDecimal(t);
for (SQLRowAccessor sqlRowAccessor : r) {
if (batchfield.getForeignLinkRow() != null) {
final List<SQLRow> referentRow = batchfield.getReferentRows(sqlRowAccessor);
if (referentRow != null && !referentRow.isEmpty()) {
for (SQLRow sqlRowT : referentRow) {
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
 
SQLRowValues rowValues = sqlRowT.createEmptyUpdateRow();
final BigDecimal value = sqlRowT.getBigDecimal(batchfield.getField().getName());
final BigDecimal value = sqlRowAccessor.asRow().getBigDecimal(field.getName());
if (value != null) {
if (isPercent) {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.multiply(v.divide(new BigDecimal(-100)).add(BigDecimal.ONE))));
rowValues.put(field.getName(), decimalToFieldType(value.multiply(v.divide(new BigDecimal(-100)).add(BigDecimal.ONE))));
} else {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.add(v)));
rowValues.put(field.getName(), decimalToFieldType(value.add(v)));
}
processBeforeUpdate(sqlRowT, rowValues);
rowValues.update();
}
}
}
} else {
 
SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
final BigDecimal value = sqlRowAccessor.asRow().getBigDecimal(batchfield.getField().getName());
 
if (value != null) {
if (isPercent) {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.multiply(v.divide(new BigDecimal(-100)).add(BigDecimal.ONE))));
} else {
rowValues.put(batchfield.getField().getName(), decimalToFieldType(value.add(v)));
}
processBeforeUpdate(sqlRowAccessor, rowValues);
rowValues.update();
}
222,10 → 164,9
}
}
}
}
 
private Object decimalToFieldType(BigDecimal v) {
final Class<?> javaType = batchfield.getField().getType().getJavaType();
final Class<?> javaType = field.getType().getJavaType();
if (javaType.equals(BigDecimal.class)) {
return v;
} else if (javaType.equals(Float.class)) {
/trunk/Modules/Module Label/lib/barcode4j-2.1.0.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/lib/jbarcode-0.2.8.jar
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/.settings/org.eclipse.jdt.core.prefs
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/JapanPost.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/AztecCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Nve18.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Ean.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/DataBar14.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/ChannelCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Logmars.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/KoreaPost.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Pharmacode2Track.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code11.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/CodeOne.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/QrCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/HumanReadableLocation.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/EanUpcAddOn.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code93.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/KixCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/ReedSolomon.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code49.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/HumanReadableAlignment.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/MaxiCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/AustraliaPost.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Codabar.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Postnet.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Telepen.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/TextBox.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/MsiPlessey.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/DataMatrix.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/AztecRune.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Composite.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Pharmacode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code128.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Pdf417.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Symbol.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/UspsPackage.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/DataBarLimited.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code2Of5.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/DataBarExpanded.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/MicroQrCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/GridMatrix.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code3Of9.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/RoyalMail4State.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code32.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/OkapiException.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/CodablockF.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Upc.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/UspsOneCode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Hexagon.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code3Of9Extended.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Code16k.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/backend/Pharmazentralnummer.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/util/Strings.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/util/Gs1.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/util/Doubles.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/util/Arrays.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/util/EciMode.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/output/SvgRenderer.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/output/ExtendedOutputStreamWriter.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/output/SymbolRenderer.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/output/Java2DRenderer.java
File deleted
/trunk/Modules/Module Label/src/uk/org/okapibarcode/output/PostScriptRenderer.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/filter/ISO646DocumentFilter.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/filter/LimitDocumentFilter.java
File deleted
\ No newline at end of file
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/filter/NumberOfProductDocumentFilter.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/filter/BatchDocumentFilter.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/filter/EANDocumentFilter.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/GS1Frame.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/gs1/GS1ParseException.java
File deleted
\ No newline at end of file
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/gs1/GS1Util.java
File deleted
\ No newline at end of file
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/gs1/GS1AIElements.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/gs1/GS1ApplicationIdentifier.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/GPLRenderer.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/GraphicsPL.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/ZPLRenderer.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/Graphics2DRenderer.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/Label.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/oc-qrcode.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/default-zpl.txt
File deleted
\ No newline at end of file
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/32.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/RowValuesLabel.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/16.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ZPLPrinterPanel.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/GS1Label.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ISO646.java
File deleted
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/48.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/96.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/logo.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/LabelFrame.java
20,6 → 20,7
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
 
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
 
29,7 → 30,7
private static final int DEFAULT_COLS = 4;
final LabelPanel labelPanel;
 
public LabelFrame(List<? extends Label> list, LabelRenderer labelRenderer) {
public LabelFrame(List<? extends SQLRowAccessor> list, LabelRenderer labelRenderer) {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/LabelPanel.java
15,9 → 15,11
 
import javax.swing.JPanel;
 
import org.openconcerto.sql.model.SQLRowAccessor;
 
public class LabelPanel extends JPanel implements Printable {
 
private List<? extends Label> list;
private List<? extends SQLRowAccessor> list;
private int lines;
private int columns;
private Boolean[][] mask;
27,7 → 29,7
private int topMargin;
private int leftMargin;
 
public LabelPanel(List<? extends Label> list, int l, int c, LabelRenderer labelRenderer) {
public LabelPanel(List<? extends SQLRowAccessor> list, int l, int c, LabelRenderer labelRenderer) {
this.list = list;
this.renderer = labelRenderer;
setSizeLayoutSize(l, c);
46,11 → 48,6
});
}
 
public void setList(List<? extends Label> list) {
this.list = list;
repaint();
}
 
private void setSizeLayoutSize(int l, int c) {
this.lines = l;
this.columns = c;
105,7 → 102,7
g.drawRect(x, y, w, h);
// Label
if (rowIndex < list.size()) {
Label row = list.get(rowIndex);
SQLRowAccessor row = list.get(rowIndex);
renderer.paintLabel(g, row, x, y, w, h, 10f);
}
rowIndex++;
172,7 → 169,7
for (int j = 0; j < this.columns; j++) {
boolean mask = this.mask[i][j];
if (!mask && rowIndex < list.size()) {
Label row = list.get(rowIndex);
SQLRowAccessor row = list.get(rowIndex);
renderer.paintLabel(g, row, j * w + imageableX, i * h + imageableY, w, h, 10f);
}
rowIndex++;
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ModuleLabel.java
4,17 → 4,10
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.geom.Rectangle2D;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.SwingWorker;
 
import org.openconcerto.erp.generationDoc.provider.AdresseFullClientValueProvider;
21,7 → 14,6
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
31,12 → 23,10
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.FileUtils;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.StringUtils;
 
public final class ModuleLabel extends AbstractModule {
final LinkedHashMap<String, String> zplTemplates = new LinkedHashMap<String, String>();
 
public ModuleLabel(ModuleFactory f) throws IOException {
super(f);
44,9 → 34,6
 
@Override
protected void setupComponents(ComponentsContext ctxt) {
readTemplates(new File("Template/Labels"));
readTemplates(new File("Configuration/Template/Labels"));
 
final String actionName = "Imprimer les étiquettes";
final PredicateRowAction aArticle = new PredicateRowAction(new AbstractAction(actionName) {
 
54,31 → 41,26
public void actionPerformed(ActionEvent arg0) {
final IListe list = IListe.get(arg0);
final List<Integer> selectedIDs = list.getSelection().getSelectedIDs();
final SQLTable tArticle = list.getSelectedRows().get(0).getTable();
final SwingWorker<List<RowValuesLabel>, String> wworker = new SwingWorker<List<RowValuesLabel>, String>() {
final SwingWorker<List<SQLRowValues>, String> wworker = new SwingWorker<List<SQLRowValues>, String>() {
 
@Override
protected List<RowValuesLabel> doInBackground() throws Exception {
protected List<SQLRowValues> doInBackground() throws Exception {
final SQLTable tArticle = list.getSelectedRows().get(0).getTable();
final SQLRowValues graph = new SQLRowValues(tArticle);
graph.putNulls("NOM", "PV_TTC");
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(graph);
final List<SQLRowValues> rows = fetcher.fetch(new Where(tArticle.getKey(), selectedIDs));
final List<RowValuesLabel> list = new ArrayList<>(rows.size());
for (SQLRowValues row : rows) {
list.add(new RowValuesLabel(row));
final List<SQLRowValues> values = fetcher.fetch(new Where(tArticle.getKey(), selectedIDs));
return values;
}
return list;
}
 
@Override
protected void done() {
try {
final List<RowValuesLabel> values = get();
final List<SQLRowValues> values = get();
 
final LabelFrame f = new LabelFrame(values, new LabelRenderer() {
 
@Override
public void paintLabel(Graphics g, Label label, int x, int y, int gridWith, int gridHeight, float fontSize) {
public void paintLabel(Graphics g, SQLRowAccessor row, int x, int y, int gridWith, int gridHeight, float fontSize) {
g.setColor(Color.BLACK);
g.setFont(g.getFont().deriveFont(fontSize));
// Labels borders
85,7 → 67,6
final int hBorder = 12;
final int vBorder = 8;
// Product name
SQLRowValues row = ((RowValuesLabel) label).getSQLRowValues();
final String text = row.getString("NOM");
final List<String> l = StringUtils.wrap(text, g.getFontMetrics(), gridWith - 2 * hBorder);
final int lineHeight = g.getFontMetrics().getHeight();
92,7 → 73,7
int lineY = y;
final int margin = gridHeight - l.size() * lineHeight;
if (margin > 0) {
lineY += margin / 2;
lineY += (int) (margin / 2);
}
for (String line : l) {
g.drawString(line, x + hBorder, lineY);
114,8 → 95,8
} catch (Exception e) {
ExceptionHandler.handle("Erreur d'impression", e);
}
}
};
};
wworker.execute();
 
}
126,11 → 107,11
public void actionPerformed(ActionEvent arg0) {
final IListe list = IListe.get(arg0);
final List<Integer> selectedIDs = list.getSelection().getSelectedIDs();
final SQLTable tClient = list.getSelectedRows().get(0).getTable();
final SwingWorker<List<RowValuesLabel>, String> wworker = new SwingWorker<List<RowValuesLabel>, String>() {
final SwingWorker<List<SQLRowValues>, String> wworker = new SwingWorker<List<SQLRowValues>, String>() {
 
@Override
protected List<RowValuesLabel> doInBackground() throws Exception {
protected List<SQLRowValues> doInBackground() throws Exception {
final SQLTable tClient = list.getSelectedRows().get(0).getTable();
final SQLRowValues graph = new SQLRowValues(tClient);
graph.putNulls("NOM");
final SQLRowValues a1 = graph.putRowValues("ID_ADRESSE");
138,24 → 119,17
final SQLRowValues a2 = graph.putRowValues("ID_ADRESSE_L");
a2.putNulls(a2.getTable().getFieldsName());
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(graph);
final List<SQLRowValues> rows = fetcher.fetch(new Where(tClient.getKey(), selectedIDs));
 
final List<RowValuesLabel> list = new ArrayList<>(rows.size());
for (SQLRowValues row : rows) {
list.add(new RowValuesLabel(row));
final List<SQLRowValues> values = fetcher.fetch(new Where(tClient.getKey(), selectedIDs));
return values;
}
return list;
}
 
@Override
protected void done() {
try {
final List<RowValuesLabel> values = get();
final List<SQLRowValues> values = get();
final LabelFrame f = new LabelFrame(values, new LabelRenderer() {
 
@Override
public void paintLabel(Graphics g, Label label, int x, int y, int gridWith, int gridHeight, float fontSize) {
SQLRowValues row = ((RowValuesLabel) label).getSQLRowValues();
public void paintLabel(Graphics g, SQLRowAccessor row, int x, int y, int gridWith, int gridHeight, float fontSize) {
SQLRowAccessor rAddr = row.getForeign("ID_ADRESSE_L");
if (rAddr == null || rAddr.isUndefined()) {
rAddr = row.getForeign("ID_ADRESSE");
191,8 → 165,8
} catch (Exception e) {
ExceptionHandler.handle("Erreur d'impression", e);
}
}
};
};
wworker.execute();
 
}
202,94 → 176,13
aClient.setPredicate(IListeEvent.createSelectionCountPredicate(1, Integer.MAX_VALUE));
ctxt.getElement("ARTICLE").getRowActions().add(aArticle);
ctxt.getElement("CLIENT").getRowActions().add(aClient);
 
if (!this.zplTemplates.isEmpty()) {
for (final Entry<String, String> entry : this.zplTemplates.entrySet()) {
final String zpl = entry.getValue();
final PredicateRowAction action = new PredicateRowAction(new AbstractAction("Imprimer l'étiquette " + entry.getKey()) {
 
@Override
public void actionPerformed(ActionEvent arg0) {
final ZPLPrinterPanel p = new ZPLPrinterPanel(zpl);
final JFrame f = new JFrame();
final IListe list = IListe.get(arg0);
final int idProduct = list.getSelection().getSelectedID();
final SQLTable tArticle = list.getSelectedRows().get(0).getTable();
 
final SwingWorker<SQLRowValues, String> wworker = new SwingWorker<SQLRowValues, String>() {
 
@Override
protected SQLRowValues doInBackground() throws Exception {
final SQLRow row = tArticle.getRow(idProduct);
row.fetchValues();
return row.asRowValues();
}
 
@Override
protected void done() {
try {
final SQLRowValues values = get();
p.initUI(values);
f.setTitle(entry.getKey());
f.setContentPane(p);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
 
} catch (Exception e) {
ExceptionHandler.handle("Erreur d'impression", e);
}
}
};
wworker.execute();
 
}
}, true, false);
 
action.setPredicate(IListeEvent.createSelectionCountPredicate(1, 1));
ctxt.getElement("ARTICLE").getRowActions().add(action);
}
}
 
}
 
@Override
protected void start() {
 
}
 
private void readTemplates(File templatesDir) {
System.out.println("ModuleLabel.readTemplates() " + templatesDir.getAbsolutePath());
if (templatesDir.exists() && templatesDir.isDirectory()) {
System.err.println("ModuleLabel.readTemplates() " + templatesDir.getAbsolutePath());
File[] files = templatesDir.listFiles();
if (files != null) {
LinkedHashMap<String, String> map = new LinkedHashMap<>();
for (File f : files) {
if (f.getName().endsWith(".zpl")) {
try {
String zpl = FileUtils.read(f, StandardCharsets.UTF_8);
String name = f.getName().substring(0, f.getName().length() - 4).trim();
map.put(name, zpl);
System.err.println("ModuleLabel.readTemplates() add " + name);
} catch (Exception e) {
System.err.println(this.getClass().getCanonicalName() + "start() cannot read zpl template : " + f.getAbsolutePath() + " : " + e.getMessage());
}
}
}
// Tri de la map par clef
final TreeMap<String, String> copy = new TreeMap<>(map);
this.zplTemplates.clear();
this.zplTemplates.putAll(copy);
}
 
} else {
System.err.println("ModuleLabel.readTemplates() " + templatesDir.getAbsolutePath() + " missing");
}
}
 
@Override
protected void stop() {
// nothing
}
}
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/LabelRenderer.java
2,6 → 2,8
 
import java.awt.Graphics;
 
import org.openconcerto.sql.model.SQLRowAccessor;
 
public interface LabelRenderer {
public void paintLabel(Graphics g, Label label, int x, int y, int gridWith, int gridHeight, float fontSize);
public void paintLabel(Graphics g, SQLRowAccessor row, int x, int y, int gridWith, int gridHeight, float fontSize);
}
/trunk/Modules/Module Label/.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.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Time Tracking/src/org/openconcerto/modules/timetracking/Module.java
52,6 → 52,7
import org.openconcerto.utils.PrefType;
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.i18n.TranslationManager;
 
public final class Module extends AbstractModule {
 
85,6 → 86,7
@Override
protected void setupElements(SQLElementDirectory dir) {
super.setupElements(dir);
TranslationManager.getInstance().addTranslationStreamFromClass(this.getClass());
 
GlobalMapper.getInstance().map(ProjectTimeTrackingSQLElement.ELEMENT_CODE + ".default", new ProjectTimeTrackingGroup());
final ProjectTimeTrackingSQLElement element = new ProjectTimeTrackingSQLElement();
117,7 → 119,7
 
private RowAction getSendMailTempsAffaireAction() {
 
final PredicateRowAction action = new PredicateRowAction(new AbstractAction("Envoyer les temps par mail") {
final PredicateRowAction action = new PredicateRowAction(new AbstractAction() {
 
@Override
public void actionPerformed(ActionEvent e) {
185,7 → 187,7
}
 
private RowAction getCreateTempsAffaireAction() {
PredicateRowAction action = new PredicateRowAction(new AbstractAction("Saisir un temps") {
PredicateRowAction action = new PredicateRowAction(new AbstractAction() {
 
@Override
public void actionPerformed(ActionEvent e) {
211,7 → 213,7
}
 
private RowAction getReportingAction() {
final PredicateRowAction action = new PredicateRowAction(new AbstractAction("Reporting") {
final PredicateRowAction action = new PredicateRowAction(new AbstractAction() {
 
@Override
public void actionPerformed(ActionEvent e) {
/trunk/Modules/Module Exchange Rates/src/org/openconcerto/modules/finance/accounting/exchangerates/ExchangeRatesDownloader.java
116,7 → 116,7
}
 
public static String downloadXML() {
final String urlString = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml";
final String urlString = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml";
BufferedInputStream in = null;
ByteArrayOutputStream fout = null;
try {
/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(this.extension, this);
return new ActionListPanel(extension, this);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/meu/actions/ActionItemEditor.java
44,8 → 44,8
 
c.weightx = 1;
 
this.textId = new JTextField();
this.add(this.textId, c);
textId = new JTextField();
this.add(textId, c);
 
//
final List<ComponentDescritor> l = extension.getCreateComponentList();
63,18 → 63,16
c.fill = GridBagConstraints.HORIZONTAL;
this.add(new JLabel("Composant", SwingConstants.RIGHT), c);
c.gridx++;
this.comboComponent = new JComboBox(v);
this.comboComponent.setRenderer(new DefaultListCellRenderer() {
comboComponent = new JComboBox(v);
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(this.comboComponent, c);
this.add(comboComponent, c);
 
c.gridx = 0;
c.gridy++;
83,9 → 81,9
this.add(new JLabel("Table", SwingConstants.RIGHT), c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
this.textTable = new JTextField(30);
this.textTable.setEnabled(false);
this.add(this.textTable, c);
textTable = new JTextField(30);
textTable.setEnabled(false);
this.add(textTable, c);
// Location
c.gridx = 0;
c.gridy++;
94,8 → 92,8
this.add(new JLabel("Emplacement", SwingConstants.RIGHT), c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
this.comboLocation = new JComboBox(new String[] { "Bouton et clic droit", "clic droit uniquement", "bouton uniquement" });
this.add(this.comboLocation, c);
comboLocation = new JComboBox(new String[] { "Bouton et clic droit", "clic droit uniquement", "bouton uniquement" });
this.add(comboLocation, c);
c.gridy++;
c.weighty = 1;
this.add(new JPanel(), c);
102,25 → 100,25
 
initUIFrom(actionDescriptor);
 
this.comboComponent.addActionListener(new ActionListener() {
comboComponent.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final ComponentDescritor componentDescritor = getComponentDescritor(ActionItemEditor.this.comboComponent.getSelectedItem().toString());
final ComponentDescritor componentDescritor = getComponentDescritor(comboComponent.getSelectedItem().toString());
if (componentDescritor != null) {
ActionItemEditor.this.textTable.setText(componentDescritor.getTable());
textTable.setText(componentDescritor.getTable());
actionDescriptor.setComponentId(componentDescritor.getId());
actionDescriptor.setTable(componentDescritor.getTable());
} else {
ActionItemEditor.this.textTable.setText("");
textTable.setText("");
}
}
});
this.comboLocation.addActionListener(new ActionListener() {
comboLocation.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
int index = ActionItemEditor.this.comboLocation.getSelectedIndex();
int index = comboLocation.getSelectedIndex();
if (index == 0) {
actionDescriptor.setLocation(ActionDescriptor.LOCATION_HEADER_POPUP);
} else if (index == 1) {
131,7 → 129,7
 
}
});
this.textId.getDocument().addDocumentListener(new DocumentListener() {
textId.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
147,7 → 145,7
 
@Override
public void changedUpdate(DocumentEvent e) {
actionDescriptor.setId(ActionItemEditor.this.textId.getText());
actionDescriptor.setId(textId.getText());
}
});
 
155,24 → 153,24
 
private void initUIFrom(ActionDescriptor item) {
 
this.textId.setText(item.getId());
textId.setText(item.getId());
final ComponentDescritor componentDescritor = getComponentDescritor(item.getComponentId());
if (componentDescritor != null) {
this.comboComponent.setSelectedItem(componentDescritor);
comboComponent.setSelectedItem(componentDescritor);
}
this.textTable.setText(item.getTable());
textTable.setText(item.getTable());
String loc = item.getLocation();
if (loc.equals(ActionDescriptor.LOCATION_HEADER_POPUP)) {
this.comboLocation.setSelectedIndex(0);
comboLocation.setSelectedIndex(0);
} else if (loc.equals(ActionDescriptor.LOCATION_HEADER)) {
this.comboLocation.setSelectedIndex(2);
comboLocation.setSelectedIndex(2);
} else {
this.comboLocation.setSelectedIndex(1);
comboLocation.setSelectedIndex(1);
}
}
 
private ComponentDescritor getComponentDescritor(String componentId) {
List<ComponentDescritor> l = this.extension.getCreateComponentList();
List<ComponentDescritor> l = 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,18 → 6,9
import org.openconcerto.ui.DefaultListModel;
 
public class AllKnownActionsListModel extends DefaultListModel {
private final Extension extension;
 
public AllKnownActionsListModel(Extension extension) {
final List<ActionDescriptor> l = extension.getActionDescriptors();
public AllKnownActionsListModel(Extension module) {
List<ActionDescriptor> l = module.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/meu/actions/ActionListPanel.java
15,14 → 15,14
 
public class ActionListPanel extends EditableListPanel {
 
private ActionMainPanel actionPanel;
private ActionMainPanel tableTranslationPanel;
private Extension extension;
 
public ActionListPanel(Extension extension, ActionMainPanel actionPanel) {
super(new AllKnownActionsListModel(extension), "Actions", "Ajouter une action", true, true);
public ActionListPanel(Extension extension, ActionMainPanel tableTranslationPanel) {
super(new AllKnownActionsListModel(extension), "Actions", "", true, true);
this.extension = extension;
this.actionPanel = actionPanel;
this.list.setCellRenderer(new DefaultListCellRenderer() {
this.tableTranslationPanel = tableTranslationPanel;
list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
value = ((ActionDescriptor) value).getId();
33,16 → 33,9
 
@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);
49,16 → 42,19
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) {
this.actionPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, this.extension)));
tableTranslationPanel.setRightPanel(new JScrollPane(new ActionItemEditor((ActionDescriptor) item, extension)));
} else {
this.actionPanel.setRightPanel(new JPanel());
tableTranslationPanel.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 = LOCATION_HEADER_POPUP; // header, popup, both
private String table = "";
private String componentId = "";
private String location; // 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 this.id;
return id;
}
 
public void setId(String id) {
23,7 → 23,7
}
 
public String getLocation() {
return this.location;
return location;
}
 
public void setLocation(String location) {
31,7 → 31,7
}
 
public String getTable() {
return this.table;
return table;
}
 
public void setTable(String table) {
39,7 → 39,7
}
 
public String getComponentId() {
return this.componentId;
return componentId;
}
 
public void setComponentId(String componentId) {
46,11 → 46,4
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/table/TableMainPanel.java
14,14 → 14,14
public TableMainPanel(Extension extension) {
this.setLayout(new GridLayout(1, 1));
JTabbedPane tab = new JTabbedPane();
this.component = new TableCreateMainPanel(extension);
tab.addTab("Tables créées par l'extension", this.component);
component = new TableCreateMainPanel(extension);
tab.addTab("Tables créées par l'extension", component);
tab.addTab("Tables modifiées", new TableModifyMainPanel(extension));
this.add(tab);
}
 
public void select(TableDescritor tableDescriptor) {
this.component.select(tableDescriptor);
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(this.extension, field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(extension, field);
p.add(editor, c);
 
c.gridx++;
104,7 → 104,7
p.remove(editor);
p.remove(close);
p.revalidate();
TableModifyPanel.this.extension.setChanged();
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 (this.link != null) {
string += " => " + this.link.toString();
if (link != null) {
string += " => " + link.toString();
}
return string;
}
 
public String getName() {
return this.name;
return name;
}
 
public void setName(String name) {
54,7 → 54,7
}
 
public String getType() {
return this.type;
return type;
}
 
public void setType(String type) {
62,7 → 62,7
}
 
public String getDefaultValue() {
return this.defaultValue;
return defaultValue;
}
 
public void setDefaultValue(String defaultValue) {
70,7 → 70,7
}
 
public String getLength() {
return this.length;
return length;
}
 
public void setLength(String length) {
78,7 → 78,7
}
 
public String getTable() {
return this.table;
return table;
}
 
public void setLink(FieldDescriptor fieldDescriptor) {
86,7 → 86,7
}
 
public FieldDescriptor getLink() {
return this.link;
return link;
}
 
public void setForeignTable(String foreignTable) {
94,7 → 94,7
}
 
public String getForeignTable() {
return this.foreignTable;
return 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.getName())) {
return (getLink() == null && f.getLink() == null) || (getLink() != null && getLink().equals(f.getLink()));
if (getTable().equals(f.getTable()) && getName().equals(f.getTable())) {
return 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);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, new JPanel());
this.add(this.split);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, new JPanel());
this.add(split);
}
 
public void setRightPanel(JComponent p) {
this.invalidate();
this.split.setRightComponent(p);
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);
this.extension.addCreateTable(obj);
extension.addCreateTable(obj);
}
 
@Override
public boolean removeElement(Object obj) {
this.extension.removeCreateTable((TableDescritor) obj);
extension.removeCreateTable((TableDescritor) obj);
return super.removeElement(obj);
}
 
@Override
public void stateChanged(ChangeEvent e) {
this.loadContent(this.extension);
this.loadContent(extension);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/ElementDescriptor.java
10,15 → 10,15
}
 
public String getId() {
return this.id;
return id;
}
 
public String getTableName() {
return this.tableName;
return tableName;
}
 
@Override
public String toString() {
return "ElementDescriptor id: " + this.id + " table: " + this.tableName;
return "ElementDescriptor id: " + id + " table: " + tableName;
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/FieldDescriptorEditor.java
1,22 → 1,16
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;
60,30 → 54,30
this.add(new JLabel("Type"), c);
c.gridx++;
 
this.comboType = new JComboBox(this.types);
this.comboType.setOpaque(false);
this.add(this.comboType, c);
comboType = new JComboBox(types);
comboType.setOpaque(false);
this.add(comboType, c);
c.gridx++;
this.add(new JLabel("Nom"), c);
c.gridx++;
c.weightx = 1;
this.fieldName = new JTextField(10);
this.add(this.fieldName, c);
fieldName = new JTextField(10);
this.add(fieldName, c);
c.weightx = 0;
c.gridx++;
this.labelOption = new JLabel("Longeur max");
this.add(this.labelOption, c);
labelOption = new JLabel("Longeur max");
this.add(labelOption, c);
c.gridx++;
this.textOption = new JTextField(6);
textOption = new JTextField(6);
c.gridx++;
this.add(this.textOption, c);
this.comboOption = new JComboBox();
this.add(textOption, c);
comboOption = new JComboBox();
 
this.add(this.comboOption, c);
this.add(comboOption, c);
 
updateFrom(fd);
this.comboType.addActionListener(this);
this.fieldName.getDocument().addDocumentListener(new DocumentListener() {
comboType.addActionListener(this);
fieldName.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
103,8 → 97,8
 
}
});
this.comboOption.addActionListener(this);
this.textOption.getDocument().addDocumentListener(new DocumentListener() {
comboOption.addActionListener(this);
textOption.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
131,7 → 125,7
if (text.trim().length() > 0) {
this.fd.setName(text);
}
this.extension.setChanged();
extension.setChanged();
 
}
 
142,127 → 136,128
switch (this.comboType.getSelectedIndex()) {
 
case TYPE_STRING:
this.fd.setLength(text);
this.fd.setDefaultValue(null);
this.fd.setForeignTable(null);
this.fd.setLink(null);
fd.setLength(text);
fd.setDefaultValue(null);
fd.setForeignTable(null);
fd.setLink(null);
break;
case TYPE_INTEGER:
this.fd.setLength(null);
fd.setLength(null);
try {
int i = Integer.parseInt(text);
this.fd.setDefaultValue(text);
fd.setDefaultValue(text);
} catch (Exception e) {
this.fd.setDefaultValue("0");
fd.setDefaultValue("0");
}
this.fd.setForeignTable(null);
this.fd.setLink(null);
fd.setForeignTable(null);
fd.setLink(null);
case TYPE_DECIMAL:
this.fd.setLength(null);
fd.setLength(null);
try {
text = text.replace(',', '.');
float i = Float.parseFloat(text);
this.fd.setDefaultValue(text);
fd.setDefaultValue(text);
} catch (Exception e) {
this.fd.setDefaultValue("0");
fd.setDefaultValue("0");
}
this.fd.setForeignTable(null);
this.fd.setLink(null);
fd.setForeignTable(null);
fd.setLink(null);
break;
 
}
this.extension.setChanged();
extension.setChanged();
 
}
}
 
protected void comboOptionModified() {
final int index = this.comboOption.getSelectedIndex();
final int index = comboOption.getSelectedIndex();
 
switch (this.comboType.getSelectedIndex()) {
 
case TYPE_BOOLEAN:
this.fd.setLength(null);
fd.setLength(null);
if (index == 0) {
this.fd.setDefaultValue("true");
fd.setDefaultValue("true");
} else {
this.fd.setDefaultValue("false");
fd.setDefaultValue("false");
}
this.fd.setForeignTable(null);
this.fd.setLink(null);
fd.setForeignTable(null);
fd.setLink(null);
break;
case TYPE_DATE:
case TYPE_TIME:
case TYPE_DATE_TIME:
this.fd.setLength(null);
fd.setLength(null);
if (index == 0) {
this.fd.setDefaultValue(null);
fd.setDefaultValue(null);
} else {
this.fd.setDefaultValue("now");
fd.setDefaultValue("now");
}
this.fd.setForeignTable(null);
this.fd.setLink(null);
fd.setForeignTable(null);
fd.setLink(null);
break;
case TYPE_REF:
this.fd.setLength(null);
this.fd.setDefaultValue(null);
this.fd.setForeignTable(this.comboOption.getSelectedItem().toString());
this.fd.setLink(null);
fd.setLength(null);
fd.setDefaultValue(null);
fd.setDefaultValue("now");
fd.setForeignTable(comboOption.getSelectedItem().toString());
fd.setLink(null);
break;
 
}
this.extension.setChanged();
extension.setChanged();
 
}
 
private void updateFrom(FieldDescriptor fd) {
if (fd.getType().equals("string")) {
this.comboType.setSelectedIndex(TYPE_STRING);
this.labelOption.setText("Longueur max");
this.textOption.setVisible(true);
this.textOption.setText(fd.getLength());
this.comboOption.setVisible(false);
comboType.setSelectedIndex(TYPE_STRING);
labelOption.setText("Longueur max");
textOption.setVisible(true);
textOption.setText(fd.getLength());
comboOption.setVisible(false);
} else if (fd.getType().equals("integer")) {
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);
comboType.setSelectedIndex(TYPE_INTEGER);
labelOption.setText("Valeur par défaut");
textOption.setVisible(true);
textOption.setText(fd.getDefaultValue());
comboOption.setVisible(false);
} else if (fd.getType().equals("decimal")) {
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);
comboType.setSelectedIndex(TYPE_DECIMAL);
labelOption.setText("Valeur par défaut");
textOption.setVisible(true);
textOption.setText(fd.getDefaultValue());
comboOption.setVisible(false);
} else if (fd.getType().equals("boolean")) {
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));
comboType.setSelectedIndex(TYPE_BOOLEAN);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vBoolean));
if (fd.getDefaultValue().equals("true")) {
this.comboOption.setSelectedIndex(0);
comboOption.setSelectedIndex(0);
} else {
this.comboOption.setSelectedIndex(1);
comboOption.setSelectedIndex(1);
}
 
} else if (fd.getType().equals("date")) {
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));
comboType.setSelectedIndex(TYPE_DATE);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vDate));
if (fd.getDefaultValue() == null || !fd.getDefaultValue().equals("now")) {
this.comboOption.setSelectedIndex(0);
comboOption.setSelectedIndex(0);
} else {
this.comboOption.setSelectedIndex(1);
comboOption.setSelectedIndex(1);
}
} else if (fd.getType().equals("time")) {
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));
comboType.setSelectedIndex(TYPE_TIME);
labelOption.setText("Valeur par défaut");
textOption.setVisible(false);
comboOption.setVisible(true);
comboOption.setModel(new DefaultComboBoxModel(vTime));
if (fd.getDefaultValue() == null || !fd.getDefaultValue().equals("now")) {
comboOption.setSelectedIndex(0);
} else {
284,27 → 279,8
labelOption.setText("Table");
textOption.setVisible(false);
comboOption.setVisible(true);
final Vector<String> tables = new Vector<String>();
tables.addAll(Arrays.asList(getTables()));
comboOption.setModel(new DefaultComboBoxModel(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);
this.listTableModified = new JList(dataModel);
this.listTableModified.addListSelectionListener(new ListSelectionListener() {
listTableModified = new JList(dataModel);
listTableModified.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
final TableDescritor tableDesc = (TableDescritor) TableModifyLeftPanel.this.listTableModified.getSelectedValue();
final TableDescritor tableDesc = (TableDescritor) listTableModified.getSelectedValue();
if (tableDesc != null) {
System.out.println("TableModifyLeftPanel.createModifiedTableList.valueChanged():" + tableDesc);
final TableModifyPanel p = new TableModifyPanel(extension.getSQLTable(tableDesc), tableDesc, extension, TableModifyLeftPanel.this);
TableModifyLeftPanel.this.tableModifyMainPanel.setRightPanel(p);
TableModifyLeftPanel.this.listTableAll.clearSelection();
tableModifyMainPanel.setRightPanel(p);
listTableAll.clearSelection();
}
}
 
}
});
final JScrollPane comp2 = new JScrollPane(this.listTableModified);
final JScrollPane comp2 = new JScrollPane(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);
this.listTableAll = new JList(dataModel);
this.listTableAll.addListSelectionListener(new ListSelectionListener() {
listTableAll = new JList(dataModel);
listTableAll.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
final SQLTable table = (SQLTable) TableModifyLeftPanel.this.listTableAll.getSelectedValue();
final SQLTable table = (SQLTable) 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);
TableModifyLeftPanel.this.tableModifyMainPanel.setRightPanel(p);
TableModifyLeftPanel.this.listTableModified.clearSelection();
tableModifyMainPanel.setRightPanel(p);
listTableModified.clearSelection();
}
}
 
}
});
this.listTableAll.setCellRenderer(new SQLTableListCellRenderer());
final JScrollPane comp2 = new JScrollPane(this.listTableAll);
listTableAll.setCellRenderer(new SQLTableListCellRenderer());
final JScrollPane comp2 = new JScrollPane(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 = 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();
TableDescritor tableDesc = extension.getOrCreateTableDescritor(tableName);
final TableModifyPanel p = new TableModifyPanel(extension.getSQLTable(tableDesc), tableDesc, extension, TableModifyLeftPanel.this);
tableModifyMainPanel.setRightPanel(p);
listTableAll.clearSelection();
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(this.extension, field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(extension, field);
p.add(editor, c);
 
c.gridx++;
86,7 → 86,7
p.remove(editor);
p.remove(close);
p.revalidate();
TableCreatePanel.this.extension.setChanged();
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(this.extension, field);
final FieldDescriptorEditor editor = new FieldDescriptorEditor(extension, field);
p.add(editor, c);
 
c.gridx++;
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableCreateMainPanel.java
12,11 → 12,11
}
 
public void select(TableDescritor tableDescriptor) {
((TableListPanel) this.leftComponent).selectItem(tableDescriptor);
((TableListPanel) leftComponent).selectItem(tableDescriptor);
}
 
@Override
public JComponent createLeftComponent() {
return new TableListPanel(this.extension, this);
return new TableListPanel(extension, this);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/table/TableListPanel.java
23,7 → 23,7
 
@Override
public void addNewItem() {
((CreateTableListModel) this.dataModel).addNewTable();
((CreateTableListModel) 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 table", JOptionPane.PLAIN_MESSAGE, null, null, e.getName());
final String s = (String) JOptionPane.showInputDialog(w, "Nouveau nom", "Renommer la liste", 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) this.dataModel).removeElement(item);
this.extension.removeCreateTable((TableDescritor) item);
((CreateTableListModel) dataModel).removeElement(item);
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, this.extension);
this.tableInfoPanel.setRightPanel(new JScrollPane(p));
final TableCreatePanel p = new TableCreatePanel(n, extension);
tableInfoPanel.setRightPanel(new JScrollPane(p));
} else {
this.tableInfoPanel.setRightPanel(new JPanel());
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(this.extension);
addContent(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(this.name) == null) {
final SQLTable table = root.getTable(this.name);
final SQLElement e = new SQLElement("ext." + this.name, "ext." + this.name, table) {
if (conf.getDirectory().getElement(name) == null) {
final SQLTable table = root.getTable(name);
final SQLElement e = new SQLElement("ext." + name, "ext." + name, table) {
 
@Override
protected List<String> getListFields() {
60,7 → 60,6
l.add("NOM");
} else {
ListDescriptor listDesc = null;
l.clear();
for (ListDescriptor listDescriptor : ext.getCreateListList()) {
if (listDescriptor.getMainTable().equals(getTable().getName())) {
listDesc = listDescriptor;
67,7 → 66,6
break;
}
}
if (listDesc != null) {
for (ColumnDescriptor string : listDesc.getColumns()) {
if (!string.getFieldsPaths().contains(".")) {
l.add(string.getFieldsPaths());
75,12 → 73,6
}
}
}
if (l.isEmpty()) {
if (!getTable().getContentFields().isEmpty()) {
l.add(new ArrayList<>(getTable().getContentFields()).get(0).getName());
}
}
}
return l;
}
 
109,7 → 101,7
return new ExtensionGroupSQLComponent(this, cDescriptor.getGroup());
}
}
JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + TableDescritor.this.name);
JOptionPane.showMessageDialog(new JFrame(), "Unable to create default creation component for table " + name);
return null;
}
};
119,7 → 111,7
}
 
public String getName() {
return this.name;
return name;
}
 
public void setName(String name) {
127,22 → 119,22
}
 
public List<FieldDescriptor> getFields() {
return this.fields;
return fields;
}
 
public void add(FieldDescriptor f) {
this.fields.add(f);
fields.add(f);
 
}
 
public void remove(FieldDescriptor field) {
this.fields.remove(field);
fields.remove(field);
 
}
 
@Override
public String toString() {
return this.name;
return name;
}
 
public void sortFields() {
/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(!this.extension.isStarted());
startButton.setEnabled(!extension.isStarted());
final JButton stopButton = new JButton("Arrêter");
panel.add(stopButton);
stopButton.setEnabled(this.extension.isStarted());
stopButton.setEnabled(extension.isStarted());
final JButton saveButton = new JButton("Enregister");
saveButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
ExtensionInfoPanel.this.extension.save();
extension.save();
 
}
});
137,10 → 137,10
 
@Override
public void actionPerformed(ActionEvent e) {
String xml = ExtensionInfoPanel.this.extension.toXML();
String xml = extension.toXML();
System.out.println(xml);
FileDialog fDialog = new FileDialog(new JFrame(), "Export", FileDialog.SAVE);
fDialog.setFile(ExtensionInfoPanel.this.extension.getName() + ".ocext");
fDialog.setFile(extension.getName() + ".ocext");
fDialog.setVisible(true);
String fileName = fDialog.getFile();
if (fileName != null) {
225,17 → 225,17
 
}
// Create extension from XML
ExtensionInfoPanel.this.extension.stop();
extension.stop();
if (!xml.isEmpty()) {
if (!ExtensionInfoPanel.this.extension.isEmpty()) {
if (!extension.isEmpty()) {
int result = JOptionPane.showConfirmDialog(ExtensionInfoPanel.this, "Attention l'extension actuelle sera écrasée.\nContinuer l'importation?");
if (result != JOptionPane.YES_OPTION) {
return;
}
}
ExtensionInfoPanel.this.extension.clearAll();
ExtensionInfoPanel.this.extension.importFromXML(xml);
ExtensionInfoPanel.this.extension.setChanged();
extension.clearAll();
extension.importFromXML(xml);
extension.setChanged();
}
 
}
251,25 → 251,11
public void run() {
final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
try {
ExtensionInfoPanel.this.extension.start(root, false);
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_EMPTY);
extension.start(root, false);
} catch (SQLException e1) {
e1.printStackTrace();
}
});
} catch (SQLException e) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_BLINK);
}
});
ExceptionHandler.handle("Start error", e);
}
}
}).start();
}
});
281,27 → 267,8
new Thread(new Runnable() {
@Override
public void run() {
try {
ExtensionInfoPanel.this.extension.stop();
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_EMPTY);
extension.stop();
}
});
} catch (Exception e) {
SwingUtilities.invokeLater(new Runnable() {
 
@Override
public void run() {
reload.setMode(ReloadPanel.MODE_BLINK);
}
});
ExceptionHandler.handle("Stop error", e);
}
 
}
}).start();
}
});
367,7 → 334,7
// --------- UI
panel.add(new JLabelBold("Interfaces de saisie"), c);
c.gridy++;
List<ComponentDescritor> createComponentList = this.extension.getCreateComponentList();
List<ComponentDescritor> createComponentList = extension.getCreateComponentList();
if (createComponentList.size() > 0) {
String components = "";
for (int i = 0; i < createComponentList.size(); i++) {
396,7 → 363,7
// --------- LIST
panel.add(new JLabelBold("Listes"), c);
c.gridy++;
List<ListDescriptor> createListList = this.extension.getCreateListList();
List<ListDescriptor> createListList = extension.getCreateListList();
if (createListList.size() > 0) {
String components = "";
for (int i = 0; i < createListList.size(); i++) {
424,9 → 391,9
// --------- MENUS
panel.add(new JLabelBold("Menus et actions"), c);
c.gridy++;
final int actionCount = this.extension.getActionDescriptors().size();
final int menuCount = this.extension.getCreateMenuList().size();
final int menuCount2 = this.extension.getRemoveMenuList().size();
final int actionCount = extension.getActionDescriptors().size();
final int menuCount = extension.getCreateMenuList().size();
final int menuCount2 = extension.getRemoveMenuList().size();
if (actionCount > 0) {
if (actionCount > 1)
panel.add(new JLabel(actionCount + " actions"), c);
460,9 → 427,9
panel.add(new JLabelBold("Traductions et renommage de labels"), c);
c.gridy++;
 
int actionTranslationCount = this.extension.getActionTranslations().size();
int menuTranslationCount = this.extension.getMenuTranslations().size();
int fieldTranslationCount = this.extension.getFieldTranslations().size();
int actionTranslationCount = extension.getActionTranslations().size();
int menuTranslationCount = extension.getMenuTranslations().size();
int fieldTranslationCount = extension.getFieldTranslations().size();
if (fieldTranslationCount > 0) {
if (fieldTranslationCount > 1)
panel.add(new JLabel(fieldTranslationCount + " traductions de champs"), c);
537,32 → 504,32
}
 
private void openTableEditor() {
final TableMainPanel contentPane = new TableMainPanel(this.extension);
openEditor(this.frameTableEditor, contentPane, "Tables dans la base de données");
final TableMainPanel contentPane = new TableMainPanel(extension);
openEditor(frameTableEditor, contentPane, "Tables dans la base de données");
 
}
 
private void openListEditor() {
final ListCreateMainPanel contentPane = new ListCreateMainPanel(this.extension);
openEditor(this.frameListEditor, contentPane, "Listes personnalisées");
final ListCreateMainPanel contentPane = new ListCreateMainPanel(extension);
openEditor(frameListEditor, contentPane, "Listes personnalisées");
 
}
 
protected void openComponentEditor() {
final ComponentCreateMainPanel contentPane = new ComponentCreateMainPanel(this.extension);
openEditor(this.frameListEditor, contentPane, "Interfaces personnalisées");
final ComponentCreateMainPanel contentPane = new ComponentCreateMainPanel(extension);
openEditor(frameListEditor, contentPane, "Interfaces personnalisées");
 
}
 
protected void openMenuEditor() {
final MenuMainPanel contentPane = new MenuMainPanel(this.extension);
openEditor(this.frameMenuEditor, contentPane, "Menus et actions");
final MenuMainPanel contentPane = new MenuMainPanel(extension);
openEditor(frameMenuEditor, contentPane, "Menus et actions");
 
}
 
protected void openTranslationEditor() {
final TranslationMainPanel contentPane = new TranslationMainPanel(this.extension);
openEditor(this.frameTranslationEditor, contentPane, "Traductions");
final TranslationMainPanel contentPane = new TranslationMainPanel(extension);
openEditor(frameTranslationEditor, contentPane, "Traductions");
 
}
 
569,7 → 536,7
private void openEditor(JFrame frame, JPanel mainPanel, String title) {
if (frame == null) {
frame = new JFrame();
frame.setTitle(this.extension.getName() + " - " + title);
frame.setTitle(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 (this.mouseOver) {
if (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<>();
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<>();
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>();
 
// Listeners
private List<ChangeListener> listeners = new ArrayList<>();
private List<ChangeListener> listeners = new ArrayList<ChangeListener>();
 
private String name;
private boolean notSaved;
119,24 → 119,24
}
 
public void clearAll() {
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();
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.notSaved = true;
this.autoStart = false;
this.isStarted = false;
notSaved = true;
autoStart = false;
isStarted = false;
 
}
 
145,7 → 145,7
}
 
public boolean isAutoStart() {
return this.autoStart;
return autoStart;
}
 
public void start(DBRoot root, boolean inModuleStart) throws SQLException {
156,13 → 156,14
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;
281,14 → 282,21
}
}, menuDescriptor.getId(), true);
}
} else if (menuDescriptor.getType().equals(MenuDescriptor.GROUP)) {
// TODO
} 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) {
297,7 → 305,7
for (ColumnDescriptor cDesc : listDesc.getColumns()) {
final String fieldspath = cDesc.getFieldsPaths();
final String[] paths = fieldspath.split(",");
final Set<FieldPath> fps = new LinkedHashSet<>();
final Set<FieldPath> fps = new LinkedHashSet<FieldPath>();
for (int i = 0; i < paths.length; i++) {
// LOCAL, id_batiment.id_site.nom
final SQLName name = SQLName.parse(paths[i].trim());
409,13 → 417,13
}
 
private boolean setupDatabase(DBRoot root) throws SQLException {
List<ChangeTable<?>> changesToApply = new ArrayList<>();
List<SQLCreateTable> createToApply = new ArrayList<>();
List<ChangeTable<?>> changesToApply = new ArrayList<ChangeTable<?>>();
List<SQLCreateTable> createToApply = new ArrayList<SQLCreateTable>();
// Create fields and tables if needed
final List<TableDescritor> t = new ArrayList<>();
final List<TableDescritor> t = new ArrayList<TableDescritor>();
t.addAll(this.createTableList);
t.addAll(this.modifyTableList);
Set<String> tableNames = new HashSet<>();
Set<String> tableNames = new HashSet<String>();
for (TableDescritor tDesc : t) {
String tableName = tDesc.getName();
tableNames.add(tableName);
475,6 → 483,7
createTable.addDateAndTimeColumn(fieldName);
} else if (type.equals(FieldDescriptor.TYPE_REF)) {
// created later
mustAdd = false;
}
mustAdd = true;
} else {
511,11 → 520,6
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);
528,7 → 532,6
}
}
}
}
// Create foreign keys
if (!changesToApply.isEmpty()) {
for (String change : ChangeTable.cat(changesToApply)) {
555,7 → 558,7
}
 
public String getName() {
return this.name;
return name;
}
 
@SuppressWarnings("unchecked")
590,7 → 593,7
FieldDescriptor f = createFieldDescriptorFrom(name, field);
tDesc.add(f);
}
if (!tDesc.getFields().isEmpty()) {
if (tDesc.getFields().size() > 0) {
if (type.equals("create")) {
this.createTableList.add(tDesc);
} else if (type.equals("modify")) {
654,7 → 657,7
listDesc.setMainTable(mainTable);
final List<Element> columns = eList.getChildren("column");
for (Element field : columns) {
ColumnDescriptor f = createColumnDescriptorFrom(field);
ColumnDescriptor f = createColumnDescriptorFrom(mainTable, field);
listDesc.add(f);
}
if (listDesc.getColumnCount() > 0) {
753,7 → 756,7
e.printStackTrace();
}
}
this.notSaved = false;
notSaved = false;
 
fireChanged();
}
821,20 → 824,20
rootElement.addContent(eTable);
}
// Translations
final HashSet<String> locales = new HashSet<>();
for (Translation tr : this.tableTranslations) {
final HashSet<String> locales = new HashSet<String>();
for (Translation tr : tableTranslations) {
locales.add(tr.getLocale());
}
for (Translation tr : this.fieldTranslations) {
for (Translation tr : fieldTranslations) {
locales.add(tr.getLocale());
}
for (Translation tr : this.menuTranslations) {
for (Translation tr : menuTranslations) {
locales.add(tr.getLocale());
}
for (Translation tr : this.actionTranslations) {
for (Translation tr : actionTranslations) {
locales.add(tr.getLocale());
}
final List<String> lLocales = new ArrayList<>(locales);
final List<String> lLocales = new ArrayList<String>(locales);
Collections.sort(lLocales);
for (String locale : lLocales) {
final Element eTranslation = new Element("translation");
841,7 → 844,7
eTranslation.setAttribute("locale", locale);
rootElement.addContent(eTranslation);
// Tables
for (TableTranslation tTranslation : this.tableTranslations) {
for (TableTranslation tTranslation : tableTranslations) {
if (tTranslation.getLocale().equals(locale)) {
final Element eTable = new Element("element");
eTable.setAttribute("refid", tTranslation.getTableName());
853,7 → 856,7
if (plural != null && !plural.isEmpty()) {
eTable.setAttribute("plural", plural);
}
for (FieldTranslation fTranslation : this.fieldTranslations) {
for (FieldTranslation fTranslation : fieldTranslations) {
// Fields
if (fTranslation.getLocale().equals(locale) && fTranslation.getTableName().equals(tTranslation.getTableName())) {
final Element eField = new Element("item");
870,7 → 873,7
}
}
// Menus
for (MenuTranslation tMenu : this.menuTranslations) {
for (MenuTranslation tMenu : menuTranslations) {
if (tMenu.getLocale().equals(locale)) {
final Element eMenu = new Element("menu");
eMenu.setAttribute("refid", tMenu.getId());
880,7 → 883,7
}
 
// Actions
for (ActionTranslation tAction : this.actionTranslations) {
for (ActionTranslation tAction : actionTranslations) {
if (tAction.getLocale().equals(locale)) {
final Element eMenu = new Element("action");
eMenu.setAttribute("refid", tAction.getId());
1073,7 → 1076,7
return f;
}
 
private ColumnDescriptor createColumnDescriptorFrom(Element field) {
private ColumnDescriptor createColumnDescriptorFrom(String table, Element field) {
final ColumnDescriptor f = new ColumnDescriptor(field.getAttributeValue("id"));
f.setFieldsPaths(field.getAttributeValue("fields"));
f.setStyle(field.getAttributeValue("style"));
1081,7 → 1084,7
}
 
private void fireChanged() {
for (ChangeListener listener : this.listeners) {
for (ChangeListener listener : listeners) {
listener.stateChanged(new ChangeEvent(this));
}
 
1088,7 → 1091,7
}
 
public List<TableDescritor> getCreateTableList() {
return this.createTableList;
return createTableList;
}
 
public void addCreateTable(TableDescritor value) {
1102,11 → 1105,11
}
 
public List<TableDescritor> getModifyTableList() {
return this.modifyTableList;
return modifyTableList;
}
 
public List<ListDescriptor> getCreateListList() {
return this.createListList;
return createListList;
}
 
public ListDescriptor getCreateListFromId(String id) {
1151,7 → 1154,8
 
public SQLTable getSQLTable(TableDescritor tableDesc) {
try {
return ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(tableDesc.getName());
SQLTable t = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(tableDesc.getName());
return t;
} catch (Exception e) {
return null;
}
1203,8 → 1207,8
}
 
public List<String> getAllKnownTableNames() {
final List<String> l = new ArrayList<>();
final Set<String> s = new HashSet<>();
final List<String> l = new ArrayList<String>();
final Set<String> s = new HashSet<String>();
for (SQLTable t : AllTableListModel.getAllDatabaseTables()) {
s.add(t.getName());
}
1236,7 → 1240,7
}
 
public List<String> getTranslatedFieldOfTable(String tableName) {
final List<String> l = new ArrayList<>();
final List<String> l = new ArrayList<String>();
for (FieldTranslation tr : this.fieldTranslations) {
if (tr.getTableName().equals(tableName)) {
l.add(tr.getFieldName());
1277,7 → 1281,7
}
 
public List<MenuDescriptor> getCreateMenuList() {
return this.createMenuList;
return createMenuList;
}
 
public void addCreateMenu(MenuDescriptor desc) {
1294,7 → 1298,7
}
 
public List<MenuDescriptor> getRemoveMenuList() {
return this.removeMenuList;
return removeMenuList;
}
 
public void addRemoveMenu(MenuDescriptor desc) {
1303,7 → 1307,7
}
 
public List<String> getAllKnownFieldName(String tableName) {
final Set<String> l = new HashSet<>();
final Set<String> l = new HashSet<String>();
// fields created in the extension
 
final List<TableDescritor> desc = getCreateTableList();
1328,11 → 1332,11
}
}
 
return new ArrayList<>(l);
return new ArrayList<String>(l);
}
 
public List<String> getAllKnownActionNames() {
final Set<String> s = new HashSet<>();
ArrayList<String> s = new ArrayList<String>();
Collection<SQLElement> elements = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElements();
for (SQLElement element : elements) {
Collection<IListeAction> actions = element.getRowActions();
1345,13 → 1349,12
}
}
}
final List<String> list = new ArrayList<>(s);
Collections.sort(list);
return list;
Collections.sort(s);
return s;
}
 
public List<String> getActionNames() {
ArrayList<String> s = new ArrayList<>();
ArrayList<String> s = new ArrayList<String>();
for (ActionDescriptor action : this.createActionList) {
s.add(action.getId());
}
1370,20 → 1373,9
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 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();
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();
}
 
public String getTableNameForElementId(String id) {
1405,24 → 1397,15
}
 
public List<MenuTranslation> getMenuTranslations() {
return this.menuTranslations;
return 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 this.actionTranslations;
return actionTranslations;
}
 
public List<FieldTranslation> getFieldTranslations() {
return this.fieldTranslations;
return fieldTranslations;
}
 
public void removeChangeListener(ChangeListener listener) {
1446,10 → 1429,10
}
 
public void removeRemoveMenuForId(String id) {
for (int i = this.removeMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = this.removeMenuList.get(i);
for (int i = removeMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = removeMenuList.get(i);
if (m.getId().equals(id)) {
this.removeMenuList.remove(i);
removeMenuList.remove(i);
}
}
 
1456,10 → 1439,10
}
 
public void removeCreateMenuForId(String id) {
for (int i = this.createMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = this.createMenuList.get(i);
for (int i = createMenuList.size() - 1; i >= 0; i--) {
final MenuDescriptor m = createMenuList.get(i);
if (m.getId().equals(id)) {
this.createMenuList.remove(i);
createMenuList.remove(i);
}
}
 
1466,7 → 1449,7
}
 
public MenuDescriptor getRemoveMenuItemFromId(String itemId) {
for (MenuDescriptor m : this.removeMenuList) {
for (MenuDescriptor m : removeMenuList) {
if (m.getId().equals(itemId)) {
return m;
}
1476,9 → 1459,9
 
public void renameMenuItem(String previousId, String newId) {
if (!previousId.equals(newId)) {
final List<MenuDescriptor> descs = new ArrayList<>(this.createMenuList.size() + this.removeMenuList.size());
descs.addAll(this.createMenuList);
descs.addAll(this.removeMenuList);
final List<MenuDescriptor> descs = new ArrayList<MenuDescriptor>(createMenuList.size() + removeMenuList.size());
descs.addAll(createMenuList);
descs.addAll(removeMenuList);
for (MenuDescriptor m : descs) {
if (m.getId().equals(previousId)) {
m.setId(newId);
1490,7 → 1473,7
}
 
public void moveMenuItem(String itemId, String parentId) {
for (MenuDescriptor m : this.createMenuList) {
for (MenuDescriptor m : createMenuList) {
if (m.getId().equals(itemId)) {
m.setInsertInMenu(parentId);
}
1557,5 → 1540,4
fTranslation.setLabel(text);
 
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/LocaleSelector.java
36,10 → 36,10
}
 
Collections.sort(langs);
this.comboLang = new JComboBox(langs);
this.add(this.comboLang);
this.comboCountry = new JComboBox();
this.add(this.comboCountry);
comboLang = new JComboBox(langs);
this.add(comboLang);
comboCountry = new JComboBox();
this.add(comboCountry);
 
try {
this.setLocale(Locale.getDefault());
46,36 → 46,36
} catch (Exception e) {
System.err.println("LocaleSelector warning: unable to set current language");
}
this.comboLang.addActionListener(new ActionListener() {
comboLang.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
if (LocaleSelector.this.interactive) {
LocaleSelector.this.lang = LocaleSelector.this.comboLang.getSelectedItem().toString();
if (interactive) {
lang = comboLang.getSelectedItem().toString();
updateCountryFromLang();
LocaleSelector.this.country = LocaleSelector.this.comboCountry.getSelectedItem().toString();
country = comboCountry.getSelectedItem().toString();
fireActionPerformed();
}
}
 
});
this.comboCountry.addActionListener(new ActionListener() {
comboCountry.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
if (LocaleSelector.this.interactive) {
LocaleSelector.this.country = LocaleSelector.this.comboCountry.getSelectedItem().toString();
if (interactive) {
country = comboCountry.getSelectedItem().toString();
fireActionPerformed();
}
}
 
});
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));
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));
}
 
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(this.lang)) {
if (lo.getLanguage().equals(lang)) {
countries.add(lo.getCountry());
}
}
92,16 → 92,16
if (countries.isEmpty()) {
countries.add("");
}
this.comboCountry.setModel(new DefaultComboBoxModel(countries));
comboCountry.setModel(new DefaultComboBoxModel(countries));
}
 
public Locale getLocale() {
Locale[] l = Locale.getAvailableLocales();
if (this.country != null) {
if (country != null) {
 
for (int i = 0; i < l.length; i++) {
Locale lo = (Locale) l[i];
if (lo.getLanguage().equals(this.lang) && lo.getCountry().equals(this.country)) {
if (lo.getLanguage().equals(lang) && lo.getCountry().equals(country)) {
return lo;
}
}
108,7 → 108,7
}
for (int i = 0; i < l.length; i++) {
Locale lo = (Locale) l[i];
if (lo.getLanguage().equals(this.lang)) {
if (lo.getLanguage().equals(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(this.lang);
this.comboLang.setSelectedItem(lang);
updateCountryFromLang();
this.comboCountry.setSelectedItem(this.country);
this.comboCountry.setSelectedItem(country);
this.interactive = true;
}
 
/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) {
this.tableTranslationPanel.setRightPanel(new JScrollPane(new TableTranslationEditorPanel(this.extension, (String) item)));
tableTranslationPanel.setRightPanel(new JScrollPane(new TableTranslationEditorPanel(extension, (String) item)));
} else {
this.tableTranslationPanel.setRightPanel(new JPanel());
tableTranslationPanel.setRightPanel(new JPanel());
}
 
}
/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);
this.hideableComponents.add(sep);
hideableComponents.add(sep);
c.gridheight = 1;
c.weightx = 1;
c.gridx++;
c.fill = GridBagConstraints.NONE;
final LocaleSelector comboLang2 = new LocaleSelector();
this.hideableComponents.add(comboLang2);
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(this.textSingular1, c);
this.add(textSingular1, c);
c.gridx += 2;
this.hideableComponents.add(this.textSingular2);
this.add(this.textSingular2, c);
hideableComponents.add(textSingular2);
this.add(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(this.textPlural1, c);
this.add(textPlural1, c);
c.gridx += 2;
this.hideableComponents.add(this.textPlural2);
this.add(this.textPlural2, c);
hideableComponents.add(textPlural2);
this.add(textPlural2, c);
 
// Fields
c.gridx = 0;
111,7 → 111,7
c.gridx = 2;
c.fill = GridBagConstraints.BOTH;
final JSeparator sep2 = new JSeparator(JSeparator.VERTICAL);
this.hideableComponents.add(sep2);
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();
this.map1.put(fName, t1);
this.fieldsMap.put(t1, fName);
map1.put(fName, t1);
fieldsMap.put(t1, fName);
this.add(t1, c);
c.gridx += 2;
final JTextField t2 = new JTextField();
this.hideableComponents.add(t2);
this.fieldsMap.put(t2, fName);
this.map2.put(fName, t2);
hideableComponents.add(t2);
fieldsMap.put(t2, fName);
map2.put(fName, t2);
this.add(t2, c);
c.gridy++;
}
189,22 → 189,22
}
 
});
for (final JTextField textField : this.map1.values()) {
for (final JTextField textField : map1.values()) {
textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setFieldTranslation(tableName, TableTranslationEditorPanel.this.fieldsMap.get(textField), comboLang1.getLocale(), text);
extension.setFieldTranslation(tableName, fieldsMap.get(textField), comboLang1.getLocale(), text);
}
 
});
}
for (final JTextField textField : this.map2.values()) {
for (final JTextField textField : map2.values()) {
textField.getDocument().addDocumentListener(new SimpleDocumentListener() {
 
@Override
public void changedUpdate(DocumentEvent e, String text) {
extension.setFieldTranslation(tableName, TableTranslationEditorPanel.this.fieldsMap.get(textField), comboLang2.getLocale(), text);
extension.setFieldTranslation(tableName, 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, this.textSingular1, this.textPlural1, this.map1);
updateUI(extension, tableName, lang, textSingular1, textPlural1, map1);
}
if (l2 != null) {
final String lang = l2.toString();
updateUI(extension, tableName, lang, this.textSingular2, this.textPlural2, this.map2);
updateUI(extension, tableName, lang, textSingular2, textPlural2, map2);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/field/FieldTranslation.java
21,19 → 21,19
}
 
public String getTableName() {
return this.tableName;
return tableName;
}
 
public String getFieldName() {
return this.fieldName;
return fieldName;
}
 
public String getLabel() {
return this.label;
return label;
}
 
public String getDocumentation() {
return this.documentation;
return 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 this.tableName;
return tableName;
}
 
public void setSingular(String singular) {
22,7 → 22,7
}
 
public String getSingular() {
return this.singular;
return singular;
}
 
public void setPlural(String plural) {
30,6 → 30,6
}
 
public String getPlural() {
return this.plural;
return 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);
this.split.setDividerLocation(250);
split.setDividerLocation(250);
}
 
public void setRightPanel(JComponent p) {
super.setRightPanel(p);
this.split.setDividerLocation(250);
split.setDividerLocation(250);
}
 
@Override
public JComponent createLeftComponent() {
return new AllTableListPanel(this.extension, this);
return new AllTableListPanel(extension, this);
}
 
public void select(TableDescritor tableDescriptor) {
((AllTableListPanel) this.leftComponent).selectItem(tableDescriptor);
((AllTableListPanel) leftComponent).selectItem(tableDescriptor);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/menu/MenuTranslation.java
13,7 → 13,7
}
 
public String getId() {
return this.id;
return 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() {
this.newModel.fillFromDescriptor(this.extension);
this.tree.setModel(this.newModel);
this.tree.expandRow(0);
newModel.fillFromDescriptor(extension);
tree.setModel(newModel);
tree.expandRow(0);
}
 
@Override
54,8 → 54,8
c.insets = new Insets(2, 2, 2, 0);
 
panel.add(new JLabel("Menus"), c);
this.newModel = new MenuItemTreeModel();
this.tree = new JTree() {
newModel = new MenuItemTreeModel();
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();
}
};
this.tree.setModel(this.newModel);
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
this.tree.expandRow(0);
tree.setModel(newModel);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
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,16 → 85,13
if (tr.getUserObject() instanceof Item) {
r.setText(((Item) tr.getUserObject()).getId());
}
if (sel) {
r.setForeground(Color.WHITE);
}
return r;
}
};
 
treeRenderer.setLeafIcon(null);
this.tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(this.tree);
tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(tree);
comp2.setMinimumSize(new Dimension(250, 150));
comp2.setPreferredSize(new Dimension(250, 150));
c.weighty = 1;
104,16 → 101,16
 
// init
 
this.tree.addMouseListener(new MouseAdapter() {
tree.addMouseListener(new MouseAdapter() {
 
@Override
public void mousePressed(MouseEvent e) {
final TreePath selectionPath = MenuTranslationPanel.this.tree.getSelectionPath();
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath == null) {
setRightPanel(new JPanel());
} else {
Item i = (Item) ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject();
setRightPanel(new MenuTranslationItemEditor(i, MenuTranslationPanel.this.extension));
setRightPanel(new MenuTranslationItemEditor(i, extension));
}
}
});
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/translation/menu/MenuTranslationItemEditor.java
2,8 → 2,6
 
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;
26,8 → 24,6
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;
41,8 → 37,8
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.gridwidth = 3;
this.textId = new JTextField();
this.add(this.textId, c);
textId = new JTextField();
this.add(textId, c);
 
// Language selector
c.gridx = 0;
54,7 → 50,7
final String[] isoLanguages = Locale.getISOLanguages();
System.out.println(isoLanguages.length);
 
comboLang1 = new LocaleSelector();
final LocaleSelector comboLang1 = new LocaleSelector();
 
c.weightx = 1;
c.gridx++;
71,7 → 67,7
c.weightx = 1;
c.gridx++;
c.fill = GridBagConstraints.NONE;
comboLang2 = new LocaleSelector();
final LocaleSelector comboLang2 = new LocaleSelector();
 
comboLang2.setLocale(Locale.ENGLISH);
this.add(comboLang2, c);
88,16 → 84,16
 
c.weightx = 1;
 
this.textTranslation1 = new JTextField(20);
textTranslation1 = new JTextField(20);
 
this.add(this.textTranslation1, c);
this.add(textTranslation1, c);
 
c.gridx += 2;
c.fill = GridBagConstraints.HORIZONTAL;
 
c.weightx = 1;
this.textTranslation2 = new JTextField(20);
this.add(this.textTranslation2, c);
textTranslation2 = new JTextField(20);
this.add(textTranslation2, c);
 
c.gridy++;
c.weighty = 1;
105,7 → 101,7
 
initUIFrom(item);
 
this.textTranslation1.getDocument().addDocumentListener(new DocumentListener() {
textTranslation1.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
120,11 → 116,11
 
@Override
public void changedUpdate(DocumentEvent e) {
extension.setMenuTranslation(item.getId(), MenuTranslationItemEditor.this.textTranslation1.getText(), comboLang1.getLocale());
extension.setMenuTranslation(item.getId(), textTranslation1.getText(), comboLang1.getLocale());
extension.setChanged();
}
});
this.textTranslation2.getDocument().addDocumentListener(new DocumentListener() {
textTranslation2.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
139,56 → 135,21
 
@Override
public void changedUpdate(DocumentEvent e) {
extension.setMenuTranslation(item.getId(), MenuTranslationItemEditor.this.textTranslation2.getText(), comboLang2.getLocale());
extension.setMenuTranslation(item.getId(), 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);
this.textId.setEnabled(false);
if (this.textId != null) {
this.textId.setText(item.getId());
textId.setEnabled(false);
if (textId != null) {
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/action/ActionListPanel.java
36,9 → 36,9
@Override
public void itemSelected(Object item) {
if (item != null) {
this.tableTranslationPanel.setRightPanel(new JScrollPane(new MenuTranslationItemEditor(new Item(item.toString()), this.extension)));
tableTranslationPanel.setRightPanel(new JScrollPane(new MenuTranslationItemEditor(new Item(item.toString()), extension)));
} else {
this.tableTranslationPanel.setRightPanel(new JPanel());
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 this.id;
return id;
}
 
public String getLabel() {
return this.label;
return 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(this.extension, this);
return new ActionListPanel(extension, this);
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/GroupTreeModel.java
19,7 → 19,7
}
 
public void setShowAll(boolean b) {
if (b != this.showAll) {
if (b != 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 (this.showAll || newChild.isActive()) {
if (showAll || newChild.isActive()) {
node.add(newChild);
}
if (item instanceof Group) {
102,7 → 102,7
this.componentDescriptor.removeGroup(item);
}
reload(n);
this.componentDescriptor.fireGroupChanged();
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);
this.componentDescriptor.fireGroupChanged();
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) this.dataModel).addComponentList();
((CreateComponentListModel) dataModel).addComponentList();
}
 
@Override
39,8 → 39,8
 
@Override
public void removeItem(Object item) {
((CreateComponentListModel) this.dataModel).removeElement(item);
this.extension.removeCreateComponent((ComponentDescritor) item);
((CreateComponentListModel) dataModel).removeElement(item);
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, this.extension);
this.tableInfoPanel.setRightPanel(p);
final ComponentCreatePanel p = new ComponentCreatePanel(n, extension);
tableInfoPanel.setRightPanel(p);
} else {
this.tableInfoPanel.setRightPanel(new JPanel());
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 this.table;
return 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(this.extension);
addContent(extension);
}
 
public void addComponentList() {
final ComponentDescritor l = new ComponentDescritor("Interface de saisie " + (this.getSize() + 1));
this.addElement(l);
this.extension.addCreateComponent(l);
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);
this.newModel = new ItemTreeModel();
this.tree = new ReorderableJTree() {
newModel = new ItemTreeModel();
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();
}
};
this.tree.setModel(this.newModel);
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
this.tree.expandRow(0);
tree.setModel(newModel);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
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);
this.tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(this.tree);
tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(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) {
GroupEditor.this.newModel.toggleActive(GroupEditor.this.tree.getSelectionPath());
newModel.toggleActive(tree.getSelectionPath());
}
});
 
147,36 → 147,36
 
@Override
public void actionPerformed(ActionEvent e) {
GroupEditor.this.newModel.setShowAll(hideCheckbox.isSelected());
setMainTable(GroupEditor.this.n.getTable());
newModel.setShowAll(hideCheckbox.isSelected());
setMainTable(n.getTable());
setRightPanel(new JPanel());
}
});
 
this.tree.addTreeSelectionListener(new TreeSelectionListener() {
tree.addTreeSelectionListener(new TreeSelectionListener() {
 
@Override
public void valueChanged(TreeSelectionEvent e) {
final Object selectedValue = GroupEditor.this.tree.getSelectionPath();
final Object selectedValue = tree.getSelectionPath();
showHideButton.setEnabled((selectedValue != null));
}
});
this.tree.addMouseListener(new MouseAdapter() {
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
GroupEditor.this.newModel.toggleActive(GroupEditor.this.tree.getSelectionPath());
newModel.toggleActive(tree.getSelectionPath());
}
}
 
@Override
public void mousePressed(MouseEvent e) {
final TreePath selectionPath = GroupEditor.this.tree.getSelectionPath();
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath == null) {
setRightPanel(new JPanel());
} else {
Item i = (Item) ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject();
setRightPanel(new ItemEditor(i, GroupEditor.this.n));
setRightPanel(new ItemEditor(i, n));
}
}
});
184,31 → 184,31
}
 
protected void addNewGroup() {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (this.tree.getModel().getRoot())).getFirstChild();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
DefaultMutableTreeNode node = root;
if (node.getChildCount() > 0) {
node = (DefaultMutableTreeNode) node.getFirstChild();
}
if (this.tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
if (tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) 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));
this.newModel.reload();
this.tree.setSelectionPath(new TreePath(this.newModel.getPathToRoot(newNode)));
newModel.reload();
tree.setSelectionPath(new TreePath(newModel.getPathToRoot(newNode)));
}
 
}
 
public void setMainTable(String table) {
this.n.setTable(table);
n.setTable(table);
 
initGroupFromTable(this.extension.getAllKnownFieldName(table));
this.newModel.fillFromGroup(this.n, this.tableGroup);
initGroupFromTable(extension.getAllKnownFieldName(table));
newModel.fillFromGroup(n, this.tableGroup);
 
this.tree.expandRow(0);
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(this.n.getId());
this.tableGroup = new Group(n.getId());
for (String field : fields) {
Item i = this.n.getItemFromId(field);
Item i = 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(this.n.getId());
if (this.n.getTable() == null) {
throw new IllegalStateException("Not table defined for " + this.n);
Group filteredGroup = new Group(n.getId());
if (n.getTable() == null) {
throw new IllegalStateException("Not table defined for " + n);
}
walk(this.newModel, filteredGroup, this.newModel.getRoot());
walk(newModel, filteredGroup, 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(this.n.getTable());
final SQLTable table = ComptaPropsConfiguration.getInstanceCompta().getRootSociete().getTable(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;
this.textId = new JTextField(30);
this.add(this.textId, c);
textId = new JTextField(30);
this.add(textId, c);
c.gridy++;
} else {
// Label du champs
77,8 → 77,8
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
this.comboType = new JComboBox(new String[] { "normal", "large", "très large" });
this.add(this.comboType, c);
comboType = new JComboBox(new String[] { "normal", "large", "très large" });
this.add(comboType, c);
c.gridy++;
}
c.gridx = 0;
92,9 → 92,9
this.add(labelSep, c);
c.gridx++;
c.fill = GridBagConstraints.NONE;
this.checkSeparated = new JCheckBox();
checkSeparated = new JCheckBox();
c.weightx = 1;
this.add(this.checkSeparated, c);
this.add(checkSeparated, c);
c.gridx = 0;
c.gridy++;
if (!this.isEditingGroup) {
104,9 → 104,9
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
this.checkLabel = new JCheckBox();
checkLabel = new JCheckBox();
 
this.add(this.checkLabel, c);
this.add(checkLabel, c);
 
c.gridy++;
 
117,8 → 117,8
c.gridx++;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
this.checkFillH = new JCheckBox();
this.add(this.checkFillH, c);
checkFillH = new JCheckBox();
this.add(checkFillH, c);
c.gridy++;
}
 
129,8 → 129,8
initUIFrom(item);
 
// Listeners
if (this.isEditingGroup) {
this.textId.getDocument().addDocumentListener(new DocumentListener() {
if (isEditingGroup) {
textId.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
146,44 → 146,44
 
@Override
public void changedUpdate(DocumentEvent e) {
item.setId(ItemEditor.this.textId.getText());
item.setId(textId.getText());
component.fireGroupChanged();
 
}
});
}
this.checkSeparated.addActionListener(new ActionListener() {
checkSeparated.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
item.setLocalHint(item.getLocalHint().getBuilder().setSeparated(ItemEditor.this.checkSeparated.isSelected()).build());
item.setLocalHint(item.getLocalHint().getBuilder().setSeparated(checkSeparated.isSelected()).build());
component.fireGroupChanged();
}
});
 
if (!this.isEditingGroup) {
this.checkLabel.addActionListener(new ActionListener() {
if (!isEditingGroup) {
checkLabel.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
item.setLocalHint(item.getLocalHint().getBuilder().setShowLabel(ItemEditor.this.checkLabel.isSelected()).build());
item.setLocalHint(item.getLocalHint().getBuilder().setShowLabel(checkLabel.isSelected()).build());
component.fireGroupChanged();
}
});
this.checkFillH.addActionListener(new ActionListener() {
checkFillH.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
item.setLocalHint(item.getLocalHint().getBuilder().setFillHeight(ItemEditor.this.checkFillH.isSelected()).build());
item.setLocalHint(item.getLocalHint().getBuilder().setFillHeight(checkFillH.isSelected()).build());
component.fireGroupChanged();
}
});
 
this.comboType.addActionListener(new ActionListener() {
comboType.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
int i = ItemEditor.this.comboType.getSelectedIndex();
int i = comboType.getSelectedIndex();
final LayoutHintsBuilder h = item.getLocalHint().getBuilder();
if (i == 0) {
h.setFillWidth(false);
208,20 → 208,20
 
final LayoutHints localHint = item.getLocalHint();
 
this.checkSeparated.setSelected(localHint.isSeparated());
checkSeparated.setSelected(localHint.isSeparated());
 
if (!this.isEditingGroup) {
if (!isEditingGroup) {
if (localHint.fillWidth() && localHint.largeWidth()) {
this.comboType.setSelectedIndex(2);
comboType.setSelectedIndex(2);
} else if (localHint.fillWidth()) {
this.comboType.setSelectedIndex(1);
comboType.setSelectedIndex(1);
} else {
this.comboType.setSelectedIndex(0);
comboType.setSelectedIndex(0);
}
this.checkFillH.setSelected(localHint.fillHeight());
this.checkLabel.setSelected(localHint.showLabel());
checkFillH.setSelected(localHint.fillHeight());
checkLabel.setSelected(localHint.showLabel());
} else {
this.textId.setText(item.getId());
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;
 
this.panel = new GroupEditor(n, extension);
panel = new GroupEditor(n, extension);
final String mainTable = n.getTable();
if (mainTable == null && comboTable.getModel().getSize() > 0) {
comboTable.setSelectedIndex(0);
this.panel.setMainTable((String) comboTable.getModel().getElementAt(0));
panel.setMainTable((String) comboTable.getModel().getElementAt(0));
} else {
comboTable.setSelectedItem(mainTable);
this.panel.setMainTable(mainTable);
panel.setMainTable(mainTable);
}
this.add(this.panel, c);
this.add(panel, c);
 
final JButton previewButton = new JButton("Prévisualiser");
c.gridy++;
82,7 → 82,7
 
@Override
public void actionPerformed(ActionEvent e) {
ComponentCreatePanel.this.panel.setMainTable((String) comboTable.getSelectedItem());
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 = ComponentCreatePanel.this.panel.getFilteredGroup();
final Group group = 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);
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());
oldGroup = group;
if (previewFrame == null || !previewFrame.isVisible()) {
previewFrame = new JFrame();
previewFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
previewFrame.setTitle("Preview: " + group.getId());
}
final EditPanel panel = new EditPanel(gComponent, EditMode.CREATION);
ComponentCreatePanel.this.previewFrame.setContentPane(panel);
ComponentCreatePanel.this.previewFrame.pack();
if (!ComponentCreatePanel.this.previewFrame.isVisible()) {
FrameUtil.show(ComponentCreatePanel.this.previewFrame);
previewFrame.setContentPane(panel);
previewFrame.pack();
if (!previewFrame.isVisible()) {
FrameUtil.show(previewFrame);
}
 
};
123,15 → 123,15
 
@Override
public void stateChanged(ChangeEvent e) {
if (ComponentCreatePanel.this.previewFrame == null || !ComponentCreatePanel.this.previewFrame.isVisible()) {
if (previewFrame == null || !previewFrame.isVisible()) {
return;
}
final Group group = ComponentCreatePanel.this.panel.getFilteredGroup();
if (group.equalsDesc(ComponentCreatePanel.this.oldGroup)) {
final Group group = panel.getFilteredGroup();
if (group.equalsDesc(oldGroup)) {
// Avoid refresh when group doesn't change
return;
}
ComponentCreatePanel.this.oldGroup = group;
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);
ComponentCreatePanel.this.previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
ComponentCreatePanel.this.previewFrame.pack();
if (!ComponentCreatePanel.this.previewFrame.isVisible()) {
FrameUtil.show(ComponentCreatePanel.this.previewFrame);
previewFrame.setContentPane(new EditPanel(gComponent, EditMode.CREATION));
previewFrame.pack();
if (!previewFrame.isVisible()) {
FrameUtil.show(previewFrame);
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ActivableMutableTreeNode.java
14,7 → 14,7
}
 
public boolean isActive() {
return this.active;
return active;
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/component/ComponentCreateMainPanel.java
9,12 → 9,12
 
public ComponentCreateMainPanel(Extension extension) {
super(extension);
this.split.setDividerLocation(0.5D);
split.setDividerLocation(0.5D);
}
 
@Override
public JComponent createLeftComponent() {
return new ComponentListPanel(this.extension, this);
return new ComponentListPanel(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 this.id;
return id;
}
 
public void setId(String id) {
31,7 → 31,7
}
 
public Group getGroup() {
return this.group;
return group;
}
 
@Override
40,7 → 40,7
}
 
public boolean containsGroupId(String gId) {
return containsGroup(this.group, gId);
return containsGroup(group, gId);
}
 
private boolean containsGroup(Item item, String gId) {
61,7 → 61,7
}
 
public Item getItemFromId(String id) {
return getItemFromId(this.group, id);
return getItemFromId(group, id);
}
 
private Item getItemFromId(Item item, String gId) {
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/MenuCreateMainPanel.java
9,12 → 9,12
 
public MenuCreateMainPanel(Extension extension) {
super(extension);
this.split.setDividerLocation(0.5D);
split.setDividerLocation(0.5D);
}
 
@Override
public JComponent createLeftComponent() {
return new MenuListPanel(this.extension, this);
return new MenuListPanel(extension, this);
}
 
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/MenuMainPanel.java
7,6 → 7,7
 
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;
14,10 → 15,9
public MenuMainPanel(Extension extension) {
this.setLayout(new GridLayout(1, 1));
JTabbedPane tab = new JTabbedPane();
this.mainMenuPanel = new MainMenuPanel(extension);
tab.addTab("Menu principal", this.mainMenuPanel);
// TODO : terminer la gestion des actions
// tab.addTab("Actions contextuelles", new ActionMainPanel(extension));
mainMenuPanel = new MainMenuPanel(extension);
tab.addTab("Menu principal", mainMenuPanel);
tab.addTab("Actions contextuelles", new ActionMainPanel(extension));
this.add(tab);
}
 
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/menu/mainmenu/MainMenuGroupEditor.java
49,20 → 49,20
}
 
public void fillModel() {
this.newModel.fillFromDescriptor(this.extension);
this.tree.setModel(this.newModel);
newModel.fillFromDescriptor(extension);
tree.setModel(newModel);
expand();
 
}
 
private void expand() {
this.tree.expandRow(0);
tree.expandRow(0);
 
final List<MenuDescriptor> m = new ArrayList<MenuDescriptor>();
m.addAll(this.extension.getCreateMenuList());
m.addAll(this.extension.getRemoveMenuList());
m.addAll(extension.getCreateMenuList());
m.addAll(extension.getRemoveMenuList());
for (MenuDescriptor menuDescriptor : m) {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) this.tree.getModel().getRoot();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) 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());
this.tree.expandPath(path);
tree.expandPath(path);
}
}
}
92,11 → 92,11
c.insets = new Insets(2, 2, 2, 0);
 
panel.add(new JLabel("Menus"), c);
this.newModel = new MenuItemTreeModel();
this.tree = new ReorderableJTree();
this.tree.setModel(this.newModel);
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
newModel = new MenuItemTreeModel();
tree = new ReorderableJTree();
tree.setModel(newModel);
tree.setRootVisible(false);
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 (MainMenuGroupEditor.this.extension.getCreateMenuItemFromId(id) != null) {
if (extension.getCreateMenuItemFromId(id) != null) {
r.setForeground(new Color(50, 80, 150));
}
}
116,16 → 116,13
if (!tr.isActive()) {
r.setForeground(Color.LIGHT_GRAY);
}
if (sel) {
r.setForeground(Color.WHITE);
}
return r;
}
};
 
treeRenderer.setLeafIcon(null);
this.tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(this.tree);
tree.setCellRenderer(treeRenderer);
final JScrollPane comp2 = new JScrollPane(tree);
comp2.setMinimumSize(new Dimension(250, 150));
comp2.setPreferredSize(new Dimension(250, 150));
c.weighty = 1;
173,13 → 170,13
removeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final TreePath selectionPath = MainMenuGroupEditor.this.tree.getSelectionPath();
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
if (node.getUserObject() != null) {
String idToDelete = ((Item) node.getUserObject()).getId();
MainMenuGroupEditor.this.extension.removeCreateMenuForId(idToDelete);
MainMenuGroupEditor.this.extension.setChanged();
extension.removeCreateMenuForId(idToDelete);
extension.setChanged();
fillModel();
}
 
190,21 → 187,21
 
@Override
public void actionPerformed(ActionEvent e) {
MainMenuGroupEditor.this.newModel.setShowAll(hideCheckbox.isSelected());
MainMenuGroupEditor.this.newModel.fillFromDescriptor(MainMenuGroupEditor.this.extension);
newModel.setShowAll(hideCheckbox.isSelected());
newModel.fillFromDescriptor(extension);
}
 
});
this.tree.addTreeSelectionListener(new TreeSelectionListener() {
tree.addTreeSelectionListener(new TreeSelectionListener() {
 
@Override
public void valueChanged(TreeSelectionEvent e) {
final TreePath selectionPath = MainMenuGroupEditor.this.tree.getSelectionPath();
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
if (node.getUserObject() != null) {
String selectedId = ((Item) node.getUserObject()).getId();
removeButton.setEnabled(MainMenuGroupEditor.this.extension.getCreateMenuItemFromId(selectedId) != null);
removeButton.setEnabled(extension.getCreateMenuItemFromId(selectedId) != null);
}
} else {
removeButton.setEnabled(false);
212,26 → 209,26
 
}
});
this.tree.addMouseListener(new MouseAdapter() {
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
MainMenuGroupEditor.this.newModel.toggleActive(MainMenuGroupEditor.this.tree.getSelectionPath());
newModel.toggleActive(tree.getSelectionPath());
}
}
 
@Override
public void mousePressed(MouseEvent e) {
final TreePath selectionPath = MainMenuGroupEditor.this.tree.getSelectionPath();
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath == null) {
setRightPanel(new JPanel());
} else {
Item i = (Item) ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject();
setRightPanel(new MenuItemEditor(MainMenuGroupEditor.this.newModel, i, MainMenuGroupEditor.this.extension));
setRightPanel(new MenuItemEditor(newModel, i, extension));
}
}
});
this.tree.getModel().addTreeModelListener(new TreeModelListener() {
tree.getModel().addTreeModelListener(new TreeModelListener() {
 
@Override
public void treeStructureChanged(TreeModelEvent e) {
260,13 → 257,13
}
 
protected void addNewGroup() {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (this.tree.getModel().getRoot())).getFirstChild();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
DefaultMutableTreeNode node = root;
if (node.getChildCount() > 0) {
node = (DefaultMutableTreeNode) node.getFirstChild();
}
if (this.tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
if (tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
}
if (node != root) {
final String newGroupId = "group" + node.getParent().getChildCount() + 1;
277,23 → 274,23
final MenuDescriptor desc = new MenuDescriptor(newGroupId);
desc.setType(MenuDescriptor.GROUP);
desc.setInsertInMenu(((Item) parent.getUserObject()).getId());
this.extension.addCreateMenu(desc);
this.extension.setChanged();
extension.addCreateMenu(desc);
extension.setChanged();
 
this.newModel.reload();
this.tree.setSelectionPath(new TreePath(this.newModel.getPathToRoot(newNode)));
newModel.reload();
tree.setSelectionPath(new TreePath(newModel.getPathToRoot(newNode)));
}
this.extension.setChanged();
extension.setChanged();
}
 
protected void addNewItem() {
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (this.tree.getModel().getRoot())).getFirstChild();
final DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) (tree.getModel().getRoot())).getFirstChild();
DefaultMutableTreeNode node = root;
if (node.getChildCount() > 0) {
node = (DefaultMutableTreeNode) node.getFirstChild();
}
if (this.tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) this.tree.getLastSelectedPathComponent();
if (tree.getSelectionPath() != null) {
node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
}
if (node != root) {
final String newActionId = "action" + node.getParent().getChildCount() + 1;
303,10 → 300,10
final MenuDescriptor desc = new MenuDescriptor(newActionId);
desc.setType(MenuDescriptor.CREATE);
desc.setInsertInMenu(((Item) parent.getUserObject()).getId());
this.extension.addCreateMenu(desc);
this.extension.setChanged();
this.newModel.reload();
this.tree.setSelectionPath(new TreePath(this.newModel.getPathToRoot(newNode)));
extension.addCreateMenu(desc);
extension.setChanged();
newModel.reload();
tree.setSelectionPath(new TreePath(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 this.id;
return id;
}
 
public void setId(String id) {
24,7 → 24,7
}
 
public String getListId() {
return this.listId;
return listId;
}
 
public void setListId(String listId) {
32,7 → 32,7
}
 
public String getComponentId() {
return this.componentId;
return componentId;
}
 
public void setComponentId(String componentId) {
44,7 → 44,7
* @return "list" or "create"
* */
public String getType() {
return this.type;
return type;
}
 
public void setType(String type) {
52,7 → 52,7
}
 
public String getInsertInMenu() {
return this.insertInMenu;
return insertInMenu;
}
 
public void setInsertInMenu(String insertInMenu) {
/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 (this.showAll || newChild.isActive()) {
if (showAll || newChild.isActive()) {
node.add(newChild);
}
if (item instanceof Group) {
81,7 → 81,7
}
 
private boolean isActive(String id) {
List<MenuDescriptor> l = this.extension.getRemoveMenuList();
List<MenuDescriptor> l = 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) {
this.extension.removeRemoveMenuForId(id);
extension.removeRemoveMenuForId(id);
} else {
this.extension.addRemoveMenu(new MenuDescriptor(id));
extension.addRemoveMenu(new MenuDescriptor(id));
}
this.extension.setChanged();
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();
this.extension.moveMenuItem(it.getId(), g.getId());
extension.moveMenuItem(it.getId(), g.getId());
super.insertNodeInto(newChild, parent, index);
this.extension.setChanged();
extension.setChanged();
}
 
@SuppressWarnings("rawtypes")
158,8 → 158,8
}
}
 
this.extension.renameMenuItem(previousId, newId);
this.extension.setChanged();
extension.renameMenuItem(previousId, newId);
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;
this.textId = new JTextField();
textId = new JTextField();
 
this.add(this.textId, c);
this.add(textId, c);
c.gridy++;
 
c.gridwidth = 1;
72,13 → 72,13
c.gridx++;
 
c.fill = GridBagConstraints.HORIZONTAL;
this.comboActionType = new JComboBox();
comboActionType = new JComboBox();
 
this.add(this.comboActionType, c);
this.add(comboActionType, c);
c.gridx++;
c.weightx = 1;
this.comboActionChoice = new JComboBox();
this.add(this.comboActionChoice, c);
comboActionChoice = new JComboBox();
this.add(comboActionChoice, c);
 
c.gridy++;
}
87,9 → 87,9
c.gridx = 1;
c.weightx = 0;
c.fill = GridBagConstraints.NONE;
this.shownInMenu = new JCheckBox("Afficher dans le menu");
shownInMenu = new JCheckBox("Afficher dans le menu");
 
this.add(this.shownInMenu, c);
this.add(shownInMenu, c);
 
JPanel spacer = new JPanel();
c.gridx = 1;
100,9 → 100,9
initUIFrom(item.getId());
 
// Listeners
if (!this.isEditingGroup) {
if (!isEditingGroup) {
// comboActionType
this.comboActionType.addActionListener(new ActionListener() {
comboActionType.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
110,14 → 110,14
int type = cb.getSelectedIndex();
if (type == 0) {
// Saisie
MenuItemEditor.this.comboActionChoice.setModel(new DefaultComboBoxModel(MenuItemEditor.this.componentIds));
comboActionChoice.setModel(new DefaultComboBoxModel(componentIds));
 
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
desc.setType(MenuDescriptor.CREATE);
desc.setListId(null);
if (MenuItemEditor.this.componentIds.size() > 0) {
MenuItemEditor.this.comboActionChoice.setSelectedIndex(0);
desc.setComponentId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
if (componentIds.size() > 0) {
comboActionChoice.setSelectedIndex(0);
desc.setComponentId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
}
124,12 → 124,12
extension.setChanged();
} else {
// Liste
MenuItemEditor.this.comboActionChoice.setModel(new DefaultComboBoxModel(MenuItemEditor.this.listIds));
comboActionChoice.setModel(new DefaultComboBoxModel(listIds));
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
desc.setType(MenuDescriptor.LIST);
if (MenuItemEditor.this.listIds.size() > 0) {
MenuItemEditor.this.comboActionChoice.setSelectedIndex(0);
desc.setListId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
if (listIds.size() > 0) {
comboActionChoice.setSelectedIndex(0);
desc.setListId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setListId(null);
}
139,15 → 139,15
 
}
});
this.comboActionChoice.addActionListener(new ActionListener() {
comboActionChoice.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
MenuDescriptor desc = extension.getCreateMenuItemFromId(item.getId());
if (desc.getType().equals(MenuDescriptor.CREATE)) {
desc.setComponentId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
desc.setComponentId(comboActionChoice.getSelectedItem().toString());
} else if (desc.getType().equals(MenuDescriptor.LIST)) {
desc.setListId(MenuItemEditor.this.comboActionChoice.getSelectedItem().toString());
desc.setListId(comboActionChoice.getSelectedItem().toString());
} else {
desc.setComponentId(null);
desc.setListId(null);
156,13 → 156,13
});
 
}
this.shownInMenu.addActionListener(new ActionListener() {
shownInMenu.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final boolean selected = MenuItemEditor.this.shownInMenu.isSelected();
final boolean selected = shownInMenu.isSelected();
 
MenuItemEditor.this.treeModel.setActive(selected, item.getId());
treeModel.setActive(selected, item.getId());
}
});
 
169,11 → 169,11
}
 
private void initUIFrom(String itemId) {
boolean hasCreated = this.extension.getCreateMenuItemFromId(itemId) != null;
this.textId.setEnabled(hasCreated);
this.previousId = itemId;
boolean hasCreated = extension.getCreateMenuItemFromId(itemId) != null;
textId.setEnabled(hasCreated);
previousId = itemId;
if (hasCreated) {
this.textId.getDocument().addDocumentListener(new DocumentListener() {
textId.getDocument().addDocumentListener(new DocumentListener() {
 
@Override
public void removeUpdate(DocumentEvent e) {
187,12 → 187,12
 
@Override
public void changedUpdate(DocumentEvent e) {
String t = MenuItemEditor.this.textId.getText();
String t = textId.getText();
System.err.println("MenuItemEditor.initUIFrom(...).new DocumentListener() {...}.changedUpdate()" + t);
 
if (!MenuItemEditor.this.previousId.equals(t)) {
MenuItemEditor.this.treeModel.renameMenuItem(MenuItemEditor.this.previousId, t);
MenuItemEditor.this.previousId = t;
if (!previousId.equals(t)) {
treeModel.renameMenuItem(previousId, t);
previousId = t;
 
}
}
199,59 → 199,59
});
}
 
this.shownInMenu.setSelected(this.extension.getRemoveMenuItemFromId(itemId) == null);
if (this.textId != null) {
this.textId.setText(itemId);
shownInMenu.setSelected(extension.getRemoveMenuItemFromId(itemId) == null);
if (textId != null) {
textId.setText(itemId);
}
if (!this.isEditingGroup) {
this.comboActionType.setEnabled(true);
this.comboActionChoice.setEnabled(true);
if (!isEditingGroup) {
comboActionType.setEnabled(true);
comboActionChoice.setEnabled(true);
final Action actionForId = MenuManager.getInstance().getActionForId(itemId);
if (hasCreated) {
MenuDescriptor desc = this.extension.getCreateMenuItemFromId(itemId);
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie", "Liste" }));
MenuDescriptor desc = extension.getCreateMenuItemFromId(itemId);
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie", "Liste" }));
//
final List<ComponentDescritor> compDescList = this.extension.getCreateComponentList();
this.componentIds = new Vector<String>(compDescList.size());
final List<ComponentDescritor> compDescList = extension.getCreateComponentList();
componentIds = new Vector<String>(compDescList.size());
for (ComponentDescritor componentDescritor : compDescList) {
final String id = componentDescritor.getId();
if (id != null) {
this.componentIds.add(id);
componentIds.add(id);
}
}
 
Collections.sort(this.componentIds);
Collections.sort(componentIds);
 
final List<ListDescriptor> listDescList = this.extension.getCreateListList();
this.listIds = new Vector<>(listDescList.size());
final List<ListDescriptor> listDescList = extension.getCreateListList();
listIds = new Vector<>(listDescList.size());
for (ListDescriptor listDescritor : listDescList) {
final String id = listDescritor.getId();
if (id != null) {
this.listIds.add(id);
listIds.add(id);
}
}
 
Collections.sort(this.listIds);
Collections.sort(listIds);
//
 
String type = desc.getType();
if (type.equals(MenuDescriptor.CREATE)) {
final String componentId = desc.getComponentId();
if (!this.componentIds.contains(componentId) && componentId != null) {
this.componentIds.add(componentId);
if (!componentIds.contains(componentId) && componentId != null) {
componentIds.add(componentId);
}
this.comboActionType.setSelectedIndex(0);
this.comboActionChoice.setModel(new DefaultComboBoxModel(this.componentIds));
this.comboActionChoice.setSelectedItem(componentId);
comboActionType.setSelectedIndex(0);
comboActionChoice.setModel(new DefaultComboBoxModel(componentIds));
comboActionChoice.setSelectedItem(componentId);
 
} else if (type.equals(MenuDescriptor.LIST)) {
final String listId = desc.getListId();
if (!this.listIds.contains(listId) && listId != null) {
this.listIds.add(listId);
if (!listIds.contains(listId) && listId != null) {
listIds.add(listId);
}
this.comboActionType.setSelectedIndex(1);
this.comboActionChoice.setModel(new DefaultComboBoxModel(this.listIds));
this.comboActionChoice.setSelectedItem(listId);
comboActionType.setSelectedIndex(1);
comboActionChoice.setModel(new DefaultComboBoxModel(listIds));
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) {
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie" }));
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Saisie" }));
} else if (frame instanceof IListFrame) {
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Liste" }));
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Liste" }));
} else {
this.comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Autre" }));
comboActionType.setModel(new DefaultComboBoxModel(new String[] { "Autre" }));
}
 
this.comboActionChoice.setModel(new DefaultComboBoxModel(new String[] { frame.getTitle() }));
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/ExtensionListPanel.java
18,10 → 18,10
}
this.extensionBuilderModule = extensionBuilderModule;
this.setLayout(new GridLayout(1, 1));
this.newLeftComponent = new ExtensionMainListPanel(this);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.newLeftComponent, this.rPanel);
newLeftComponent = new ExtensionMainListPanel(this);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, newLeftComponent, rPanel);
this.add(this.split);
this.newLeftComponent.fill();
newLeftComponent.fill();
}
 
public void setRightPanel(JComponent p) {
32,11 → 32,11
}
 
public ExtensionBuilderModule getExtensionBuilderModule() {
return this.extensionBuilderModule;
return extensionBuilderModule;
}
 
public void modelChanged() {
this.newLeftComponent.modelChanged();
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 : this.extensions) {
for (Extension extension : 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 : this.extensions) {
for (Extension extension : extensions) {
if (extension.isAutoStart()) {
try {
extension.start(root, true);
124,7 → 124,7
 
@Override
protected void stop() {
for (Extension extension : this.extensions) {
for (Extension extension : 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(this.moduleListPanel.getExtensionBuilderModule().getExtensions());
addAll(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;
this.moduleListPanel.getExtensionBuilderModule().add(e);
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) {
this.moduleListPanel.getExtensionBuilderModule().remove(extenstion);
moduleListPanel.getExtensionBuilderModule().remove(extenstion);
extenstion.removeChangeListener(this);
return super.removeElement(obj);
}
58,7 → 58,7
 
@Override
public void stateChanged(ChangeEvent e) {
this.moduleListPanel.modelChanged();
moduleListPanel.modelChanged();
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListListPanel.java
21,7 → 21,7
 
@Override
public void addNewItem() {
((CreateListListModel) this.dataModel).addNewList();
((CreateListListModel) dataModel).addNewList();
}
 
@Override
36,8 → 36,8
 
@Override
public void removeItem(Object item) {
((CreateListListModel) this.dataModel).removeElement(item);
this.extension.removeCreateList((ListDescriptor) item);
((CreateListListModel) dataModel).removeElement(item);
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, this.extension);
this.tableInfoPanel.setRightPanel(p);
final ListCreatePanel p = new ListCreatePanel(n, extension);
tableInfoPanel.setRightPanel(p);
} else {
this.tableInfoPanel.setRightPanel(new JPanel());
tableInfoPanel.setRightPanel(new JPanel());
}
}
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/ListDescriptor.java
15,7 → 15,7
}
 
public String getId() {
return this.id;
return id;
}
 
public void setId(String id) {
27,11 → 27,11
}
 
public String getMainTable() {
return this.mainTable;
return mainTable;
}
 
public List<ColumnDescriptor> getColumns() {
return this.columns;
return columns;
}
 
@Override
51,8 → 51,4
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 this.id;
return id;
}
 
public String getFieldsPaths() {
String r = "";
final int size = this.fieldPaths.size();
final int size = fieldPaths.size();
for (int i = 0; i < size; i++) {
String fieldPath = this.fieldPaths.get(i);
String fieldPath = fieldPaths.get(i);
if (i != 0) {
r += ",";
}
33,14 → 33,14
 
public void setFieldsPaths(String paths) {
final List<String> l = StringUtils.fastSplit(paths, ',');
this.fieldPaths.clear();
fieldPaths.clear();
for (String string : l) {
this.fieldPaths.add(string.trim());
fieldPaths.add(string.trim());
}
}
 
public String getStyle() {
return this.style;
return 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(this.extension.getCreateListList());
this.addAll(extension.getCreateListList());
}
 
@Override
28,11 → 28,11
 
public void addNewList() {
final ListDescriptor l = new ListDescriptor("liste " + (this.getSize() + 1));
final List<String> allKnownTableNames = this.extension.getAllKnownTableNames();
final List<String> allKnownTableNames = extension.getAllKnownTableNames();
final String mainTable = allKnownTableNames.get(0);
l.setMainTable(mainTable);
this.addElement(l);
this.extension.addCreateList(l);
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;
this.panel = new FieldDescSelector(n, extension);
panel = new FieldDescSelector(n, extension);
final String mainTable = n.getMainTable();
if (mainTable == null && comboTable.getModel().getSize() > 0) {
comboTable.setSelectedIndex(0);
this.panel.setMainTable((String) comboTable.getModel().getElementAt(0));
panel.setMainTable((String) comboTable.getModel().getElementAt(0));
} else {
comboTable.setSelectedItem(mainTable);
this.panel.setMainTable(mainTable);
panel.setMainTable(mainTable);
}
this.add(this.panel, c);
this.add(panel, c);
 
comboTable.addActionListener(new ActionListener() {
 
54,7 → 54,7
@Override
public void actionPerformed(ActionEvent e) {
n.removeAllColumns();
ListCreatePanel.this.panel.setMainTable((String) comboTable.getSelectedItem());
panel.setMainTable((String) comboTable.getSelectedItem());
extension.setChanged();
}
});
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/FieldDescSelector.java
9,7 → 9,6
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;
47,8 → 46,8
// Col 0
c.gridx = 0;
c.gridy++;
this.treeModel = new FieldTreeModel(extension);
this.tree = new JTree(this.treeModel) {
treeModel = new FieldTreeModel(extension);
this.tree = new JTree(treeModel) {
@Override
public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
62,19 → 61,19
return " " + d.getName();
}
};
this.tree.setRootVisible(false);
this.tree.setShowsRootHandles(true);
tree.setRootVisible(false);
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")));
this.tree.setCellRenderer(treeRenderer);
tree.setCellRenderer(treeRenderer);
c.gridheight = 2;
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.add(new JScrollPane(this.tree), c);
this.add(new JScrollPane(tree), c);
// Col 1
c.gridx = 1;
c.gridheight = 1;
94,7 → 93,7
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
this.listModel = new DefaultListModel() {
listModel = new DefaultListModel() {
@Override
public void addElement(Object obj) {
if (!(obj instanceof ColumnDescriptor)) {
104,9 → 103,9
}
 
};
this.list = new ReorderableJList();
this.list.setModel(this.listModel);
this.list.setCellRenderer(new DefaultListCellRenderer() {
list = new ReorderableJList();
list.setModel(listModel);
list.setCellRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
ColumnDescriptor f = (ColumnDescriptor) value;
114,9 → 113,9
return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
}
});
this.add(new JScrollPane(this.list), c);
this.add(new JScrollPane(list), c);
// Listeners
this.tree.addMouseListener(new MouseAdapter() {
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
141,7 → 140,7
 
}
});
this.list.addKeyListener(new KeyAdapter() {
list.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
155,8 → 154,8
 
public void setMainTable(String table) {
this.listDescriptor.setMainTable(table);
this.treeModel.fillFromTable(table);
this.listModel.removeAllElements();
treeModel.fillFromTable(table);
listModel.removeAllElements();
for (ColumnDescriptor d : this.listDescriptor.getColumns()) {
this.listModel.addElement(d);
}
163,24 → 162,18
}
 
private void deleteSelectedInList() {
List<Object> vals = this.list.getSelectedValuesList();
if (vals.isEmpty())
Object[] vals = list.getSelectedValues();
if (vals == null)
return;
for (Object object : vals) {
boolean b = this.listModel.removeElement(object);
if (!b) {
throw new IllegalStateException("cannot remove " + object + " from list model " + this.listModel);
for (int i = 0; i < vals.length; i++) {
Object object = vals[i];
this.listModel.removeElement(object);
}
if (object instanceof ColumnDescriptor) {
ColumnDescriptor c = (ColumnDescriptor) object;
this.listDescriptor.remove(c);
list.clearSelection();
}
}
this.list.clearSelection();
}
 
private void addTreeSelectionToList() {
final TreePath[] paths = this.tree.getSelectionPaths();
final TreePath[] paths = tree.getSelectionPaths();
if (paths == null)
return;
for (int i = 0; i < paths.length; i++) {
210,10 → 203,10
if (d != null && root != null) {
boolean add = true;
final String extendedLabel = root.getPath();
final int size = this.listModel.getSize();
final int size = listModel.getSize();
// Check if already in the list
for (int j = 0; j < size; j++) {
if (((ColumnDescriptor) this.listModel.getElementAt(j)).getFieldsPaths().contains(extendedLabel)) {
if (((ColumnDescriptor) listModel.getElementAt(j)).getFieldsPaths().contains(extendedLabel)) {
add = false;
break;
}
221,12 → 214,12
if (add) {
final ColumnDescriptor colDesc = new ColumnDescriptor(root.getPath());
colDesc.setFieldsPaths(root.getPath());
this.listModel.addElement(colDesc);
this.listDescriptor.add(colDesc);
listModel.addElement(colDesc);
listDescriptor.add(colDesc);
}
}
}
this.tree.clearSelection();
tree.clearSelection();
}
 
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/list/FieldTreeModel.java
80,7 → 80,7
newChild.setAllowsChildren(false);
}
}
this.setRoot(this.root);
this.setRoot(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(this.extension, this);
return new ListListPanel(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);
}
this.list = new JList(dataModel);
this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane comp2 = new JScrollPane(this.list);
list = new JList(dataModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
final JScrollPane comp2 = new JScrollPane(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) {
this.renameButton = new JButton("Renommer");
this.add(this.renameButton, c);
this.renameButton.setEnabled(false);
this.renameButton.addActionListener(new ActionListener() {
renameButton = new JButton("Renommer");
this.add(renameButton, c);
renameButton.setEnabled(false);
renameButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
if (EditableListPanel.this.list.getSelectedValue() != null) {
renameItem(EditableListPanel.this.list.getSelectedValue());
if (list.getSelectedValue() != null) {
renameItem(list.getSelectedValue());
}
}
 
80,9 → 80,9
c.gridy++;
}
 
this.removeButton = new JButton("Supprimer");
this.removeButton.setEnabled(false);
this.add(this.removeButton, c);
removeButton = new JButton("Supprimer");
removeButton.setEnabled(false);
this.add(removeButton, c);
 
// init
 
98,25 → 98,25
 
});
 
this.removeButton.addActionListener(new ActionListener() {
removeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (EditableListPanel.this.list.getSelectedValue() != null) {
removeItem(EditableListPanel.this.list.getSelectedValue());
if (list.getSelectedValue() != null) {
removeItem(list.getSelectedValue());
}
}
});
}
this.list.addListSelectionListener(new ListSelectionListener() {
list.addListSelectionListener(new ListSelectionListener() {
 
@Override
public void valueChanged(ListSelectionEvent e) {
final Object selectedValue = EditableListPanel.this.list.getSelectedValue();
if (EditableListPanel.this.removeButton != null) {
EditableListPanel.this.removeButton.setEnabled(selectedValue != null);
final Object selectedValue = list.getSelectedValue();
if (removeButton != null) {
removeButton.setEnabled(selectedValue != null);
}
if (EditableListPanel.this.renameButton != null) {
EditableListPanel.this.renameButton.setEnabled(selectedValue != null);
if (renameButton != null) {
renameButton.setEnabled(selectedValue != null);
}
if (!e.getValueIsAdjusting() && selectedValue != null) {
 
136,7 → 136,7
* Select an item in the list
* */
public void selectItem(Object item) {
this.list.setSelectedValue(item, true);
list.setSelectedValue(item, true);
}
 
/**
162,7 → 162,7
public abstract void itemSelected(Object item);
 
public void reload() {
this.list.invalidate();
this.list.repaint();
list.invalidate();
list.repaint();
}
}
/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);
this.leftComponent = createLeftComponent();
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.leftComponent, new JPanel());
this.add(this.split);
leftComponent = createLeftComponent();
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, new JPanel());
this.add(split);
}
 
public void setRightPanel(JComponent p) {
this.invalidate();
this.split.setRightComponent(p);
split.setRightComponent(p);
this.revalidate();
this.repaint();
}
/trunk/Modules/Module Extension Builder/src/org/openconcerto/modules/extensionbuilder/ExtensionMainListPanel.java
22,7 → 22,6
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;
36,13 → 35,13
}
 
public void fill() {
((ExtensionListModel) this.dataModel).fill(this);
((ExtensionListModel) dataModel).fill(this);
 
}
 
@Override
public void addNewItem() {
((ExtensionListModel) this.dataModel).addNewModule();
((ExtensionListModel) dataModel).addNewModule();
}
 
@Override
57,22 → 56,22
 
@Override
public void removeItem(Object item) {
((ExtensionListModel) this.dataModel).removeElement(item);
((ExtensionListModel) dataModel).removeElement(item);
}
 
@Override
public void itemSelected(Object item) {
if (item != null) {
final ExtensionInfoPanel p = new ExtensionInfoPanel((Extension) item, this.moduleListPanel);
this.moduleListPanel.setRightPanel(p);
final ExtensionInfoPanel p = new ExtensionInfoPanel((Extension) item, moduleListPanel);
moduleListPanel.setRightPanel(p);
} else {
this.moduleListPanel.setRightPanel(new JPanel());
moduleListPanel.setRightPanel(new JPanel());
}
 
}
 
public void modelChanged() {
this.list.invalidate();
this.list.repaint();
list.invalidate();
list.repaint();
}
}
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/Module.java
40,6 → 40,7
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.utils.i18n.TranslationManager;
 
public final class Module extends AbstractModule {
 
109,6 → 110,7
@Override
protected void setupElements(final SQLElementDirectory dir) {
super.setupElements(dir);
TranslationManager.getInstance().addTranslationStreamFromClass(this.getClass());
dir.addSQLElement(SubscriptionSQLElement.class);
NumerotationAutoSQLElement.addClass(SubscriptionSQLElement.class, "ABONNEMENT");
((SaisieVenteFactureSQLElement) dir.getElement("SAISIE_VENTE_FACTURE")).putSpecialAction("subscription.autocreate", new DoWithRow() {
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/FacturesAboPanel.java
11,11 → 11,11
 
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieVenteFacture;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.IResultSetHandler;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRow;
33,19 → 33,18
}
 
private final SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
private SQLElement eltFact = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE");
 
@Override
protected void validItem(SQLRowAccessor sqlRowAccessor) {
// Affectation d'un numero
SQLRowValues rowVals = sqlRowAccessor.createEmptyUpdateRow();
String nextNumero = NumerotationAutoSQLElement.getNextNumero(this.eltFact.getClass());
String nextNumero = NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class);
rowVals.put("DATE", new Date());
rowVals.put("NUMERO", nextNumero);
 
SQLRowValues rowValsNum = new SQLRowValues(tableNum);
 
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(this.eltFact.getClass());
String labelNumberFor = NumerotationAutoSQLElement.getLabelNumberFor(SaisieVenteFactureSQLElement.class);
int val = tableNum.getRow(2).getInt(labelNumberFor);
val++;
rowValsNum.put(labelNumberFor, Integer.valueOf(val));
110,7 → 109,7
@Override
protected void injectRow(SQLRow row, SQLRowValues rowVals, Date dateNew, SQLRow rowAbonnement) {
super.injectRow(row, rowVals, dateNew, rowAbonnement);
rowVals.put("NUMERO", "ABO--" + NumerotationAutoSQLElement.getNextNumero(this.eltFact.getClass()));
rowVals.put("NUMERO", "ABO--" + NumerotationAutoSQLElement.getNextNumero(SaisieVenteFactureSQLElement.class));
rowVals.put("ID_ADRESSE", row.getObject("ID_ADRESSE"));
rowVals.put("ID_COMPTE_PCE_SERVICE", row.getObject("ID_COMPTE_PCE_SERVICE"));
rowVals.put("PORT_HT", row.getObject("PORT_HT"));
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/AboPanel.java
120,11 → 120,11
* @param type
*/
private void createUI(final SQLElement elt, final SQLElement itemsElement, final String type) {
final SQLTableModelSourceOnline tableCmd = elt.getTableSource(true);
final SwingWorker<SQLTableModelSourceOnline, Object> worker = new SwingWorker<SQLTableModelSourceOnline, Object>() {
 
@Override
protected SQLTableModelSourceOnline doInBackground() throws Exception {
final SQLTableModelSourceOnline tableCmd = elt.getTableSource(true);
Where wD = new Where(elt.getTable().getField("CREATION_AUTO_VALIDER"), "=", Boolean.FALSE);
wD = wD.and(new Where(elt.getTable().getField("ID_ABONNEMENT"), "IS NOT", (Object) null));
tableCmd.getReq().setWhere(wD);
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/BonCommandeAboPanel.java
8,10 → 8,10
import java.util.List;
 
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.sales.order.element.CommandeClientSQLElement;
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
26,18 → 26,17
}
 
private SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
private SQLElement eltCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT");
 
@Override
protected void injectRow(SQLRow row, SQLRowValues rowVals, Date dateNew, SQLRow rowAbonnement) {
// TODO Raccord de méthode auto-généré
super.injectRow(row, rowVals, dateNew, rowAbonnement);
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(this.eltCmd.getClass()));
rowVals.put("NUMERO", NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class));
// incrémentation du numéro auto
final SQLRowValues rowValsNum = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(this.eltCmd.getClass()));
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(CommandeClientSQLElement.class));
val++;
rowValsNum.put(NumerotationAutoSQLElement.getLabelNumberFor(this.eltCmd.getClass()), new Integer(val));
rowValsNum.put(NumerotationAutoSQLElement.getLabelNumberFor(CommandeClientSQLElement.class), new Integer(val));
try {
rowValsNum.update(2);
} catch (final SQLException e) {
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/DevisAboPanel.java
8,8 → 8,8
import java.util.Date;
 
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
import org.openconcerto.erp.core.sales.quote.element.DevisSQLElement;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
21,19 → 21,18
}
 
private SQLTable tableNum = Configuration.getInstance().getRoot().findTable("NUMEROTATION_AUTO");
private SQLElement eltDev = Configuration.getInstance().getDirectory().getElement("DEVIS");
 
@Override
protected void injectRow(SQLRow row, SQLRowValues rowVals, Date dateNew, SQLRow rowAbonnement) {
super.injectRow(row, rowVals, dateNew, rowAbonnement);
String nextNumero = NumerotationAutoSQLElement.getNextNumero(this.eltDev.getClass());
String nextNumero = NumerotationAutoSQLElement.getNextNumero(DevisSQLElement.class);
rowVals.put("NUMERO", nextNumero);
 
// incrémentation du numéro auto
final SQLRowValues rowValsNum = new SQLRowValues(this.tableNum);
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(this.eltDev.getClass()));
int val = this.tableNum.getRow(2).getInt(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class));
val++;
rowValsNum.put(NumerotationAutoSQLElement.getLabelNumberFor(this.eltDev.getClass()), new Integer(val));
rowValsNum.put(NumerotationAutoSQLElement.getLabelNumberFor(DevisSQLElement.class), new Integer(val));
try {
rowValsNum.update(2);
} catch (final SQLException e) {
/trunk/Modules/Module Google Docs/src/org/openconcerto/modules/google/docs/GoogleDocsPreferencePanel.java
101,10 → 101,8
ll.uploadFile(f, "OpenConcerto/Devis/2010", "Test Google Docs", true);
JOptionPane.showMessageDialog(GoogleDocsPreferencePanel.this, "Connexion réussie");
} catch (AuthenticationException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(GoogleDocsPreferencePanel.this, "Identifiant ou mot de passe invalide");
} catch (Throwable e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(GoogleDocsPreferencePanel.this, e1.getMessage());
}
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/labels_fr.xml
1,7 → 1,7
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<element refid="customersupport.ticket" nameClass="masculine" name="ticket de support">
<FIELD name="STATUS" label="Statut" />
<FIELD name="STATUS" label="Status" />
<FIELD name="LABEL" label="Libellé" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="NUMBER" label="Numéro" />
10,7 → 10,7
<FIELD name="RATING" label="Priorité" />
<FIELD name="TYPE" label="Type" />
<FIELD name="REMIND_DATE" label="Prochain rappel le" />
<FIELD name="DATE" label="Date ticket" />
<FIELD name="DATE" label="Date" />
<FIELD name="CLOSED_AND_ARCHIVED" label="Archivé" />
</element>
<element refid="customersupport.ticket.history" nameClass="feminine" name="Intervention sur ticket">
17,6 → 17,6
<FIELD name="ID_CUSTOMER_SUPPORT_TICKET" label="Ticket" />
<FIELD name="ID_USER_COMMON" label="Utilisateur en charge" />
<FIELD name="INFORMATION" label="Détails de l'intervention" />
<FIELD name="DATE" label="Date inter." />
<FIELD name="DATE" label="Date" />
</element>
</ROOT>
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/Module.java
1,5 → 1,6
package org.openconcerto.modules.customersupport;
 
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.sql.SQLException;
8,6 → 9,7
import java.util.List;
import java.util.Set;
 
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.config.MainFrame;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
14,15 → 16,20
import org.openconcerto.erp.modules.DBContext;
import org.openconcerto.erp.modules.MenuContext;
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.erp.modules.ModulePackager;
import org.openconcerto.erp.modules.RuntimeModuleFactory;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRequestLog;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.ui.ConnexionPanel;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationHistoryPanel.java
72,7 → 72,6
public void propertyChange(PropertyChangeEvent evt) {
final List<SQLRowValues> selectedRows = list.getSelectedRows();
final IListPanel listePanel = listHistoriquePanel.getListePanel(0);
// Activation/Desactivation des boutons Mofifier/Supprimer
if (selectedRows != null && !selectedRows.isEmpty()) {
final Set<Long> idsCalendarItemGroup = new HashSet<>();
for (SQLRowValues sqlRowValues : selectedRows) {
143,25 → 142,24
cal.set(Calendar.YEAR, selectedYear + 1);
Date dEnd = cal.getTime();
 
final SQLTable itemGroupTable = comboRequest.getPrimaryTable().getTable("CALENDAR_ITEM_GROUP");
final SQLTable itemTable = comboRequest.getPrimaryTable().getTable("CALENDAR_ITEM");
final SQLTable operationTable = comboRequest.getPrimaryTable().getTable("OPERATION");
final SQLTable groupT = comboRequest.getPrimaryTable().getTable("CALENDAR_ITEM_GROUP");
final SQLTable calItemT = comboRequest.getPrimaryTable().getTable("CALENDAR_ITEM");
final List<?> dateGroupIDs;
{
final SQLSelect copy = new SQLSelect(input);
copy.clearSelect();
copy.addSelect(copy.getAlias(itemGroupTable.getKey()));
copy.setWhere(copy.getAlias(operationTable.getField("ID_SITE")), "=", panel.getSelectedRow().getID());
final List<?> allGroupIDs = itemTable.getDBSystemRoot().getDataSource().executeCol(copy.asString());
copy.addSelect(copy.getAlias(groupT.getKey()));
copy.setWhere(copy.getAlias(comboRequest.getPrimaryTable().getTable("OPERATION").getField("ID_SITE")), "=", panel.getSelectedRow().getID());
final List<?> allGroupIDs = calItemT.getDBSystemRoot().getDataSource().executeCol(copy.asString());
 
final SQLSelect selIDGroup = new SQLSelect();
selIDGroup.addSelect(itemTable.getField("ID_CALENDAR_ITEM_GROUP"));
final Where where = new Where(itemTable.getField("START"), dStart, true, dEnd, true);
selIDGroup.setWhere(where).andWhere(new Where(itemTable.getField("ID_CALENDAR_ITEM_GROUP"), allGroupIDs));
dateGroupIDs = itemTable.getDBSystemRoot().getDataSource().executeCol(selIDGroup.asString());
selIDGroup.addSelect(calItemT.getField("ID_CALENDAR_ITEM_GROUP"));
final Where where = new Where(calItemT.getField("START"), dStart, true, dEnd, true);
selIDGroup.setWhere(where).andWhere(new Where(calItemT.getField("ID_CALENDAR_ITEM_GROUP"), allGroupIDs));
dateGroupIDs = calItemT.getDBSystemRoot().getDataSource().executeCol(selIDGroup.asString());
}
 
Where w = new Where(input.getAlias(itemGroupTable.getKey()), dateGroupIDs);
input.setWhere(w);
input.setWhere(new Where(input.getAlias(groupT.getKey()), dateGroupIDs));
} catch (Throwable e) {
e.printStackTrace();
}
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/CalendarPrintPanel.java
43,8 → 43,6
private static final double POINTS_PER_INCH = 72.0;
 
public CalendarPrintPanel(final OperationCalendarManager manager, final int week, final int year, final List<User> selectedUsers, final List<String> selectedStates) {
 
System.err.println("CalendarPrintPanel.CalendarPrintPanel()" + selectedUsers);
preview.setSelected(true);
//
this.setLayout(new GridBagLayout());
111,15 → 109,8
});
final PageFormat pf = new PageFormat();
pf.setPaper(new A4());
List<JCalendarItem> itemsToWork = new ArrayList<>();
for (JCalendarItem item : itemInWeek) {
if (!item.hasFlag(ModuleOperation.FREE_TIME_FLAG)) {
itemsToWork.add(item);
}
}
final CalendarItemPrinter printable = new OperationCalendarItemPrinter(user.getFullName(), itemInWeek, pf);
 
final CalendarItemPrinter printable = new OperationCalendarItemPrinter(user.getFullName(), itemInWeek, pf, itemsToWork);
 
p.add(printable);
}
}
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/ModuleOperation.java
62,6 → 62,8
// SQLRequestLog.showFrame();
TemplateManager.getInstance().register(OPERATIONS_REPORT_TEMPLATE_ID);
TemplateManager.getInstance().register(OPERATIONS_REPORT_TEMPLATE2_ID);
// Translation loading
TranslationManager.getInstance().addTranslationStreamFromClass(this.getClass());
}
 
@Override
146,10 → 148,6
createTableOperation.addVarCharColumn("DESCRIPTION", 10000);
createTableOperation.addVarCharColumn("PLANNER_UID", 2048);
createTableOperation.addVarCharColumn("PLANNER_XML", 2048);
 
ctxt.executeSQL();
// SQLTable.setUndefID(ctxt.getRoot().getSchema(), TABLE_SITE, null);
// SQLTable.setUndefID(ctxt.getRoot().getSchema(), TABLE_OPERATION, null);
}
}
 
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationCalendarPanel.java
117,11 → 117,12
this.beginStateSaving(conf.getConfDir(), w);
}
 
public static Map<Integer, Long> getDurations(List<List<JCalendarItem>> list, final Flag requiredFlag, final Flag excludedFlag) {
public static Map<Integer, Long> getDurations(List<List<JCalendarItem>> list, final Flag requiredFlag) {
final Map<Integer, Long> res = new HashMap<>();
final Flag freeTimeFlag = ModuleOperation.FREE_TIME_FLAG;
for (List<JCalendarItem> items : list) {
for (JCalendarItem item : items) {
if (!item.hasFlag(excludedFlag) && (requiredFlag == null || item.hasFlag(requiredFlag)) && item.getCookie() instanceof SQLRowValues) {
if (!item.hasFlag(freeTimeFlag) && (requiredFlag == null || item.hasFlag(requiredFlag)) && item.getCookie() instanceof SQLRowValues) {
final SQLRowValues user = (SQLRowValues) item.getCookie();
final long toAddMinutes = (item.getDtEnd().getTimeInMillis() - item.getDtStart().getTimeInMillis()) / (60 * 1000);
final Integer key = user.getID();
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/UserOperationListModel.java
140,7 → 140,7
return this.usersAndWeeklyMinutes;
}
}
final Map<User, Integer> uInfo = new LinkedHashMap<>();
final Map<User, Integer> uInfo = new LinkedHashMap<User, Integer>();
final SQLRowValues v = new SQLRowValues(this.salarieElem.getTable());
v.putNulls("NOM", "PRENOM");
v.putRowValues("ID_INFOS_SALARIE_PAYE").putNulls("DUREE_HEBDO");
152,14 → 152,10
for (int i = 0; i < size; i++) {
final User u = users.get(i);
final String name = u.getName().trim();
final String firstName = u.getFirstName().trim();
final String firstName = u.getFirstName();
Integer minutes = null;
for (SQLRowValues row : rows) {
// Matching Utilisateur <-> Salarié
// Nom et prénom identique
final String sName = row.getString("NOM").trim();
final String sFirstName = row.getString("PRENOM").trim();
if (sName.equalsIgnoreCase(name) && sFirstName.equalsIgnoreCase(firstName)) {
if (row.getString("NOM").trim().equalsIgnoreCase(name) && row.getString("PRENOM").trim().equalsIgnoreCase(firstName)) {
minutes = (int) row.getForeign("ID_INFOS_SALARIE_PAYE").getFloat("DUREE_HEBDO") * 60;
break;
}
173,8 → 169,8
}
 
private void setDurations(final List<List<JCalendarItem>> viewItems) {
final Map<Integer, Long> all = OperationCalendarPanel.getDurations(viewItems, null, ModuleOperation.FREE_TIME_FLAG);
final Map<Integer, Long> locked = OperationCalendarPanel.getDurations(viewItems, Flag.getFlag("locked"), ModuleOperation.FREE_TIME_FLAG);
final Map<Integer, Long> all = OperationCalendarPanel.getDurations(viewItems, null);
final Map<Integer, Long> locked = OperationCalendarPanel.getDurations(viewItems, Flag.getFlag("locked"));
synchronized (this) {
this.allDurations = Collections.unmodifiableMap(all);
this.lockedDurations = Collections.unmodifiableMap(locked);
221,10 → 217,10
// not a SALARIE
suffix = "";
} else {
// Durée planifiée
final int d = getDuration(all, u.getId());
// Durée verrouillée
final int d2 = getDuration(locked, u.getId());
// Durée planifiée
final int d = getDuration(all, u.getId());
suffix = " [" + formatDuration(d2) + " / " + formatDuration(d) + " / " + formatDuration(weeklyMinutes) + "]";
}
res.add(createItem(u, (u.getFullName() + suffix).trim()));
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/UserColor.java
18,16 → 18,12
final int size = users.size();
for (int i = 0; i < size; i++) {
final User u = users.get(i);
if (u.getColor() == null) {
this.map.put(u.getId(), Color.decode(COLORS[i % COLORS.length]));
} else {
this.map.put(u.getId(), u.getColor());
map.put(u.getId(), Color.decode(COLORS[i % COLORS.length]));
}
}
}
 
public synchronized Color getColor(int id) {
return this.map.get(id);
return map.get(id);
}
 
public static final synchronized UserColor getInstance() {
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationExportPanel.java
74,13 → 74,13
public class OperationExportPanel extends JPanel {
 
@GuardedBy("EDT")
private static final DateFormat DF = new SimpleDateFormat("yyyyMMdd");
static private final DateFormat DF = new SimpleDateFormat("yyyyMMdd");
 
final JCheckBox lockedCheckBox = new JCheckBox("verrouillées uniquement");
final JButton bPrint = new JButton("Exporter");
 
public OperationExportPanel(final OperationCalendarManager manager, final List<SQLRowValues> rowsSite) {
this.lockedCheckBox.setSelected(true);
lockedCheckBox.setSelected(true);
//
this.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
141,8 → 141,8
//
final JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.RIGHT));
p.add(this.lockedCheckBox);
p.add(this.bPrint);
p.add(lockedCheckBox);
p.add(bPrint);
c.gridwidth = 2;
c.gridx = 0;
c.gridy++;
151,7 → 151,7
this.add(p, c);
//
 
this.bPrint.addActionListener(new ActionListener() {
bPrint.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
160,9 → 160,9
}
final String statusVal = statusCombo.getValue();
final List<String> states = StringUtils.isEmpty(statusVal, true) ? null : Collections.singletonList(statusVal);
final List<JCalendarItem> items = manager.getItemIn(d1.getDate(), d2.getDate(), manager.getAllUsers(), states);
final List<JCalendarItemDB> itemsToExport = new ArrayList<>(items.size());
if (OperationExportPanel.this.lockedCheckBox.isSelected()) {
final List<JCalendarItem> items = manager.getItemIn(d1.getDate(), d2.getDate(), null, states);
final List<JCalendarItemDB> itemsToExport = new ArrayList<JCalendarItemDB>(items.size());
if (lockedCheckBox.isSelected()) {
for (JCalendarItem jCalendarItem : items) {
JCalendarItemDB i = (JCalendarItemDB) jCalendarItem;
if (i.getFlagsString().contains("locked")) {
176,12 → 176,12
}
}
if (rowsSite != null && !rowsSite.isEmpty()) {
final Set<String> allowedSites = new HashSet<>();
final Set<String> allowedSites = new HashSet<String>();
for (SQLRowValues r : rowsSite) {
String siteName = r.getString("NAME");
allowedSites.add(siteName);
}
final List<JCalendarItemDB> filtered = new ArrayList<>(itemsToExport.size());
final List<JCalendarItemDB> filtered = new ArrayList<JCalendarItemDB>(itemsToExport.size());
for (JCalendarItemDB i : itemsToExport) {
if (allowedSites.contains(i.getSiteName())) {
filtered.add(i);
218,9 → 218,9
});
}
 
private static final class Planner implements Comparable<Planner> {
static private final class Planner implements Comparable<Planner> {
 
private static final BigDecimal MS_PER_HOUR = BigDecimal.valueOf(1000 * 3600);
static private final BigDecimal MS_PER_HOUR = BigDecimal.valueOf(1000 * 3600);
 
private final String uid;
private final String xml;
256,7 → 256,7
 
final Element scheduleElem = doc.getRootElement().getChild("schedule");
this.startTime = new Date(Long.valueOf(scheduleElem.getAttributeValue("start")));
final long endTime = Long.parseLong(scheduleElem.getAttributeValue("end"));
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);
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationCalendarManager.java
62,10 → 62,6
this.userMngr = userMngr;
}
 
public UserManager getUserMngr() {
return userMngr;
}
 
public final SQLElementDirectory getDirectory() {
return this.dir;
}
393,15 → 389,4
}
return l.get(0);
}
 
/**
* Enabled or disabled users
*/
public List<User> getAllUsers() {
final List<User> result = new ArrayList<>();
for (User user : this.userMngr.getUsers().values()) {
result.add(user);
}
return result;
}
}
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/JCalendarItemDB.java
25,13 → 25,7
assert r.isFrozen();
this.item = r;
this.group = dir.getElement(this.item.getTable()).getContainer(this.item);
if (this.group == null) {
throw new IllegalArgumentException("no group found for row " + r);
}
this.operationElem = dir.getElement(OperationSQLElement.class);
if (this.operationElem == null) {
throw new IllegalStateException("no element found " + OperationSQLElement.class);
}
this.operation = CollectionUtils.getSole(this.group.getReferentRows(this.operationElem.getTable()));
}
 
90,7 → 84,7
}
 
public String getStatus() {
return this.status;
return status;
}
 
public void setOperationType(String type) {
98,7 → 92,7
}
 
public String getType() {
return this.type;
return type;
}
 
public String getFlagsString() {
115,7 → 109,7
}
 
public String getPlannerXML() {
return this.plannerXML;
return plannerXML;
}
 
public void setPlannerXML(String string) {
123,7 → 117,7
}
 
public String getPlannerUID() {
return this.plannerUID;
return plannerUID;
}
 
public void setPlannerUID(String plannerUID) {
131,7 → 125,7
}
 
public String getSiteName() {
return this.siteName;
return siteName;
}
 
public void setSiteName(String siteName) {
139,7 → 133,7
}
 
public String getSiteComment() {
return this.siteComment;
return siteComment;
}
 
public void setSiteComment(String siteComment) {
151,7 → 145,7
}
 
public Number getSiteId() {
return this.siteId;
return siteId;
}
 
public int getId() {
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationCalendarItemPrinter.java
11,11 → 11,9
 
public class OperationCalendarItemPrinter extends CalendarItemPrinter {
public static final Font FONT_LINE = new Font("Arial", Font.PLAIN, 9);
private List<JCalendarItem> itemsToWork;
 
public OperationCalendarItemPrinter(String title, List<JCalendarItem> items, PageFormat pf, List<JCalendarItem> itemsToWork) {
public OperationCalendarItemPrinter(String title, List<JCalendarItem> items, PageFormat pf) {
super(title, items, pf);
this.itemsToWork = itemsToWork;
}
 
@Override
40,7 → 38,7
 
@Override
public String getTitle() {
final List<JCalendarItem> items = this.itemsToWork;
final List<JCalendarItem> items = this.getItems();
int totalMinutes = 0;
for (JCalendarItem jCalendarItem : items) {
long t2 = jCalendarItem.getDtEnd().getTimeInMillis();
/trunk/Modules/Module Badge/src/org/openconcerto/modules/badge/Module.java
31,7 → 31,7
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.ComptaContactSQLElement;
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;
166,7 → 166,6
 
createTable.addForeignColumn("ID_ADRESSE", addrElem.getTable());
createTable.addForeignColumn("ID_PLAGE_HORAIRE", new SQLName("PLAGE_HORAIRE"), SQLSyntax.ID_NAME, null);
ctxt.executeSQL();
}
// at least v1.0
 
241,7 → 240,7
vals.put("CODE", code);
newClient = vals.insert();
}
final SQLRowValues contactVals = new SQLRowValues(ctxt.getElementDirectory().getElement(ComptaContactSQLElement.class).getTable());
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);
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/translation_fr.xml
File deleted
\ No newline at end of file
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadGroup.java
1,5 → 1,6
package org.openconcerto.modules.customerrelationship.lead;
 
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.ui.group.Group;
10,59 → 11,52
public LeadGroup() {
super("customerrelationship.lead.default");
final Group g = new Group("customerrelationship.lead.identifier");
g.addItem("NUMBER", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("DATE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("NUMBER");
g.addItem("DATE");
g.addItem("COMPANY", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(g);
 
final Group gContact = new Group("customerrelationship.lead.person", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gContact.addItem("ID_TITRE_PERSONNEL", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gContact.addItem("NAME", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gContact.addItem("FIRSTNAME", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gContact.addItem("NAME");
gContact.addItem("FIRSTNAME");
gContact.addItem("ID_TITRE_PERSONNEL");
this.add(gContact);
 
final Group gCustomer = new Group("customerrelationship.lead.contact", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gCustomer.addItem("ROLE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gCustomer.addItem("PHONE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gCustomer.addItem("MOBILE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gCustomer.addItem("FAX", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gCustomer.addItem("PHONE");
gCustomer.addItem("MOBILE");
gCustomer.addItem("FAX");
gCustomer.addItem("EMAIL", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gCustomer.addItem("WEBSITE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(gCustomer);
 
final Group gAddress = new Group("customerrelationship.lead.address", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gAddress.addItem("ID_ADRESSE", LayoutHints.DEFAULT_VERY_LARGE_FIELD_HINTS);
gAddress.addItem("ID_ADRESSE");
this.add(gAddress);
 
final Group gInfos = new Group("customerrelationship.lead.info", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gInfos.addItem("INFORMATION", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gInfos.addItem("INDUSTRY", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gInfos.addItem("REVENUE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gInfos.addItem("EMPLOYEES", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gInfos.addItem("INFOS", new LayoutHints(true, true, true, true, true, true, true, true));
final Group gInfos = new Group("customerrelationship.lead.info");
gInfos.addItem("INFORMATION", new LayoutHints(true, true, true, true, true, true));
gInfos.addItem("INDUSTRY");
gInfos.addItem("REVENUE");
gInfos.addItem("EMPLOYEES");
gInfos.addItem("INFOS", new LayoutHints(true, true, true, true, true, true));
this.add(gInfos);
 
final Group gState = new Group("customerrelationship.lead.state", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gState.addItem("RATING", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gState.addItem("SOURCE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gState.addItem("STATUS", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gState.addItem("ID_COMMERCIAL", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gState.addItem("REMIND_DATE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
final Group gState = new Group("customerrelationship.lead.state");
gState.addItem("RATING");
gState.addItem("SOURCE");
gState.addItem("STATUS");
gState.addItem("ID_COMMERCIAL");
gState.addItem("REMIND_DATE");
UserRights rights = UserRightsManager.getCurrentUserRights();
if (rights.haveRight("CLIENT_PROSPECT")) {
gState.addItem("ID_CLIENT", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gState.addItem("ID_CLIENT");
}
gState.addItem("DISPO", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gState.addItem("DISPO");
 
this.add(gState);
 
final Group gItems = new Group("customerrelationship.lead.items.call.tab");
gItems.addItem("customerrelationship.lead.items.call", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
this.add(gItems);
 
final Group gItems2 = new Group("customerrelationship.lead.items.visit.tab");
gItems2.addItem("customerrelationship.lead.items.visit", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
this.add(gItems2);
 
}
 
public static void main(String[] args) {
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/CustomerCallSQLElement.java
15,7 → 15,6
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.component.ITextArea;
 
public class CustomerCallSQLElement extends ModuleElement {
 
28,11 → 27,6
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_CLIENT");
l.add("INFORMATION");
if (getTable().contains("ID_COMMERCIAL")) {
l.add("ID_COMMERCIAL");
}
return l;
}
 
60,8 → 54,10
@Override
public JComponent createEditor(String id) {
if (id.equals("INFORMATION")) {
final ITextArea jTextArea = new ITextArea();
jTextArea.setRows(20);
final JTextArea jTextArea = new JTextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setMinimumSize(new Dimension(200, 150));
jTextArea.setPreferredSize(new Dimension(200, 150));
return new JScrollPane(jTextArea);
} else if (id.equals("DATE")) {
return new JDate(true);
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/LeadCallSQLElement.java
7,6 → 7,7
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
14,7 → 15,6
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.component.ITextArea;
 
public class LeadCallSQLElement extends ModuleElement {
 
27,11 → 27,6
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_LEAD");
l.add("INFORMATION");
if (getTable().contains("ID_COMMERCIAL")) {
l.add("ID_COMMERCIAL");
}
 
return l;
}
 
59,8 → 54,10
@Override
public JComponent createEditor(String id) {
if (id.equals("INFORMATION")) {
final ITextArea jTextArea = new ITextArea();
jTextArea.setRows(20);
final JTextArea jTextArea = new JTextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setMinimumSize(new Dimension(200, 150));
jTextArea.setPreferredSize(new Dimension(200, 150));
return new JScrollPane(jTextArea);
} else if (id.equals("DATE")) {
return new JDate(true);
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadSQLElement.java
4,7 → 4,6
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
55,38 → 54,6
super(module, Module.TABLE_LEAD);
 
// Call
final RowAction.PredicateRowAction addDuplicateAction = new RowAction.PredicateRowAction(new AbstractAction("Créer à partir de") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
final SQLTable table = LeadSQLElement.this.getTable().getTable(Module.TABLE_LEAD);
final SQLElement leadElt = LeadSQLElement.this.getDirectory().getElement(table);
EditFrame editFrame = new EditFrame(leadElt);
final SQLRowValues sqlRowValues = new SQLRowValues(table);
sqlRowValues.put("COMPANY", sRow.getObject("COMPANY"));
sqlRowValues.put("PHONE", sRow.getObject("PHONE"));
sqlRowValues.put("FAX", sRow.getObject("FAX"));
sqlRowValues.put("WEBSITE", sRow.getObject("WEBSITE"));
sqlRowValues.put("DATE", new Date());
SQLRowValues adr = new SQLRowValues(sRow.getForeign("ID_ADRESSE").asRowValues());
sqlRowValues.put("ID_ADRESSE", adr);
sqlRowValues.put("INDUSTRY", sRow.getObject("INDUSTRY"));
sqlRowValues.put("REVENUE", sRow.getObject("REVENUE"));
sqlRowValues.put("EMPLOYEES", sRow.getObject("EMPLOYEES"));
sqlRowValues.put("LOCALISATION", sRow.getObject("LOCALISATION"));
sqlRowValues.put("SIRET", sRow.getObject("SIRET"));
sqlRowValues.put("APE", sRow.getObject("APE"));
 
editFrame.getSQLComponent().select(sqlRowValues);
FrameUtil.show(editFrame);
}
}, true) {
};
addDuplicateAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(addDuplicateAction);
 
// Call
final RowAction.PredicateRowAction addCallAction = new RowAction.PredicateRowAction(new AbstractAction("Appeler") {
 
@Override
154,79 → 121,6
}
}
 
if (getTable().contains("MODIFICATION_DATE")) {
BaseSQLTableModelColumn dateM = new BaseSQLTableModelColumn("Date de modification", Date.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
return r.getObject("MODIFICATION_DATE");
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
return CollectionUtils.createSet(new FieldPath(p, "MODIFICATION_DATE"));
}
};
source.getColumns().add(1, dateM);
}
 
BaseSQLTableModelColumn dateV = new BaseSQLTableModelColumn("Visite", Date.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
Date d = null;
Collection<? extends SQLRowAccessor> l = r.getReferentRows(r.getTable().getTable("LEAD_VISIT"));
for (SQLRowAccessor sqlRowAccessor : l) {
if (d != null && sqlRowAccessor.getObject("DATE") != null && d.before(sqlRowAccessor.getDate("DATE").getTime())) {
d = sqlRowAccessor.getDate("DATE").getTime();
} else {
if (d == null && sqlRowAccessor.getObject("DATE") != null) {
d = sqlRowAccessor.getDate("DATE").getTime();
}
}
 
}
return d;
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(p.getLast().getTable("LEAD_VISIT"));
return CollectionUtils.createSet(new FieldPath(p, "DATE"));
}
};
source.getColumns().add(1, dateV);
 
BaseSQLTableModelColumn dateA = new BaseSQLTableModelColumn("Appel", Date.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
Date d = null;
Collection<? extends SQLRowAccessor> l = r.getReferentRows(r.getTable().getTable("LEAD_CALL"));
for (SQLRowAccessor sqlRowAccessor : l) {
if (d != null && sqlRowAccessor.getObject("DATE") != null && d.before(sqlRowAccessor.getDate("DATE").getTime())) {
d = sqlRowAccessor.getDate("DATE").getTime();
} else {
if (d == null && sqlRowAccessor.getObject("DATE") != null) {
d = sqlRowAccessor.getDate("DATE").getTime();
}
}
 
}
return d;
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(p.getLast().getTable("LEAD_CALL"));
return CollectionUtils.createSet(new FieldPath(p, "DATE"));
}
};
source.getColumns().add(1, dateA);
 
BaseSQLTableModelColumn adresse = new BaseSQLTableModelColumn("Adresse", String.class) {
 
@Override
295,32 → 189,6
};
source.getColumns().add(ville);
 
BaseSQLTableModelColumn dpt = new BaseSQLTableModelColumn("Département", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
String s = r.getForeign("ID_ADRESSE").getString("CODE_POSTAL");
if (s != null && s.length() >= 2) {
return s.substring(0, 2);
} else {
return s;
}
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
final SQLTable clientT = getTable().getForeignTable("ID_CLIENT");
p = p.add(clientT);
p = p.add(clientT.getField("ID_ADRESSE"));
return CollectionUtils.createSet(new FieldPath(p, "VILLE"), new FieldPath(p, "CODE_POSTAL"));
}
};
 
source.getColumns().add(dpt);
 
if (getTable().contains("REMIND_DATE")) {
BaseSQLTableModelColumn dateRemind = new BaseSQLTableModelColumn("Date de rappel", Date.class) {
 
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadCustomerSQLInjector.java
3,8 → 3,6
*/
package org.openconcerto.modules.customerrelationship.lead;
 
import java.util.Date;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRowAccessor;
28,8 → 26,6
map(leadTable.getField("MOBILE"), customerTable.getField("TEL_P"));
// map(leadTable.getField("INFORMATION"), customerTable.getField("INFOS"));
map(getSource().getField("INFOS"), getDestination().getField("INFOS"));
remove(leadTable.getField("DATE"), customerTable.getField("DATE"));
mapDefaultValues(customerTable.getField("DATE"), new Date());
remove(leadTable.getField("ID_ADRESSE"), customerTable.getField("ID_ADRESSE"));
}
 
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/labels_fr.xml
38,7 → 38,6
name="rapport d'appel prospect" namePlural="rapports d'appel prospect">
<FIELD name="DATE" label="Date de l'appel" />
<FIELD name="ID_LEAD" label="Entreprise" />
<FIELD name="ID_COMMERCIAL" label="Commercial" />
<FIELD name="INFORMATION" label="Résumé de l'appel" />
<FIELD name="NEXTCONTACT_DATE" label="Date de prochain contact" />
<FIELD name="NEXTCONTACT_INFO" label="Motif de prochain contact" />
48,7 → 47,6
</element>
<element refid="org.openconcerto.modules.customerrelationship.lead/CUSTOMER_CALL" nameClass="masculine"
name="rapport d'appel client" namePlural="rapports d'appel client">
<FIELD name="ID_COMMERCIAL" label="Commercial" />
<FIELD name="DATE" label="Date de l'appel" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="INFORMATION" label="Résumé de l'appel" />
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadSQLComponent.java
5,17 → 5,13
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
 
import org.openconcerto.modules.customerrelationship.lead.visit.LeadActionItemTable;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.ui.JDate;
25,12 → 21,8
import org.openconcerto.ui.group.Group;
 
public class LeadSQLComponent extends GroupSQLComponent {
 
private LeadActionItemTable tableCall, tableVisit;
 
public LeadSQLComponent(SQLElement element, Group group) {
super(element, group);
startTabGroupAfter("customerrelationship.lead.state");
}
 
@Override
45,26 → 37,10
public JComponent getLabel(String id) {
if (id.equals("customerrelationship.lead.person")) {
return new JLabelBold("Contact");
}
if (id.equals("customerrelationship.lead.items.visit.tab")) {
return new JLabelBold("Visites");
}
if (id.equals("customerrelationship.lead.items.visit")) {
return new JLabelBold("");
}
if (id.equals("customerrelationship.lead.items.call.tab")) {
return new JLabelBold("Appels");
}
if (id.equals("customerrelationship.lead.items.call")) {
return new JLabelBold("");
} else if (id.equals("customerrelationship.lead.contact")) {
return new JLabel();
} else if (id.equals("customerrelationship.lead.address")) {
return new JLabelBold("Adresse");
} else if (id.equals("customerrelationship.lead.info")) {
return new JLabelBold("Infos");
} else if (id.equals("customerrelationship.lead.state")) {
return new JLabelBold("Statut");
} else {
return super.getLabel(id);
}
72,61 → 48,20
 
@Override
public JComponent createEditor(String id) {
 
if (id.equals("INFORMATION") || id.equals("INFOS")) {
final ITextArea jTextArea = new ITextArea(3,3);
final ITextArea jTextArea = new ITextArea();
jTextArea.setFont(new JLabel().getFont());
return jTextArea;
} else if (id.equals("ID_COMMERCIAL") || id.equals("ID_TITRE_PERSONNEL")) {
ElementComboBox comp = new ElementComboBox(false, 1);
((ElementComboBox) comp).init(getElement().getForeignElement(id));
return comp;
} else if (id.equals("customerrelationship.lead.items.call")) {
tableCall = new LeadActionItemTable(getElement().getDirectory().getElement(Module.TABLE_LEAD_CALL));
return tableCall;
} else if (id.equals("customerrelationship.lead.items.visit")) {
tableVisit = new LeadActionItemTable(getElement().getDirectory().getElement(Module.TABLE_LEAD_VISIT));
return tableVisit;
} else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE") || id.equals("DISPO")) {
return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 1, false);
return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
} else if (id.equals("DATE")) {
return new JDate(true);
}
JComponent comp = super.createEditor(id);
if(comp.getClass() == JTextField.class) {
JTextField jtxt = new JTextField(10);
comp = jtxt;
return super.createEditor(id);
}
return comp;
}
 
@Override
public int insert(SQLRow order) {
int id = super.insert(order);
this.tableCall.updateField("ID_LEAD", id);
this.tableVisit.updateField("ID_LEAD", id);
return id;
}
 
@Override
public void select(SQLRowAccessor r) {
super.select(r);
if (r != null) {
this.tableCall.insertFrom("ID_LEAD", r.getID());
this.tableVisit.insertFrom("ID_LEAD", r.getID());
}
}
 
@Override
public void update() {
super.update();
this.tableCall.updateField("ID_LEAD", getSelectedID());
this.tableVisit.updateField("ID_LEAD", getSelectedID());
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("STATUS", "Nouveau");
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/LeadActionItemTable.java
File deleted
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/CustomerVisitSQLElement.java
28,10 → 28,6
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_CLIENT");
l.add("INFORMATION");
if (getTable().contains("ID_COMMERCIAL")) {
l.add("ID_COMMERCIAL");
}
l.add("NEXTCONTACT_DATE");
return l;
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/LeadVisitSQLElement.java
28,11 → 28,6
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_LEAD");
l.add("INFORMATION");
if (getTable().contains("ID_COMMERCIAL")) {
l.add("ID_COMMERCIAL");
}
 
l.add("NEXTCONTACT_DATE");
return l;
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/importer/LeadImporter.java
19,15 → 19,10
import org.openconcerto.openoffice.spreadsheet.Sheet;
import org.openconcerto.openoffice.spreadsheet.SpreadSheet;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesCluster;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.utils.cc.IdentityHashSet;
import org.openconcerto.utils.text.CSVReader;
import org.openconcerto.utils.text.CharsetHelper;
81,82 → 76,6
public abstract T convert(String[] line);
}
 
public Map<Object, LeadCSV> exportLeads(SQLTable tableLead, File dir2save, File sheetFile) throws Exception {
List<String[]> adresse = new ArrayList<String[]>();
List<String[]> leadList = new ArrayList<String[]>();
 
Map<Object, LeadCSV> leadMap = new HashMap<Object, LeadCSV>();
 
SQLSelect sel = new SQLSelect();
sel.addSelectStar(tableLead);
List<SQLRow> leads = SQLRowListRSH.execute(sel);
int i = 1;
for (SQLRow lead : leads) {
 
int idAdr = adresse.size();
AdresseCSV adr = createAdresse(i, lead.getForeign("ID_ADRESSE"));
adresse.add(adr.toCSVLine());
LeadCSV leadCsv = createLeadFromRow(i, lead, Integer.valueOf(adr.getId().toString()));
leadList.add(leadCsv.toCSVLine());
leadMap.put(leadCsv.getId(), leadCsv);
i++;
}
 
DataImporter importer = new DataImporter(tableLead);
final File csvFile = new File(dir2save, "Lead.csv");
csvFile.createNewFile();
importer.exportModelToCSV(csvFile, leadList);
DataImporter importerAdr = new DataImporter(tableLead.getForeignTable("ID_ADRESSE"));
final File csvFile2 = new File(dir2save, "Address.csv");
csvFile2.createNewFile();
importerAdr.exportModelToCSV(csvFile2, adresse);
 
return leadMap;
}
 
public AdresseCSV createAdresse(int i, SQLRow rowAdr) {
 
String street = rowAdr.getString("RUE");
final String ville = rowAdr.getString("VILLE");
final String cp = rowAdr.getString("CODE_POSTAL");
 
AdresseCSV adrLine = new AdresseCSV(i, street, ville, cp);
 
return adrLine;
}
 
public LeadCSV createLeadFromRow(int i, SQLRowAccessor row, int idAdr) {
 
LeadCSV leadLine = new LeadCSV(i, row.getString("COMPANY"), "");
 
leadLine.setIdAdr(idAdr);
 
leadLine.setPhone(row.getString("PHONE"));
leadLine.setMail(row.getString("EMAIL"));
leadLine.setCell(row.getString("MOBILE"));
leadLine.setFax(row.getString("FAX"));
leadLine.setContact(row.getString("NAME"));
leadLine.setLocalisation(row.getString("LOCALISATION"));
leadLine.setSecteur(row.getString("INDUSTRY"));
leadLine.setEffectif(String.valueOf(row.getInt("EMPLOYEES")));
leadLine.setOrigine(row.getString("SOURCE"));
 
leadLine.setSiret(row.getString("SIRET"));
leadLine.setApe(row.getString("APE"));
 
leadLine.setNom(row.getString("NAME"));
leadLine.setPrenom(row.getString("FIRSTNAME"));
leadLine.setDesc(row.getString("INFORMATION"));
// rowVals.put("REVENUE", (getBudget().trim().length()==0?0:Integer);
leadLine.setDispo(row.getString("DISPO"));
leadLine.setTypeT(row.getString("INDUSTRY"));
leadLine.setStatut(row.getString("STATUS"));
leadLine.setInfos(row.getString("INFOS"));
 
return leadLine;
 
}
 
public LeadCSV createLead(int i, Sheet sheet, int idAdr, int id) {
final Cell<SpreadSheet> cell0 = sheet.getImmutableCellAt(0, i);
final String societeName = cell0.getValue().toString().trim();
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/Module.java
94,6 → 94,7
import org.openconcerto.utils.Tuple2;
import org.openconcerto.utils.cc.IExnClosure;
import org.openconcerto.utils.cc.ITransformer;
import org.openconcerto.utils.i18n.TranslationManager;
 
public final class Module extends AbstractModule {
 
190,6 → 191,7
@Override
protected void setupElements(final SQLElementDirectory dir) {
super.setupElements(dir);
TranslationManager.getInstance().addTranslationStreamFromClass(this.getClass());
dir.addSQLElement(ProjectSQLElement.class);
dir.addSQLElement(ProjectStateSQLElement.class);
dir.addSQLElement(ProjectTypeSQLElement.class);
605,7 → 607,7
protected void setupComponents(final ComponentsContext ctxt) {
 
DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
List<String> table2check = Arrays.asList("BON_RECEPTION", "DEMANDE_PRIX", "DEMANDE_ACHAT_ELEMENT", "FACTURE_FOURNISSEUR");
List<String> table2check = Arrays.asList("BON_RECEPTION", "DEMANDE_PRIX", "DEMANDE_ACHAT_ELEMENT");
for (String table : table2check) {
if (root.contains(table)) {
SQLTable tableCR = root.getTable(table);
/trunk/Modules/Module Expense/src/org/openconcerto/modules/humanresources/travel/expense/translation_fr.xml
File deleted
\ No newline at end of file
/trunk/Modules/Module Expense/src/org/openconcerto/modules/humanresources/travel/expense/labels_fr.xml
1,7 → 1,7
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<TABLE name="EXPENSE_STATE">
<FIELD name="NAME" label="Statut" />
<FIELD name="NAME" label="Nom" />
</TABLE>
<TABLE name="EXPENSE">
<FIELD name="NAME" label="Nom" />
12,9 → 12,9
<FIELD name="TRAVEL_RATE" label="Tarif kilométrique" />
<FIELD name="TRAVEL_AMOUNT" label="Montant des frais kilométriques" />
<FIELD name="MISC_AMOUNT" label="Montant des frais annexes" />
<FIELD name="ID_EXPENSE_STATE" label="Statut" />
<FIELD name="ID_EXPENSE_STATE" label="Status" />
<FIELD name="ID_USER_COMMON" label="Employé" />
<FIELD name="ID_EXPENSE_STATE" label="Statut" />
<FIELD name="ID_EXPENSE_STATE" label="Status" />
</TABLE>
 
</ROOT>
/trunk/Modules/Module Expense/src/org/openconcerto/modules/humanresources/travel/expense/ExpenseSQLComponent.java
7,7 → 7,6
import java.util.Set;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.text.AbstractDocument;
import javax.swing.text.JTextComponent;
 
14,10 → 13,9
import org.openconcerto.erp.core.common.ui.DeviseField;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.sqlobject.ElementComboBox;
import org.openconcerto.sql.sqlobject.itemview.VWRowItemView;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.component.text.TextComponentUtils;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.text.DocumentFilterList;
43,13 → 41,11
}
};
 
final AbstractDocument comp1 = (AbstractDocument) TextComponentUtils
.getDocument(getView("TRAVEL_DISTANCE").getComp());
final AbstractDocument comp1 = (AbstractDocument) TextComponentUtils.getDocument(getView("TRAVEL_DISTANCE").getComp());
DocumentFilterList.add(comp1, new LimitedSizeDocumentFilter(5), FilterType.SIMPLE_FILTER);
getView("TRAVEL_DISTANCE").addValueListener(listener);
 
final AbstractDocument comp2 = (AbstractDocument) TextComponentUtils
.getDocument(getView("TRAVEL_RATE").getComp());
final AbstractDocument comp2 = (AbstractDocument) TextComponentUtils.getDocument(getView("TRAVEL_RATE").getComp());
DocumentFilterList.add(comp2, new LimitedSizeDocumentFilter(5), FilterType.SIMPLE_FILTER);
 
getView("TRAVEL_RATE").addValueListener(listener);
66,33 → 62,17
}
 
@Override
public JComponent createEditor(String id) {
if(id.equals("ID_USER_COMMON") || id.equals("ID_EXPENSE_STATE")) {
ElementComboBox comp = new ElementComboBox(false, 15);
((ElementComboBox) comp).init(getElement().getForeignElement(id));
return comp;
}
else if (id.equals("DATE")) {
public JComponent getEditor(String id) {
if (id.equals("DESCRIPTION")) {
return new ITextArea();
} else if (id.equals("DATE")) {
return new JDate(true);
} else if (id.endsWith("AMOUNT")) {
return new DeviseField();
}
return super.createEditor(id);
return super.getEditor(id);
}
 
@Override
public JLabel getLabel(String id) {
if (id.equals("humanresources.travel.expense.travel")) {
return new JLabelBold("Frais kilometriques");
} else if (id.equals("humanresources.travel.expense.default")) {
return new JLabelBold("Descriptif");
} else if (id.equals("humanresources.travel.expense.misc")) {
return new JLabelBold("Frais annexes");
} else {
return (JLabel) super.getLabel(id);
}
}
 
private void updateAmount() {
float v1 = getFloat("TRAVEL_DISTANCE");
float v2 = getFloat("TRAVEL_RATE");
/trunk/Modules/Module Expense/src/org/openconcerto/modules/humanresources/travel/expense/ExpenseGroup.java
7,31 → 7,32
public class ExpenseGroup extends Group {
 
public ExpenseGroup() {
super(ExpenseSQLElement.ELEMENT_CODE + ".default", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
super(ExpenseSQLElement.ELEMENT_CODE + ".default");
final Group g = new Group(ExpenseSQLElement.ELEMENT_CODE + ".identifier");
g.addItem("DATE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("ID_USER_COMMON", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("DATE");
g.addItem("ID_USER_COMMON");
 
this.add(g);
 
final Group gDescription = new Group(ExpenseSQLElement.ELEMENT_CODE + ".description");
gDescription.addItem("DESCRIPTION", new LayoutHints(true, true, true, true, true, true, true, true));
gDescription.addItem("ID_EXPENSE_STATE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gDescription.add(new Item("DESCRIPTION", new LayoutHints(true, true, true, true, true, true)));
this.add(gDescription);
 
final Group gTravel = new Group(ExpenseSQLElement.ELEMENT_CODE + ".travel",
LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gTravel.addItem("TRAVEL_DISTANCE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gTravel.addItem("TRAVEL_RATE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gTravel.addItem("TRAVEL_AMOUNT", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
final Group gTravel = new Group(ExpenseSQLElement.ELEMENT_CODE + ".travel", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gTravel.addItem("TRAVEL_DISTANCE");
gTravel.addItem("TRAVEL_RATE");
gTravel.addItem("TRAVEL_AMOUNT");
this.add(gTravel);
 
final Group gAddress = new Group(ExpenseSQLElement.ELEMENT_CODE + ".misc",
LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gAddress.addItem("MISC_AMOUNT", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
// gAddress.addItem("ID_EXPENSE_STATE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
final Group gAddress = new Group(ExpenseSQLElement.ELEMENT_CODE + ".misc", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gAddress.addItem("MISC_AMOUNT");
this.add(gAddress);
 
final Group gState = new Group(ExpenseSQLElement.ELEMENT_CODE + ".state");
gState.addItem("ID_EXPENSE_STATE");
 
this.add(gState);
 
}
 
}