/** * Returns the index in this list of the first occurrence of the specified * <code>element</code>, or -1 if this list does not contain this * <code>element</code>. More formally, returns the lowest index <tt>i</tt> * such that <tt>uniqueListComparator.compare(get(i), element) == 0</tt>, * or -1 if there is no such index. * * <p>Note: This is a departure from the contract for {@link List#indexOf} * since it does not guarantee that <tt>element.equals(get(i))</tt> where i * is a positive index returned from this method. * * @param element the element to search for. * @return the index in this list of the first occurrence of the specified * element, or -1 if this list does not contain this element * @throws ClassCastException if the type of the specified element * is incompatible with this list */ @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); // if the element is not found (index is negative) then return -1 to indicate the list does not contain it return index < 0 ? -1 : index; }
/** * Returns the index in this list of the first occurrence of the specified * <code>element</code>, or -1 if this list does not contain this * <code>element</code>. More formally, returns the lowest index <tt>i</tt> * such that <tt>uniqueListComparator.compare(get(i), element) == 0</tt>, * or -1 if there is no such index. * * <p>Note: This is a departure from the contract for {@link List#indexOf} * since it does not guarantee that <tt>element.equals(get(i))</tt> where i * is a positive index returned from this method. * * @param element the element to search for. * @return the index in this list of the first occurrence of the specified * element, or -1 if this list does not contain this element * @throws ClassCastException if the type of the specified element * is incompatible with this list */ @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); // if the element is not found (index is negative) then return -1 to indicate the list does not contain it return index < 0 ? -1 : index; }
/** * Returns the index in this list of the first occurrence of the specified * <code>element</code>, or -1 if this list does not contain this * <code>element</code>. More formally, returns the lowest index <tt>i</tt> * such that <tt>uniqueListComparator.compare(get(i), element) == 0</tt>, * or -1 if there is no such index. * * <p>Note: This is a departure from the contract for {@link List#indexOf} * since it does not guarantee that <tt>element.equals(get(i))</tt> where i * is a positive index returned from this method. * * @param element the element to search for. * @return the index in this list of the first occurrence of the specified * element, or -1 if this list does not contain this element * @throws ClassCastException if the type of the specified element * is incompatible with this list */ @Override public int indexOf(Object element) { final int index = Collections.binarySearch(this, (E) element, ((SortedList<E>)source).getComparator()); // if the element is not found (index is negative) then return -1 to indicate the list does not contain it return index < 0 ? -1 : index; }
/** * Create a new {@link Grouper} that manages groups for the * specified {@link SortedList}. */ public Grouper(SortedList<E> sortedList, Client client) { this.sortedList = sortedList; this.client = client; setComparator(sortedList.getComparator()); }
/** * Create a new {@link Grouper} that manages groups for the * specified {@link SortedList}. */ public Grouper(SortedList<E> sortedList, Client client) { this.sortedList = sortedList; this.client = client; setComparator(sortedList.getComparator()); }
/** * Create a new {@link Grouper} that manages groups for the * specified {@link SortedList}. */ public Grouper(SortedList<E> sortedList, Client client) { this.sortedList = sortedList; this.client = client; setComparator(sortedList.getComparator()); }
/** * Modify the behaviour of this {@link SortedList} to one of the predefined modes. * * @param mode either {@link #STRICT_SORT_ORDER} or {@link #AVOID_MOVING_ELEMENTS}. */ public void setMode(int mode) { if(mode != STRICT_SORT_ORDER && mode != AVOID_MOVING_ELEMENTS) throw new IllegalArgumentException("Mode must be either SortedList.STRICT_SORT_ORDER or SortedList.AVOID_MOVING_ELEMENTS"); if(mode == this.mode) return; // apply the new mode this.mode = mode; // we need to re-sort the table on the off-chance that an element // was out of order before if(this.mode == STRICT_SORT_ORDER) { setComparator(getComparator()); } } /**
/** * Modify the behaviour of this {@link SortedList} to one of the predefined modes. * * @param mode either {@link #STRICT_SORT_ORDER} or {@link #AVOID_MOVING_ELEMENTS}. */ public void setMode(int mode) { if(mode != STRICT_SORT_ORDER && mode != AVOID_MOVING_ELEMENTS) throw new IllegalArgumentException("Mode must be either SortedList.STRICT_SORT_ORDER or SortedList.AVOID_MOVING_ELEMENTS"); if(mode == this.mode) return; // apply the new mode this.mode = mode; // we need to re-sort the table on the off-chance that an element // was out of order before if(this.mode == STRICT_SORT_ORDER) { setComparator(getComparator()); } } /**
/** * Modify the behaviour of this {@link SortedList} to one of the predefined modes. * * @param mode either {@link #STRICT_SORT_ORDER} or {@link #AVOID_MOVING_ELEMENTS}. */ public void setMode(int mode) { if(mode != STRICT_SORT_ORDER && mode != AVOID_MOVING_ELEMENTS) throw new IllegalArgumentException("Mode must be either SortedList.STRICT_SORT_ORDER or SortedList.AVOID_MOVING_ELEMENTS"); if(mode == this.mode) return; // apply the new mode this.mode = mode; // we need to re-sort the table on the off-chance that an element // was out of order before if(this.mode == STRICT_SORT_ORDER) { setComparator(getComparator()); } } /**
Comparator<? super TreeAsset> comparator = sortedList.getComparator(); if (comparator != null) { int result = comparator.compare(o1, o2);
/** {@inheritDoc} */ @Override public void listChanged(ListEvent<E> listChanges) { updates.beginEvent(true); // check if this ListEvent was caused due to a change in the // Comparator that creates the groups final SortedList<E> sortedSource = (SortedList<E>) source; final Comparator<? super E> sourceComparator = sortedSource.getComparator(); if (sourceComparator != grouper.getComparator()) { // when the grouping comparator is changed in the source list, let // the grouper know so we can rebuild our groups from scratch // record the impending removal of all groups before adjusting the barcode for (int i = 0, n = size(); i < n; i++) updates.elementDeleted(0, get(i)); // adjust the Comparator used by the Grouper (which will change the barcode) grouper.setComparator(sourceComparator); // rebuild the tree which maps GroupLists to indices (so the tree matches the new barcode) rebuildGroupListTreeFromBarcode(); // insert all new groups (represented by the newly formed barcode) updates.addInsert(0, size() - 1); } else { grouper.listChanged(listChanges); } updates.commitEvent(); }
/** {@inheritDoc} */ @Override public void listChanged(ListEvent<E> listChanges) { updates.beginEvent(true); // check if this ListEvent was caused due to a change in the // Comparator that creates the groups final SortedList<E> sortedSource = (SortedList<E>) source; final Comparator<? super E> sourceComparator = sortedSource.getComparator(); if (sourceComparator != grouper.getComparator()) { // when the grouping comparator is changed in the source list, let // the grouper know so we can rebuild our groups from scratch // record the impending removal of all groups before adjusting the barcode for (int i = 0, n = size(); i < n; i++) updates.elementDeleted(0, get(i)); // adjust the Comparator used by the Grouper (which will change the barcode) grouper.setComparator(sourceComparator); // rebuild the tree which maps GroupLists to indices (so the tree matches the new barcode) rebuildGroupListTreeFromBarcode(); // insert all new groups (represented by the newly formed barcode) updates.addInsert(0, size() - 1); } else { grouper.listChanged(listChanges); } updates.commitEvent(); }
/** {@inheritDoc} */ @Override public void listChanged(ListEvent<E> listChanges) { updates.beginEvent(true); // check if this ListEvent was caused due to a change in the // Comparator that creates the groups final SortedList<E> sortedSource = (SortedList<E>) source; final Comparator<? super E> sourceComparator = sortedSource.getComparator(); if (sourceComparator != grouper.getComparator()) { // when the grouping comparator is changed in the source list, let // the grouper know so we can rebuild our groups from scratch // record the impending removal of all groups before adjusting the barcode for (int i = 0, n = size(); i < n; i++) updates.elementDeleted(0, get(i)); // adjust the Comparator used by the Grouper (which will change the barcode) grouper.setComparator(sourceComparator); // rebuild the tree which maps GroupLists to indices (so the tree matches the new barcode) rebuildGroupListTreeFromBarcode(); // insert all new groups (represented by the newly formed barcode) updates.addInsert(0, size() - 1); } else { grouper.listChanged(listChanges); } updates.commitEvent(); }
Comparator<? super E> sourceComparator = sortedSource.getComparator(); if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator);
Comparator<? super E> sourceComparator = sortedSource.getComparator(); if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator);
Comparator<? super E> sourceComparator = sortedSource.getComparator(); if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator);
Comparator<? super E> sourceComparator = sortedSource.getComparator(); if(sourceComparator != grouper.getComparator()) { grouper.setComparator(sourceComparator);
final Comparator<? super E> sourceComparator = sortedSource.getComparator(); if (sourceComparator != grouper.getComparator()) { if (!listChanges.isReordering()) {
final Comparator<? super E> sourceComparator = sortedSource.getComparator(); if (sourceComparator != grouper.getComparator()) { if (!listChanges.isReordering()) {
final Comparator<? super E> sourceComparator = sortedSource.getComparator(); if (sourceComparator != grouper.getComparator()) { if (!listChanges.isReordering()) {