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.jdal.swing.table.ListTableModelSorter.java

/**
 * {@inheritDoc}/*from ww  w . jav  a  2  s .c om*/
 */
@Override
public void toggleSortOrder(int column) {
    if (key.getColumn() != column) {
        key = new SortKey(column, javax.swing.SortOrder.ASCENDING);
    } else {
        key = new SortKey(column,
                key.getSortOrder() == SortOrder.ASCENDING ? SortOrder.DESCENDING : SortOrder.ASCENDING);
    }
    sort();
}

From source file:de.tor.tribes.util.PropertyHelper.java

public static void restoreTableProperties(JXTable pTable, Configuration pConfig, String pPrefix) {
    //set col width
    List<TableColumn> cols = ((TableColumnModelExt) pTable.getColumnModel()).getColumns(true);

    for (TableColumn c : cols) {
        TableColumnExt col = (TableColumnExt) c;
        String title = col.getTitle();
        try {//from w w w. j  a  v  a  2  s . c om
            col.setPreferredWidth(
                    pConfig.getInteger(pPrefix + ".table.col." + title + ".width", col.getWidth()));
        } catch (ConversionException ignored) {
        }
        try {
            col.setVisible(pConfig.getBoolean(pPrefix + ".table.col." + title + ".visible", true));
        } catch (ConversionException ce) {
            col.setVisible(true);
        }
    }

    SortOrder sortOrder = SortOrder.UNSORTED;
    int iSortOrder = 0;
    try {
        iSortOrder = pConfig.getInteger(pPrefix + ".table.sort.order", 0);
    } catch (ConversionException ignored) {
    }

    switch (iSortOrder) {
    case 1:
        sortOrder = SortOrder.ASCENDING;
        break;
    case -1:
        sortOrder = SortOrder.DESCENDING;
        break;
    default:
        sortOrder = SortOrder.UNSORTED;
    }

    Boolean scroll = false;
    try {
        scroll = pConfig.getBoolean(pPrefix + ".table.horizontal.scroll", false);
    } catch (ConversionException ignored) {
    }

    pTable.setHorizontalScrollEnabled(scroll);

    Integer orderCol = 0;
    try {
        orderCol = pConfig.getInteger(pPrefix + ".table.sort.col", 0);
    } catch (ConversionException ignored) {
    }

    try {
        pTable.setSortOrder(orderCol.intValue(), sortOrder);
    } catch (IndexOutOfBoundsException ignored) {
    }
}

From source file:com.moneydance.modules.features.importlist.util.Preferences.java

/**
 * The constructor must be called exactly once before using the only
 * instance of this class.//  www .j  a  v a2  s  .  com
 */
Preferences() {
    this.settings = Helper.INSTANCE.getSettings();
    this.columnWidths = new StreamTable();
    this.columnOrderDefault = new StreamTable();
    this.columnOrderDefault.put("0", this.settings.getDescName());
    this.columnOrderDefault.put("1", this.settings.getDescModified());
    this.columnOrderDefault.put("2", this.settings.getDescImport());
    this.columnOrderDefault.put("3", this.settings.getDescDelete());
    this.sortOrderDefault = new StreamTable();
    this.sortOrderDefault.put("0", SortOrder.ASCENDING.toString());
}

From source file:org.jdal.swing.table.ListTableModelSorter.java

/**
 * /*from  w w  w  .ja  v  a  2 s.com*/
 */
@SuppressWarnings("unchecked")
private void sort() {
    String propertyName = model.getPropertyName(key.getColumn());
    sortDefinition.setProperty(propertyName);
    sortDefinition.setAscending(SortOrder.ASCENDING.equals(key.getSortOrder()));
    Collections.sort(model.getList(), comparator);
    fireSortOrderChanged();
}

From source file:Visuals.PieChart.java

