Author: chatellier Date: 2010-12-14 10:13:31 +0000 (Tue, 14 Dec 2010) New Revision: 402 Log: Affiche des graphiques associ?\195?\169 aux errors lors du double clic dans l'arbre Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx 2010-12-13 17:06:44 UTC (rev 401) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlGraphFrame.jaxx 2010-12-14 10:13:31 UTC (rev 402) @@ -22,7 +22,7 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JFrame title="coser.ui.graph.compareNumberCatchSize" name="catchLengthCompareFrame"> +<JFrame title="coser.ui.graph.compareNumberCatchLength" name="catchLengthCompareFrame"> <ControlHandler id="handler" javaBean="null" /> 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 2010-12-13 17:06:44 UTC (rev 401) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-12-14 10:13:31 UTC (rev 402) @@ -83,6 +83,7 @@ import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.control.ControlError; import fr.ifremer.coser.control.ControlErrorGroup; +import fr.ifremer.coser.control.DiffCatchLengthControlError; import fr.ifremer.coser.data.AbstractDataEntity; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.data.Haul; @@ -398,6 +399,13 @@ } try { + + // genere la liste des graphes a se moment + PublicationService publicationService = view.getContextValue(PublicationService.class); + Map<String, JFreeChart> charts = publicationService.getCompareCatchLengthGraph(project, project.getControl(), null); + view.setContextValue(charts, "CompareCatchLengthGraph"); + view.getCompareNumberCatchLengthButton().setEnabled(true); + // hack parce que impossible de faire un faire // sans que les colonnes soit redimentionnées view.getGlobalControlErrorTable().setAutoCreateColumnsFromModel(false); @@ -519,18 +527,22 @@ /** * Affiche le menu contextuel de l'arbre qui contient les erreurs de - * validation globales. + * validation globales ou les graphes de comparaison captures/taille + * dans le cas d'un double clic sur une {@link DiffCatchLengthControlError}. * * @param controlView view * @param event mouse event + * @see DiffCatchLengthControlError */ - public void showGlobalErrorTableContextMenu(final ControlView controlView, MouseEvent event) { + public void globalErrorTableMouseCLicked(final ControlView controlView, MouseEvent event) { - // clic contextuel - if (event.getButton() == MouseEvent.BUTTON3) { + int eventButton = event.getButton(); + + // clic contextuel (clic droit) + if (eventButton == MouseEvent.BUTTON3) { TreePath selectedError = controlView.getGlobalControlErrorTable().getTreeSelectionModel().getSelectionPath(); - JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.control.globalErrorMenuLabel")); + JPopupMenu popupMenu = new JPopupMenu(); // plusieurs lignes selectionnées et pas la premiere colonne (Line index) if (selectedError != null) { @@ -566,6 +578,23 @@ popupMenu.show(controlView.getGlobalControlErrorTable(), event.getX(), event.getY()); } + + // double clic (bouton normal) + else if (eventButton == MouseEvent.BUTTON1 && event.getClickCount() == 2) { + TreePath selectedError = controlView.getGlobalControlErrorTable().getTreeSelectionModel().getSelectionPath(); + + // 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; + String species = error.getSpecies(); + displayCompareNumberCatchGraph(controlView, species); + } + } + } } /** @@ -830,35 +859,36 @@ * * @param view view */ - public void displayCompareNumberCatchGraph(final ControlView view) { + public void displayCompareNumberCatchGraph(ControlView view) { + displayCompareNumberCatchGraph(view, null); + } - final Project project = view.getContextValue(Project.class); - final PublicationService publicationService = view.getContextValue(PublicationService.class); - final SwingSession session = view.getContextValue(SwingSession.class); + /** + * Display data graph, initialized with graph for selected specy + * selected. + * + * @param view view + * @param selectedSpecies if not null (auto select species in combo box) + */ + public void displayCompareNumberCatchGraph(ControlView view, String selectedSpecies) { + SwingSession session = view.getContextValue(SwingSession.class); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - try { - setWaitCursor(view); + // get matrix (form context by method #checkData) + Map<String, JFreeChart> charts = view.getContextValue(Map.class, "CompareCatchLengthGraph"); + List<String> species = new ArrayList<String>(charts.keySet()); - // get matrix - Map<String, JFreeChart> charts = publicationService.getCompareCatchLengthGraph(project, project.getControl(), null); - List<String> species = new ArrayList<String>(charts.keySet()); - - ControlGraphFrame frame = new ControlGraphFrame(view); - frame.setHandler(ControlHandler.this); - frame.setContextValue(charts); - frame.getSpecyComboModel().setSpecy(species); - frame.pack(); - frame.setLocationRelativeTo(view); - session.add(frame); // session restore - frame.setVisible(true); - } - finally { - setDefaultCursor(view); - } - } - }); + ControlGraphFrame frame = new ControlGraphFrame(view); + frame.setHandler(ControlHandler.this); + frame.setContextValue(charts); + frame.getSpecyComboModel().setSpecy(species); + if (selectedSpecies != null) { + frame.getSpecyComboModel().setSelectedItem(selectedSpecies); + updateCompareNumberCatchGraph(frame); + } + frame.pack(); + frame.setLocationRelativeTo(view); + session.add(frame); // session restore + frame.setVisible(true); } /** @@ -880,7 +910,7 @@ */ public void updateCompareNumberCatchGraph(ControlGraphFrame view) { String specyName = (String)view.getSpecyComboModel().getSelectedItem(); - Map<String, JFreeChart> charts = view.getContextValue(Map.class); + Map<String, JFreeChart> charts = view.getContextValue(Map.class, "CompareCatchLengthGraph"); JFreeChart chart = charts.get(specyName); view.getControlGraphPanel().removeAll(); ChartPanel chartPanel = new ChartPanel(chart); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-12-13 17:06:44 UTC (rev 401) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-12-14 10:13:31 UTC (rev 402) @@ -53,8 +53,8 @@ <JToolBar.Separator /> <JButton icon="spellcheck.png" text="coser.ui.control.checkData" onActionPerformed="getHandler().checkData(this)" /> - <JToolBar.Separator /> - <JButton icon="chart_curve.png" text="coser.ui.graph.compareNumberCatchSize" + <JButton id="compareNumberCatchLengthButton" icon="chart_curve.png" enabled="false" + text="coser.ui.graph.compareNumberCatchLength" toolTipText="coser.ui.graph.compareNumberCatchLengthTip" onActionPerformed="getHandler().displayCompareNumberCatchGraph(this)"/> <JButton icon="chart_bar.png" text="coser.ui.graph.lengthStructure" onActionPerformed="getHandler().displayLengthStructureGraph(this)"/> @@ -159,7 +159,7 @@ <JXTreeTable id='globalControlErrorTable' treeTableModel="{globalControlErrorModel}" rootVisible="false" showsRootHandles="true" treeCellRenderer="{new ControlErrorTreeRenderer()}" - onMouseClicked="getHandler().showGlobalErrorTableContextMenu(this, event)" + onMouseClicked="getHandler().globalErrorTableMouseCLicked(this, event)" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> <javax.swing.tree.TreeSelectionModel id="globalControlErrorSelectionModel" javaBean="globalControlErrorTable.getTreeSelectionModel()" 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 2010-12-13 17:06:44 UTC (rev 401) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-12-14 10:13:31 UTC (rev 402) @@ -28,7 +28,7 @@ coser.ui.control.confirmDeletionsMessage=Are you sure you want to delete %d selected lines ? coser.ui.control.controlSaved=Control saved. coser.ui.control.controlTitle=Control -coser.ui.control.controlValidated=Control validated. +coser.ui.control.controlValidated=Control validated and saved. coser.ui.control.dataMenuDeleteSelected=Deleted selected lines coser.ui.control.dataMenuLabel=Data menu coser.ui.control.dataMenuReplace=Replace in %s for selection @@ -38,7 +38,6 @@ coser.ui.control.global.done=\u2026 coser.ui.control.global.message=Message coser.ui.control.globalErrorMenuGenerateHTML=Export as HTML -coser.ui.control.globalErrorMenuLabel=Error menu coser.ui.control.globalErrorMenuSelectAll=Select all lines coser.ui.control.graph.species=Species \: coser.ui.control.logreport=Modification report @@ -62,7 +61,8 @@ coser.ui.error.htmlmessage=An error occurs \: %s coser.ui.error.reportSendTo=A repport has been sent to %s coser.ui.error.title=Global application error -coser.ui.graph.compareNumberCatchSize=Comparison Catch/Length +coser.ui.graph.compareNumberCatchLength=Comparison Catch/Length +coser.ui.graph.compareNumberCatchLengthTip=Display catch and length number comparison graphs (data are generated only during error check) coser.ui.graph.lengthStructure=Length structure coser.ui.locale.mustRestart=You must restart application to take effect coser.ui.locale.title=Locale modification @@ -196,7 +196,7 @@ coser.ui.selection.selectionFilterDescription=Coser selection (*.selection) coser.ui.selection.selectionSaved=Selection saved. coser.ui.selection.selectionTitle=Selection -coser.ui.selection.selectionValidated=Selection validated. +coser.ui.selection.selectionValidated=Selection validated and saved. coser.ui.selection.sizeAllYearSpecies=L3 \: Species with size all year (%d/%d) coser.ui.selection.speciesMenuFusion=Merge coser.ui.selection.speciesMerged=Species merged. 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 2010-12-13 17:06:44 UTC (rev 401) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-12-14 10:13:31 UTC (rev 402) @@ -28,7 +28,7 @@ coser.ui.control.confirmDeletionsMessage=\u00CAtes vous s\u00FBr de vouloir supprimer les %d lignes s\u00E9lectionn\u00E9es ? coser.ui.control.controlSaved=Contr\u00F4le sauv\u00E9. coser.ui.control.controlTitle=Contr\u00F4le -coser.ui.control.controlValidated=Contr\u00F4le valid\u00E9. +coser.ui.control.controlValidated=Contr\u00F4le valid\u00E9 et sauv\u00E9. coser.ui.control.dataMenuDeleteSelected=Supprimer les lignes s\u00E9lectionn\u00E9es coser.ui.control.dataMenuLabel=Menu des donn\u00E9es coser.ui.control.dataMenuReplace=Remplacer dans %s pour la s\u00E9lection @@ -38,7 +38,6 @@ coser.ui.control.global.done=\u2026 coser.ui.control.global.message=Message coser.ui.control.globalErrorMenuGenerateHTML=Exporter en HTML -coser.ui.control.globalErrorMenuLabel=Menu des erreurs coser.ui.control.globalErrorMenuSelectAll=S\u00E9lectionner toutes les lignes coser.ui.control.graph.species=Esp\u00E8ces \: coser.ui.control.logreport=Rapport des modifications @@ -62,7 +61,8 @@ coser.ui.error.htmlmessage=Une erreur s'est produite \: %s coser.ui.error.reportSendTo=Un rapport a \u00E9t\u00E9 envoy\u00E9 \u00E0 %s coser.ui.error.title=Erreur globale -coser.ui.graph.compareNumberCatchSize=Comparaison Captures/Tailles +coser.ui.graph.compareNumberCatchLength=Comparaison Captures/Tailles +coser.ui.graph.compareNumberCatchLengthTip=Affiche les graphiques de comparaison des nombres entre les captures et les tailles (Les donn\u00E9es sont g\u00E9n\u00E9r\u00E9es uniquement lors de la v\u00E9rification des erreurs) coser.ui.graph.lengthStructure=Structures en taille coser.ui.locale.mustRestart=Vous devez red\u00E9marrer l'application pour prendre en compte la modification. coser.ui.locale.title=Modification de la langue @@ -196,7 +196,7 @@ coser.ui.selection.selectionFilterDescription=Coser s\u00E9lection (*.selection) coser.ui.selection.selectionSaved=S\u00E9lection sauv\u00E9e. coser.ui.selection.selectionTitle=S\u00E9lection -coser.ui.selection.selectionValidated=S\u00E9lection valid\u00E9e. +coser.ui.selection.selectionValidated=S\u00E9lection valid\u00E9e et sauv\u00E9e. coser.ui.selection.sizeAllYearSpecies=L3 \: Esp\u00E8ces avec taille pour toutes les ann\u00E9es (%d/%d) coser.ui.selection.speciesMenuFusion=Fusion coser.ui.selection.speciesMerged=Esp\u00E8ces fusionn\u00E9es.