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();
} // 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".
* Windows = lightGray
@ -306,7 +330,7 @@ public final class AdempierePLAF
s_vp_adempiereTheme = new ValueNamePair("org.adempiere.plaf.AdempiereTheme", AdempiereThemeInnova.NAME);
plasticThemes.add (s_vp_adempiereTheme);
List installedThemes = AdempiereLookAndFeel.getInstalledThemes();
List<?> installedThemes = AdempiereLookAndFeel.getInstalledThemes();
for(Object t : installedThemes) {
MetalTheme theme = (MetalTheme)t;
vp = new ValueNamePair(theme.getClass().getName(), theme.getName());
@ -337,7 +361,7 @@ public final class AdempierePLAF
// Install discovered PLAFs
for (int i = 0; i < plafList.size(); i++)
{
vp = (ValueNamePair)plafList.get(i);
vp = plafList.get(i);
UIManager.installLookAndFeel(vp.getName(), vp.getValue());
}
@ -451,7 +475,7 @@ public final class AdempierePLAF
log.config(plaf + (theme == null ? "" : (" - " + theme)));
// Look & Feel
Class lafClass = null;
Class<?> lafClass = null;
try {
lafClass = Class.forName(plaf.getValue());
}
@ -484,7 +508,7 @@ public final class AdempierePLAF
{
try
{
Class c = Class.forName(theme.getValue());
Class<?> c = Class.forName(theme.getValue());
MetalTheme t = (MetalTheme)c.newInstance();
if (compiere)
CompiereLookAndFeel.setCurrentTheme(t);
@ -661,7 +685,7 @@ public final class AdempierePLAF
String className = args[0];
// find class
Class startClass = null;
Class<?> startClass = null;
try
{
startClass = Class.forName(className);

View File

@ -48,6 +48,7 @@ import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.util.MSort;
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
@ -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 {
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_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_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_FG_KEY = "TextField.errorForeground";
public final static String MANDATORY_BG_KEY = "TextField.mandatoryBackground";
public final static String INACTIVE_BG_KEY = "TextField.inactiveBackground";
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";
}