Package org.apache.myfaces.trinidad.model

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


    _testRange(keySet, size, size*2, false, false);
  }

  public void testInvert()
  {
    RowKeySetImpl set = _createKeySet(false);
    int endOfTrueRange = _initModel(set);

    // the item at this index was previously selected:
    int index = endOfTrueRange - 1;
    // make sure that the item is unselected after inverting:
    set.getCollectionModel().setRowKey(_getKey(index));
    assertFalse("item is unselected", set.invert());
    assertFalse("item is unselected", set.isContained());

    // the item at this index was previously unselected:
    index = endOfTrueRange + 1;
    // make sure that the item is selected after inverting:
    set.getCollectionModel().setRowKey(_getKey(index));
    assertTrue("item is selected", set.invert());
    assertTrue("item is selected", set.isContained());
  }
View Full Code Here


    assertTrue("item is selected", set.isContained());
  }

  public void testInvertAll()
  {
    RowKeySetImpl set = _createKeySet(false);
    int endOfTrueRange = _initModel(set);
    set.invertAll();
    // after inverting, all the items in this range should be unselected:
    _testAll(set, false, 0, endOfTrueRange);
    // after inverting, all the items in this range should be selected:
    _testAll(set, true, endOfTrueRange, _TEST_SIZE);
  }
View Full Code Here

  public void testSerialization() throws IOException, ClassNotFoundException
  {
    final byte[] bytes;
    final int endOfTrueRange;
    {
      RowKeySetImpl set = _createKeySet(false);
      endOfTrueRange = _initModel(set);

      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ObjectOutputStream out = new ObjectOutputStream(bos);
      // no need to worry about testing to make sure the model isn't
      // serialized, because the Entry class isn't Serializable.
      out.writeObject(set);
      out.close();

      bytes = bos.toByteArray();
      // test to make sure that the serialized size is reasonable:
     assertTrue(bytes.length <= 200);
     assertTrue(bytes.length >= 80);
    }

    ObjectInputStream in =
      new ObjectInputStream(new ByteArrayInputStream(bytes));
    RowKeySetImpl set = (RowKeySetImpl)in.readObject();
    assertNull("transient model", set.getCollectionModel());
    set.setCollectionModel(_MODEL);
    in.close();

    _testAll(set, true, 0, endOfTrueRange);
    _testAll(set, false, endOfTrueRange, _TEST_SIZE);
  }
View Full Code Here

    _testAll(set, false, endOfTrueRange, _TEST_SIZE);
  }

  public void testGetRowKeyIterator()
  {
    RowKeySetImpl set = _createKeySet(false);
    int endOfTrueRange = _initModel(set);
    Iterator<Object> selections = set.iterator();
    _testSelectionIterator(set.getCollectionModel(), selections,
                           endOfTrueRange, 0, endOfTrueRange);
  }
View Full Code Here

                           endOfTrueRange, 0, endOfTrueRange);
  }

  public void testInvertAllRowKeyIterator()
  {
    RowKeySetImpl set = _createKeySet(false);
    int endOfTrueRange = _initModel(set);
    set.invertAll();
    Iterator<Object> selections = set.iterator();
    _testSelectionIterator(set.getCollectionModel(), selections,
                           _TEST_SIZE - endOfTrueRange,
                           endOfTrueRange, _TEST_SIZE);
  }
View Full Code Here

                           endOfTrueRange, _TEST_SIZE);
  }

  public void testClone() throws CloneNotSupportedException
  {
    RowKeySetImpl set = _createKeySet(false);
    int endOfTrueRange = _initModel(set);

    RowKeySetImpl clone = set.clone();
    _testAll(clone, true, 0, endOfTrueRange);
    _testAll(clone, false, endOfTrueRange, _TEST_SIZE);

    // modify the original. no change should be observed on the clone:
    CollectionModel model = set.getCollectionModel();
    model.setRowIndex(0);
    set.remove();
    assertFalse(set.isContained());
    assertTrue(clone.isContained());

    // modify the clone. no change should be observed on the original:
    model.setRowIndex(endOfTrueRange);
    clone.add();
    assertFalse(set.isContained());
    assertTrue(clone.isContained());
  }
View Full Code Here

    return ModelUtils.toCollectionModel(lst);
  }

  private RowKeySetImpl _createKeySet(boolean defState)
  {
    RowKeySetImpl set = new RowKeySetImpl(defState);
    set.setCollectionModel(_MODEL);
    return set;
  }
View Full Code Here

  @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

  private static class TestTable extends CoreTable
  {
    public TestTable()
    {
      super();
      setSelectedRowKeys(new RowKeySetImpl());
      setDisclosedRowKeys(new RowKeySetImpl());
    }
View Full Code Here

    RowKeySet selectedRowKeys = getSelectedRowKeys();

    if (selectedRowKeys == null)
    {
      selectedRowKeys = new RowKeySetImpl();
      setSelectedRowKeys(selectedRowKeys);
    }

    RowKeySet disclosedRowKeys = getDisclosedRowKeys();

    if (disclosedRowKeys == null)
    {
      disclosedRowKeys = new RowKeySetImpl();
      setDisclosedRowKeys(disclosedRowKeys);
    }

    selectedRowKeys.setCollectionModel(model);
    disclosedRowKeys.setCollectionModel(model);
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.