1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import java.util.Date ; 14 import org.eclipse.jface.viewers.Viewer; 15 import org.eclipse.jface.viewers.ViewerFilter; 16 import org.eclipse.team.internal.ccvs.core.ILogEntry; 17 18 public class HistoryFilter extends ViewerFilter { 19 private HistoryView view; 20 public String author; 21 public Date fromDate; 22 public Date toDate; 23 public String comment; 24 public boolean isOr; 25 26 public HistoryFilter(HistoryView hView, String author, String comment, Date fromDate, Date toDate, boolean isOr) { 27 this.view = hView; 28 this.author = author; 29 this.comment = comment; 30 this.fromDate = fromDate; 31 this.toDate = toDate; 32 this.isOr = isOr; 33 } 34 37 public boolean select(Viewer aviewer, Object parentElement, Object element) { 38 if (element instanceof ILogEntry) { 39 ILogEntry entry = (ILogEntry)element; 40 if (isOr) { 41 return (hasAuthor() && authorMatch(entry) ) 43 || (hasDate() && dateMatch(entry)) 44 || (hasComment() && commentMatch(entry)); 45 } else { 46 return (!hasAuthor() || authorMatch(entry)) 49 && (!hasDate() || dateMatch(entry)) 50 && (!hasComment() || commentMatch(entry)); 51 } 52 } 53 return false; 54 } 55 protected boolean authorMatch(ILogEntry entry) { 56 return entry.getAuthor().equals(author); 57 } 58 protected boolean commentMatch(ILogEntry entry) { 59 return !(entry.getComment().toLowerCase().indexOf(comment.toLowerCase()) == -1); 60 } 61 protected boolean dateMatch(ILogEntry entry) { 62 return (fromDate.before(entry.getDate())) 63 && (toDate.after(entry.getDate())); 64 } 65 protected boolean hasAuthor() { 66 return !author.equals(""); } 68 protected boolean hasComment() { 69 return !comment.equals(""); } 71 protected boolean hasDate() { 72 return fromDate != null && toDate != null; 73 } 74 } 75 | Popular Tags |