r1025 - in trunk: . coser-business/src/main/java/fr/ifremer/coser/control coser-business/src/main/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/control coser-ui/src/main/resources/i18n
Author: echatellier Date: 2012-07-19 11:36:52 +0200 (Thu, 19 Jul 2012) New Revision: 1025 Url: http://forge.codelutin.com/repositories/revision/coser/1025 Log: fixes #1320: Regrouper les warning capture/taille par esp?\195?\168ce Added: trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties trunk/pom.xml Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric + * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -36,27 +36,9 @@ * Last update : $Date$ * By : $Author$ */ -public class DiffCatchLengthControlError extends ControlError implements Comparable<DiffCatchLengthControlError> { +public class DiffCatchLengthControlError extends SpeciesControlError { - /** serialVersionUID. */ - private static final long serialVersionUID = -3254763296138201677L; + /** serialVersionUID */ + private static final long serialVersionUID = 6646855823928956144L; - protected String species; - - public String getSpecies() { - return species; - } - - public void setSpecies(String species) { - this.species = species; - } - - @Override - public int compareTo(DiffCatchLengthControlError o) { - int result = -1; - if (species != null) { - result = species.compareTo(o.species); - } - return result; - } } Added: trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java (rev 0) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -0,0 +1,63 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.coser.control; + +/** + * Erreur de controle specifique pour les différences des nombres entre + * les captures et les tailles pour utilisation typée de cette erreur + * (export html) et information supplémentaires (especes). + * + * @author chatellier + * @version $Revision$ + * @since 1.3 + * + * Last update : $Date$ + * By : $Author$ + */ +public class SpeciesControlError extends ControlError implements Comparable<SpeciesControlError> { + + /** serialVersionUID. */ + private static final long serialVersionUID = -3254763296138201677L; + + protected String species; + + public String getSpecies() { + return species; + } + + public void setSpecies(String species) { + this.species = species; + } + + @Override + public int compareTo(SpeciesControlError o) { + int result = -1; + if (species != null) { + result = species.compareTo(o.species); + } + return result; + } +} Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/control/SpeciesControlError.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -66,6 +66,7 @@ import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.control.ControlError; import fr.ifremer.coser.control.DiffCatchLengthControlError; +import fr.ifremer.coser.control.SpeciesControlError; import fr.ifremer.coser.data.AbstractDataEntity; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.data.Haul; @@ -212,7 +213,7 @@ // valide chaque category List<ControlError> validationErrors = new ArrayList<ControlError>(); - for (Category category : Category.values()) { + /*for (Category category : Category.values()) { if (category.isDataCategory()) { // validation de la category seule (generique) List<ControlError> categoryErrors = validateCategoryXWork(control, category, progress); @@ -228,7 +229,7 @@ } progress.nextStep(); } - } + }*/ // validation entre catch et length (specific) List<? extends ControlError> diffCatchLengthErrors = validateDiffCatchLength(control, progress); @@ -593,7 +594,7 @@ progress.setTotal(total); } - List<DiffCatchLengthControlError> validationErrors = new ArrayList<DiffCatchLengthControlError>(); + List<SpeciesControlError> validationErrors = new ArrayList<SpeciesControlError>(); // data necessary for compute SortedSet<String> setYear = new TreeSet<String>(); @@ -715,15 +716,14 @@ // warning si taille = 0 et captures différent de 0 // nomespece, année(s) avec absence de taille if (lengthNumber == 0 && catchNumber > 0 && !missingYearLengthSpecies.contains(species)) { - DiffCatchLengthControlError error = new DiffCatchLengthControlError(); + SpeciesControlError error = new SpeciesControlError(); error.setSpecies(species); error.setLevel(ValidationLevel.WARNING); error.setMessage(_("coser.business.control.error.diffCatchLengthMissingYear")); error.setDetailMessage(_("coser.business.control.error.diffCatchLengthMissingYearDetail", species)); validationErrors.add(error); missingYearLengthSpecies.add(species); - } - else { + } else { // diff entre 4 et 5 = (5-4) * 100 / 5 double min = Math.min(catchNumber, lengthNumber); // si c'est 0, ou absence de catures, ce n'est pas une erreur @@ -1216,7 +1216,7 @@ // especes de tailles doivent etre dans especes de captures (fatal) Collection<String> missingCatchSpeciesNames = CollectionUtils.subtract(lengthSpeciesNames, catchSpeciesNames); for (String missingCatchSpeciesName : missingCatchSpeciesNames) { - DiffCatchLengthControlError error = new DiffCatchLengthControlError(); + SpeciesControlError error = new SpeciesControlError(); error.setLevel(ValidationLevel.FATAL); error.setSpecies(missingCatchSpeciesName); error.setMessage(_("coser.business.control.error.missingCatchSpeciesFromLength")); @@ -1230,7 +1230,7 @@ // especes de captures doivent etre dans especes de tailles (warning) Collection<String> missingLengthSpeciesNames = CollectionUtils.subtract(catchSpeciesNames, lengthSpeciesNames); for (String missingLengthSpeciesName : missingLengthSpeciesNames) { - DiffCatchLengthControlError error = new DiffCatchLengthControlError(); + SpeciesControlError error = new SpeciesControlError(); error.setLevel(ValidationLevel.WARNING); error.setSpecies(missingLengthSpeciesName); error.setMessage(_("coser.business.control.error.missingLengthSpeciesFromCatch")); Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -92,11 +92,11 @@ import fr.ifremer.coser.control.ControlError; import fr.ifremer.coser.control.ControlErrorGroup; import fr.ifremer.coser.control.DiffCatchLengthControlError; +import fr.ifremer.coser.control.SpeciesControlError; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.data.Length; import fr.ifremer.coser.storage.DataStorage; import fr.ifremer.coser.storage.MemoryDataStorage; -import freemarker.template.TemplateException; /** * Publication service (charts, reports, export, pdf...) @@ -347,8 +347,8 @@ errorGroup.add(group); } - if (validationError instanceof DiffCatchLengthControlError) { - DiffCatchLengthControlError diffError = (DiffCatchLengthControlError)validationError; + if (validationError instanceof SpeciesControlError) { + SpeciesControlError diffError = (SpeciesControlError)validationError; speciesGraph.add(diffError.getSpecies()); } childErrors.add(validationError); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlErrorTreeRenderer.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -33,10 +33,13 @@ import javax.swing.tree.DefaultTreeCellRenderer; import jaxx.runtime.validator.swing.SwingValidatorUtil; + +import org.jdesktop.swingx.treetable.TreeTableNode; + import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.CoserConstants.ValidationLevel; +import fr.ifremer.coser.control.ControlError; import fr.ifremer.coser.control.ControlErrorGroup; -import fr.ifremer.coser.control.ControlError; /** * Renderer pour le table des erreurs globales. @@ -73,18 +76,19 @@ GlobalControlErrorModel model = (GlobalControlErrorModel)tree.getModel(); JLabel component = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + Object userObject = ((TreeTableNode)value).getUserObject(); ImageIcon icon = null; String text = null; String tooltipText = null; - if (value instanceof String) { - text = _((String)value) + " (" + model.getChildCount(value) + ")"; + if (userObject instanceof String) { + text = _((String)userObject) + " (" + model.getChildCount(value) + ")"; } - else if (value instanceof Category) { - text = _(((Category)value).getTranslationKey()) + " (" + model.getChildCount(value) + ")"; + else if (userObject instanceof Category) { + text = _(((Category)userObject).getTranslationKey()) + " (" + model.getChildCount(value) + ")"; } - else if (value instanceof ControlErrorGroup) { - ControlErrorGroup validationErrorGroup = (ControlErrorGroup)value; + else if (userObject instanceof ControlErrorGroup) { + ControlErrorGroup validationErrorGroup = (ControlErrorGroup)userObject; ValidationLevel level = validationErrorGroup.getValidationLevel(); switch (level) { case FATAL: @@ -104,8 +108,8 @@ String message = validationErrorGroup.getMessage(); text = _(message) + " (" + model.getChildCount(value) + ")"; } - else if (value instanceof ControlError) { - ControlError validationError = (ControlError)value; + else if (userObject instanceof ControlError) { + ControlError validationError = (ControlError)userObject; ValidationLevel level = validationError.getLevel(); switch (level) { case FATAL: Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -24,6 +24,7 @@ package fr.ifremer.coser.ui.control; import static org.nuiton.i18n.I18n._; +import static org.nuiton.i18n.I18n.n_; import java.awt.BorderLayout; import java.awt.GridBagConstraints; @@ -36,6 +37,7 @@ import java.beans.Introspector; import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -67,6 +69,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTreeTable; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.nuiton.widget.SwingSession; @@ -81,6 +86,7 @@ import fr.ifremer.coser.control.ControlError; import fr.ifremer.coser.control.ControlErrorGroup; import fr.ifremer.coser.control.DiffCatchLengthControlError; +import fr.ifremer.coser.control.SpeciesControlError; import fr.ifremer.coser.data.AbstractDataEntity; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.data.Haul; @@ -452,10 +458,12 @@ throw new CoserException("Can't validate data", ex); } } + + }; task.execute(); } - + /** * Called when selection change to display selected bean * in edition panel. @@ -514,18 +522,19 @@ */ public void showSelectedError(ControlView view, TreeSelectionEvent event) { TreePath selectedError = view.getGlobalControlErrorTable().getTreeSelectionModel().getSelectionPath(); - if (selectedError != null) { - Object[] pathWay = selectedError.getPath(); + if (selectedError != null && selectedError.getPathCount() >= 3) { + TreeTableNode cateNode = (TreeTableNode)selectedError.getPathComponent(1); + Object cateObject = cateNode.getUserObject(); + TreeTableNode lastNode = (TreeTableNode)selectedError.getLastPathComponent(); + Object userObject = lastNode.getUserObject(); - // 2 = validation group (middle level) - // 3 = validation error (last level) - if (pathWay.length == 4 && pathWay[1] instanceof Category) { - Category category = (Category)pathWay[1]; + if (cateObject instanceof Category && userObject instanceof ControlError) { + Category category = (Category)cateObject; // swap category view.getCategoryComboBoxModel().setSelectedItem(category); - - ControlError error = (ControlError)pathWay[3]; + + ControlError error = (ControlError)userObject; List<String> errorLineNumbers = error.getLineNumbers(); // peut être vide, si l'erreur ne porte pas sur un bean en particulier if (errorLineNumbers != null) { @@ -555,11 +564,11 @@ /** * Affiche le menu contextuel de l'arbre qui contient les erreurs de * validation globales ou les graphes de comparaison captures/taille - * dans le cas d'un double clic sur une {@link DiffCatchLengthControlError}. + * dans le cas d'un double clic sur une {@link SpeciesControlError}. * * @param controlView view * @param event mouse event - * @see DiffCatchLengthControlError + * @see SpeciesControlError */ public void globalErrorTableMouseClicked(final ControlView controlView, MouseEvent event) { @@ -573,20 +582,22 @@ JPopupMenu popupMenu = new JPopupMenu(); // plusieurs lignes selectionnées et pas la premiere colonne (Line index) - if (selectedError != null) { - Object[] pathWay = selectedError.getPath(); + if (selectedError != null && selectedError.getPathCount() >= 3) { - // 2 = validation group (middle level) - if (pathWay.length == 3) { - if (pathWay[1] instanceof Category) { - final Category category = (Category)pathWay[1]; - final ControlErrorGroup validationGroup = (ControlErrorGroup)pathWay[2]; - + TreeTableNode cateNode = (TreeTableNode)selectedError.getPathComponent(1); + Object cateObject = cateNode.getUserObject(); + + if (cateObject instanceof Category) { // ca peut être 'tout' en String + final Category category = (Category)cateObject; + final TreeTableNode lastNode = (TreeTableNode)selectedError.getLastPathComponent(); + + // selectall n'a d'interet que pour les groupes d'erreurs + if (lastNode.getChildCount() > 0) { JMenuItem replaceMenu = new JMenuItem(_("coser.ui.control.globalErrorMenuSelectAll")); replaceMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - selectAllErrorGroupLines(controlView, category, validationGroup); + selectAllErrorGroupLines(controlView, category, lastNode); } }); popupMenu.add(replaceMenu); @@ -617,10 +628,10 @@ // si la selection est une instance de DiffCatchLengthControlError // affiche le graphe avec l'espece correspondante if (selectedError != null) { - Object[] pathWay = selectedError.getPath(); - Object lastComponent = pathWay[pathWay.length - 1]; - if (lastComponent instanceof DiffCatchLengthControlError) { - DiffCatchLengthControlError error = (DiffCatchLengthControlError)lastComponent; + TreeTableNode lastComponent = (TreeTableNode)selectedError.getLastPathComponent(); + Object userObject = lastComponent.getUserObject(); + if (userObject instanceof SpeciesControlError) { + SpeciesControlError error = (SpeciesControlError)userObject; String species = error.getSpecies(); displayCompareNumberCatchGraph(controlView, species); } @@ -632,38 +643,64 @@ * Selectionne toutes les lignes associés au erreur d'un groupe d'erreur. * * @param controlView controlView - * @param validationGroup validationGroup + * @param category la categorie pour switcher les tables + * @param lastNode validationGroup */ - protected void selectAllErrorGroupLines(ControlView controlView, Category category, ControlErrorGroup validationGroup) { + protected void selectAllErrorGroupLines(ControlView controlView, Category category, TreeTableNode lastNode) { // swap category controlView.getCategoryComboBoxModel().setSelectedItem(category); // select all lines + JTable displayedTable = getControlDataTable(controlView); + ListSelectionModel selectionModel = displayedTable.getSelectionModel(); + selectionModel.clearSelection(); + selectAllErrorGroupLines(controlView, lastNode, true); + } + + /** + * Methode recursive qui selection toutes les lignes correspondant à un + * groupe d'erreurs. + * + * @param controlView + * @param lastNode + * @param scrollToVisible allow to scroll to visible + */ + protected void selectAllErrorGroupLines(ControlView controlView, TreeTableNode lastNode, boolean scrollToVisible) { GlobalControlErrorModel model = controlView.getGlobalControlErrorModel(); JTable displayedTable = getControlDataTable(controlView); ControlTableModel tableModel = (ControlTableModel)displayedTable.getModel(); ListSelectionModel selectionModel = displayedTable.getSelectionModel(); - selectionModel.clearSelection(); - boolean first = true; - int childCount = model.getChildCount(validationGroup); + + boolean first = scrollToVisible; + int childCount = model.getChildCount(lastNode); for (int indexChild = 0 ; indexChild < childCount ; ++indexChild) { - ControlError validationError = (ControlError)model.getChild(validationGroup, indexChild); - List<String> errorLineNumbers = validationError.getLineNumbers(); + TreeTableNode childNode = (TreeTableNode)model.getChild(lastNode, indexChild); + Object userObject = childNode.getUserObject(); - for (String errorLineNumber : errorLineNumbers) { - int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber); + if (userObject instanceof ControlErrorGroup) { // recursive + selectAllErrorGroupLines(controlView, childNode, first); + first = false; + } else if (userObject instanceof ControlError) { + ControlError validationError = (ControlError)userObject; + List<String> errorLineNumbers = validationError.getLineNumbers(); + + for (String errorLineNumber : errorLineNumbers) { + int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber); - // ca peut arriver si la ligne a été supprimée - if (errorLineIndex >= 0) { - selectionModel.addSelectionInterval(errorLineIndex, errorLineIndex); - if (first) { - scrollToVisible(displayedTable, errorLineIndex, 0); - first = false; + // ca peut arriver si la ligne a été supprimée + if (errorLineIndex >= 0) { + selectionModel.addSelectionInterval(errorLineIndex, errorLineIndex); + if (first) { + scrollToVisible(displayedTable, errorLineIndex, 0); + first = false; + } } } } } } + + /** * Scroll le viewport de la table à la ligne demandée. Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalControlErrorModel.java 2012-07-19 09:36:52 UTC (rev 1025) @@ -3,7 +3,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -26,21 +26,19 @@ import static org.nuiton.i18n.I18n._; import static org.nuiton.i18n.I18n.n_; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.jdesktop.swingx.treetable.AbstractTreeTableModel; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; -import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.CoserConstants.ValidationLevel; -import fr.ifremer.coser.control.ControlErrorGroup; import fr.ifremer.coser.control.ControlError; +import fr.ifremer.coser.control.ControlErrorGroup; +import fr.ifremer.coser.control.DiffCatchLengthControlError; /** * Global validation table model. @@ -51,23 +49,19 @@ * Last update : $Date$ * By : $Author$ */ -public class GlobalControlErrorModel extends AbstractTreeTableModel { +public class GlobalControlErrorModel extends DefaultTreeTableModel { protected List<ControlError> controlErrors; - protected List<Object> controlErrorCategory; - protected Map<Object, List<ControlErrorGroup>> controlCategoryChild; - protected Map<ControlErrorGroup, List<ControlError>> controlErrorsChilds; protected Set<Object> checkedControlErrors; public GlobalControlErrorModel() { - super(1); + super(null); } public void setControlErrors(List<ControlError> controlErrors) { this.controlErrors = controlErrors; - getValidationErrorAsMaps(controlErrors); - modelSupport.fireNewRoot(); - + buildGlobalControlErrorTreeModel(controlErrors); + checkedControlErrors = new HashSet<Object>(); } public List<ControlError> getControlErrors() { @@ -75,60 +69,61 @@ } /** - * Convert error list to tree structure. + * Utilise une simple liste d'erreur issue du contôle pour en faire + * une représentation sous forme d'arbre pour l'utilisateur. * - * @param validationErrors list to convert + * @param errors errors list to render */ - protected void getValidationErrorAsMaps(List<ControlError> validationErrors) { + protected void buildGlobalControlErrorTreeModel(List<ControlError> validationErrors) { - controlCategoryChild = new HashMap<Object, List<ControlErrorGroup>>(); - controlErrorsChilds = new HashMap<ControlErrorGroup, List<ControlError>>(); + Map<Object, DefaultMutableTreeTableNode> nodeCache = new HashMap<Object, DefaultMutableTreeTableNode>(); + DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode(null); for (ControlError validationError : validationErrors) { - Object category = validationError.getCategory() == null ? n_("coser.ui.control.error.allCategories") : validationError.getCategory(); - List<ControlErrorGroup> errorGroup = controlCategoryChild.get(category); - if (errorGroup == null) { - errorGroup = new ArrayList<ControlErrorGroup>(); - controlCategoryChild.put(category, errorGroup); + + // definition du noeud categorie + DefaultMutableTreeTableNode categoryNode = nodeCache.get(category); + if (categoryNode == null) { + categoryNode = new DefaultMutableTreeTableNode(category); + root.add(categoryNode); + nodeCache.put(category, categoryNode); } - ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), validationError.getMessage()); - - List<ControlError> childErrors = controlErrorsChilds.get(group); - if (childErrors == null) { - childErrors = new ArrayList<ControlError>(); - controlErrorsChilds.put(group, childErrors); - errorGroup.add(group); + // definition du noeud de regroupement + // des erreurs de categories communes + DefaultMutableTreeTableNode parentNode = nodeCache.get(validationError.getMessage()); + if (parentNode == null) { + ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), validationError.getMessage()); + parentNode = new DefaultMutableTreeTableNode(group); + categoryNode.add(parentNode); + nodeCache.put(validationError.getMessage(), parentNode); } - - childErrors.add(validationError); - } - - controlErrorCategory = new ArrayList<Object>(controlCategoryChild.keySet()); - Collections.sort(controlErrorCategory, new Comparator<Object>() { - @Override - public int compare(Object o1, Object o2) { - int result = -1; - if (o1 instanceof String) { - if (o2 instanceof String) { - result = ((String)o1).compareTo((String)o2); - } + + // cas special pour les erreurs DiffCatchLengthControlError + // regroupement supplémentaire par espèce + if (validationError instanceof DiffCatchLengthControlError) { + DiffCatchLengthControlError diffCatchError = (DiffCatchLengthControlError)validationError; + String species = diffCatchError.getSpecies(); + String speciesCategory = _("coser.ui.control.error.diffcatchlenghtspecies", species); + + ControlErrorGroup group = new ControlErrorGroup(validationError.getCategory(), validationError.getLevel(), speciesCategory); + DefaultMutableTreeTableNode newParent = nodeCache.get(speciesCategory); + if (newParent == null) { + newParent = new DefaultMutableTreeTableNode(group); + parentNode.add(newParent); + nodeCache.put(speciesCategory, newParent); } - else if (o1 instanceof Category) { - if (o2 instanceof Category) { - result = ((Category)o1).compareTo((Category)o2); - } - } - return result; + parentNode = newParent; } - - }); - for (List<ControlErrorGroup> groups : controlCategoryChild.values()) { - Collections.sort(groups); + + // ajout de l'erreur dans sa categories + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(validationError); + parentNode.add(node); } - checkedControlErrors = new HashSet<Object>(); + + setRoot(root); } /* @@ -188,73 +183,7 @@ return result; } - /* - * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int) - */ @Override - public Object getChild(Object parent, int index) { - - Object result = null; - - if (parent == getRoot()) { - result = controlErrorCategory.get(index); - } - else if (parent instanceof String || parent instanceof Category) { - result = controlCategoryChild.get(parent).get(index); - } - else if (parent instanceof ControlErrorGroup) { - List<ControlError> childError = controlErrorsChilds.get(parent); - result = childError.get(index); - } - - return result; - } - - /* - * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object) - */ - @Override - public int getChildCount(Object parent) { - int result = 0; - - if (parent == getRoot()) { - if (controlErrorCategory != null) { - result = controlErrorCategory.size(); - } - } - else if (parent instanceof String || parent instanceof Category) { - result = controlCategoryChild.get(parent).size(); - } - else if (parent instanceof ControlErrorGroup) { - List<ControlError> childError = controlErrorsChilds.get(parent); - result = childError.size(); - } - - return result; - } - - /* - * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object) - */ - @Override - public int getIndexOfChild(Object parent, Object child) { - int result = -1; - - if (parent == getRoot()) { - result = controlErrorCategory.indexOf(child); - } - else if (parent instanceof String || parent instanceof Category) { - result = controlCategoryChild.get(parent).indexOf(child); - } - else if (parent instanceof ControlErrorGroup) { - List<ControlError> childError = controlErrorsChilds.get(parent); - result = childError.indexOf(child); - } - - return result; - } - - @Override public boolean isCellEditable(Object node, int column) { boolean result = false; if (column == 1) { @@ -275,12 +204,10 @@ } // recursive check of sub errors - if (node instanceof String || node instanceof Category || node instanceof ControlErrorGroup) { - int childCount = getChildCount(node); - for (int i = 0 ; i < childCount; ++i) { - Object child = getChild(node, i); - setValueAt(value, child, column); - } + int childCount = getChildCount(node); + for (int i = 0 ; i < childCount; ++i) { + Object child = getChild(node, i); + setValueAt(value, child, column); } } } Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2012-07-19 09:36:52 UTC (rev 1025) @@ -35,6 +35,7 @@ coser.ui.control.dataMenuReplaceAll=Replace in %s in all data coser.ui.control.deleteLine=Delete line coser.ui.control.error.allCategories=All categories +coser.ui.control.error.diffcatchlenghtspecies=Differences between length and catch for %s coser.ui.control.global.message=Message coser.ui.control.globalErrorMenuGenerateHTML=Control report coser.ui.control.globalErrorMenuSelectAll=Select all lines Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties =================================================================== --- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2012-07-19 09:36:52 UTC (rev 1025) @@ -35,6 +35,7 @@ coser.ui.control.dataMenuReplaceAll=Remplacer dans %s pour toutes les lignes coser.ui.control.deleteLine=Supprimer la ligne coser.ui.control.error.allCategories=Toutes les catégories +coser.ui.control.error.diffcatchlenghtspecies=Différence entre les captures et taille pour %s coser.ui.control.global.message=Message coser.ui.control.globalErrorMenuGenerateHTML=Rapport de contrôle coser.ui.control.globalErrorMenuSelectAll=Sélectionner toutes les lignes Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-07-18 10:24:01 UTC (rev 1024) +++ trunk/pom.xml 2012-07-19 09:36:52 UTC (rev 1025) @@ -316,7 +316,7 @@ <roles> <role>Développeur</role> </roles> - <timezone>+2</timezone> + <timezone>Europe/Paris</timezone> </developer> <developer> <id>tchemit</id> @@ -326,7 +326,7 @@ <roles> <role>Développeur</role> </roles> - <timezone>+2</timezone> + <timezone>Europe/Paris</timezone> </developer> </developers>
participants (1)
-
echatellier@users.forge.codelutin.com