Changeset 660 for AE/installer2/src/net/oni2/aeinstaller/gui/modtable
- Timestamp:
- Jan 30, 2013, 11:05:56 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/gui/modtable
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTable.java
r659 r660 98 98 setRowSorter(sorter); 99 99 100 setFilter(null, 0 );100 setFilter(null, 0, null, EApplyFilterTo.ALL); 101 101 102 102 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); … … 221 221 * @param downloadState 222 222 * Show only: 0 = all, 1 = online, 2 = downloaded 223 */ 224 public void setFilter(Type type, int downloadState) { 223 * @param filterString 224 * String to filter on 225 * @param filterTo 226 * Fields to use string filter on 227 */ 228 public void setFilter(Type type, int downloadState, String filterString, 229 EApplyFilterTo filterTo) { 225 230 sorter.setRowFilter(new ModTableFilter(type, downloadState, 226 contentType == ETableContentType.CORE, false)); 231 filterString, filterTo, contentType == ETableContentType.CORE, 232 false)); 227 233 } 228 234 … … 378 384 379 385 private class KeyEventHandler extends KeyAdapter { 386 private void goToRow(int row) { 387 setRowSelectionInterval(row, row); 388 JViewport viewport = (JViewport) getParent(); 389 Rectangle rect = getCellRect(row, 0, true); 390 Rectangle r2 = viewport.getVisibleRect(); 391 scrollRectToVisible(new Rectangle(rect.x, rect.y, 392 (int) r2.getWidth(), (int) r2.getHeight())); 393 } 394 380 395 @Override 381 396 public void keyTyped(KeyEvent e) { … … 384 399 if (e.getModifiers() == 0) { 385 400 String key = String.valueOf(e.getKeyChar()).toLowerCase(); 386 for (int i = 0; i < getRowCount(); i++) { 401 int row = getSelectedRow(); 402 if (row == (getRowCount() - 1)) 403 row = -1; 404 for (int i = row + 1; i < getRowCount(); i++) { 387 405 Package m = (Package) getValueAt(i, -1); 388 406 if (m.getName().toLowerCase().startsWith(key)) { 389 setRowSelectionInterval(i, i); 390 JViewport viewport = (JViewport) getParent(); 391 Rectangle rect = getCellRect(i, 0, true); 392 Rectangle r2 = viewport.getVisibleRect(); 393 scrollRectToVisible(new Rectangle(rect.x, rect.y, 394 (int) r2.getWidth(), (int) r2.getHeight())); 395 break; 407 goToRow(i); 408 return; 409 } 410 } 411 if (row > 0) { 412 for (int i = 0; i < row; i++) { 413 Package m = (Package) getValueAt(i, -1); 414 if (m.getName().toLowerCase().startsWith(key)) { 415 goToRow(i); 416 return; 417 } 396 418 } 397 419 } -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableFilter.java
r657 r660 12 12 private Type type = null; 13 13 private int downloadState = 0; 14 private EApplyFilterTo filterTo = EApplyFilterTo.ALL; 15 private String filterString = null; 14 16 15 17 private boolean showCorePackages = false; … … 21 23 * @param downloadState 22 24 * Show only: 0 = all, 1 = online, 2 = downloaded 25 * @param filterString 26 * Filter for the given string 27 * @param filterTo 28 * Use the string filter only on the named field 23 29 * @param showCorePackages 24 30 * Show core packages in table … … 26 32 * Show packages not valid on this platform 27 33 */ 28 public ModTableFilter(Type type, int downloadState, 29 boolean showCorePackages, boolean showInvalidPlatform) { 34 public ModTableFilter(Type type, int downloadState, String filterString, 35 EApplyFilterTo filterTo, boolean showCorePackages, 36 boolean showInvalidPlatform) { 30 37 super(); 31 38 this.type = type; 32 39 this.downloadState = downloadState; 40 if (filterString != null) 41 this.filterString = filterString.toLowerCase(); 42 this.filterTo = filterTo; 33 43 this.showCorePackages = showCorePackages; 34 44 this.showInvalidPlatform = showInvalidPlatform; … … 58 68 break; 59 69 } 70 if (filterString != null && filterString.length() > 1) { 71 switch (filterTo) { 72 case ALL: 73 result &= mod.getName().toLowerCase() 74 .contains(filterString) 75 || mod.getCreator().toLowerCase() 76 .contains(filterString) 77 || mod.getDescription().toLowerCase() 78 .contains(filterString); 79 break; 80 case CREATOR: 81 result &= mod.getCreator().toLowerCase() 82 .contains(filterString); 83 break; 84 case DESCRIPTION: 85 result &= mod.getDescription().toLowerCase() 86 .contains(filterString); 87 break; 88 case NAME: 89 result &= mod.getName().toLowerCase() 90 .contains(filterString); 91 break; 92 } 93 } 60 94 61 95 return result;
Note:
See TracChangeset
for help on using the changeset viewer.