Package org.apache.myfaces.trinidad.model

Examples of org.apache.myfaces.trinidad.model.RowKeySetImpl


  @Override
  void __init()
  {
    super.__init();
    if (getSelectedRowKeys() == null)
      setSelectedRowKeys(new RowKeySetImpl());
    if (getDisclosedRowKeys() == null)
      setDisclosedRowKeys(new RowKeySetImpl());
    // if "first" is valueBound, we can't deal with it changing
    // during the lifecycle. So stash it as a local value.
    // see bug 4537121:
    setFirst(getFirst());
  }
View Full Code Here


      return _treeState;
    }
    else if("disclosureState".equals(name))
    {
      if(_disclosureState == null)
        _disclosureState = new RowKeySetImpl(true);
      return _disclosureState;
    }
    else if("arrayString".equals(name))
    {
      String stringArray[] = {"id1","id2","id3"};
View Full Code Here

    return new TestSuite(RowKeySetImplTest.class);
  }
 
  public void testInitialyEmpty()
  {
    RowKeySetImpl set = _createKeySet(false);
    // make sure that set is empty:
    _testAll(set, false);
  }
View Full Code Here

    _testAll(set, false);
  }

  public void testInitialAddAll()
  {
    RowKeySetImpl set = _createKeySet(true);
    // make sure that everything is added:
    _testAll(set, true);
  }
View Full Code Here

    _testAll(set, true);
  }

  public void testAddAll()
  {
    RowKeySetImpl set = _createKeySet(false);
    _initModel(set);
    set.addAll();
    _testAll(set, true);
  }
View Full Code Here

    _testAll(set, true);
  }

  public void testAddRemoveAllWithSimpleSet()
  {
    RowKeySetImpl set1 = _createKeySet(false);
    RowKeySetImpl set2 = _createKeySet(false);

    Object k1 = _getKey(0);
    Object k2 = _getKey(1);
    Object k3 = _getKey(2);

    set1.add(k1);
    set1.add(k2);
    set2.add(k2);
    set2.add(k3);

    set1.addAll(set2);
    assertEquals("size", 3, set1.size());
    assertEquals("size", 2, set2.size());

    assertTrue(set1.contains(k1));
    assertTrue(set1.contains(k2));
    assertTrue(set1.contains(k3));

    assertFalse(set2.contains(k1));
    assertTrue(set2.contains(k2));
    assertTrue(set2.contains(k3));

    set1.removeAll(set2);
    assertEquals("size", 1, set1.size());
    assertTrue(set1.contains(k1));
    assertFalse(set1.contains(k2));
View Full Code Here

        throw new AssertionFailedError("must not fetch all data");
      }
    };

    RowKeySetImpl set1 = _createKeySet(true);
    set1.setCollectionModel(ModelUtils.toCollectionModel(infinite));
    set1.remove(k3);

    RowKeySetImpl set2 = _createKeySet(false);
    set2.addAll(set1);
    assertTrue(set2.contains(k1));
    assertTrue(set2.contains(k2));
    assertFalse(set2.contains(k3));

    // now test removeAll:
    set2.add(k3);
    set2.removeAll(set1);
    assertFalse(set2.contains(k1));
    assertFalse(set2.contains(k2));
    assertTrue(set2.contains(k3));
    assertEquals("size", 1, set2.size());

    // now test with both sets being infinite:
    set1 = _createKeySet(true);
    set1.setCollectionModel(ModelUtils.toCollectionModel(infinite));
    set1.remove(k1);
    set1.remove(k2);

    set2 = _createKeySet(true);
    set2.setCollectionModel(ModelUtils.toCollectionModel(infinite));
    set2.remove(k2);
    set2.remove(k3);

    RowKeySetImpl set3 = set2.clone(); // save for later

    // test addAll:
    set2.addAll(set1);
    assertTrue(set2.contains(k1));
    assertFalse(set2.contains(k2));
    assertTrue(set2.contains(k3));

    // test removeAll:
    set3.removeAll(set1);
    assertTrue(set3.contains(k1));
    assertFalse(set3.contains(k2));
    assertFalse(set3.contains(k3));
    assertEquals("size", 1, set3.size());
  }
View Full Code Here

    assertEquals("size", 1, set3.size());
  }

  public void testClear()
  {
    RowKeySetImpl set = _createKeySet(false);
    _initModel(set);
    set.clear();
    _testAll(set, false);
  }
View Full Code Here

    _testAll(set, false);
  }

  public void testAddRemove()
  {
    RowKeySetImpl set = _createKeySet(false);
    int endOfTrueRange = _initModel(set);
    boolean state = true;
    for(int i=0; i<endOfTrueRange; i++)
    {
      // all of the items in this range should have been previously
      // added:
      set.getCollectionModel().setRowKey(_getKey(i));
      assertTrue("item is selected", set.isContained());
      if (state)
        set.add();
      else
        set.remove();
      // make sure that the selection changed correctly:
      assertEquals("selection changed", state, set.isContained());
      // we are going to alternate between selecting and unselecting:
      state = !state;
    }
    for(int i=endOfTrueRange; i<_TEST_SIZE; i++)
    {
      // all of the items in this range should have been previously
      // removed:
      set.getCollectionModel().setRowKey(_getKey(i));
      assertFalse("item not selected", set.isContained());
      if (state)
        set.add();
      else
        set.remove();
      assertEquals("selection changed", state, set.isContained());
      state = !state;
    }
  }
View Full Code Here

    }
  }

  public void testAddRemoveNoModel()
  {
    RowKeySetImpl keySet = _createKeySet(false);
    keySet.setCollectionModel(null);

    int size = 10;
    _testRange(keySet, 0, size, false, true);
    _testRange(keySet, size/2, size, true, true);
    _testRange(keySet, size/2, size, true, false);
View Full Code Here

TOP

Related Classes of org.apache.myfaces.trinidad.model.RowKeySetImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.