Example usage for javax.swing SortOrder ASCENDING

List of usage examples for javax.swing SortOrder ASCENDING

Introduction

In this page you can find the example usage for javax.swing SortOrder ASCENDING.

Prototype

SortOrder ASCENDING

To view the source code for javax.swing SortOrder ASCENDING.

Click Source Link

Document

Enumeration value indicating the items are sorted in increasing order.

Usage

From source file:org.drugis.addis.gui.builder.StudyOutcomeMeasuresView.java

public JComponent buildPanel() {
    FormLayout layout = new FormLayout("left:pref, 3dlu, left:0:grow, 3dlu, left:pref, 3dlu, left:pref", "p");
    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    List<? extends StudyOutcomeMeasure<?>> outcomeMeasures = null;
    if (d_type == Endpoint.class) {
        outcomeMeasures = d_model.getBean().getEndpoints();
    } else if (d_type == AdverseEvent.class) {
        outcomeMeasures = d_model.getBean().getAdverseEvents();
    } else if (d_type == PopulationCharacteristic.class) {
        outcomeMeasures = d_model.getBean().getPopulationChars();
    }//from   w  w w .  ja va 2 s.  c o  m
    if (outcomeMeasures.isEmpty()) {
        builder.addLabel("No " + d_type.getSimpleName(), cc.xy(1, 1));
    } else {
        int row = 1;
        for (StudyOutcomeMeasure<?> som : outcomeMeasures) {
            Variable var = (Variable) som.getValue();
            NoteViewButton omNotes = new NoteViewButton(d_mainWindow, var.getName(), som.getNotes());
            builder.add(omNotes, cc.xy(1, row));

            builder.add(GUIFactory.createOutcomeMeasureLabelWithIcon(var, som.getIsPrimary()), cc.xy(3, row));

            JPanel panel = new JPanel(new FlowLayout());
            if (var instanceof OutcomeMeasure) {
                OutcomeMeasure om = (OutcomeMeasure) var;
                if (om.getVariableType() instanceof RateVariableType) {
                    panel.add(createOddsRatioButton(om));
                    panel.add(createRiskRatioButton(om));
                    panel.add(createRiskDifferenceButton(om));
                } else if (om.getVariableType() instanceof ContinuousVariableType) {
                    panel.add(createWMDButton(om));
                    panel.add(createSMDButton(om));
                }
            }
            builder.add(panel, cc.xy(5, row));
            row += 2;

            LayoutUtil.addRow(layout);
        }

        EnhancedTable measurementTable = null;
        if (d_type == Endpoint.class) {
            measurementTable = EnhancedTable.createWithSorter(d_model.getEndpointTableModel());
        } else if (d_type == AdverseEvent.class) {
            measurementTable = EnhancedTable.createWithSorter(d_model.getAdverseEventTableModel());
        } else if (d_type == PopulationCharacteristic.class) {
            measurementTable = EnhancedTable.createWithSorter(d_model.getPopulationCharTableModel());
        }
        measurementTable.getRowSorter()
                .setSortKeys(Collections.singletonList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
        measurementTable.setDefaultRenderer(MissingMeasurementPresentation.class,
                new MeasurementCellRenderer());
        measurementTable.autoSizeColumns();

        builder.add(new TablePanel(measurementTable), cc.xyw(1, row, 5));
    }
    return builder.getPanel();
}

From source file:org.evors.rs.ui.frames.PopulationViewer.java

private void sortByFitness() {
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(jTable1.getModel());
    jTable1.setRowSorter(sorter);//from ww  w.  j av  a  2 s  .com
    List<RowSorter.SortKey> sortKeys = new ArrayList<>();

    int columnIndexToSort = 1;
    sortKeys.add(new RowSorter.SortKey(columnIndexToSort, SortOrder.ASCENDING));

    sorter.setSortKeys(sortKeys);
    sorter.sort();
}

From source file:org.nuclos.client.ui.collect.model.SortableCollectableTableModelImpl.java

@Override
public void toggleSortOrder(final int column, boolean sortImmediately) {
    if (!isSortable(column)) {
        return;/* w  ww  . j a  v  a  2 s . c om*/
    }

    List<SortKey> newSortKeys = new LinkedList<SortKey>(sortKeys);
    int currentSortIndex = CollectionUtils.indexOfFirst(sortKeys, new Predicate<SortKey>() {
        @Override
        public boolean evaluate(SortKey t) {
            return t.getColumn() == column;
        }
    });

    SortOrder newSortOrder = SortOrder.ASCENDING;
    int lastSortIndex = newSortKeys.size();
    if (currentSortIndex != -1) {
        SortKey oldSortKey = newSortKeys.remove(currentSortIndex);
        if (oldSortKey.getSortOrder() != SortOrder.UNSORTED) {
            switch (oldSortKey.getSortOrder()) {
            case ASCENDING:
                newSortOrder = SortOrder.DESCENDING;
                newSortKeys.add(currentSortIndex, new SortKey(column, newSortOrder));
                break;
            case DESCENDING:
                newSortOrder = SortOrder.UNSORTED;
                // if descending, nothing will be added. 3-click behavior. asc,desc,unsorted.
                newSortKeys.add(currentSortIndex, new SortKey(column, newSortOrder));
                break;
            case UNSORTED:
                newSortOrder = SortOrder.ASCENDING;
                newSortKeys.add(currentSortIndex, new SortKey(column, newSortOrder));
                break;
            }
        } else {
            newSortOrder = SortOrder.ASCENDING;
            newSortKeys.add(
                    lastSortIndex == 0 ? 0
                            : (lastSortIndex > newSortKeys.size() ? lastSortIndex - 1 : lastSortIndex),
                    new SortKey(column, newSortOrder));
        }
    } else {
        newSortOrder = SortOrder.ASCENDING;
        newSortKeys.add(
                lastSortIndex == 0 ? 0
                        : (lastSortIndex > newSortKeys.size() ? lastSortIndex - 1 : lastSortIndex),
                new SortKey(column, newSortOrder));
    }

    List<SortKey> newSortKeys1 = new LinkedList<SortKey>();
    List<SortKey> newSortKeys2 = new LinkedList<SortKey>();
    for (SortKey sortKey : newSortKeys) {
        if (sortKey.getSortOrder() == SortOrder.UNSORTED) {
            newSortKeys1.add(sortKey);
        } else {
            newSortKeys2.add(sortKey);
        }
    }

    newSortKeys.clear();
    newSortKeys.addAll(
            newSortKeys2.subList(newSortKeys2.size() < 3 ? 0 : newSortKeys2.size() - 3, newSortKeys2.size()));
    newSortKeys.addAll(newSortKeys1);

    if (LOG.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder("Sort subform by:");
        for (SortKey sk : newSortKeys) {
            sb.append("\n\t" + getCollectableEntityField(sk.getColumn()).getName() + " " + sk.getSortOrder());
        }
        LOG.debug(sb.toString());
    }
    setSortKeys(newSortKeys, sortImmediately);
}

From source file:org.nuclos.client.ui.collect.model.SortableCollectableTableModelImpl.java

/**
 * addititional Method for restoring the sorting order without fireing any changes etc.
 * needed for the WYSIWYG Editor./*from w w w  . ja va 2s  .c o  m*/
 * @param iSortedColumn
 * @param bSortedAscending
 * @deprecated refactor to use regular setSortKeys
 */
@Deprecated
public void restoreSortingOrder(int iSortedColumn, boolean bSortedAscending) {
    if (!(iSortedColumn >= -1 && iSortedColumn < this.getColumnCount())) {
        throw new IllegalArgumentException("iSortedColumn");
    }
    this.sortKeys = Collections.singletonList(
            new SortKey(iSortedColumn, bSortedAscending ? SortOrder.ASCENDING : SortOrder.DESCENDING));
}

From source file:org.nuclos.client.ui.collect.result.ResultController.java

/**
 * @return the list of sorting columns.//from www . j  a  v  a  2s  .c  o m
 * TODO make this private
 */
public List<CollectableSorting> getCollectableSortingSequence() {
    final String baseEntity = getEntity().getName();
    final Set<CollectableSorting> set = new HashSet<CollectableSorting>();
    final List<CollectableSorting> result = new ArrayList<CollectableSorting>();
    for (SortKey sortKey : clctctl.getResultTableModel().getSortKeys()) {
        final CollectableEntityField sortField = clctctl.getResultTableModel()
                .getCollectableEntityField(sortKey.getColumn());
        final CollectableSorting sort;
        if (sortField instanceof CollectableEOEntityField) {
            final CollectableEOEntityField sf = (CollectableEOEntityField) sortField;
            final EntityFieldMetaDataVO mdField = sf.getMeta();
            final PivotInfo pinfo = mdField.getPivotInfo();
            if (pinfo != null) {
                assert pinfo.getSubform().equals(sortField.getEntityName());
                if (sortKey.getSortOrder() != SortOrder.UNSORTED) {
                    sort = new CollectableSorting(mdField, baseEntity.equals(pinfo.getSubform()),
                            sortKey.getSortOrder() == SortOrder.ASCENDING);
                } else {
                    continue;
                }
            } else {
                throw new NotImplementedException();
            }
        } else if (sortField.getEntityName().equals(baseEntity)) {
            if (sortKey.getSortOrder() != SortOrder.UNSORTED) {
                sort = new CollectableSorting(SystemFields.BASE_ALIAS, baseEntity,
                        baseEntity.equals(sortField.getEntityName()), sortField.getName(),
                        sortKey.getSortOrder() == SortOrder.ASCENDING);
            } else {
                continue;
            }
        } else {
            // not a pivot element and not a field of the base entity => we cannot sort that
            continue;
        }
        // only use each sort column once
        if (set.add(sort)) {
            result.add(sort);
        }
    }
    // ??? is this needed (see above)
    CollectionUtils.removeDublicates(result);
    return result;
}

From source file:org.sleuthkit.autopsy.imageanalyzer.grouping.GroupManager.java

synchronized public void clear() {

    if (groupByTask != null) {
        groupByTask.cancel(true);/*w w  w .  j  a v  a2  s  .  c  o m*/
    }
    sortBy = GroupSortBy.GROUP_BY_VALUE;
    groupBy = DrawableAttribute.PATH;
    sortOrder = SortOrder.ASCENDING;
    Platform.runLater(() -> {
        synchronized (unSeenGroups) {
            unSeenGroups.clear();
        }
        analyzedGroups.clear();
    });
    synchronized (groupMap) {
        groupMap.clear();
    }
    db = null;
}

From source file:org.sleuthkit.autopsy.imageanalyzer.grouping.GroupManager.java

/**
 * find the distinct values of the regroup attribute in the order given by
 * sortBy with a ascending order// w  w  w  .  jav  a 2s  .co m
 *
 * @param regroup
 * @param sortBy
 *
 * @return
 */
public <A extends Comparable<A>> List<A> findValuesForAttribute(DrawableAttribute<A> groupBy,
        GroupSortBy sortBy) {
    return findValuesForAttribute(groupBy, sortBy, SortOrder.ASCENDING);
}

From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java

synchronized public void clear() {

    if (groupByTask != null) {
        groupByTask.cancel(true);//from  w w w.ja  v  a  2  s  .  c om
    }
    sortBy = GroupSortBy.GROUP_BY_VALUE;
    groupBy = DrawableAttribute.PATH;
    sortOrder = SortOrder.ASCENDING;
    Platform.runLater(() -> {
        unSeenGroups.forEach(controller.getCategoryManager()::unregisterListener);
        unSeenGroups.clear();
        analyzedGroups.forEach(controller.getCategoryManager()::unregisterListener);
        analyzedGroups.clear();

    });
    synchronized (groupMap) {
        groupMap.values().forEach(controller.getCategoryManager()::unregisterListener);
        groupMap.clear();
    }
    db = null;
}

From source file:org.sleuthkit.autopsy.imagegallery.grouping.GroupManager.java

synchronized public void clear() {

    if (groupByTask != null) {
        groupByTask.cancel(true);//from w w w  .ja  v a  2s.  co m
    }
    sortBy = GroupSortBy.GROUP_BY_VALUE;
    groupBy = DrawableAttribute.PATH;
    sortOrder = SortOrder.ASCENDING;
    Platform.runLater(() -> {
        unSeenGroups.clear();
        analyzedGroups.clear();
    });
    synchronized (groupMap) {
        groupMap.clear();
    }
    db = null;
}

From source file:org.zaproxy.zap.extension.ascan.PolicyAllCategoryPanel.java

/**
 * This method initializes tableTest//  w w w  . j ava2 s . co  m
 *
 * @return javax.swing.JTable
 */
private JTable getTableTest() {
    if (tableTest == null) {
        tableTest = new JTable();
        tableTest.setModel(getAllCategoryTableModel());
        tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
        tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
        tableTest.setAutoCreateRowSorter(true);

        //Default sort by name (column 0)
        List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1);
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        tableTest.getRowSorter().setSortKeys(sortKeys);

        for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
            TableColumn column = tableTest.getColumnModel().getColumn(i);
            column.setPreferredWidth(width[i]);
        }

        JComboBox<String> jcb1 = new JComboBox<>();
        jcb1.addItem(""); // Always show a blank one for where they are not all the same
        for (AlertThreshold level : AlertThreshold.values()) {
            jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
        }

        tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));

        JComboBox<String> jcb2 = new JComboBox<>();
        jcb2.addItem(""); // Always show a blank one for where they are not all the same
        for (AttackStrength level : AttackStrength.values()) {
            jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
        }

        tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2));
    }

    return tableTest;
}