r367 - in trunk/coser-ui/src/main: java/fr/ifremer/coser/ui/selection resources/i18n
Author: chatellier Date: 2010-12-06 13:48:55 +0000 (Mon, 06 Dec 2010) New Revision: 367 Log: G?\195?\169n?\195?\169ration des graphes par menu contextuel. Fix un pb de rafraichissement. Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.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 Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-12-06 13:25:56 UTC (rev 366) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-12-06 13:48:55 UTC (rev 367) @@ -207,7 +207,7 @@ <SpecyListModel id="filteredSpecyListModel" onContentsChanged='filteredSpecyLabel.setText(_("coser.ui.selection.details.filteredSpecies", filteredSpecyList.getSelectedIndices().length, filteredSpecyList.getModel().getSize()))'/> <JList id="filteredSpecyList" model="{filteredSpecyListModel}" - onMouseClicked="getHandler().showSpeciesContextMenu(this, event)" + onMouseClicked="getHandler().showFilteredSpeciesContextMenu(this, event)" selectionModel="{new CoserListSelectionModel(filteredSpecyList.getSelectionModel(), filteredSpecyListModel)}" enabled="{isYearsValidated() && isStrataValidated()}" onValueChanged='filteredSpecyLabel.setText(_("coser.ui.selection.details.filteredSpecies", filteredSpecyList.getSelectedIndices().length, filteredSpecyList.getModel().getSize()))' /> @@ -232,14 +232,6 @@ enabled="{getSelectedSpecyList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}"/> </cell> </row> - <row> - <cell> - <JButton icon="chart_curve.png" - toolTipText="coser.ui.selection.details.displayDiffCatchLengthGraphTip" - onActionPerformed='getHandler().showSelectedSpeciesGraph(this, "SPECIESGRAPH")' - enabled="{getFilteredSpecyList().getSelectedIndex() != -1 && isYearsValidated() && isStrataValidated()}" /> - </cell> - </row> </Table> </cell> <cell weightx="1" weighty="1" fill="both"> @@ -247,6 +239,7 @@ <SpecyListModel id="selectedSpecyListModel" onContentsChanged='selectedSpecyLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpecyList.getSelectedIndices().length, selectedSpecyList.getModel().getSize()))'/> <JList id="selectedSpecyList" model="{selectedSpecyListModel}" + onMouseClicked="getHandler().showSelectedSpeciesContextMenu(this, event)" selectionModel="{new CoserListSelectionModel(selectedSpecyList.getSelectionModel(), selectedSpecyListModel)}" enabled="{isYearsValidated() && isStrataValidated()}" onValueChanged='selectedSpecyLabel.setText(_("coser.ui.selection.details.selectedSpecies", selectedSpecyList.getSelectedIndices().length, selectedSpecyList.getModel().getSize()))'/> Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-12-06 13:25:56 UTC (rev 366) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-12-06 13:48:55 UTC (rev 367) @@ -45,6 +45,7 @@ import javax.swing.JList; import javax.swing.JMenuItem; import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JTextField; import javax.swing.event.ChangeEvent; @@ -321,7 +322,7 @@ * @param view view * @param event mouse event */ - public void showSpeciesContextMenu(final SelectionDetailsView view, MouseEvent event) { + public void showFilteredSpeciesContextMenu(final SelectionDetailsView view, MouseEvent event) { // clic droit if (event.getButton() == MouseEvent.BUTTON3) { @@ -349,6 +350,18 @@ }); popupMenu.add(fusionMenu); } + + if (selectedRows.length > 0) { + // graph + JMenuItem graphMenu = new JMenuItem(_("coser.ui.selection.details.displayDiffCatchLengthGraph")); + graphMenu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showSelectedSpeciesGraph(view, view.getFilteredSpecyList()); + } + }); + popupMenu.add(graphMenu); + } // select all menu JMenuItem selectAllMenu = new JMenuItem(_("coser.ui.common.selectAll")); @@ -360,7 +373,9 @@ } }); popupMenu.add(selectAllMenu); - + + + // unselect all menu JMenuItem unselectAllMenu = new JMenuItem(_("coser.ui.common.unselectAll")); unselectAllMenu.addActionListener(new ActionListener() { @@ -374,7 +389,59 @@ popupMenu.show(view.getFilteredSpecyList(), event.getX(), event.getY()); } } + + /** + * Affiche un menu contextuel lors du clic (droit) sur la liste des especes + * sélectionnées. + * + * @param view view + * @param event mouse event + */ + public void showSelectedSpeciesContextMenu(final SelectionDetailsView view, MouseEvent event) { + // clic droit + if (event.getButton() == MouseEvent.BUTTON3) { + + JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.selection.speciesMenuLabel")); + + int[] selectedRows = view.getSelectedSpecyList().getSelectedIndices(); + if (selectedRows.length > 0) { + // graph + JMenuItem graphMenu = new JMenuItem(_("coser.ui.selection.details.displayDiffCatchLengthGraph")); + graphMenu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showSelectedSpeciesGraph(view, view.getSelectedSpecyList()); + } + }); + popupMenu.add(graphMenu); + } + + // select all menu + JMenuItem selectAllMenu = new JMenuItem(_("coser.ui.common.selectAll")); + selectAllMenu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int size = view.getSelectedSpecyList().getModel().getSize(); + view.getSelectedSpecyList().getSelectionModel().addSelectionInterval(0, size - 1); + } + }); + popupMenu.add(selectAllMenu); + + // unselect all menu + JMenuItem unselectAllMenu = new JMenuItem(_("coser.ui.common.unselectAll")); + unselectAllMenu.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + view.getSelectedSpecyList().getSelectionModel().clearSelection(); + } + }); + popupMenu.add(unselectAllMenu); + + popupMenu.show(view.getSelectedSpecyList(), event.getX(), event.getY()); + } + } + /** * Sauvegarde (ou creer) la sélection (partie details). * @@ -745,27 +812,30 @@ /** * Affiche les graphes de différence captures/taille dans le panel - * reféréncé par {@code cardLayoutContraints}. + * reféréncé par {@code cardLayoutContraints} suivant la liste + * sur laquelle porte l'appel. * * @param view view - * @param cardLayoutContraints + * @param source */ - public void showSelectedSpeciesGraph(SelectionDetailsView view, String cardLayoutContraints) { + public void showSelectedSpeciesGraph(SelectionDetailsView view, JList source) { PublicationService publicationService = view.getContextValue(PublicationService.class); Project project = view.getContextValue(Project.class); Selection selection = view.getContextValue(Selection.class); - Object[] selectedFilteredSpecies = view.getFilteredSpecyList().getSelectedValues(); + Object[] selectedSpecies = source.getSelectedValues(); Set<String> graphSpecies = new HashSet<String>(); - for (Object selectedFilteredSpecy : selectedFilteredSpecies) { - graphSpecies.add((String)selectedFilteredSpecy); + for (Object selectedSingleSpecies : selectedSpecies) { + graphSpecies.add((String)selectedSingleSpecies); } Map<String, JFreeChart> chartsMap = publicationService.getCompareCatchLengthGraph(project, selection, graphSpecies); Collection<JFreeChart> charts = chartsMap.values(); - - view.getSpeciesGraphPanel().removeAll(); + + // add all this graphes in panel + JPanel graphPanel = view.getSpeciesGraphPanel(); + graphPanel.removeAll(); Iterator<JFreeChart> itCharts = charts.iterator(); int chartIndex = 0; while (itCharts.hasNext()) { @@ -777,7 +847,9 @@ GridBagConstraints.BOTH, new Insets(0, 3, 3, 3), 0, 0)); chartIndex++; } - view.getDetailDecisionPanelLayout().show(view.getDetailDecisionPanel(), cardLayoutContraints); + view.getDetailDecisionPanelLayout().show(view.getDetailDecisionPanel(), "SPECIESGRAPH"); + view.getDetailDecisionPanel().validate(); + view.getDetailDecisionPanel().repaint(); } /** 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-06 13:25:56 UTC (rev 366) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-12-06 13:48:55 UTC (rev 367) @@ -153,7 +153,7 @@ coser.ui.selection.details.comment=Comments \: coser.ui.selection.details.dates=Years \: coser.ui.selection.details.description=Description \: -coser.ui.selection.details.displayDiffCatchLengthGraphTip=Display selected species's comparison catch/length graphs. +coser.ui.selection.details.displayDiffCatchLengthGraph=Comparison catch/length graphs coser.ui.selection.details.filteredSpecies=Filtered species (%d/%d) \: coser.ui.selection.details.name=Selection name \: coser.ui.selection.details.removeFromSelectedListTip=Remove selected species from selected species list 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-06 13:25:56 UTC (rev 366) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-12-06 13:48:55 UTC (rev 367) @@ -153,7 +153,7 @@ coser.ui.selection.details.comment=Commentaire \: coser.ui.selection.details.dates=Ann\u00E9es \: coser.ui.selection.details.description=Description \: -coser.ui.selection.details.displayDiffCatchLengthGraphTip=Affiche les graphiques des diff\u00E9rences captures/tailles pour les esp\u00E8ces s\uFFFDlectionn\uFFFDes. +coser.ui.selection.details.displayDiffCatchLengthGraph=Graphiques des diff\u00E9rences captures/tailles coser.ui.selection.details.filteredSpecies=Esp\u00E8ces filtr\u00E9es (%d/%d) \: coser.ui.selection.details.name=Nom de la s\u00E9lection \: coser.ui.selection.details.removeFromSelectedListTip=Retire les esp\u00E8ces s\u00E9lectionn\u00E9es de la liste des esp\u00E8ces s\u00E9lectionn\u00E9es
participants (1)
-
chatellier@users.labs.libre-entreprise.org