Author: vsalaun Date: 2011-05-17 15:02:49 +0200 (Tue, 17 May 2011) New Revision: 3131 Url: http://chorem.org/repositories/revision/lima/3131 Log: #359 possibilite de deselectionner une ligne dans certains tableaux Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -1,5 +1,9 @@ package org.chorem.lima.ui.accountsreports; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import org.apache.commons.logging.Log; @@ -9,7 +13,8 @@ import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.jdesktop.swingx.JXTable; -public class AccountsReportsTable extends JXTable { +public class AccountsReportsTable extends JXTable + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 6093850347322834480L; @@ -24,9 +29,57 @@ this.handler = handler; + addKeyListener(this); + addMouseListener(this); + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); } + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -1,5 +1,9 @@ package org.chorem.lima.ui.balance; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -7,7 +11,7 @@ import org.chorem.lima.ui.balance.BalanceViewHandler; import org.jdesktop.swingx.JXTable; -public class BalanceTable extends JXTable { +public class BalanceTable extends JXTable implements KeyListener, MouseListener{ /** serialVersionUID. */ private static final long serialVersionUID = 6093850347322834480L; @@ -22,9 +26,57 @@ this.handler = handler; + addKeyListener(this); + addMouseListener(this); + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); } + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -27,6 +27,10 @@ import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import org.chorem.lima.entity.Entry; @@ -39,7 +43,8 @@ import org.jdesktop.swingx.decorator.Highlighter; -public class EntryBooksReportsTable extends JXTable { +public class EntryBooksReportsTable extends JXTable + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 1L; @@ -60,6 +65,10 @@ this.handler = handler; this.model = model; + + addKeyListener(this); + addMouseListener(this); + highlighterReportsDatasBoolean=true; //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); @@ -97,4 +106,49 @@ new ColorHighlighter(predicate, new Color(222,222,222), null); addHighlighter(colorReportsDatas); } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -27,6 +27,10 @@ import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.text.SimpleDateFormat; import org.apache.commons.logging.Log; @@ -43,7 +47,8 @@ import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.decorator.Highlighter; -public class FinancialPeriodTable extends JXTable { +public class FinancialPeriodTable extends JXTable + implements KeyListener, MouseListener { private static final long serialVersionUID = -1960326844433064178L; @@ -64,6 +69,10 @@ public FinancialPeriodTable(FinancialPeriodViewHandler handler) { this.handler = handler; + + addKeyListener(this); + addMouseListener(this); + model = this.handler.getView().modelFinancialPeriodTable; financialPeriodService = LimaServiceFactory.getInstance().getService( @@ -125,5 +134,50 @@ new ColorHighlighter(predicate, null, new Color(222,0,0)); addHighlighter(colorTransaction); } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -27,6 +27,11 @@ import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + import org.chorem.lima.beans.FinancialStatementAmounts; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; @@ -35,7 +40,8 @@ import org.jdesktop.swingx.decorator.Highlighter; -public class FinancialStatementReportTable extends JXTable { +public class FinancialStatementReportTable extends JXTable + implements KeyListener, MouseListener { private static final long serialVersionUID = 154211277688304679L; @@ -51,6 +57,10 @@ public FinancialStatementReportTable(FinancialStatementReportViewHandler handler) { super(handler.getView().modelTable); this.handler = handler; + + addKeyListener(this); + addMouseListener(this); + model = this.handler.getView().modelTable; //highlight financial financial transactions @@ -112,4 +122,49 @@ addHighlighter(colorTransaction); } + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -29,6 +29,8 @@ import java.awt.Component; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import java.util.Date; import javax.swing.SwingWorker; @@ -56,7 +58,8 @@ * * @author jpepin */ -public class FinancialTransactionTable extends JXTable implements KeyListener { +public class FinancialTransactionTable extends JXTable + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; @@ -79,6 +82,7 @@ this.handler = handler; addKeyListener(this); + addMouseListener(this); //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); @@ -204,6 +208,13 @@ handler.addFinancialTransaction(); } + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + /** * Touche tab * Incrémente le curseur de case tant que la case n'est pas editable @@ -307,7 +318,29 @@ @Override public void keyReleased(KeyEvent e) { - } - + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -27,6 +27,10 @@ import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import java.util.Date; import org.chorem.lima.entity.Account; @@ -50,7 +54,8 @@ * @author ore * @author Rémi Chapelet */ -public class FinancialTransactionSearchTable extends JXTable { +public class FinancialTransactionSearchTable extends JXTable + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; @@ -67,6 +72,9 @@ this.handler = handler; + addKeyListener(this); + addMouseListener(this); + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); //Get new entry book editor @@ -144,4 +152,51 @@ new ColorHighlighter(predicate, new Color(255, 198, 209), null); addHighlighter(colorTransaction); } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + + } + + @Override + public void keyReleased(KeyEvent e) { + } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -29,6 +29,8 @@ import java.awt.Component; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import java.util.Date; import org.chorem.lima.entity.Account; @@ -53,7 +55,8 @@ * @author ore * @author Rémi Chapelet */ -public class FinancialTransactionUnbalancedTable extends JXTable implements KeyListener { +public class FinancialTransactionUnbalancedTable extends JXTable + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; @@ -71,6 +74,7 @@ this.handler = handler; addKeyListener(this); + addMouseListener(this); //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); @@ -173,6 +177,13 @@ && e.getModifiers() == KeyEvent.CTRL_MASK)) { handler.addEmptyEntry(); } + + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } /** * Touche tab @@ -207,11 +218,30 @@ } - /* - * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) - */ @Override public void keyReleased(KeyEvent e) { - } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -27,6 +27,11 @@ import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + import org.chorem.lima.entity.FiscalPeriod; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; @@ -34,7 +39,8 @@ import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.decorator.Highlighter; -public class FiscalPeriodTable extends JXTable { +public class FiscalPeriodTable extends JXTable + implements KeyListener, MouseListener { private static final long serialVersionUID = -8462838870024505659L; @@ -47,6 +53,10 @@ public FiscalPeriodTable(FiscalPeriodViewHandler handler) { this.handler = handler; + + addKeyListener(this); + addMouseListener(this); + model = this.handler.getView().getModelFiscalPeriodTable(); //highlight financial financial transactions @@ -67,5 +77,50 @@ new ColorHighlighter(predicate, null, new Color(222,0,0)); addHighlighter(colorTransaction); } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -27,6 +27,10 @@ import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; @@ -43,7 +47,7 @@ * @author ore * @author Rémi Chapelet */ -public class LedgerTable extends JXTable { +public class LedgerTable extends JXTable implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; @@ -58,6 +62,9 @@ this.handler = handler; + addKeyListener(this); + addMouseListener(this); + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); @@ -86,4 +93,49 @@ new ColorHighlighter(predicate, new Color(222,222,222), null); addHighlighter(colorReportsDatas); } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2011-05-17 08:24:05 UTC (rev 3130) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2011-05-17 13:02:49 UTC (rev 3131) @@ -29,6 +29,8 @@ import java.awt.Component; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.math.BigDecimal; import java.util.Date; @@ -55,7 +57,8 @@ * * @author jpepin */ -public class LetteringTable extends JXTable implements KeyListener { +public class LetteringTable extends JXTable + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; @@ -75,6 +78,7 @@ this.handler = handler; addKeyListener(this); + addMouseListener(this); //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); @@ -166,19 +170,47 @@ handler.addLetter(); } + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!this.isEditing()) { + this.clearSelection(); + } + } + } @Override public void keyTyped(KeyEvent e) { - } @Override public void keyReleased(KeyEvent e) { - } + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + if (this.rowAtPoint(e.getPoint()) == -1) { + this.clearSelection(); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + }