1 11 package org.eclipse.team.internal.ui.history; 12 13 import java.util.ArrayList ; 14 import com.ibm.icu.util.Calendar; 15 16 import org.eclipse.team.core.history.IFileRevision; 17 18 public class DateHistoryCategory extends AbstractHistoryCategory { 19 20 private String name; 21 private Calendar fromDate; 22 private Calendar toDate; 23 24 private IFileRevision[] revisions; 25 26 34 public DateHistoryCategory(String name, Calendar fromDate, Calendar toDate){ 35 this.name = name; 36 this.fromDate = fromDate; 37 this.toDate = toDate; 38 } 39 40 43 public String getName() { 44 return name; 45 } 46 47 50 public boolean collectFileRevisions(IFileRevision[] fileRevisions, boolean shouldRemove) { 51 52 ArrayList pertinentRevisions = new ArrayList (); 53 ArrayList nonPertinentRevisions = new ArrayList (); 54 55 for (int i = 0; i < fileRevisions.length; i++) { 56 Calendar fileRevDate = Calendar.getInstance(); 58 fileRevDate.setTimeInMillis(fileRevisions[i].getTimestamp()); 59 60 int fileRevDay = fileRevDate.get(Calendar.DAY_OF_YEAR); 61 int fileRevYear = fileRevDate.get(Calendar.YEAR); 62 63 if (fromDate == null){ 64 if (((fileRevDay<toDate.get(Calendar.DAY_OF_YEAR)) && (fileRevYear == toDate.get(Calendar.YEAR))) || 66 (fileRevYear < toDate.get(Calendar.YEAR))){ 67 pertinentRevisions.add(fileRevisions[i]); 68 } else { 69 nonPertinentRevisions.add(fileRevisions[i]); 71 } 72 } else if (toDate == null){ 73 if ((fileRevDay == fromDate.get(Calendar.DAY_OF_YEAR)) && 75 (fileRevYear == fromDate.get(Calendar.YEAR))){ 76 pertinentRevisions.add(fileRevisions[i]); 77 } else { 78 nonPertinentRevisions.add(fileRevisions[i]); 79 } 80 } else { 81 if ((fileRevYear >= fromDate.get(Calendar.YEAR)) && 83 (fileRevYear <= toDate.get(Calendar.YEAR)) && 84 (fileRevDay >= fromDate.get(Calendar.DAY_OF_YEAR)) && 85 (fileRevDay < toDate.get(Calendar.DAY_OF_YEAR)) 86 ) { 87 pertinentRevisions.add(fileRevisions[i]); 88 } else { 89 nonPertinentRevisions.add(fileRevisions[i]); 90 } 91 } 92 } 93 94 if (shouldRemove){ 96 99 } 100 101 if (pertinentRevisions.size() > 0){ 102 IFileRevision[] tempRevision = (IFileRevision[]) pertinentRevisions.toArray(new IFileRevision[pertinentRevisions.size()]); 103 revisions = new IFileRevision[tempRevision.length]; 104 System.arraycopy(tempRevision, 0, revisions, 0, tempRevision.length); 105 return true; 106 } 107 108 return false; 109 } 110 111 114 public IFileRevision[] getRevisions() { 115 return revisions; 116 } 117 118 121 public boolean hasRevisions() { 122 if (revisions != null && revisions.length > 0) 123 return true; 124 125 return false; 126 } 127 128 } 129 | Popular Tags |