FR [2982910] Usability - Color of consecutive rows - thanks to waqarazeem and jmpiloq

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2982910
This commit is contained in:
Carlos Ruiz 2010-04-07 19:09:49 +00:00
parent b58d0b19e2
commit 409519b13b
3 changed files with 52 additions and 7 deletions

View File

@ -114,6 +114,30 @@ public final class AdempierePLAF
return getFieldBackground_Normal(); return getFieldBackground_Normal();
} // getFieldBackground_Inactive } // getFieldBackground_Inactive
/**
* Return Selected field background color
* @return Color
*/
public static Color getFieldBackground_Selected()
{
Color c = UIManager.getColor(ExtendedTheme.SELECTED_BG_KEY);
if (c == null)
c = ExtendedTheme.DEFAULT_SELECTED_BG;
return ColorBlind.getDichromatColor(c);
} // getFieldBackground_Selected
/**
* Return ReadOnly field background color
* @return Color
*/
public static Color getFieldBackground_ReadOnly()
{
Color c = UIManager.getColor(ExtendedTheme.READONLY_BG_KEY);
if (c == null)
c = ExtendedTheme.DEFAULT_READONLY_BG;
return ColorBlind.getDichromatColor(c);
} // getFieldBackground_ReadOnly
/** /**
* Return form background color "control". * Return form background color "control".
* Windows = lightGray * Windows = lightGray
@ -306,7 +330,7 @@ public final class AdempierePLAF
s_vp_adempiereTheme = new ValueNamePair("org.adempiere.plaf.AdempiereTheme", AdempiereThemeInnova.NAME); s_vp_adempiereTheme = new ValueNamePair("org.adempiere.plaf.AdempiereTheme", AdempiereThemeInnova.NAME);
plasticThemes.add (s_vp_adempiereTheme); plasticThemes.add (s_vp_adempiereTheme);
List installedThemes = AdempiereLookAndFeel.getInstalledThemes(); List<?> installedThemes = AdempiereLookAndFeel.getInstalledThemes();
for(Object t : installedThemes) { for(Object t : installedThemes) {
MetalTheme theme = (MetalTheme)t; MetalTheme theme = (MetalTheme)t;
vp = new ValueNamePair(theme.getClass().getName(), theme.getName()); vp = new ValueNamePair(theme.getClass().getName(), theme.getName());
@ -337,7 +361,7 @@ public final class AdempierePLAF
// Install discovered PLAFs // Install discovered PLAFs
for (int i = 0; i < plafList.size(); i++) for (int i = 0; i < plafList.size(); i++)
{ {
vp = (ValueNamePair)plafList.get(i); vp = plafList.get(i);
UIManager.installLookAndFeel(vp.getName(), vp.getValue()); UIManager.installLookAndFeel(vp.getName(), vp.getValue());
} }
@ -451,7 +475,7 @@ public final class AdempierePLAF
log.config(plaf + (theme == null ? "" : (" - " + theme))); log.config(plaf + (theme == null ? "" : (" - " + theme)));
// Look & Feel // Look & Feel
Class lafClass = null; Class<?> lafClass = null;
try { try {
lafClass = Class.forName(plaf.getValue()); lafClass = Class.forName(plaf.getValue());
} }
@ -484,7 +508,7 @@ public final class AdempierePLAF
{ {
try try
{ {
Class c = Class.forName(theme.getValue()); Class<?> c = Class.forName(theme.getValue());
MetalTheme t = (MetalTheme)c.newInstance(); MetalTheme t = (MetalTheme)c.newInstance();
if (compiere) if (compiere)
CompiereLookAndFeel.setCurrentTheme(t); CompiereLookAndFeel.setCurrentTheme(t);
@ -661,7 +685,7 @@ public final class AdempierePLAF
String className = args[0]; String className = args[0];
// find class // find class
Class startClass = null; Class<?> startClass = null;
try try
{ {
startClass = Class.forName(className); startClass = Class.forName(className);

View File

@ -48,6 +48,7 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.util.MSort; import org.compiere.util.MSort;
import org.jdesktop.swingx.icon.ColumnControlIcon; import org.jdesktop.swingx.icon.ColumnControlIcon;
@ -65,7 +66,7 @@ public class CTable extends JTable
/** /**
* *
*/ */
private static final long serialVersionUID = 772619961990977001L; private static final long serialVersionUID = 975975420639030844L;
/** /**
* Default Constructor * Default Constructor
@ -707,6 +708,22 @@ public class CTable extends JTable
} }
} }
public Component prepareRenderer(TableCellRenderer renderer, int rowIndex,
int vColIndex) {
Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
if (!this.isCellEditable(rowIndex, vColIndex))
return c;
if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
c.setBackground(AdempierePLAF.getFieldBackground_Selected());
} else {
// If not shaded, match the table's background
c.setBackground(getBackground());
}
if (isCellSelected(rowIndex, vColIndex))
c.setBackground(AdempierePLAF.getFieldBackground_ReadOnly());
return c;
}
class ColumnAttributes { class ColumnAttributes {
protected TableCellEditor cellEditor; protected TableCellEditor cellEditor;

View File

@ -19,12 +19,16 @@ public interface ExtendedTheme {
public final static ColorUIResource DEFAULT_ERROR_FG = new ColorUIResource(204, 0, 0); // dark red public final static ColorUIResource DEFAULT_ERROR_FG = new ColorUIResource(204, 0, 0); // dark red
public final static ColorUIResource DEFAULT_INACTIVE_BG = new ColorUIResource(234, 234, 234); // light gray public final static ColorUIResource DEFAULT_INACTIVE_BG = new ColorUIResource(234, 234, 234); // light gray
public final static ColorUIResource DEFAULT_INFO_BG = new ColorUIResource(253, 237, 207); // light yellow public final static ColorUIResource DEFAULT_INFO_BG = new ColorUIResource(253, 237, 207); // light yellow
public final static ColorUIResource DEFAULT_SELECTED_BG = new ColorUIResource(240, 248, 255); // light gray
public final static ColorUIResource DEFAULT_READONLY_BG = new ColorUIResource(255, 245, 238); // light yellow
public void setUIProperties(Map propertyMap); public void setUIProperties(Map<?, ?> propertyMap);
public final static String ERROR_BG_KEY = "TextField.errorBackground"; public final static String ERROR_BG_KEY = "TextField.errorBackground";
public final static String ERROR_FG_KEY = "TextField.errorForeground"; public final static String ERROR_FG_KEY = "TextField.errorForeground";
public final static String MANDATORY_BG_KEY = "TextField.mandatoryBackground"; public final static String MANDATORY_BG_KEY = "TextField.mandatoryBackground";
public final static String INACTIVE_BG_KEY = "TextField.inactiveBackground"; public final static String INACTIVE_BG_KEY = "TextField.inactiveBackground";
public final static String INFO_BG_KEY = "Info.background"; public final static String INFO_BG_KEY = "Info.background";
public final static String SELECTED_BG_KEY = "TextField.selectedBackground";
public final static String READONLY_BG_KEY = "TextField.readonlyBackground";
} }