public void createGroupFromItem(SearchConditionItem i) {
   i.removeListener(this);
   int indexOfItem = items.indexOf(i);
   items.remove(i);
   SearchConditionGroupItem g = new SearchConditionGroupItem(QueryRelation.AND, i, this);
   addItem(g, indexOfItem);
 }
 public void moveItemToGroupAtIndex(
     SearchConditionItem i, SearchConditionGroupItem g, int newIndex) {
   i.removeListener(this);
   items.remove(i);
   i.setParent(null);
   g.addItem(i);
   g.moveItemToIndex(i, newIndex);
   fireSearchConditionOrderChangedEvent();
 }
  public void moveItemToGroup(SearchConditionItem i, SearchConditionGroupItem g) {
    i.removeListener(this);
    items.remove(i);
    i.setParent(null);
    g.addItem(i);

    if (items.size() < 1) {
      if (getParent() != null) {
        getParent().removeItem(this);
      }
    } else {
      fireSearchConditionOrderChangedEvent();
    }
  }
 public void addItem(SearchConditionItem i) {
   addItem(i, items.size()); // add to the end
 }