r3509 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
Author: mallon Date: 2012-07-10 13:52:09 +0200 (Tue, 10 Jul 2012) New Revision: 3509 Url: http://chorem.org/repositories/revision/lima/3509 Log: refs #688 Corrections sur le modele de selection, quand le lettrage n est pas present (null), et sur la selection / deselection de ligne pour les entree non-lettrees Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-10 08:26:59 UTC (rev 3508) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-10 11:52:09 UTC (rev 3509) @@ -11,6 +11,7 @@ public class LetteringSelectionModel extends AbstractGenericListSelectionModel<Entry> { protected LetteringTableModel letteringTableModel; + protected int lineSelected; //Modele de selection du tableau lors de la selection d une entree lettree @@ -20,7 +21,8 @@ @Override public void setSelectionInterval(int row, int column){ - super.setSelectionInterval(row, column); + lineSelected = row; + super.setSelectionInterval(lineSelected, column); //select entries with the same letter of the selected entry for(Entry entry : getEntries()){ if (entry.getLettering() != null && !entry.getLettering().isEmpty()){ @@ -47,7 +49,7 @@ } public Entry getCurrentEntrySelected(){ - return letteringTableModel.getEntryAt(super.getMaxSelectionIndex()); + return letteringTableModel.getEntryAt(lineSelected); } public String getCurrentLettring(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 08:26:59 UTC (rev 3508) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 11:52:09 UTC (rev 3509) @@ -188,10 +188,10 @@ <cell fill="both" weightx="1" weighty="1" columns="4"> <JScrollPane> <LetteringTable - id="table" sortable="false" rowHeight="22" + id="table" sortable="false" rowHeight="22" editable='true' constructorParams="getTableModel()" selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" - selectionModel="{lettringAndUnlettringSelectionModel}" + selectionModel="{lettringAndUnlettringSelectionModel.getSelectedModel()}" /> </JScrollPane> </cell> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-10 08:26:59 UTC (rev 3508) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-10 11:52:09 UTC (rev 3509) @@ -14,11 +14,13 @@ protected LetteringSelectionModel letteringSelectionModel; protected UnlettringSelectionModel unlettringSelectionModel; protected LetteringTableModel letteringTableModel; + protected boolean modelSelected; public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel, UnlettringSelectionModel unlettringSelectionModel, LetteringTableModel letteringTableModel) { this.letteringSelectionModel = letteringSelectionModel; this.unlettringSelectionModel = unlettringSelectionModel; this.letteringTableModel = letteringTableModel; + modelSelected = false; //By default, unLettred entries } /**choice of model : two differents ui reactions, if lettering is present or not*/ @@ -27,12 +29,15 @@ if (log.isInfoEnabled()) { log.info("Selection de ligne : choix du modele"); } + if (!letteringNotExist(row)) { + modelSelected = true; letteringSelectionModel.setSelectionInterval(row, column); } else { if (log.isInfoEnabled()) { log.info("Modele de selection utilise : 'unlettringSelectionModel'"); } + modelSelected = false; unlettringSelectionModel.setSelectionInterval(row, column); } } @@ -66,14 +71,22 @@ return letteringTableModel.getEntryAt(i); } + public AbstractGenericListSelectionModel<Entry> getSelectedModel(){ + if (modelSelected) { + return letteringSelectionModel; + }else{ + return unlettringSelectionModel; + } + } + /**clear the selection of the current using model*/ - @Override + /*@Override public void clearSelection(){ if (letteringSelectionModel.getSelectedValues().size() == 0) { letteringSelectionModel.clearSelection(); }else{ unlettringSelectionModel.clearSelection(); } - } + }*/ } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-10 08:26:59 UTC (rev 3508) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-10 11:52:09 UTC (rev 3509) @@ -1,23 +1,66 @@ package org.chorem.lima.ui.lettering; import jaxx.runtime.swing.model.AbstractGenericListSelectionModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Entry; +import java.util.ArrayList; +import java.util.List; + public class UnlettringSelectionModel extends AbstractGenericListSelectionModel<Entry> { + private static final Log log = LogFactory.getLog(LetteringViewHandler.class); protected LetteringTableModel letteringTableModel; + protected List<Integer> selectedRows; //Modele de selection du tableau lors de la selection d une entree non lettree - public UnlettringSelectionModel(LetteringTableModel letteringTableModel) { this.letteringTableModel = letteringTableModel; + selectedRows = new ArrayList<Integer>(); } @Override public void setSelectionInterval(int row, int column){ - super.addSelectionInterval(row, column); + + //Case where line is selected a second time (So, must deselect it on second click) + if (selectedRows.isEmpty() || !searchRowSelected(row)){ + selectedRows.add(row); + super.addSelectionInterval(row, column); + }else { + deleteLine(row); + super.removeSelectionInterval(row, column); + } } + /** + * search the line in a list of selected rows + * and delete it + * @param row line to delete + * */ + public void deleteLine(int row){ + for (Integer rowSearching : selectedRows){ + if (rowSearching == row){ + selectedRows.remove(rowSearching); + break; + } + } + } + + /**search if the selected row is in the list + * (List of precedent selected rows) + * @param row line searched in the list + * @return true if line find + * */ + public boolean searchRowSelected(int row){ + for (Integer rowSearching : selectedRows){ + if (rowSearching == row){ + return true; + } + } + return false; + } + @Override public int getSize() { return letteringTableModel.getRowCount();
participants (1)
-
mallon@users.chorem.org