Author: vsalaun Date: 2011-05-17 17:57:08 +0200 (Tue, 17 May 2011) New Revision: 3132 Url: http://chorem.org/repositories/revision/lima/3132 Log: #359 possibilite de deselectionner une ligne dans certains tableaux (2/2) Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java 2011-05-17 15:57:08 UTC (rev 3132) @@ -0,0 +1,78 @@ +package org.chorem.lima.ui.account; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTreeTable; + +public class AccountTreeTable extends JXTreeTable + implements KeyListener, MouseListener { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1092873442245932784L; + + /** log. */ + private static final Log log = LogFactory + .getLog(AccountTreeTable.class); + + protected AccountViewHandler handler; + + public AccountTreeTable(AccountViewHandler handler) { + + this.handler = handler; + + addKeyListener(this); + addMouseListener(this); + + } + + @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/account/AccountView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2011-05-17 13:02:49 UTC (rev 3131) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2011-05-17 15:57:08 UTC (rev 3132) @@ -37,7 +37,8 @@ <row> <cell fill="both" weightx="1" weighty="1" rows='5'> <JScrollPane> - <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" + <AccountTreeTable id="accountsTreeTable" + constructorParams="getHandler()" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" treeTableModel="{new org.chorem.lima.ui.account.AccountTreeTableModel()}" highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" /> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2011-05-17 15:57:08 UTC (rev 3132) @@ -0,0 +1,78 @@ +package org.chorem.lima.ui.entrybook; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; + +public class EntryBookTable extends JXTable + implements KeyListener, MouseListener { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6228396251512013262L; + + /** log. */ + private static final Log log = LogFactory + .getLog(EntryBookTable.class); + + protected EntryBookViewHandler handler; + + public EntryBookTable(EntryBookViewHandler handler) { + + this.handler = handler; + + addKeyListener(this); + addMouseListener(this); + + } + + @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/entrybook/EntryBookView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2011-05-17 13:02:49 UTC (rev 3131) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2011-05-17 15:57:08 UTC (rev 3132) @@ -38,7 +38,8 @@ <row> <cell fill="both" weightx="1" weighty="1" rows='5'> <JScrollPane> - <org.jdesktop.swingx.JXTable id="entryBooksTable" rowHeight="24" + <EntryBookTable id="entryBooksTable" rowHeight="24" + constructorParams="getHandler()" model="{new org.chorem.lima.ui.entrybook.EntryBookTableModel()}" highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java 2011-05-17 15:57:08 UTC (rev 3132) @@ -0,0 +1,77 @@ +package org.chorem.lima.ui.financialstatementchart; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTreeTable; + +public class FinancialStatementChartTreeTable extends JXTreeTable + implements KeyListener, MouseListener { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3221024449873737253L; + + /** log. */ + private static final Log log = LogFactory + .getLog(FinancialStatementChartTreeTable.class); + + protected FinancialStatementChartViewHandler handler; + + public FinancialStatementChartTreeTable(FinancialStatementChartViewHandler handler) { + this.handler = handler; + + addKeyListener(this); + addMouseListener(this); + + } + + @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/financialstatementchart/FinancialStatementChartView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2011-05-17 13:02:49 UTC (rev 3131) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartView.jaxx 2011-05-17 15:57:08 UTC (rev 3132) @@ -37,7 +37,8 @@ <row> <cell fill="both" weightx="1" weighty="1" rows='6'> <JScrollPane> - <org.jdesktop.swingx.JXTreeTable id="treeTable" + <FinancialStatementChartTreeTable id="treeTable" + constructorParams="getHandler()" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" treeTableModel="{new org.chorem.lima.ui.financialstatementchart.FinancialStatementChartTreeTableModel()}" highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" />