r3551 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: celleditor financialtransaction
Author: mallon Date: 2012-07-24 16:47:00 +0200 (Tue, 24 Jul 2012) New Revision: 3551 Url: http://chorem.org/repositories/revision/lima/3551 Log: fixes #647 Le contenu des cellules de saisie est d?\195?\169sormais s?\195?\169lectionn?\195?\169 par d?\195?\169faut lors d'une ?\195?\169dition. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2012-07-24 14:25:42 UTC (rev 3550) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2012-07-24 14:47:00 UTC (rev 3551) @@ -26,10 +26,7 @@ import jaxx.runtime.swing.editor.cell.NumberCellEditor; import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; import java.awt.Component; -import java.awt.event.FocusEvent; import java.math.BigDecimal; /** @@ -38,7 +35,6 @@ public class BigDecimalTableCellEditor extends NumberCellEditor<BigDecimal>{ protected int row; - protected JTextField textFieldNumberValue; /** * constructor @@ -47,42 +43,10 @@ super(BigDecimal.class, false); } - public int getRow() { - return row; - } - @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { this.row = row; return super.getTableCellEditorComponent(table, value, isSelected, row, column); } - //To stay with old value and just complete it - @Override - public void focusGained(FocusEvent e) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - textFieldNumberValue = numberEditor.getTextField(); - textFieldNumberValue.requestFocus(); - int length = textFieldNumberValue.getText().length(); - textFieldNumberValue.select(length, length); - } - }); - } - - /**To limit number of decimals at two, and rounded up it - * */ - /*@Override - public void focusLost(FocusEvent e) {*/ - //getCellEditorValue().setScale(2, RoundingMode.HALF_UP); - /*SwingUtilities.invokeLater(new Runnable() { - public void run() {*/ - /* BigDecimal cellEditorValue = getCellEditorValue(); - cellEditorValue.setScale(2, RoundingMode.HALF_UP); - System.out.println("cellEditorValue : " + cellEditorValue); - numberEditor.getTextField().setText(cellEditorValue.toString()); - System.out.println("numberEditor.getTextField().getText() : " + numberEditor.getTextField().getText());*/ - /* } - });*/ - //} } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2012-07-24 14:25:42 UTC (rev 3550) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2012-07-24 14:47:00 UTC (rev 3551) @@ -29,11 +29,13 @@ import org.chorem.lima.LimaContext; import org.jdesktop.swingx.JXDatePicker; -import javax.swing.*; +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.SwingUtilities; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.table.TableCellEditor; -import java.awt.*; +import java.awt.Component; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.MouseEvent; @@ -100,13 +102,10 @@ } /** Listeners */ - //To stay with old value and just complete it - @Override public void focusGained(FocusEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { - int length = datePicker.getEditor().getText().length(); - datePicker.getEditor().select(length, length); + datePicker.getEditor().selectAll(); } }); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2012-07-24 14:25:42 UTC (rev 3550) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2012-07-24 14:47:00 UTC (rev 3551) @@ -24,15 +24,14 @@ */ package org.chorem.lima.ui.celleditor; -import java.awt.Color; -import java.awt.Component; - import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Color; +import java.awt.Component; /** * Renderer qui affiche la valeur de la cellule (toString()) en permettant de 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 2012-07-24 14:25:42 UTC (rev 3550) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-07-24 14:47:00 UTC (rev 3551) @@ -34,7 +34,6 @@ import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.chorem.lima.ui.celleditor.DateTableCellEditor; import org.chorem.lima.ui.celleditor.EmptyCellRenderer; -import org.jdesktop.swingx.JXDatePicker; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; @@ -45,7 +44,6 @@ import javax.swing.UIManager; import javax.swing.border.LineBorder; import javax.swing.plaf.BorderUIResource; -import javax.swing.text.JTextComponent; import java.awt.Color; import java.awt.Component; import java.awt.event.KeyAdapter; @@ -54,7 +52,6 @@ import java.awt.event.MouseEvent; import java.math.BigDecimal; import java.util.Date; -import java.util.EventObject; /** * Table des transaction qui ajoute des comportement (keys). @@ -313,27 +310,4 @@ } } - @Override - public boolean editCellAt(int row, int column, EventObject e) { - boolean result = super.editCellAt(row, column, e); - int lengthCellValue; - Component editorComponent = getEditorComponent(); - if (editorComponent != null) { - if (editorComponent instanceof JXDatePicker) { - JXDatePicker datePickerComponent = (JXDatePicker) editorComponent; - lengthCellValue = datePickerComponent.getEditor().getText().length(); - if (lengthCellValue != -1) { - datePickerComponent.getEditor().select(lengthCellValue, lengthCellValue); - } - } else if ((editorComponent instanceof JTextComponent)) { - JTextComponent textComponent = (JTextComponent) editorComponent; - lengthCellValue = textComponent.getText().length(); - if (lengthCellValue != -1) { - textComponent.select(lengthCellValue, lengthCellValue); - } - } - } - return result; - } - }
participants (1)
-
mallon@users.chorem.org