Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
March 2014
- 3 participants
- 21 discussions
r3751 - in trunk/lima-swing/src/main: java/org/chorem/lima java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/common java/org/chorem/lima/ui/financialperiod java/org/chorem/lima/ui/financialtransaction java/org/chorem/lima/ui/fiscalperiod resources/i18n
by sbavencoff@users.chorem.org 05 Mar '14
by sbavencoff@users.chorem.org 05 Mar '14
05 Mar '14
Author: sbavencoff
Date: 2014-03-05 12:59:43 +0100 (Wed, 05 Mar 2014)
New Revision: 3751
Url: http://forge.chorem.org/projects/lima/repository/revisions/3751
Log:
refs #971 : color of table cell
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/TableCellErrorDetector.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodErrorDetector.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodErrorDetector.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -511,8 +511,152 @@
_("lima.config.selectAllEditingCell.label"),
n_("lima.config.selectAllEditingCell.description"),
"true",
- Boolean.class, false, false);
+ Boolean.class, false, false),
+ TABLE_CELL_BACKGROUND("lima.ui.table.cell.background",
+ _("lima.config.cell.background.label"),
+ n_("lima.config.cell.background.description"),
+ "#FFFFFF",
+ Color.class, false, false),
+
+ TABLE_CELL_FOREGROUND("lima.ui.table.cell.foreground",
+ _("lima.config.cell.foreground.label"),
+ n_("lima.config.cell.foreground.description"),
+ "#000000",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_BACKGROUND("lima.ui.table.cell.pair.background",
+ _("lima.config.cell.pair.background.label"),
+ n_("lima.config.cell.pair.background.description"),
+ "#EEEEEE",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_FOREGROUND("lima.ui.table.cell.pair.foreground",
+ _("lima.config.cell.pair.foreground.label"),
+ n_("lima.config.cell.pair.foreground.description"),
+ "#000000",
+ Color.class, false, false),
+
+ TABLE_CELL_SELECTED_BACKGROUND("lima.ui.table.cell.selected.background",
+ _("lima.config.cell.selected.background.label"),
+ n_("lima.config.cell.selected.background.description"),
+ "#0066CC",
+ Color.class, false, false),
+
+ TABLE_CELL_SELECTED_FOREGROUND("lima.ui.table.cell.selected.foreground",
+ _("lima.config.cell.selected.foreground.label"),
+ n_("lima.config.cell.selected.foreground.description"),
+ "#FFFFFF",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_SELECTED_BACKGROUND("lima.ui.table.cell.pair.selected.background",
+ _("lima.config.cell.pair.selected.background.label"),
+ n_("lima.config.cell.pair.selected.background.description"),
+ "#006699",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_SELECTED_FOREGROUND("lima.ui.table.cell.pair.selected.foreground",
+ _("lima.config.cell.pair.selected.foreground.label"),
+ n_("lima.config.cell.pair.selected.foreground.description"),
+ "#FFFFFF",
+ Color.class, false, false),
+
+ TABLE_CELL_ERROR_BACKGROUND("lima.ui.table.cell.error.background",
+ _("lima.config.cell.error.background.label"),
+ n_("lima.config.cell.error.background.description"),
+ "#FFFFFF",
+ Color.class, false, false),
+
+ TABLE_CELL_ERROR_FOREGROUND("lima.ui.table.cell.error.foreground",
+ _("lima.config.cell.error.foreground.label"),
+ n_("lima.config.cell.error.foreground.description"),
+ "#FF0936",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_ERROR_BACKGROUND("lima.ui.table.cell.pair.error.background",
+ _("lima.config.cell.pair.error.background.label"),
+ n_("lima.config.cell.pair.error.background.description"),
+ "#EEEEEE",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_ERROR_FOREGROUND("lima.ui.table.cell.pair.error.foreground",
+ _("lima.config.cell.pair.error.foreground.label"),
+ n_("lima.config.cell.pair.error.foreground.description"),
+ "#FC0625",
+ Color.class, false, false),
+
+ TABLE_CELL_SELECTED_ERROR_BACKGROUND("lima.ui.table.cell.selected.error.background",
+ _("lima.config.cell.selected.error.background.label"),
+ n_("lima.config.cell.selected.error.background.description"),
+ "#0066CC",
+ Color.class, false, false),
+
+ TABLE_CELL_SELECTED_ERROR_FOREGROUND("lima.ui.table.cell.selected.error.foreground",
+ _("lima.config.cell.selected.error.foreground.label"),
+ n_("lima.config.cell.selected.error.foreground.description"),
+ "#C998C1",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_SELECTED_ERROR_BACKGROUND("lima.ui.table.cell.pair.selected.error.background",
+ _("lima.config.cell.pair.selected.error.background.label"),
+ n_("lima.config.cell.pair.selected.error.background.description"),
+ "#006699",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_SELECTED_ERROR_FOREGROUND("lima.ui.table.cell.pair.selected.error.foreground",
+ _("lima.config.cell.pair.selected.error.foreground.label"),
+ n_("lima.config.cell.pair.selected.error.foreground.description"),
+ "#C96678",
+ Color.class, false, false),
+
+ TABLE_CELL_MANDATORY_BACKGROUND("lima.ui.table.cell.mandatory.background",
+ _("lima.config.cell.mandatory.background.label"),
+ n_("lima.config.cell.mandatory.background.description"),
+ "#FFCCCC",
+ Color.class, false, false),
+
+ TABLE_CELL_MANDATORY_FOREGROUND("lima.ui.table.cell.mandatory.foreground",
+ _("lima.config.cell.mandatory.foreground.label"),
+ n_("lima.config.cell.mandatory.foreground.description"),
+ "#000000",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_MANDATORY_BACKGROUND("lima.ui.table.cell.pair.mandatory.background",
+ _("lima.config.cell.pair.mandatory.background.label"),
+ n_("lima.config.cell.pair.mandatory.background.description"),
+ "#FF99CC",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_MANDATORY_FOREGROUND("lima.ui.table.cell.pair.mandatory.foreground",
+ _("lima.config.cell.pair.mandatory.foreground.label"),
+ n_("lima.config.cell.pair.mandatory.foreground.description"),
+ "#000000",
+ Color.class, false, false),
+
+ TABLE_CELL_SELECTED_MANDATORY_BACKGROUND("lima.ui.table.cell.selected.mandatory.background",
+ _("lima.config.cell.selected.mandatory.background.label"),
+ n_("lima.config.cell.selected.mandatory.background.description"),
+ "#FF0000",
+ Color.class, false, false),
+
+ TABLE_CELL_SELECTED_MANDATORY_FOREGROUND("lima.ui.table.cell.selected.mandatory.foreground",
+ _("lima.config.cell.selected.mandatory.foreground.label"),
+ n_("lima.config.cell.selected.mandatory.foreground.description"),
+ "#FFFFFF",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_SELECTED_MANDATORY_BACKGROUND("lima.ui.table.cell.pair.selected.mandatory.background",
+ _("lima.config.cell.pair.selected.mandatory.background.label"),
+ n_("lima.config.cell.pair.selected.mandatory.background.description"),
+ "#990000",
+ Color.class, false, false),
+
+ TABLE_CELL_PAIR_SELECTED_MANDATORY_FOREGROUND("lima.ui.table.cell.pair.selected.mandatory.foreground",
+ _("lima.config.cell.pair.selected.mandatory.foreground.label"),
+ n_("lima.config.cell.pair.selected.mandatory.foreground.description"),
+ "#000000",
+ Color.class, false, false);
+
public enum ComportmentEditingCellEnum {ALL, NOTHING}
public final String key;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -1,13 +1,10 @@
package org.chorem.lima.ui.celleditor;
-import org.chorem.lima.ui.common.FinancialTransactionTableModel;
+import org.chorem.lima.LimaConfig;
import org.chorem.lima.ui.common.TableModelWithGroup;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
-import sun.swing.DefaultLookup;
import javax.swing.*;
import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
@@ -18,74 +15,101 @@
private String text = null;
+ protected boolean mandatory;
+
+ protected TableCellErrorDetector errorDetector;
+
+ public DefaultLimaTableCellRenderer() {
+ mandatory = false;
+ errorDetector = new TableCellErrorDetector();
+ }
+
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//Create a new JLabel to avoid colouring only when row is selected
JLabel myCell = new JLabel();
myCell.setOpaque(true);
- myCell.setBorder(new EmptyBorder(1, 1, 1, 1));
+
myCell.setName("Table.entryCellRenderer");
- Color background = Color.WHITE;
- Color foreground = Color.BLACK;
+ int line = row;
- if (isSelected) {
- foreground = table.getSelectionForeground();
- background = table.getSelectionBackground();
- } else {
- Color alternateColor = new Color(204, 207, 223);
+ if (table.getModel() instanceof TableModelWithGroup) {
+ TableModelWithGroup model = (TableModelWithGroup) table.getModel();
- if (table.getModel() instanceof TableModelWithGroup) {
- TableModelWithGroup model = (TableModelWithGroup) table.getModel();
- if (model.indexGroupAt(row) % 2 != 0) {
- background = alternateColor;
- }
- } else if (row % 2 != 0) {
- background = alternateColor;
- }
+ line = model.indexInGroup(row);
}
- if (table.isCellEditable(row, column)
- && (value == null
- || (value instanceof String) && ((String) value).isEmpty()
- )
- ) {
- background = new Color(255, 198, 209);
- }
+ LimaConfig limaConfig = LimaConfig.getInstance();
- if (table instanceof FinancialTransactionTable) {
- FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
- if (model.getBalanceTransactionInRow(row).signum() != 0) {
- foreground = new Color(240, 30, 30);
- }
+ // border
+ Border border = BorderFactory.createEmptyBorder(1, 1, 1, 1);
+ if (hasFocus) {
+ Color color = limaConfig.getOptionAsColor(LimaConfig.Option.COLOR_SELECTION_FOCUS.key);
+ border = BorderFactory.createLineBorder(color, 2);
+ } else if (line == 0 && table.getModel() instanceof TableModelWithGroup) {
+ border = BorderFactory.createMatteBorder(1, 0, 0, 0, Color.BLACK);
}
- if (hasFocus) {
- Border border = null;
+ myCell.setBorder(border);
+
+ // color
+
+ LimaConfig.Option backgroundOption;
+ LimaConfig.Option foreGroundOption;
+
+ if (line % 2 == 1) {
if (isSelected) {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusSelectedCellHighlightBorder");
+ if (errorDetector.isError(table, value, row, column)) {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_PAIR_SELECTED_ERROR_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_PAIR_SELECTED_ERROR_FOREGROUND;
+ } else if (isMandatory(table, value, row, column)){
+ backgroundOption = LimaConfig.Option.TABLE_CELL_PAIR_SELECTED_MANDATORY_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_PAIR_SELECTED_MANDATORY_FOREGROUND;
+ } else {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_PAIR_SELECTED_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_PAIR_SELECTED_FOREGROUND;
+ }
+ } else {
+ if (errorDetector.isError(table, value, row, column)) {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_PAIR_ERROR_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_PAIR_ERROR_FOREGROUND;
+ } else if (isMandatory(table, value, row, column)){
+ backgroundOption = LimaConfig.Option.TABLE_CELL_PAIR_MANDATORY_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_PAIR_MANDATORY_FOREGROUND;
+ } else {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_PAIR_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_PAIR_FOREGROUND;
+ }
}
- if (border == null) {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusCellHighlightBorder");
- }
- myCell.setBorder(border);
- if (table.getModel().isCellEditable(row, column)) {
- background = Color.WHITE;
- foreground = Color.BLACK;
- }
} else {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- Border border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.cellNoFocusBorder");
- if (border == null) {
- border = new EmptyBorder(1, 1, 1, 1);
+ if (isSelected) {
+ if (errorDetector.isError(table, value, row, column)) {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_SELECTED_ERROR_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_SELECTED_ERROR_FOREGROUND;
+ } else if (isMandatory(table, value, row, column)){
+ backgroundOption = LimaConfig.Option.TABLE_CELL_SELECTED_MANDATORY_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_SELECTED_MANDATORY_FOREGROUND;
+ } else {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_SELECTED_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_SELECTED_FOREGROUND;
+ }
+ } else {
+ if (errorDetector.isError(table, value, row, column)) {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_ERROR_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_ERROR_FOREGROUND;
+ } else if (isMandatory(table, value, row, column)){
+ backgroundOption = LimaConfig.Option.TABLE_CELL_MANDATORY_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_MANDATORY_FOREGROUND;
+ } else {
+ backgroundOption = LimaConfig.Option.TABLE_CELL_BACKGROUND;
+ foreGroundOption = LimaConfig.Option.TABLE_CELL_FOREGROUND;
+ }
}
- myCell.setBorder(border);
}
- myCell.setBackground(background);
- myCell.setForeground(foreground);
+ myCell.setBackground(limaConfig.getOptionAsColor(backgroundOption.key));
+ myCell.setForeground(limaConfig.getOptionAsColor(foreGroundOption.key));
setValue(value);
myCell.setText(text);
@@ -97,4 +121,28 @@
this.text = (value == null) ? "" : value.toString();
}
+ public boolean isMandatory() {
+ return mandatory;
+ }
+
+ public void setMandatory(boolean mandatory) {
+ this.mandatory = mandatory;
+ }
+
+ protected boolean isMandatory(JTable table, Object value, int row, int column) {
+ return mandatory && table.isCellEditable(row, column)
+ && (value == null
+ || (value instanceof String) && ((String) value).isEmpty());
+ }
+
+ public TableCellErrorDetector getError() {
+ return errorDetector;
+ }
+
+ public void setErrorDetector(TableCellErrorDetector errorDetector) {
+ this.errorDetector = errorDetector;
+ }
+
+
+
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -1,52 +0,0 @@
-package org.chorem.lima.ui.celleditor;
-
-/*
- * #%L
- * Lima :: Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2013 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.chorem.lima.ui.common.FinancialTransactionTableModel;
-import org.chorem.lima.ui.common.LineRenderer;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class EntryTableCellRenderer extends LineRenderer {
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- if (table instanceof FinancialTransactionTable) {
- FinancialTransactionTableModel model = (FinancialTransactionTableModel) table.getModel();
- if (!isSelected && model.getBalanceTransactionInRow(row).signum() != 0) {
- component.setForeground(new Color(240, 30, 30));
- }
- }
-
- return component;
- }
-}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/TableCellErrorDetector.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/TableCellErrorDetector.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/TableCellErrorDetector.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -0,0 +1,15 @@
+package org.chorem.lima.ui.celleditor;
+
+import javax.swing.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class TableCellErrorDetector {
+
+ public boolean isError(JTable table, Object value, int row, int column) {
+ return false;
+ }
+
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -18,7 +18,6 @@
import javax.swing.*;
import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -36,13 +35,9 @@
protected H handler;
- protected LineRenderer lineRenderer;
-
public AbstractLimaTable(H handler) {
this.handler = handler;
- lineRenderer = new LineRenderer();
-
setShowHorizontalLines(true);
setShowVerticalLines(true);
setGridColor(new Color(232, 232, 246));
@@ -64,6 +59,8 @@
setDefaultEditor(Account.class, new AccountTableCellEditor());
setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
setDefaultEditor(String.class, new StringTableCellEditor());
+
+ setShowHorizontalLines(false);
}
protected void initNavigation() {
@@ -87,17 +84,6 @@
return handler;
}
- @Override
- public TableCellRenderer getCellRenderer(int row, int column) {
- TableCellRenderer renderer = super.getCellRenderer(row, column);
-
- if (lineRenderer != null) {
- lineRenderer.setCellRenderer(renderer);
- renderer = lineRenderer;
- }
- return renderer;
- }
-
public void exit() {
if (isEditing()) {
TableCellEditor editor = getCellEditor();
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -1,44 +0,0 @@
-package org.chorem.lima.ui.common;
-
-import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer;
-
-import javax.swing.*;
-import javax.swing.table.TableCellRenderer;
-import java.awt.*;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class LineRenderer extends DefaultLimaTableCellRenderer {
-
- protected TableCellRenderer cellRenderer;
-
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
- Component component;
-
- if (cellRenderer != null) {
-
- component = cellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- } else {
-
- component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- }
-
-
- return component;
-
- }
-
- public TableCellRenderer getCellRenderer() {
- return cellRenderer;
- }
-
- public void setCellRenderer(TableCellRenderer cellRenderer) {
- this.cellRenderer = cellRenderer;
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -43,5 +43,14 @@
}
+ public int indexInGroup(int row) {
+ int index = 0;
+ while (row-index > 0 && sameGroup(get(row), get(row-index-1))) {
+ index++;
+ }
+ return index;
+
+ }
+
public abstract boolean sameGroup(E e1, E e2);
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodErrorDetector.java (from rev 3750, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodErrorDetector.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodErrorDetector.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -0,0 +1,32 @@
+package org.chorem.lima.ui.financialperiod;
+
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+import org.chorem.lima.ui.celleditor.TableCellErrorDetector;
+
+import javax.swing.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialPeriodErrorDetector extends TableCellErrorDetector {
+
+ @Override
+ public boolean isError(JTable table, Object value, int row, int column) {
+
+ boolean error = false;
+
+ if (table.getModel() instanceof FinancialPeriodTableModel) {
+
+ FinancialPeriodTableModel model = (FinancialPeriodTableModel) table.getModel();
+
+ ClosedPeriodicEntryBook closedPeriodicEntryBook = model.get(row);
+
+ error = closedPeriodicEntryBook.getLocked();
+
+ }
+
+ return error;
+
+ }
+
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodRenderer.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodRenderer.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -1,29 +0,0 @@
-package org.chorem.lima.ui.financialperiod;
-
-import org.chorem.lima.entity.ClosedPeriodicEntryBook;
-import org.chorem.lima.ui.common.LineRenderer;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class FinancialPeriodRenderer extends LineRenderer {
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
- Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- if (table.getModel() instanceof FinancialPeriodTableModel) {
- FinancialPeriodTableModel model = (FinancialPeriodTableModel) table.getModel();
- ClosedPeriodicEntryBook closedPeriodicEntryBook = model.get(row);
- if (!isSelected && closedPeriodicEntryBook.getLocked()) {
- component.setForeground(new Color(222, 0, 0));
- }
- }
- return component;
- }
-
-}
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 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -25,8 +25,15 @@
package org.chorem.lima.ui.financialperiod;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellRender;
+import org.chorem.lima.ui.celleditor.TableCellErrorDetector;
import org.chorem.lima.ui.common.AbstractLimaTable;
+import java.util.Date;
+
/**
* Financial period table adding color hidhlighter and key management.
*
@@ -49,8 +56,21 @@
public FinancialPeriodTable(FinancialPeriodViewHandler handler) {
super(handler);
- lineRenderer = new FinancialPeriodRenderer();
+ // renderer
+ TableCellErrorDetector errorDetector = new FinancialPeriodErrorDetector();
+ DefaultLimaTableCellRenderer renderer = new DefaultLimaTableCellRenderer();
+ renderer.setErrorDetector(errorDetector);
+ setDefaultRenderer(Object.class, renderer);
+
+ renderer = new DateLimaTableCellRenderer();
+ renderer.setErrorDetector(errorDetector);
+ setDefaultRenderer(Date.class, renderer);
+
+ renderer = new EntryBookTableCellRender();
+ renderer.setErrorDetector(errorDetector);
+ setDefaultRenderer(EntryBook.class, renderer);
+
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -26,13 +26,22 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellRender;
+import org.chorem.lima.ui.celleditor.TableCellErrorDetector;
import org.chorem.lima.ui.common.AbstractLimaTable;
import org.chorem.lima.ui.common.CellRouteHorizontalAction;
import org.chorem.lima.ui.common.CellRouteVerticalAction;
import javax.swing.*;
import java.awt.event.KeyEvent;
+import java.math.BigDecimal;
+import java.util.Date;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
@@ -47,7 +56,29 @@
public FinancialTransactionDefaultTable(H handler) {
super(handler);
setSortable(false);
- lineRenderer = new EntryTableCellRenderer();
+
+ // renderer
+ TableCellErrorDetector errorDetector = new FinancialTransactionErrorDetector();
+
+ DefaultLimaTableCellRenderer renderer = new DefaultLimaTableCellRenderer();
+ renderer.setMandatory(true);
+ setDefaultRenderer(Object.class, renderer);
+
+ renderer = new DateLimaTableCellRenderer();
+ renderer.setMandatory(true);
+ setDefaultRenderer(Date.class, renderer);
+
+ renderer = new BigDecimalTableCellRenderer();
+ renderer.setErrorDetector(errorDetector);
+ setDefaultRenderer(BigDecimal.class, renderer);
+
+ renderer = new AccountTableCellRenderer();
+ renderer.setMandatory(true);
+ setDefaultRenderer(Account.class, renderer);
+
+ renderer = new EntryBookTableCellRender();
+ renderer.setMandatory(true);
+ setDefaultRenderer(EntryBook.class, renderer);
}
@Override
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionErrorDetector.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -0,0 +1,30 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.ui.celleditor.TableCellErrorDetector;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
+
+import javax.swing.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialTransactionErrorDetector extends TableCellErrorDetector {
+
+ @Override
+ public boolean isError(JTable table, Object value, int row, int column) {
+
+ boolean error = false;
+
+ if (table.getModel() instanceof FinancialTransactionTableModel) {
+
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel) table.getModel();
+
+ error = model.getBalanceTransactionInRow(row).signum() != 0;
+
+ }
+
+ return error;
+
+
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodErrorDetector.java (from rev 3750, trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodErrorDetector.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodErrorDetector.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -0,0 +1,31 @@
+package org.chorem.lima.ui.fiscalperiod;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.celleditor.TableCellErrorDetector;
+
+import javax.swing.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FiscalPeriodErrorDetector extends TableCellErrorDetector {
+
+ @Override
+ public boolean isError(JTable table, Object value, int row, int column) {
+
+ boolean error = false;
+
+ if (table.getModel() instanceof FiscalPeriodTableModel) {
+
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+
+ FiscalPeriod fiscalPeriod = model.get(row);
+
+ error = fiscalPeriod.getLocked();
+
+ }
+
+ return error;
+
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -1,28 +0,0 @@
-package org.chorem.lima.ui.fiscalperiod;
-
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.ui.common.LineRenderer;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class FiscalPeriodRenderer extends LineRenderer {
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
- Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- if (table.getModel() instanceof FiscalPeriodTableModel) {
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
- FiscalPeriod fiscalPeriod = model.get(row);
- if (!isSelected && fiscalPeriod.getLocked()) {
- component.setForeground(new Color(222, 0, 0));
- }
- }
- return component;
- }
-}
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 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2014-03-05 11:59:43 UTC (rev 3751)
@@ -25,8 +25,13 @@
package org.chorem.lima.ui.fiscalperiod;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer;
+import org.chorem.lima.ui.celleditor.TableCellErrorDetector;
import org.chorem.lima.ui.common.AbstractLimaTable;
+import java.util.Date;
+
/**
* Fiscal period table add support for JXTable.
*
@@ -48,7 +53,17 @@
public FiscalPeriodTable(FiscalPeriodViewHandler handler) {
super(handler);
- lineRenderer = new FiscalPeriodRenderer();
+
+ // renderer
+ TableCellErrorDetector errorDetector = new FiscalPeriodErrorDetector();
+
+ DefaultLimaTableCellRenderer renderer = new DefaultLimaTableCellRenderer();
+ renderer.setErrorDetector(errorDetector);
+ setDefaultRenderer(Object.class, renderer);
+
+ renderer = new DateLimaTableCellRenderer();
+ renderer.setErrorDetector(errorDetector);
+ setDefaultRenderer(Date.class, renderer);
}
}
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2014-03-05 11:59:43 UTC (rev 3751)
@@ -91,6 +91,54 @@
lima.config.category.directories.description=Directories used by LIMA
lima.config.category.other=Other
lima.config.category.other.description=Other configuration properties
+lima.config.cell.background.description=
+lima.config.cell.background.label=
+lima.config.cell.error.background.description=
+lima.config.cell.error.background.label=
+lima.config.cell.error.foreground.description=
+lima.config.cell.error.foreground.label=
+lima.config.cell.foreground.description=
+lima.config.cell.foreground.label=
+lima.config.cell.mandatory.background.description=
+lima.config.cell.mandatory.background.label=
+lima.config.cell.mandatory.foreground.description=
+lima.config.cell.mandatory.foreground.label=
+lima.config.cell.pair.background.description=
+lima.config.cell.pair.background.label=
+lima.config.cell.pair.error.background.description=
+lima.config.cell.pair.error.background.label=
+lima.config.cell.pair.error.foreground.description=
+lima.config.cell.pair.error.foreground.label=
+lima.config.cell.pair.foreground.description=
+lima.config.cell.pair.foreground.label=
+lima.config.cell.pair.mandatory.background.description=
+lima.config.cell.pair.mandatory.background.label=
+lima.config.cell.pair.mandatory.foreground.description=
+lima.config.cell.pair.mandatory.foreground.label=
+lima.config.cell.pair.selected.background.description=
+lima.config.cell.pair.selected.background.label=
+lima.config.cell.pair.selected.error.background.description=
+lima.config.cell.pair.selected.error.background.label=
+lima.config.cell.pair.selected.error.foreground.description=
+lima.config.cell.pair.selected.error.foreground.label=
+lima.config.cell.pair.selected.foreground.description=
+lima.config.cell.pair.selected.foreground.label=
+lima.config.cell.pair.selected.mandatory.background.description=
+lima.config.cell.pair.selected.mandatory.background.label=
+lima.config.cell.pair.selected.mandatory.foreground.description=
+lima.config.cell.pair.selected.mandatory.foreground.label=
+lima.config.cell.selected.background.description=
+lima.config.cell.selected.background.label=
+lima.config.cell.selected.error.background.description=
+lima.config.cell.selected.error.background.label=
+lima.config.cell.selected.error.foreground.description=
+lima.config.cell.selected.error.foreground.label=
+lima.config.cell.selected.foreground.description=
+lima.config.cell.selected.foreground.label=
+lima.config.cell.selected.mandatory.background.description=
+lima.config.cell.selected.mandatory.background.label=
+lima.config.cell.selected.mandatory.foreground.description=
+lima.config.cell.selected.mandatory.foreground.label=
lima.config.colorselectionfocus=Cadring color of the selection of a cell
lima.config.colorselectionfocus.description=
lima.config.colorselectionfocus.label=
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-02-28 15:18:09 UTC (rev 3750)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2014-03-05 11:59:43 UTC (rev 3751)
@@ -80,6 +80,54 @@
lima.config.category.directories.description=Répertoires utilisés par Lima
lima.config.category.other=Autre
lima.config.category.other.description=Autre propriétés de configuration
+lima.config.cell.background.description=
+lima.config.cell.background.label=
+lima.config.cell.error.background.description=
+lima.config.cell.error.background.label=
+lima.config.cell.error.foreground.description=
+lima.config.cell.error.foreground.label=
+lima.config.cell.foreground.description=
+lima.config.cell.foreground.label=
+lima.config.cell.mandatory.background.description=
+lima.config.cell.mandatory.background.label=
+lima.config.cell.mandatory.foreground.description=
+lima.config.cell.mandatory.foreground.label=
+lima.config.cell.pair.background.description=
+lima.config.cell.pair.background.label=
+lima.config.cell.pair.error.background.description=
+lima.config.cell.pair.error.background.label=
+lima.config.cell.pair.error.foreground.description=
+lima.config.cell.pair.error.foreground.label=
+lima.config.cell.pair.foreground.description=
+lima.config.cell.pair.foreground.label=
+lima.config.cell.pair.mandatory.background.description=
+lima.config.cell.pair.mandatory.background.label=
+lima.config.cell.pair.mandatory.foreground.description=
+lima.config.cell.pair.mandatory.foreground.label=
+lima.config.cell.pair.selected.background.description=
+lima.config.cell.pair.selected.background.label=
+lima.config.cell.pair.selected.error.background.description=
+lima.config.cell.pair.selected.error.background.label=
+lima.config.cell.pair.selected.error.foreground.description=
+lima.config.cell.pair.selected.error.foreground.label=
+lima.config.cell.pair.selected.foreground.description=
+lima.config.cell.pair.selected.foreground.label=
+lima.config.cell.pair.selected.mandatory.background.description=
+lima.config.cell.pair.selected.mandatory.background.label=
+lima.config.cell.pair.selected.mandatory.foreground.description=
+lima.config.cell.pair.selected.mandatory.foreground.label=
+lima.config.cell.selected.background.description=
+lima.config.cell.selected.background.label=
+lima.config.cell.selected.error.background.description=
+lima.config.cell.selected.error.background.label=
+lima.config.cell.selected.error.foreground.description=
+lima.config.cell.selected.error.foreground.label=
+lima.config.cell.selected.foreground.description=
+lima.config.cell.selected.foreground.label=
+lima.config.cell.selected.mandatory.background.description=
+lima.config.cell.selected.mandatory.background.label=
+lima.config.cell.selected.mandatory.foreground.description=
+lima.config.cell.selected.mandatory.foreground.label=
lima.config.colorselectionfocus=
lima.config.colorselectionfocus.description=Couleur des bordures de la séléction
lima.config.colorselectionfocus.label=Couleur de l'encadrement de sélection d'une cellule
1
0