Search in sources :

Example 1 with RecordFieldComparator

use of com.revolsys.record.comparator.RecordFieldComparator in project com.revolsys.open by revolsys.

the class Sort method setFieldName.

public void setFieldName(final String fieldName) {
    this.fieldName = fieldName;
    this.comparator = new RecordFieldComparator(fieldName);
}
Also used : RecordFieldComparator(com.revolsys.record.comparator.RecordFieldComparator)

Example 2 with RecordFieldComparator

use of com.revolsys.record.comparator.RecordFieldComparator in project com.revolsys.open by revolsys.

the class RecordListTableModel method setSortOrder.

@Override
public SortOrder setSortOrder(final int column) {
    final SortOrder sortOrder = super.setSortOrder(column);
    if (this.records != null) {
        final String fieldName = getColumnFieldName(column);
        final Comparator<Record> comparator = new RecordFieldComparator(sortOrder == SortOrder.ASCENDING, fieldName);
        Collections.sort(this.records, comparator);
        fireTableDataChanged();
    }
    return sortOrder;
}
Also used : SortOrder(javax.swing.SortOrder) Record(com.revolsys.record.Record) RecordFieldComparator(com.revolsys.record.comparator.RecordFieldComparator)

Example 3 with RecordFieldComparator

use of com.revolsys.record.comparator.RecordFieldComparator in project com.revolsys.open by revolsys.

the class CodeTableProperty method loadAll.

public synchronized void loadAll() {
    final long time = System.currentTimeMillis();
    if (this.threadLoading.get() != Boolean.TRUE) {
        if (this.loading) {
            while (this.loading) {
                try {
                    wait(1000);
                } catch (final InterruptedException e) {
                }
            }
            return;
        } else {
            this.threadLoading.set(Boolean.TRUE);
            this.loading = true;
            try {
                final RecordDefinition recordDefinition = this.recordStore.getRecordDefinition(this.typePath);
                final Query query = new Query(recordDefinition);
                query.setFieldNames(recordDefinition.getFieldNames());
                for (final String order : this.orderBy) {
                    query.addOrderBy(order);
                }
                try (Reader<Record> reader = this.recordStore.getRecords(query)) {
                    final List<Record> codes = reader.toList();
                    final CategoryLabelCountMap statistics = this.recordStore.getStatistics();
                    if (statistics != null) {
                        statistics.getLabelCountMap("query").addCount(this.typePath, -codes.size());
                    }
                    Collections.sort(codes, new RecordFieldComparator(this.orderBy));
                    addValues(codes);
                }
                Property.firePropertyChange(this, "valuesChanged", false, true);
            } finally {
                this.loading = false;
                this.loaded = true;
                this.threadLoading.set(null);
                this.notifyAll();
            }
        }
    }
    Dates.debugEllapsedTime(this, "Load All: " + getTypePath(), time);
}
Also used : Query(com.revolsys.record.query.Query) CategoryLabelCountMap(com.revolsys.util.count.CategoryLabelCountMap) Record(com.revolsys.record.Record) RecordFieldComparator(com.revolsys.record.comparator.RecordFieldComparator) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

RecordFieldComparator (com.revolsys.record.comparator.RecordFieldComparator)3 Record (com.revolsys.record.Record)2 Query (com.revolsys.record.query.Query)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1 CategoryLabelCountMap (com.revolsys.util.count.CategoryLabelCountMap)1 SortOrder (javax.swing.SortOrder)1