public JPanel addCharts() {
    ChartPanel piePanel = drawPieChart();
    piePanel.setDomainZoomable(true);/*www.  j  a  v  a 2s  . c om*/
    JPanel thisPiePanel = new JPanel();

    String[][] finalRisks = new String[riskCount][4];
    for (int i = 0; i < riskCount; i++) {
        finalRisks[i][0] = risks[i][0];
        finalRisks[i][1] = risks[i][1];
        finalRisks[i][2] = risks[i][2];
        finalRisks[i][3] = risks[i][3];
    }

    JTable table = new JTable(finalRisks, columns);
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    TableRowSorter<TableModel> sorter = new TableRowSorter<>(table.getModel());
    table.setRowSorter(sorter);
    List<RowSorter.SortKey> sortKeys = new ArrayList<>();

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

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

    TableColumn tcol = table.getColumnModel().getColumn(2);
    table.removeColumn(tcol);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.getColumnModel().getColumn(1).setPreferredWidth(600);

    table.getColumnModel().getColumn(2).setPreferredWidth(600);

    JLabel right = new JLabel(
            "                                                                                                    ");
    thisPiePanel.add(right, BorderLayout.EAST);

    table.setShowHorizontalLines(true);
    table.setRowHeight(40);

    JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    Dimension d = table.getPreferredSize();
    tableScrollPane
            .setPreferredSize(new Dimension((d.width - 400), (table.getRowHeight() + 1) * (riskCount + 1)));
    table.setEnabled(false);
    thisPiePanel.setLayout(new BorderLayout());
    if (riskCount == 0) {

        thisPiePanel.add(piePanel, BorderLayout.CENTER);
    } else {
        thisPiePanel.add(right, BorderLayout.EAST);
        thisPiePanel.add(piePanel, BorderLayout.CENTER);
        thisPiePanel.add(tableScrollPane, BorderLayout.SOUTH);
    }
    thisPiePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
    return thisPiePanel;
}

From source file:au.com.jwatmuff.eventmanager.gui.admin.WithdrawPlayerDialog.java

/** Creates new form WithdrawPlayerDialog */
public WithdrawPlayerDialog(java.awt.Frame parent, boolean modal, Database database,
        TransactionNotifier notifier) {//from  w  ww .jav  a2s  . c  o m
    super(parent, modal);
    initComponents();
    setLocationRelativeTo(null);

    this.database = database;
    this.notifier = notifier;

    divisionTableModel = new DivisionTableModel();
    divisionTableModel.updateFromDatabase();
    divisionTable.setModel(divisionTableModel);
    divisionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    divisionTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            playerTableModel.updateFromDatabase();
        }
    });
    notifier.addListener(divisionTableModel, Pool.class);

    playerTableModel = new PlayerTableModel();
    playerTable.setModel(playerTableModel);
    playerTable.setSelectionModel(new NullSelectionModel()); // disable selection
    // set up cell editor for status column
    // see PlayerTableModel.setValueAt() for how edits to cells are handled
    playerTable.getColumnModel().getColumn(1)
            .setCellEditor(new DefaultCellEditor(new JComboBox<Status>(statuses)));
    playerTable.getColumnModel().getColumn(1).setCellRenderer(new ComboBoxCellRenderer(Status.values()));
    // sort by name
    playerTable.getRowSorter().setSortKeys(Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
    notifier.addListener(playerTableModel, PlayerPool.class);
}

From source file:Visuals.BarChart.java

