/** * Sorts the rows of the table alphabetically. * * @param column index of the column to sort. In this table there are only 2 columns. */ public void sort(int column) { // Orders the layer alphabetically according the Spanish // alphabetically rules switch (column) { case 0: stringComparator.setColumn(WFSLayerStringComparator.LAYER_NAME); break; case 1: stringComparator.setColumn(WFSLayerStringComparator.GEOMETRY_TYPE); break; } if (previousColumnSorted != column) stringComparator.setAscendingOrdering(true); previousColumnSorted = (short) column; WFSLayerNode layer = getSelectedValue(); Collections.sort(layers, stringComparator); if (layer != null) { updatingSelection = true; unselectAllFeatures(); int row = Collections.binarySearch(layers, layer, stringComparator); if (row != -1) { ListSelectionModel model = getSelectionModel(); model.setLeadSelectionIndex(row); } updatingSelection = false; } stringComparator.setAscendingOrdering(!stringComparator.isAscendingOrdering()); }
/** Constructs an investment table model. */ public LayerTableModel() { super(); // Alphabetical sort ordering support updatingSelection = false; previousColumnSorted = -1; Collator collator = Collator.getInstance(new Locale("en_EN")); stringComparator = new WFSLayerStringComparator(); stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator)); stringComparator.setCaseSensitive(false); stringComparator.setAscendingOrdering(true); }