コード例 #1
0
ファイル: GroupByViewImpl.java プロジェクト: triplekill/esper
 protected static void updateChildViews(
     Object subViews, EventBean[] newData, EventBean[] oldData) {
   if (subViews instanceof List) {
     List<View> viewList = (List<View>) subViews;
     ViewSupport.updateChildren(viewList, newData, oldData);
   } else {
     ((View) subViews).update(newData, oldData);
   }
 }
コード例 #2
0
ファイル: GroupByViewImpl.java プロジェクト: triplekill/esper
 @Override
 public boolean removeView(View view) {
   if (!(view instanceof GroupableView)) {
     super.removeView(view);
   }
   boolean removed = super.removeView(view);
   if (!removed) {
     return false;
   }
   if (!hasViews()) {
     subViewsPerKey.clear();
     return true;
   }
   GroupableView removedView = (GroupableView) view;
   Deque<Object> removedKeys = null;
   for (Map.Entry<Object, Object> entry : subViewsPerKey.entrySet()) {
     Object value = entry.getValue();
     if (value instanceof View) {
       GroupableView subview = (GroupableView) value;
       if (compareViews(subview, removedView)) {
         if (removedKeys == null) {
           removedKeys = new ArrayDeque<Object>();
         }
         removedKeys.add(entry.getKey());
       }
     } else if (value instanceof List) {
       List<View> subviews = (List<View>) value;
       for (int i = 0; i < subviews.size(); i++) {
         GroupableView subview = (GroupableView) subviews.get(i);
         if (compareViews(subview, removedView)) {
           subviews.remove(i);
           if (subviews.isEmpty()) {
             if (removedKeys == null) {
               removedKeys = new ArrayDeque<Object>();
             }
             removedKeys.add(entry.getKey());
           }
           break;
         }
       }
     }
   }
   if (removedKeys != null) {
     for (Object key : removedKeys) {
       subViewsPerKey.remove(key);
     }
   }
   return true;
 }
コード例 #3
0
ファイル: TestViewSupport.java プロジェクト: arberzal/esper
  public void testFindDescendent() {
    // Test a deep find
    List<View> descendents = ViewSupport.findDescendent(top, child_2_2_1);
    assertEquals(2, descendents.size());
    assertEquals(child_2, descendents.get(0));
    assertEquals(child_2_2, descendents.get(1));

    descendents = ViewSupport.findDescendent(top, child_2_1_1);
    assertEquals(2, descendents.size());
    assertEquals(child_2, descendents.get(0));
    assertEquals(child_2_1, descendents.get(1));

    descendents = ViewSupport.findDescendent(top, child_2_1);
    assertEquals(1, descendents.size());
    assertEquals(child_2, descendents.get(0));

    // Test a shallow find
    descendents = ViewSupport.findDescendent(top, child_2);
    assertEquals(0, descendents.size());

    // Test a no find
    descendents = ViewSupport.findDescendent(top, new SupportSchemaNeutralView());
    assertEquals(null, descendents);
  }