/**
* Copyright (c) 2002-2007 Yuri Schimke. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.baulsupp.kolja.log.viewer.highlight;
import com.baulsupp.kolja.log.LogConstants;
import com.baulsupp.kolja.log.line.Line;
import com.baulsupp.kolja.log.line.type.Priority;
import com.baulsupp.kolja.util.colours.ColourPair;
public class PriorityHighlight implements Highlight<Line> {
private static final long serialVersionUID = 2264643873100280184L;
private String priorityField = LogConstants.PRIORITY;
public PriorityHighlight() {
}
public String getPriorityField() {
return priorityField;
}
public void setPriorityField(String priorityField) {
this.priorityField = priorityField;
}
public HighlightResult getHighlights(Line viewRow) {
Priority priority = (Priority) viewRow.getValue(priorityField);
if (priority != null) {
if (priority.atleast(Priority.ERROR)) {
return HighlightResult.row(ColourPair.RED_ON_WHITE);
} else if (priority.atleast(Priority.WARN)) {
return HighlightResult.row(ColourPair.MAGENTA_ON_BLACK);
} else if (priority.atleast(Priority.INFO)) {
return HighlightResult.column(priorityField, ColourPair.GREEN_ON_BLACK);
}
}
return null;
}
}