public JPanel addCharts() {
    ChartPanel barPanel = drawBarChart();
    barPanel.setDomainZoomable(true);// w w  w. j av  a 2s  .co  m
    JPanel thisBarPanel = new JPanel();
    thisBarPanel.setLayout(new BorderLayout());

    String[][] finalRisks = new String[riskCount][4];
    for (int i = 0; i < riskCount; i++) {
        finalRisks[i][0] = risks[i][0];
        finalRisks[i][1] = risks[i][1];
        finalRisks[i][2] = risks[i][2];
        finalRisks[i][3] = risks[i][3];
    }

    JTable table = new JTable(finalRisks, columns);
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    TableRowSorter<TableModel> sorter = new TableRowSorter<>(table.getModel());
    table.setRowSorter(sorter);
    List<RowSorter.SortKey> sortKeys = new ArrayList<>();

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

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

    TableColumn tcol = table.getColumnModel().getColumn(2);
    table.removeColumn(tcol);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.getColumnModel().getColumn(1).setPreferredWidth(600);
    table.getColumnModel().getColumn(2).setPreferredWidth(600);

    table.setShowHorizontalLines(true);
    table.setRowHeight(40);
    table.setEnabled(false);

    JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    Dimension d = table.getPreferredSize();
    tableScrollPane
            .setPreferredSize(new Dimension((d.width - 400), (table.getRowHeight() + 1) * (riskCount + 1)));

    JLabel right = new JLabel(
            "                                                                                                    ");
    thisBarPanel.add(right, BorderLayout.EAST);
    thisBarPanel.add(barPanel, BorderLayout.CENTER);
    thisBarPanel.add(tableScrollPane, BorderLayout.SOUTH);
    return thisBarPanel;
}

From source file:com.hp.alm.ali.idea.ui.MultipleItemsDialog.java

public MultipleItemsDialog(Project project, String title, final MultipleItemsDialogModel<K, E> model) {
    super(project, title, true);

    this.model = model;

    mySelectionModel = new MySelectionModel();
    myListSelectionListener = new MyListSelectionListener();

    tooMany = new JLabel("Too many results, narrow your search");
    tooMany.setBorder(BorderFactory.createEtchedBorder());
    tooMany.setVisible(false);//from w  w  w. j  a v  a2 s. co  m
    selected = new JLabel("Showing currently selected items");
    selected.setVisible(false);
    toggleSelected = new JToggleButton();
    toggleSelected.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            model.setShowingSelected(toggleSelected.isSelected());
            if (!model.isShowingSelected() && !model.getSelectedFields().isEmpty()) {
                updateSelectionFromModel();
            } else if (model.isShowingSelected()) {
                header.getFilterEditor(1).setContent("");
            }
        }
    });
    updateSelected();

    table = new JBTable() {
        @Override
        public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
            int column = convertColumnIndexToModel(columnIndex);
            mySelectionModel.setFirstColumnEvent(column == 0);
            super.changeSelection(rowIndex, columnIndex, toggle, extend);
        }
    };
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(false);
    table.setAutoCreateColumnsFromModel(false);
    table.setModel(model);
    final MyTableRowSorter sorter = new MyTableRowSorter(model);
    table.setRowSorter(sorter);
    table.setDefaultRenderer(Boolean.class, new MyRenderer());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    table.setSelectionModel(mySelectionModel);

    sorter.setIgnoreAddRowSorterListener(true); // prevent auto-selection (functionality not accessible via proper API)
    header = new TableFilterHeader(table);
    sorter.setIgnoreAddRowSorterListener(false);

    sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(1, SortOrder.ASCENDING)));
    JPanel panel = new JPanel(new BorderLayout());
    JPanel toolbar = new JPanel(new BorderLayout());
    toolbar.setBorder(BorderFactory.createEtchedBorder());
    panel.add(toolbar, BorderLayout.NORTH);
    toolbar.add(toggleSelected, BorderLayout.EAST);

    if (model.isMultiple()) {
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        table.getColumnModel().addColumn(createColumn(0, model, 45, 45));
        header.getFilterEditor(0).setEditable(false);
        header.getFilterEditor(0).setUserInteractionEnabled(false);

        final LinkListener selectUnselect = new LinkListener() {
            public void linkSelected(LinkLabel aSource, Object aLinkData) {
                if (model.isShowingSelected()) {
                    if (!Boolean.TRUE.equals(aLinkData)) {
                        List<Integer> ixs = new ArrayList<Integer>();
                        for (int i = 0; i < sorter.getViewRowCount(); i++) {
                            ixs.add(sorter.convertRowIndexToModel(i));
                        }
                        // make sure indexes are not affected by removal by starting from the last
                        Collections.sort(ixs);
                        Collections.reverse(ixs);
                        for (int ix : ixs) {
                            model.setValueAt(aLinkData, ix, 0);
                        }
                    }
                } else {
                    if (Boolean.TRUE.equals(aLinkData)) {
                        mySelectionModel.doAddSelectionInterval(0, table.getRowCount() - 1);
                    } else {
                        mySelectionModel.removeSelectionInterval(0, table.getRowCount() - 1);
                    }
                }
            }
        };

        JPanel left = new JPanel(new FlowLayout(FlowLayout.LEFT));
        left.add(new LinkLabel("Select All", IconLoader.getIcon("/actions/selectall.png"), selectUnselect,
                true));
        left.add(new LinkLabel("Unselect All", IconLoader.getIcon("/actions/unselectall.png"), selectUnselect,
                false));
        toolbar.add(left, BorderLayout.WEST);
    } else {
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    table.getColumnModel().addColumn(createColumn(1, model, 450, null));
    table.getSelectionModel().addListSelectionListener(myListSelectionListener);

    model.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            selected.setVisible(model.isShowingSelected());
            tooMany.setVisible(model.hasMore() && !model.isShowingSelected());
            updateSelected();
        }
    });

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.add(selected, BorderLayout.NORTH);
    contentPanel.add(new JBScrollPane(table), BorderLayout.CENTER);
    contentPanel.add(tooMany, BorderLayout.SOUTH);
    panel.add(contentPanel, BorderLayout.CENTER);
    JPanel buttons = new JPanel();
    okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            ok = true;
            close(true);
        }
    });
    buttons.add(okButton);
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            close(false);
        }
    });
    buttons.add(cancel);
    panel.add(buttons, BorderLayout.SOUTH);
    getContentPane().add(panel, BorderLayout.CENTER);

    pack();
    setResizable(false);
    centerOnOwner();

    requestPropertyFilterFocus(header);

    load(true, null);
}

