package com.onaro.sanscreen.client.view.common.highlights; import org.eclipse.core.runtime.IAdaptable; import com.onaro.client.swing.table.functional.FunctionalTableModel; import com.onaro.client.swing.table.functional.IFunction; import com.onaro.client.swing.table.functional.IFunctionGroup; import com.onaro.sanscreen.client.view.tabular.FunctionalHighlight; /** * Used to change the row highlighting to red if the object has a violation * @param {@link IFunction} * @see FunctionalHighlight */ public class HasViolationHighlight> extends FunctionalHighlight { private static final String STYLE_NAME = "violationRow"; //$NON-NLS-1$ private final Class functionClass; /** * Constructor for a violation highlight for a specific function model and corresponding table model * @param {@link functionClass} * @param {@link FunctionalTableModel} */ public HasViolationHighlight(Class functionClass, FunctionalTableModel tableModel) { super(tableModel); this.functionClass = functionClass; setStyleName(STYLE_NAME); } /** * Creates a violation highlight for a specific function model and corresponding table model * @param {@link functionClass} * @param {@link FunctionalTableModel} */ public static > HasViolationHighlight create(Class functionClass, FunctionalTableModel tableModel) { return new HasViolationHighlight(functionClass, tableModel); } @Override public boolean shouldApply(IAdaptable row) { F getHasViolationsFunction = getFunction(functionClass); Boolean hasViolations = getHasViolationsFunction.evaluate(row); return Boolean.TRUE.equals(hasViolations); } @Override public void getRequiredFunctions(IFunctionGroup group) { super.getRequiredFunctions(group); group.add(functionClass); } }