Jmexico-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- 164 discussions
r8 - in trunk: jmexico-model/src/main/java/fr/reseaumexico/model/parser jmexico-model/src/main/java/fr/reseaumexico/model/writer jmexico-swing-editor jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/model jmexico-swing-editor/src/main/resources/i18n
by sletellier@users.forge.codelutin.com 19 Dec '11
by sletellier@users.forge.codelutin.com 19 Dec '11
19 Dec '11
Author: sletellier
Date: 2011-12-19 18:40:54 +0100 (Mon, 19 Dec 2011)
New Revision: 8
Url: http://forge.codelutin.com/repositories/revision/jmexico/8
Log:
- Write jmexicoTableModel
- Creating InputDesignEditor
- Debug ExperimentDesign parser
Added:
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.css
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditor.jaxx
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditorHandler.java
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/model/
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/model/InputDesignTableModel.java
trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_en_GB.properties
Modified:
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/XmlNode.java
trunk/jmexico-swing-editor/pom.xml
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java
trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_fr_FR.properties
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java 2011-12-16 15:54:27 UTC (rev 7)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java 2011-12-19 17:40:54 UTC (rev 8)
@@ -68,6 +68,7 @@
import static fr.reseaumexico.model.MexicoXmlConstant.EXPERIMENT_DESIGN_LICENCE;
import static fr.reseaumexico.model.MexicoXmlConstant.FACTORS;
import static fr.reseaumexico.model.MexicoXmlConstant.FACTOR_DESCRIPTION;
+import static fr.reseaumexico.model.MexicoXmlConstant.FACTOR_ID;
import static fr.reseaumexico.model.MexicoXmlConstant.FEATURE;
import static fr.reseaumexico.model.MexicoXmlConstant.FEATURE_NAME;
import static fr.reseaumexico.model.MexicoXmlConstant.FEATURE_VALUE;
@@ -156,6 +157,10 @@
Factor factor = new FactorImpl();
+ // parse id
+ String id = parser.getAttributeValue(null, FACTOR_ID);
+ factor.setId(id);
+
// parse description
int eventType = parser.nextTag();
if (eventType == XmlPullParser.START_TAG &&
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/XmlNode.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/XmlNode.java 2011-12-16 15:54:27 UTC (rev 7)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/XmlNode.java 2011-12-19 17:40:54 UTC (rev 8)
@@ -118,7 +118,11 @@
for (Map.Entry<String,String> entry : entries) {
// add to builder param like : name="value"
- builder.append(" ").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"");
+ builder.append(" ")
+ .append(entry.getKey())
+ .append("=\"")
+ .append(StringEscapeUtils.escapeXml(entry.getValue()))
+ .append("\"");
}
return builder.toString();
}
Modified: trunk/jmexico-swing-editor/pom.xml
===================================================================
--- trunk/jmexico-swing-editor/pom.xml 2011-12-16 15:54:27 UTC (rev 7)
+++ trunk/jmexico-swing-editor/pom.xml 2011-12-19 17:40:54 UTC (rev 8)
@@ -61,6 +61,14 @@
<name>JMexico :: Swing Editor</name>
<description>JMexico - Swing Editor module</description>
+ <properties>
+ <!-- jaxx configuration -->
+ <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath>
+ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+ <jaxx.autoImportCss>true</jaxx.autoImportCss>
+ <jaxx.autoRecurseInCss>false</jaxx.autoRecurseInCss>
+ </properties>
+
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
<!-- ************************************************************* -->
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.css
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.css (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.css 2011-12-19 17:40:54 UTC (rev 8)
@@ -0,0 +1,36 @@
+/*
+ * #%L
+ * JMexico :: Swing Editor
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Réseau Mexico, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+#menuFile {
+ text:"jmexico.menu.file";
+ mnemonic:F;
+}
+#menuFileOpen {
+ text:"jmexico.menu.file.open";
+ mnemonic:O;
+}
+#menuFileSave {
+ text:"jmexico.menu.file.save";
+ mnemonic:S;
+}
\ No newline at end of file
Modified: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx 2011-12-16 15:54:27 UTC (rev 7)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx 2011-12-19 17:40:54 UTC (rev 8)
@@ -24,8 +24,30 @@
-->
<JFrame id='mainFrame' decorator='help'
width='800' height='800'
+ layout='{new BorderLayout()}'
onWindowClosing='getHandler().closeApplication(this)'>
+ <import>
+ java.io.File
+ fr.reseaumexico.editor.ui.editor.InputDesignEditor
+ </import>
+
<MexicoMainUIHandler id="handler"
initializer='getContextValue(MexicoMainUIHandler.class)'/>
+
+ <File id="selectedFile" javaBean='null'/>
+
+ <!-- menu -->
+ <JMenuBar id='menu'>
+ <JMenu id='menuFile'>
+ <JMenuItem id='menuFileOpen'
+ onActionPerformed="getHandler().openFile(this)"/>
+
+ <JMenuItem id='menuFileSave'
+ enabled='{selectedFile != null}'
+ onActionPerformed="getHandler().saveFile(this)"/>
+
+ </JMenu>
+ </JMenuBar>
+ <InputDesignEditor id='inputDesignEditor' constraints='BorderLayout.CENTER'/>
</JFrame>
Modified: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java 2011-12-16 15:54:27 UTC (rev 7)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java 2011-12-19 17:40:54 UTC (rev 8)
@@ -24,9 +24,18 @@
*/
package fr.reseaumexico.editor.ui;
+import fr.reseaumexico.model.InputDesign;
+import fr.reseaumexico.model.parser.InputDesignParser;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.swing.ErrorDialogUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import javax.swing.*;
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Handler of main UI
*
@@ -35,6 +44,9 @@
*/
public class MexicoMainUIHandler {
+ /** Logger */
+ private static Log log = LogFactory.getLog(MexicoMainUIHandler.class);
+
public void closeApplication(MexicoMainUI ui) {
ui.dispose();
}
@@ -55,4 +67,47 @@
return ui;
}
+
+ public void openFile(MexicoMainUI ui) {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setDialogTitle(_("jmexico.file.open.dialog"));
+ int returnVal = fileChooser.showOpenDialog(ui);
+ if(returnVal == JFileChooser.APPROVE_OPTION) {
+ File selectedFile = fileChooser.getSelectedFile();
+ InputDesign inputDesign = readInputDesignFile(selectedFile);
+
+ // keep selected file
+ ui.setSelectedFile(selectedFile);
+
+ // set input design
+ ui.getInputDesignEditor().setInputDesign(inputDesign);
+ }
+ }
+
+ public void saveFile(MexicoMainUI ui) {
+ // get selected file
+ File selectedFile = ui.getSelectedFile();
+
+ // get modified model
+
+ // TODO save it
+ }
+
+ protected InputDesign readInputDesignFile(File selectedFile) {
+ InputDesign inputDesignModel = null;
+ try {
+ // parse inputDesign
+ InputDesignParser inputDesignParser = new InputDesignParser(selectedFile);
+ try {
+ inputDesignModel = inputDesignParser.getModel();
+ } finally {
+ inputDesignParser.close();
+ }
+
+ } catch (Exception eee) {
+ log.error("Failed to read inputDesign file '" + selectedFile.getName() + "'", eee);
+ }
+
+ return inputDesignModel;
+ }
}
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditor.jaxx
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditor.jaxx (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditor.jaxx 2011-12-19 17:40:54 UTC (rev 8)
@@ -0,0 +1,65 @@
+<!--
+ #%L
+ JMexico :: Swing Editor
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Réseau Mexico, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='inputDesignEditor' layout='{new BorderLayout()}'>
+
+ <import>
+javax.swing.table.TableModel
+javax.swing.table.DefaultTableModel
+fr.reseaumexico.model.InputDesign
+fr.reseaumexico.editor.ui.model.InputDesignTableModel
+ </import>
+
+ <InputDesignEditorHandler id='handler'/>
+
+ <InputDesignTableModel id='model' javaBean="new InputDesignTableModel()"/>
+
+ <script>
+ <![CDATA[
+public void setInputDesign(InputDesign inputDesign) {
+ getModel().setInputDesign(inputDesign);
+}
+
+public InputDesign getInputDesign() {
+ return getModel().getInputDesign();
+}
+ ]]>
+ </script>
+
+ <JScrollPane constraints='BorderLayout.CENTER'>
+ <JTable id='inputDesignTable' model='{getModel()}'/>
+ </JScrollPane>
+
+ <JPanel id='factorActionPanel' constraints='BorderLayout.SOUTH'>
+ <JButton id='addScenarioButton'
+ text='jmexico.add.scenario'
+ constraints='BorderLayout.WEST'
+ onActionPerformed='getHandler().addScenario(this)'/>
+ <JButton id='removeScenarioButton'
+ text='jmexico.remove.scenario'
+ constraints='BorderLayout.EAST'
+ onActionPerformed='getHandler().removeScenario(this)'/>
+ </JPanel>
+
+</JPanel>
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditorHandler.java
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditorHandler.java (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignEditorHandler.java 2011-12-19 17:40:54 UTC (rev 8)
@@ -0,0 +1,95 @@
+/*
+ * #%L
+ * JMexico :: Swing Editor
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Réseau Mexico, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package fr.reseaumexico.editor.ui.editor;
+
+import com.google.common.collect.Maps;
+import fr.reseaumexico.model.Factor;
+import fr.reseaumexico.model.InputDesign;
+import fr.reseaumexico.model.Scenario;
+import fr.reseaumexico.model.ScenarioImpl;
+
+import javax.swing.*;
+
+import java.util.Collection;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class InputDesignEditorHandler {
+
+ public void addScenario(InputDesignEditor editor) {
+ InputDesign inputDesign = editor.getInputDesign();
+
+ String selectedName = JOptionPane.showInputDialog(editor, _("jmexico.scenario.inputName"));
+
+ // check that name is never used
+ Collection<Scenario> scenarios = inputDesign.getScenarios();
+
+ int maxOrder = 0;
+ for (Scenario scenario : scenarios) {
+ if (selectedName.equalsIgnoreCase(scenario.getName())) {
+
+ JOptionPane.showMessageDialog(editor,
+ _("jmexico.error.title"),
+ _("jmexico.error.scenario.name.used"),
+ JOptionPane.ERROR_MESSAGE);
+
+ return;
+ }
+ int orderNumber = scenario.getOrderNumber();
+ if (maxOrder < orderNumber) {
+ maxOrder = orderNumber;
+ }
+ }
+
+ // create new scenario
+ Scenario scenarioToAdd = new ScenarioImpl();
+
+ // set last order
+ // TODO sletellier 20111219 : ask user order number
+ scenarioToAdd.setOrderNumber(maxOrder + 1);
+
+ // set name
+ scenarioToAdd.setName(selectedName);
+
+ // create all empty factor values
+ Collection<Factor> factors = inputDesign.getExperimentDesign().getFactors();
+ Map<Factor, Object> factorValues = Maps.newHashMap();
+ for (Factor factor : factors) {
+ factorValues.put(factor, null);
+ }
+ scenarioToAdd.setFactorValues(factorValues);
+
+ inputDesign.addScenarios(scenarioToAdd);
+ }
+
+ public void removeScenario(InputDesignEditor editor) {
+
+ }
+}
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/model/InputDesignTableModel.java
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/model/InputDesignTableModel.java (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/model/InputDesignTableModel.java 2011-12-19 17:40:54 UTC (rev 8)
@@ -0,0 +1,204 @@
+/*
+ * #%L
+ * JMexico :: Swing Editor
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Réseau Mexico, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package fr.reseaumexico.editor.ui.model;
+
+import fr.reseaumexico.model.Factor;
+import fr.reseaumexico.model.InputDesign;
+import fr.reseaumexico.model.Scenario;
+
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableModel;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author sletellier <letellier(a)codelutin.com>
+ */
+public class InputDesignTableModel extends AbstractTableModel {
+
+ protected TableModel delegate;
+ protected InputDesign inputDesign;
+
+ public InputDesignTableModel() {
+ delegate = new DefaultTableModel();
+ }
+
+ public void setInputDesign(InputDesign inputDesign) {
+ this.inputDesign = inputDesign;
+ inputDesign.addPropertyChangeListener(InputDesign.PROPERTY_SCENARIOS, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
+ Object newValue = propertyChangeEvent.getNewValue();
+ if (newValue == null) {
+ // was removed
+ scenarioRemoved();
+ }
+
+ Object oldValue = propertyChangeEvent.getOldValue();
+ if (oldValue == null) {
+ // was added
+ scenarioAdded();
+ }
+ }
+ });
+
+ fireTableStructureChanged();
+ }
+
+ protected void scenarioAdded() {
+ fireTableStructureChanged();
+ }
+
+ protected void scenarioRemoved() {
+ fireTableStructureChanged();
+ }
+
+ public InputDesign getInputDesign() {
+ return inputDesign;
+ }
+
+ public Collection<Scenario> getScenarios() {
+ return inputDesign.getScenarios();
+ }
+
+ public Scenario getScenario(int i) {
+ return inputDesign.getScenarios(i);
+ }
+
+ @Override
+ public int getRowCount() {
+ if (inputDesign == null) {
+ return delegate.getRowCount();
+ }
+ Map<Factor, Object> factorValues = getScenario(0).getFactorValues();
+ return factorValues == null ? 0 : factorValues.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ if (inputDesign == null) {
+ return delegate.getColumnCount();
+ }
+ Collection<Scenario> scenarios = getScenarios();
+ if (scenarios == null) {
+ return 1;
+ }
+ return scenarios.size() + 1;
+ }
+
+ @Override
+ public String getColumnName(int rowIndex) {
+ if (inputDesign == null) {
+ return delegate.getColumnName(rowIndex);
+ }
+ if (rowIndex == 0) {
+ return _("jmexico.factor.name");
+ }
+ Scenario scenario = getScenario(rowIndex - 1);
+ return scenario == null ? "" : scenario.getName();
+ }
+
+ @Override
+ public Class<?> getColumnClass(int rowIndex) {
+ if (inputDesign == null) {
+ return delegate.getColumnClass(rowIndex);
+ }
+ if (rowIndex == 0) {
+ return String.class;
+ }
+ return Object.class;
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ if (inputDesign == null) {
+ return delegate.isCellEditable(rowIndex, columnIndex);
+ }
+ return columnIndex > 0;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ if (inputDesign == null) {
+ return delegate.getValueAt(rowIndex, columnIndex);
+ }
+
+ boolean isFirstColumn = columnIndex == 0;
+ if (!isFirstColumn) {
+ columnIndex = columnIndex - 1;
+ }
+ Scenario scenario = getScenario(columnIndex);
+ if (scenario == null) {
+ return null;
+ }
+ Map<Factor,Object> factorValues = scenario.getFactorValues();
+
+ // get key if rowIndex
+ Set<Factor> factors = factorValues.keySet();
+ List<Factor> factorsList = new ArrayList<Factor>(factors);
+ Factor factor = factorsList.get(rowIndex);
+ if (isFirstColumn) {
+ return factor.getId();
+ }
+ return factorValues.get(factor);
+ }
+
+ @Override
+ public void setValueAt(Object o, int rowIndex, int columnIndex) {
+ if (inputDesign == null) {
+ delegate.setValueAt(o, rowIndex, columnIndex);
+ return;
+ }
+ if (columnIndex == 0) {
+
+ // must never append
+ return;
+ }
+ int scenarioIndex = columnIndex - 1;
+ Scenario scenario = getScenario(scenarioIndex);
+ Map<Factor,Object> factorValues = scenario.getFactorValues();
+
+ // get key if rowIndex
+ Set<Factor> factors = factorValues.keySet();
+ List<Factor> factorsList = new ArrayList<Factor>(factors);
+ Factor factor = factorsList.get(rowIndex);
+
+ // TODO sletellier 20111219 : open specific editor
+
+ factorValues.put(factor, o);
+ scenario.setFactorValues(factorValues);
+
+ fireTableCellUpdated(rowIndex, columnIndex);
+ }
+}
Added: trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_en_GB.properties
===================================================================
--- trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_en_GB.properties (rev 0)
+++ trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_en_GB.properties 2011-12-19 17:40:54 UTC (rev 8)
@@ -0,0 +1,10 @@
+jmexico.add.scenario=Ajout d'un scenario
+jmexico.error.scenario.name.used=Error \: scenario name '%1$s' is already used.
+jmexico.error.title=Error
+jmexico.factor.name=Factor
+jmexico.file.open.dialog=Open an InputDesign file.
+jmexico.menu.file=File
+jmexico.menu.file.open=Open
+jmexico.menu.file.save=Save
+jmexico.remove.scenario=Suppression d'un scenario
+jmexico.scenario.inputName=Name of scenario to add \:
Modified: trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_fr_FR.properties
===================================================================
--- trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_fr_FR.properties 2011-12-16 15:54:27 UTC (rev 7)
+++ trunk/jmexico-swing-editor/src/main/resources/i18n/jmexico-swing-editor_fr_FR.properties 2011-12-19 17:40:54 UTC (rev 8)
@@ -0,0 +1,10 @@
+jmexico.add.scenario=Ajout d'un scenario
+jmexico.error.scenario.name.used=Erreur \: le scenario '%1$s' est déjà utilisé.
+jmexico.error.title=Erreur
+jmexico.factor.name=Facteur
+jmexico.file.open.dialog=Ouvrir un fichier InputDesign
+jmexico.menu.file=Fichier
+jmexico.menu.file.open=Ouvrir
+jmexico.menu.file.save=Sauvegarder
+jmexico.remove.scenario=Suppression d'un scenario
+jmexico.scenario.inputName=Nom du scénario à ajouter \:
\ No newline at end of file
1
0
r7 - in trunk: jmexico-model/src/main/java/fr/reseaumexico/model/parser jmexico-swing-editor jmexico-swing-editor/src/main/java jmexico-swing-editor/src/main/java/fr jmexico-swing-editor/src/main/java/fr/reseaumexico jmexico-swing-editor/src/main/java/fr/reseaumexico/editor jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui jmexico-swing-editor/src/main/resources
by sletellier@users.forge.codelutin.com 16 Dec '11
by sletellier@users.forge.codelutin.com 16 Dec '11
16 Dec '11
Author: sletellier
Date: 2011-12-16 16:54:27 +0100 (Fri, 16 Dec 2011)
New Revision: 7
Url: http://forge.codelutin.com/repositories/revision/jmexico/7
Log:
Init jaxx ui
Added:
trunk/jmexico-swing-editor/src/main/java/fr/
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/RunMexico.java
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx
trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java
trunk/jmexico-swing-editor/src/main/resources/log4j.properties
Modified:
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/InputDesignParser.java
trunk/jmexico-swing-editor/pom.xml
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java 2011-12-16 15:24:26 UTC (rev 6)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java 2011-12-16 15:54:27 UTC (rev 7)
@@ -76,8 +76,8 @@
import static fr.reseaumexico.model.MexicoXmlConstant.LEVEL_WEIGHT;
/**
-* @author sletellier <letellier(a)codelutin.com>
-*/
+ * @author sletellier <letellier(a)codelutin.com>
+ */
public class ExperimentDesignParser extends MexicoXmlParser<ExperimentDesign> {
protected Map<String, Factor> factors;
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/InputDesignParser.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/InputDesignParser.java 2011-12-16 15:24:26 UTC (rev 6)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/InputDesignParser.java 2011-12-16 15:54:27 UTC (rev 7)
@@ -52,8 +52,8 @@
import static fr.reseaumexico.model.MexicoXmlConstant.SCENARIO_ORDER_NUMBER;
/**
-* @author sletellier <letellier(a)codelutin.com>
-*/
+ * @author sletellier <letellier(a)codelutin.com>
+ */
public class InputDesignParser extends MexicoXmlParser<InputDesign> {
protected ExperimentDesignParser experimentDesignParser;
Modified: trunk/jmexico-swing-editor/pom.xml
===================================================================
--- trunk/jmexico-swing-editor/pom.xml 2011-12-16 15:24:26 UTC (rev 6)
+++ trunk/jmexico-swing-editor/pom.xml 2011-12-16 15:54:27 UTC (rev 7)
@@ -46,6 +46,12 @@
<artifactId>commons-logging</artifactId>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/RunMexico.java
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/RunMexico.java (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/RunMexico.java 2011-12-16 15:54:27 UTC (rev 7)
@@ -0,0 +1,55 @@
+/*
+ * #%L
+ * JMexico :: Swing Editor
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Réseau Mexico, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package fr.reseaumexico.editor;
+
+import fr.reseaumexico.editor.ui.MexicoMainUIHandler;
+import fr.reseaumexico.editor.ui.MexicoMainUI;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.ErrorDialogUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author sletellier <letellier(a)codelutin.com>
+ */
+public class RunMexico {
+
+ /** Logger */
+ private static Log log = LogFactory.getLog(RunMexico.class);
+
+ public static void main(String[] args) {
+
+ try {
+ JAXXInitialContext jaxxContext = new JAXXInitialContext();
+ MexicoMainUIHandler mainHandler = new MexicoMainUIHandler();
+
+ MexicoMainUI mainUI = mainHandler.initUI(jaxxContext);
+ } catch (Exception eee) {
+ log.error(eee.getMessage(), eee);
+ ErrorDialogUI.showError(eee);
+ System.exit(1);
+ }
+ }
+}
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUI.jaxx 2011-12-16 15:54:27 UTC (rev 7)
@@ -0,0 +1,31 @@
+<!--
+ #%L
+ JMexico :: Swing Editor
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Réseau Mexico, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+<JFrame id='mainFrame' decorator='help'
+ width='800' height='800'
+ onWindowClosing='getHandler().closeApplication(this)'>
+
+ <MexicoMainUIHandler id="handler"
+ initializer='getContextValue(MexicoMainUIHandler.class)'/>
+</JFrame>
Added: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java
===================================================================
--- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java (rev 0)
+++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/MexicoMainUIHandler.java 2011-12-16 15:54:27 UTC (rev 7)
@@ -0,0 +1,58 @@
+/*
+ * #%L
+ * JMexico :: Swing Editor
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Réseau Mexico, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package fr.reseaumexico.editor.ui;
+
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.ErrorDialogUI;
+
+/**
+ * Handler of main UI
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class MexicoMainUIHandler {
+
+ public void closeApplication(MexicoMainUI ui) {
+ ui.dispose();
+ }
+
+ public MexicoMainUI initUI(JAXXInitialContext context) {
+
+ // share handler
+ context.add(this);
+
+ // construt main UI
+ MexicoMainUI ui = new MexicoMainUI(context);
+
+ // display
+ ui.setVisible(true);
+
+ // synch to error dialog
+ ErrorDialogUI.init(ui);
+
+ return ui;
+ }
+}
Added: trunk/jmexico-swing-editor/src/main/resources/log4j.properties
===================================================================
--- trunk/jmexico-swing-editor/src/main/resources/log4j.properties (rev 0)
+++ trunk/jmexico-swing-editor/src/main/resources/log4j.properties 2011-12-16 15:54:27 UTC (rev 7)
@@ -0,0 +1,34 @@
+###
+# #%L
+# JMexico :: Swing Editor
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2011 Réseau Mexico, Codelutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+
+# Console output
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+
+# mexicos
+log4j.logger.fr.reseaumexico.editor=INFO
1
0
r6 - in trunk/jmexico-model/src/main: java/fr/reseaumexico/model java/fr/reseaumexico/model/parser java/fr/reseaumexico/model/writer xmi
by sletellier@users.forge.codelutin.com 16 Dec '11
by sletellier@users.forge.codelutin.com 16 Dec '11
16 Dec '11
Author: sletellier
Date: 2011-12-16 16:24:26 +0100 (Fri, 16 Dec 2011)
New Revision: 6
Url: http://forge.codelutin.com/repositories/revision/jmexico/6
Log:
- Change model to add multiple levels and distributionParameters
- Apply modification on writer and parser
Modified:
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/MexicoXmlConstant.java
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java
trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/ExperimentDesignXmlWriter.java
trunk/jmexico-model/src/main/xmi/mexico.zargo
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/MexicoXmlConstant.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/MexicoXmlConstant.java 2011-12-16 10:34:15 UTC (rev 5)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/MexicoXmlConstant.java 2011-12-16 15:24:26 UTC (rev 6)
@@ -24,6 +24,8 @@
*/
package fr.reseaumexico.model;
+import java.beans.Introspector;
+
/**
* Regroup all mexico xml constants tags
*
@@ -32,31 +34,37 @@
*/
public class MexicoXmlConstant {
- public static final String EXPERIMENT_DESIGN = ExperimentDesign.class.getSimpleName().toLowerCase();
+ public static final String EXPERIMENT_DESIGN = Introspector.decapitalize(ExperimentDesign.class.getSimpleName());
public static final String EXPERIMENT_DESIGN_DATE = ExperimentDesign.PROPERTY_DATE;
public static final String EXPERIMENT_DESIGN_ID = ExperimentDesign.PROPERTY_ID;
public static final String EXPERIMENT_DESIGN_AUTHOR = ExperimentDesign.PROPERTY_AUTHOR;
public static final String EXPERIMENT_DESIGN_LICENCE = ExperimentDesign.PROPERTY_LICENCE;
public static final String EXPERIMENT_DESIGN_DESCRIPTION = ExperimentDesign.PROPERTY_DESCRIPTION;
public static final String FACTORS = ExperimentDesign.PROPERTY_FACTORS;
- public static final String FACTOR = Factor.class.getSimpleName().toLowerCase();
+ public static final String FACTOR = Introspector.decapitalize(Factor.class.getSimpleName());
public static final String FACTOR_ID = Factor.PROPERTY_ID;
public static final String FACTOR_NAME = Factor.PROPERTY_NAME;
public static final String FACTOR_UNIT = Factor.PROPERTY_UNIT;
public static final String FACTOR_DESCRIPTION = Factor.PROPERTY_DESCRIPTION;
public static final String DOMAIN = Factor.PROPERTY_DOMAIN;
public static final String DOMAIN_NAME = Domain.PROPERTY_NAME;
- public static final String DOMAIN_DISTRIBUTION_PARAMETER = Domain.PROPERTY_DISTRIBUTION_PARAMETER;
- public static final String DOMAIN_LEVEL = Domain.PROPERTY_LEVEL;
+ public static final String DOMAIN_DISTRIBUTION_NAME = Domain.PROPERTY_DISTRIBUTION_NAME;
+ public static final String DOMAIN_DISTRIBUTION_PARAMETER = Introspector.decapitalize(DistributionParameter.class.getSimpleName());
+ public static final String DISTRIBUTION_PARAMETER_NAME = DistributionParameter.PROPERTY_NAME;
+ public static final String DISTRIBUTION_PARAMETER_VALUE = DistributionParameter.PROPERTY_VALUE;
+ public static final String DISTRIBUTION_PARAMETER_VALUE_TYPE = DistributionParameter.PROPERTY_VALUE_TYPE;
+ public static final String DOMAIN_LEVEL = Introspector.decapitalize(Level.class.getSimpleName());
+ public static final String LEVEL_VALUE = Level.PROPERTY_VALUE;
+ public static final String LEVEL_WEIGHT = Level.PROPERTY_WEIGHT;
public static final String DOMAIN_VALUE_TYPE = Domain.PROPERTY_VALUE_TYPE;
public static final String DOMAIN_NOMINAL_VALUE = Domain.PROPERTY_NOMINAL_VALUE;
- public static final String FEATURE = Feature.class.getSimpleName().toLowerCase();
+ public static final String FEATURE = Introspector.decapitalize(Feature.class.getSimpleName());
public static final String FEATURE_NAME = Feature.PROPERTY_NAME;
public static final String FEATURE_VALUE = Feature.PROPERTY_VALUE;
public static final String FEATURE_VALUE_TYPE = Feature.PROPERTY_VALUE_TYPE;
- public static final String INPUT_DESIGN = InputDesign.class.getSimpleName().toLowerCase();
+ public static final String INPUT_DESIGN = Introspector.decapitalize(InputDesign.class.getSimpleName());
public static final String INPUT_DESIGN_DATE = InputDesign.PROPERTY_DATE;
- public static final String SCENARIO = Scenario.class.getSimpleName().toLowerCase();
+ public static final String SCENARIO = Introspector.decapitalize(Scenario.class.getSimpleName());
public static final String SCENARIO_NAME = Scenario.PROPERTY_NAME;
public static final String SCENARIO_ORDER_NUMBER = Scenario.PROPERTY_ORDER_NUMBER;
public static final String SCENARIO_FACTOR_VALUES = Scenario.PROPERTY_FACTOR_VALUES;
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java 2011-12-16 10:34:15 UTC (rev 5)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/parser/ExperimentDesignParser.java 2011-12-16 15:24:26 UTC (rev 6)
@@ -26,6 +26,8 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import fr.reseaumexico.model.DistributionParameter;
+import fr.reseaumexico.model.DistributionParameterImpl;
import fr.reseaumexico.model.Domain;
import fr.reseaumexico.model.DomainImpl;
import fr.reseaumexico.model.ExperimentDesign;
@@ -34,6 +36,8 @@
import fr.reseaumexico.model.FactorImpl;
import fr.reseaumexico.model.Feature;
import fr.reseaumexico.model.FeatureImpl;
+import fr.reseaumexico.model.Level;
+import fr.reseaumexico.model.LevelImpl;
import fr.reseaumexico.model.MexicoTechnicalException;
import fr.reseaumexico.model.ValueType;
import org.xmlpull.v1.XmlPullParser;
@@ -47,7 +51,11 @@
import java.util.Map;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN;
+import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_DISTRIBUTION_NAME;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_DISTRIBUTION_PARAMETER;
+import static fr.reseaumexico.model.MexicoXmlConstant.DISTRIBUTION_PARAMETER_NAME;
+import static fr.reseaumexico.model.MexicoXmlConstant.DISTRIBUTION_PARAMETER_VALUE;
+import static fr.reseaumexico.model.MexicoXmlConstant.DISTRIBUTION_PARAMETER_VALUE_TYPE;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_LEVEL;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_NAME;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_NOMINAL_VALUE;
@@ -64,6 +72,8 @@
import static fr.reseaumexico.model.MexicoXmlConstant.FEATURE_NAME;
import static fr.reseaumexico.model.MexicoXmlConstant.FEATURE_VALUE;
import static fr.reseaumexico.model.MexicoXmlConstant.FEATURE_VALUE_TYPE;
+import static fr.reseaumexico.model.MexicoXmlConstant.LEVEL_VALUE;
+import static fr.reseaumexico.model.MexicoXmlConstant.LEVEL_WEIGHT;
/**
* @author sletellier <letellier(a)codelutin.com>
@@ -187,30 +197,79 @@
return factor;
}
- protected Domain parseDomain(XmlPullParser parser) throws XmlPullParserException {
+ protected Domain parseDomain(XmlPullParser parser) throws XmlPullParserException, IOException {
Domain domain = new DomainImpl();
// name
- String name = parser.getAttributeValue(null, DOMAIN_NAME);
- domain.setName(name);
+ String domaineName = parser.getAttributeValue(null, DOMAIN_NAME);
+ domain.setName(domaineName);
- // distributionParameter
- String distributionParameter = parser.getAttributeValue(null, DOMAIN_DISTRIBUTION_PARAMETER);
- domain.setDistributionParameter(distributionParameter);
+ // distributionName
+ String distributionName = parser.getAttributeValue(null, DOMAIN_DISTRIBUTION_NAME);
+ domain.setDistributionName(distributionName);
- // level
- String level = parser.getAttributeValue(null, DOMAIN_LEVEL);
- domain.setLevel(Integer.parseInt(level));
-
// valueType
- String valueType = parser.getAttributeValue(null, DOMAIN_VALUE_TYPE);
- domain.setValueType(ValueType.valueOf(valueType));
+ String domaineValueType = parser.getAttributeValue(null, DOMAIN_VALUE_TYPE);
+ domain.setValueType(ValueType.valueOf(domaineValueType));
// nominaleValue
// TODO sletellier 20111215 : take care of type
String nominaleValue = parser.getAttributeValue(null, DOMAIN_NOMINAL_VALUE);
domain.setNominalValue(nominaleValue);
+ // distributionParameters
+ int eventType = parser.nextTag();
+ if (eventType == XmlPullParser.START_TAG &&
+ parserEqual(parser, DOMAIN_DISTRIBUTION_PARAMETER)) {
+
+ List<DistributionParameter> distributionParameters = Lists.newArrayList();
+ while (parserEqual(parser, DOMAIN_DISTRIBUTION_PARAMETER)) {
+ DistributionParameter distributionParameter = new DistributionParameterImpl();
+
+ // name
+ String name = parser.getAttributeValue(null, DISTRIBUTION_PARAMETER_NAME);
+ distributionParameter.setName(name);
+
+ // value
+ // TODO sletellier 20111215 : take care of type
+ String value = parser.getAttributeValue(null, DISTRIBUTION_PARAMETER_VALUE);
+ distributionParameter.setValue(value);
+
+ // valueType
+ String valueType = parser.getAttributeValue(null, DISTRIBUTION_PARAMETER_VALUE_TYPE);
+ distributionParameter.setValueType(ValueType.valueOf(valueType));
+
+ distributionParameters.add(distributionParameter);
+
+ // read close tag
+ parser.nextTag();
+
+ // read next start tag
+ eventType = parser.nextTag();
+ }
+ domain.setDistributionParameters(distributionParameters);
+ }
+
+ // level
+ if (eventType == XmlPullParser.START_TAG &&
+ parserEqual(parser, DOMAIN_LEVEL)) {
+
+ List<Level> levels = Lists.newArrayList();
+ while (parserEqual(parser, DOMAIN_LEVEL)) {
+ Level level = new LevelImpl();
+
+ // value
+ String value = parser.getAttributeValue(null, LEVEL_VALUE);
+ level.setValue(value);
+
+ // weight
+ String weight = parser.getAttributeValue(null, LEVEL_WEIGHT);
+ level.setWeight(Integer.valueOf(weight));
+
+ levels.add(level);
+ }
+ domain.setLevels(levels);
+ }
return domain;
}
Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/ExperimentDesignXmlWriter.java
===================================================================
--- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/ExperimentDesignXmlWriter.java 2011-12-16 10:34:15 UTC (rev 5)
+++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/writer/ExperimentDesignXmlWriter.java 2011-12-16 15:24:26 UTC (rev 6)
@@ -24,9 +24,11 @@
*/
package fr.reseaumexico.model.writer;
+import fr.reseaumexico.model.DistributionParameter;
import fr.reseaumexico.model.Domain;
import fr.reseaumexico.model.ExperimentDesign;
import fr.reseaumexico.model.Factor;
+import fr.reseaumexico.model.Level;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
@@ -35,8 +37,14 @@
import java.util.Date;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN;
+import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_DISTRIBUTION_NAME;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_DISTRIBUTION_PARAMETER;
+import static fr.reseaumexico.model.MexicoXmlConstant.DISTRIBUTION_PARAMETER_NAME;
+import static fr.reseaumexico.model.MexicoXmlConstant.DISTRIBUTION_PARAMETER_VALUE;
+import static fr.reseaumexico.model.MexicoXmlConstant.DISTRIBUTION_PARAMETER_VALUE_TYPE;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_LEVEL;
+import static fr.reseaumexico.model.MexicoXmlConstant.LEVEL_VALUE;
+import static fr.reseaumexico.model.MexicoXmlConstant.LEVEL_WEIGHT;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_NAME;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_NOMINAL_VALUE;
import static fr.reseaumexico.model.MexicoXmlConstant.DOMAIN_VALUE_TYPE;
@@ -124,10 +132,30 @@
if (domain != null) {
XmlNode domainXmlNode = XmlNode.createElement(factorXmlNode, DOMAIN);
addParameter(domainXmlNode, DOMAIN_NAME, domain.getName());
- addParameter(domainXmlNode, DOMAIN_DISTRIBUTION_PARAMETER, domain.getDistributionParameter());
- addParameter(domainXmlNode, DOMAIN_LEVEL, String.valueOf(domain.getLevel()));
addParameter(domainXmlNode, DOMAIN_VALUE_TYPE, domain.getValueType());
addParameter(domainXmlNode, DOMAIN_NOMINAL_VALUE, domain.getNominalValue());
+ addParameter(domainXmlNode, DOMAIN_DISTRIBUTION_NAME, domain.getDistributionName());
+
+ // distributionParameters
+ Collection<DistributionParameter> distributionParameters = domain.getDistributionParameters();
+ if (distributionParameters != null) {
+ for (DistributionParameter distributionParameter : distributionParameters) {
+ XmlNode distributionParameterXmlNode = XmlNode.createElement(domainXmlNode, DOMAIN_DISTRIBUTION_PARAMETER);
+ addParameter(distributionParameterXmlNode, DISTRIBUTION_PARAMETER_NAME, distributionParameter.getName());
+ addParameter(distributionParameterXmlNode, DISTRIBUTION_PARAMETER_VALUE, distributionParameter.getValue());
+ addParameter(distributionParameterXmlNode, DISTRIBUTION_PARAMETER_VALUE_TYPE, distributionParameter.getValueType());
+ }
+ }
+
+ // levels
+ Collection<Level> levels = domain.getLevels();
+ if (levels != null) {
+ for (Level level : levels) {
+ XmlNode distributionParameterXmlNode = XmlNode.createElement(domainXmlNode, DOMAIN_LEVEL);
+ addParameter(distributionParameterXmlNode, LEVEL_VALUE, level.getValue());
+ addParameter(distributionParameterXmlNode, LEVEL_WEIGHT, level.getWeight());
+ }
+ }
}
// features
Modified: trunk/jmexico-model/src/main/xmi/mexico.zargo
===================================================================
(Binary files differ)
1
0
Author: tchemit
Date: 2011-12-16 11:34:15 +0100 (Fri, 16 Dec 2011)
New Revision: 5
Url: http://forge.codelutin.com/repositories/revision/jmexico/5
Log:
tune forge
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-12-16 09:25:14 UTC (rev 4)
+++ trunk/pom.xml 2011-12-16 10:34:15 UTC (rev 5)
@@ -72,6 +72,7 @@
<properties>
+ <platform>forge.codelutin.com</platform>
<projectId>jmexico</projectId>
<!-- libraries version -->
1
0