@Test public void testInsertFront() { final Widget a = mock(Widget.class); final Widget b = mock(Widget.class); final Widget c = mock(Widget.class); final ComparableContent aaa = new ComparableContent("AAA", a); final ComparableContent bbb = new ComparableContent("BBB", b); final ComparableContent ccc = new ComparableContent("CCC", c); view.addToSlot(slot, ccc); view.addToSlot(slot, bbb); view.addToSlot(slot, aaa); final InOrder inOrder = inOrder(container); inOrder.verify(container).insert(c, 0); inOrder.verify(container).insert(b, 0); inOrder.verify(container).insert(a, 0); }
@SuppressWarnings("unchecked") @Override public void addToSlot(Object slot, IsWidget content) { if (hasWidgetSlots.containsKey(slot)) { if (orderedSlots.containsKey(slot)) { final List<Comparable<Comparable<?>>> list = orderedSlots.get(slot); final int index = Collections.binarySearch(list, (Comparable<Comparable<?>>) content); final int insertIdx; if (index > 0) { insertIdx = index; } else { insertIdx = -index - 1; } list.add(insertIdx, (Comparable<Comparable<?>>) content); final InsertPanel insertPanel = (InsertPanel) hasWidgetSlots.get(slot); insertPanel.insert(content.asWidget(), insertIdx); } else { hasWidgetSlots.get(slot).add(content.asWidget()); } } }
ViewImpl implements View { @SuppressWarnings("unchecked") @Override public void addToSlot(Object slot, IsWidget content) { if (hasWidgetSlots.containsKey(slot)) { if (orderedSlots.containsKey(slot)) { final List<Comparable<Comparable<?>>> list = orderedSlots.get(slot); final int index = Collections.binarySearch(list, (Comparable<Comparable<?>>) content); final int insertIdx; if (index > 0) { insertIdx = index; } else { insertIdx = -index - 1; } list.add(insertIdx, (Comparable<Comparable<?>>) content); final InsertPanel insertPanel = (InsertPanel) hasWidgetSlots.get(slot); insertPanel.insert(content.asWidget(), insertIdx); } else { hasWidgetSlots.get(slot).add(content.asWidget()); } } } }
ViewImpl implements View { @SuppressWarnings("unchecked") @Override public void addToSlot(Object slot, IsWidget content) { if (hasWidgetSlots.containsKey(slot)) { if (orderedSlots.containsKey(slot)) { final List<Comparable<Comparable<?>>> list = orderedSlots.get(slot); final int index = Collections.binarySearch(list, (Comparable<Comparable<?>>) content); final int insertIdx; if (index > 0) { insertIdx = index; } else { insertIdx = -index - 1; } list.add(insertIdx, (Comparable<Comparable<?>>) content); final InsertPanel insertPanel = (InsertPanel) hasWidgetSlots.get(slot); insertPanel.insert(content.asWidget(), insertIdx); } else { hasWidgetSlots.get(slot).add(content.asWidget()); } } }  }
ViewImpl implements View { @SuppressWarnings("unchecked") @Override public void addToSlot(Object slot, IsWidget content) { if (hasWidgetSlots.containsKey(slot)) { if (orderedSlots.containsKey(slot)) { final List<Comparable<Comparable<?>>> list = orderedSlots.get(slot); final int index = Collections.binarySearch(list, (Comparable<Comparable<?>>) content); final int insertIdx; if (index > 0) { insertIdx = index; } else { insertIdx = -index - 1; } list.add(insertIdx, (Comparable<Comparable<?>>) content); final InsertPanel insertPanel = (InsertPanel) hasWidgetSlots.get(slot); insertPanel.insert(content.asWidget(), insertIdx); } else { hasWidgetSlots.get(slot).add(content.asWidget()); } } }  @SuppressWarnings("unchecked") @Override void addToSlot(Object slot, IsWidget content); @Override void removeFromSlot(Object slot, IsWidget content); @SuppressWarnings("unchecked") @Override void setInSlot(Object slot, IsWidget content); @Override Widget asWidget(); }
ViewImpl implements View { @SuppressWarnings("unchecked") @Override public void addToSlot(Object slot, IsWidget content) { if (hasWidgetSlots.containsKey(slot)) { if (orderedSlots.containsKey(slot)) { final List<Comparable<Comparable<?>>> list = orderedSlots.get(slot); final int index = Collections.binarySearch(list, (Comparable<Comparable<?>>) content); final int insertIdx; if (index > 0) { insertIdx = index; } else { insertIdx = -index - 1; } list.add(insertIdx, (Comparable<Comparable<?>>) content); final InsertPanel insertPanel = (InsertPanel) hasWidgetSlots.get(slot); insertPanel.insert(content.asWidget(), insertIdx); } else { hasWidgetSlots.get(slot).add(content.asWidget()); } } }  @SuppressWarnings("unchecked") @Override void addToSlot(Object slot, IsWidget content); @Override void removeFromSlot(Object slot, IsWidget content); @SuppressWarnings("unchecked") @Override void setInSlot(Object slot, IsWidget content); @Override Widget asWidget();  }