| 1 |
|
package org.kuali.student.lum.common.client.helpers; |
| 2 |
|
|
| 3 |
|
import java.util.ArrayList; |
| 4 |
|
import java.util.List; |
| 5 |
|
|
| 6 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
| 7 |
|
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 17 |
Complexity Density: 0.61 |
|
| 8 |
|
public class RecentlyViewedHelper{ |
| 9 |
|
|
| 10 |
|
public static List<RecentDocInfo> recentlyViewedDocs = new ArrayList<RecentDocInfo>(); |
| 11 |
|
public static List<HasRecentlyViewedData> dependants = new ArrayList<HasRecentlyViewedData>(); |
| 12 |
|
public static final int MAX_RECENT_HISTORY = 8; |
| 13 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 14 |
0
|
public static void addCurrentDocument(String name){... |
| 15 |
0
|
RecentDocInfo info = new RecentDocInfo(name, HistoryManager.collectHistoryStack()); |
| 16 |
0
|
for(int i=0; i < recentlyViewedDocs.size(); i++){ |
| 17 |
0
|
if(info.getLocation().equals(recentlyViewedDocs.get(i).getLocation())){ |
| 18 |
0
|
recentlyViewedDocs.remove(i); |
| 19 |
0
|
break; |
| 20 |
|
} |
| 21 |
|
} |
| 22 |
0
|
recentlyViewedDocs.add(0, info); |
| 23 |
0
|
if(recentlyViewedDocs.size() > MAX_RECENT_HISTORY){ |
| 24 |
0
|
recentlyViewedDocs.remove(MAX_RECENT_HISTORY); |
| 25 |
|
} |
| 26 |
0
|
for(int i =0; i < dependants.size(); i++){ |
| 27 |
0
|
dependants.get(i).update(); |
| 28 |
|
} |
| 29 |
|
} |
| 30 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 31 |
0
|
public static void addDocument(String name, String specificLocation){... |
| 32 |
0
|
RecentDocInfo info = new RecentDocInfo(name, specificLocation); |
| 33 |
0
|
for(int i=0; i < recentlyViewedDocs.size(); i++){ |
| 34 |
0
|
if(info.getLocation().equals(recentlyViewedDocs.get(i).getLocation())){ |
| 35 |
0
|
recentlyViewedDocs.remove(i); |
| 36 |
0
|
break; |
| 37 |
|
} |
| 38 |
|
} |
| 39 |
0
|
recentlyViewedDocs.add(0, info); |
| 40 |
0
|
if(recentlyViewedDocs.size() > MAX_RECENT_HISTORY){ |
| 41 |
0
|
recentlyViewedDocs.remove(MAX_RECENT_HISTORY); |
| 42 |
|
} |
| 43 |
0
|
for(int i =0; i < dependants.size(); i++){ |
| 44 |
0
|
dependants.get(i).update(); |
| 45 |
|
} |
| 46 |
|
} |
| 47 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
0
|
public static List<RecentDocInfo> getRecentlyViewed(){... |
| 49 |
0
|
return recentlyViewedDocs; |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
0
|
public static void addDependant(HasRecentlyViewedData object){... |
| 53 |
0
|
dependants.add(object); |
| 54 |
|
} |
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.83 |
|
| 56 |
0
|
public static void updateTitle(String oldTitle, String newTitle, String docId) {... |
| 57 |
0
|
for(int i=0; i < recentlyViewedDocs.size(); i++){ |
| 58 |
0
|
if(oldTitle.equals(recentlyViewedDocs.get(i).getName()) |
| 59 |
|
&& recentlyViewedDocs.get(i).getLocation().contains(docId)){ |
| 60 |
0
|
recentlyViewedDocs.get(i).setName(newTitle); |
| 61 |
0
|
break; |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
0
|
for(int i =0; i < dependants.size(); i++){ |
| 65 |
0
|
dependants.get(i).update(); |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
} |