From source file:com.hp.alm.ali.idea.services.SprintService.java

private void loadSprints(final Entity release) {
    EntityQuery query = new EntityQuery("release-cycle");
    query.addColumn("id", 1);
    query.addColumn("name", 1);
    query.addColumn("tense", 1);
    query.addColumn("start-date", 1);
    query.addColumn("end-date", 1);
    query.setValue("parent-id", String.valueOf(release.getId()));
    query.setPropertyResolved("parent-id", true);
    query.addOrder("start-date", SortOrder.ASCENDING);
    EntityList list = EntityList.empty();
    try {/*  w  ww .  j a v  a  2s  .c  o  m*/
        list = entityService.query(query);
    } finally {
        synchronized (this) {
            sprintSelector.values = list;
            sprintSelector.requestRunning = false;

            if (!sprintSelector.values.contains(sprintSelector.selected)) {
                selectSprint(findClosest(list));
            }
            notifyAll();
        }
    }
}

From source file:com.hp.alm.ali.idea.services.SprintService.java

private void loadTeams(final Entity release) {
    EntityQuery query = new EntityQuery("team");
    query.addColumn("id", 1);
    query.addColumn("name", 1);
    // release by cross filter is necessary to support global team
    query.setValue("release.id", release.getPropertyValue("id"));
    query.setPropertyResolved("release.id", true);
    query.addOrder("name", SortOrder.ASCENDING);
    EntityList list = EntityList.empty();
    try {//from  www . j  a  v a  2  s  .  com
        list = entityService.query(query);
    } finally {
        synchronized (this) {
            teamSelector.values = list;
            teamSelector.requestRunning = false;

            if (!teamSelector.values.contains(teamSelector.selected)) {
                // TODO: choose my team
                selectTeam(list.isEmpty() ? null : list.get(0));
            }
            notifyAll();
        }
    }
}