Changeset 11387 in josm for trunk/src/org
- Timestamp:
- 2016-12-13T02:42:20+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r11367 r11387 104 104 public abstract class SourceEditor extends JPanel { 105 105 106 /** the type of source entry **/ 106 107 protected final SourceType sourceType; 108 /** determines if the entry type can be enabled (set as active) **/ 107 109 protected final boolean canEnable; 108 110 111 /** the table of active sources **/ 109 112 protected final JTable tblActiveSources; 113 /** the underlying model of active sources **/ 110 114 protected final ActiveSourcesModel activeSourcesModel; 115 /** the list of available sources **/ 111 116 protected final JList<ExtendedSourceEntry> lstAvailableSources; 117 /** the underlying model of available sources **/ 112 118 protected final AvailableSourcesListModel availableSourcesModel; 119 /** the URL from which the available sources are fetched **/ 113 120 protected final String availableSourcesUrl; 121 /** the list of source providers **/ 114 122 protected final transient List<SourceProvider> sourceProviders; 115 123 … … 117 125 private IconPathTableModel iconPathsModel; 118 126 127 /** determines if the source providers have been initially loaded **/ 119 128 protected boolean sourcesInitiallyLoaded; 120 129 … … 397 406 public abstract boolean finish(); 398 407 408 /** 409 * Default implementation of {@link #finish}. 410 * @param prefHelper Helper class for specialized extensions preferences 411 * @param iconPref icons path preference 412 * @return true if restart is required 413 */ 399 414 protected boolean doFinish(SourcePrefHelper prefHelper, String iconPref) { 400 415 boolean changed = prefHelper.put(activeSourcesModel.getSources()); … … 512 527 } 513 528 529 /** 530 * Reload available sources. 531 * @param url the URL from which the available sources are fetched 532 * @param sourceProviders the list of source providers 533 */ 514 534 protected void reloadAvailableSources(String url, List<SourceProvider> sourceProviders) { 515 535 Main.worker.submit(new SourceLoader(url, sourceProviders)); … … 526 546 } 527 547 548 /** 549 * List model of available sources. 550 */ 528 551 protected static class AvailableSourcesListModel extends DefaultListModel<ExtendedSourceEntry> { 529 552 private final transient List<ExtendedSourceEntry> data; 530 553 private final DefaultListSelectionModel selectionModel; 531 554 555 /** 556 * Constructs a new {@code AvailableSourcesListModel} 557 * @param selectionModel selection model 558 */ 532 559 public AvailableSourcesListModel(DefaultListSelectionModel selectionModel) { 533 560 data = new ArrayList<>(); … … 535 562 } 536 563 564 /** 565 * Sets the source list. 566 * @param sources source list 567 */ 537 568 public void setSources(List<ExtendedSourceEntry> sources) { 538 569 data.clear(); … … 554 585 } 555 586 587 /** 588 * Deletes the selected sources. 589 */ 556 590 public void deleteSelected() { 557 591 Iterator<ExtendedSourceEntry> it = data.iterator(); … … 567 601 } 568 602 603 /** 604 * Returns the selected sources. 605 * @return the selected sources 606 */ 569 607 public List<ExtendedSourceEntry> getSelected() { 570 608 List<ExtendedSourceEntry> ret = new ArrayList<>(); … … 578 616 } 579 617 618 /** 619 * Table model of active sources. 620 */ 580 621 protected class ActiveSourcesModel extends AbstractTableModel { 581 622 private transient List<SourceEntry> data; 582 623 private final DefaultListSelectionModel selectionModel; 583 624 625 /** 626 * Constructs a new {@code ActiveSourcesModel}. 627 * @param selectionModel selection model 628 */ 584 629 public ActiveSourcesModel(DefaultListSelectionModel selectionModel) { 585 630 this.selectionModel = selectionModel; … … 626 671 } 627 672 673 /** 674 * Sets active sources. 675 * @param sources active sources 676 */ 628 677 public void setActiveSources(Collection<? extends SourceEntry> sources) { 629 678 data.clear(); … … 636 685 } 637 686 687 /** 688 * Adds an active source. 689 * @param entry source to add 690 */ 638 691 public void addSource(SourceEntry entry) { 639 692 if (entry == null) return; … … 646 699 } 647 700 701 /** 702 * Removes the selected sources. 703 */ 648 704 public void removeSelected() { 649 705 Iterator<SourceEntry> it = data.iterator(); … … 659 715 } 660 716 717 /** 718 * Removes the sources at given indexes. 719 * @param idxs indexes to remove 720 */ 661 721 public void removeIdxs(Collection<Integer> idxs) { 662 722 List<SourceEntry> newData = new ArrayList<>(); … … 670 730 } 671 731 732 /** 733 * Adds multiple sources. 734 * @param sources source entries 735 */ 672 736 public void addExtendedSourceEntries(List<ExtendedSourceEntry> sources) { 673 737 if (sources == null) return; … … 687 751 } 688 752 753 /** 754 * Returns the active sources. 755 * @return the active sources 756 */ 689 757 public List<SourceEntry> getSources() { 690 758 return new ArrayList<>(data); … … 832 900 } 833 901 902 /** 903 * Dialog to edit a source entry. 904 */ 834 905 protected class EditSourceEntryDialog extends ExtendedDialog { 835 906 … … 838 909 private JCheckBox cbActive; 839 910 911 /** 912 * Constructs a new {@code EditSourceEntryDialog}. 913 * @param parent parent component 914 * @param title dialog title 915 * @param e source entry to edit 916 */ 840 917 public EditSourceEntryDialog(Component parent, String title, SourceEntry e) { 841 918 super(parent, title, new String[] {tr("Ok"), tr("Cancel")}); … … 935 1012 } 936 1013 1014 /** 1015 * Returns the entered URL / File. 1016 * @return the entered URL / File 1017 */ 937 1018 public String getURL() { 938 1019 return tfURL.getText(); 939 1020 } 940 1021 1022 /** 1023 * Determines if the active combobox is selected. 1024 * @return {@code true} if the active combobox is selected 1025 */ 941 1026 public boolean active() { 942 1027 if (!canEnable) … … 1160 1245 } 1161 1246 1247 /** 1248 * Table model for icons paths. 1249 */ 1162 1250 protected static class IconPathTableModel extends AbstractTableModel { 1163 1251 private final List<String> data; 1164 1252 private final DefaultListSelectionModel selectionModel; 1165 1253 1254 /** 1255 * Constructs a new {@code IconPathTableModel}. 1256 * @param selectionModel selection model 1257 */ 1166 1258 public IconPathTableModel(DefaultListSelectionModel selectionModel) { 1167 1259 this.selectionModel = selectionModel; … … 1194 1286 } 1195 1287 1288 /** 1289 * Sets the icons paths. 1290 * @param paths icons paths 1291 */ 1196 1292 public void setIconPaths(Collection<String> paths) { 1197 1293 data.clear(); … … 1203 1299 } 1204 1300 1301 /** 1302 * Adds an icon path. 1303 * @param path icon path to add 1304 */ 1205 1305 public void addPath(String path) { 1206 1306 if (path == null) return; … … 1214 1314 } 1215 1315 1316 /** 1317 * Updates icon path at given index. 1318 * @param pos position 1319 * @param path new path 1320 */ 1216 1321 public void updatePath(int pos, String path) { 1217 1322 if (path == null) return; … … 1226 1331 } 1227 1332 1333 /** 1334 * Removes the selected path. 1335 */ 1228 1336 public void removeSelected() { 1229 1337 Iterator<String> it = data.iterator(); … … 1240 1348 } 1241 1349 1350 /** 1351 * Sorts paths lexicographically. 1352 */ 1242 1353 protected void sort() { 1243 1354 data.sort((o1, o2) -> { … … 1250 1361 } 1251 1362 1363 /** 1364 * Returns the icon paths. 1365 * @return the icon paths 1366 */ 1252 1367 public List<String> getIconPaths() { 1253 1368 return new ArrayList<>(data); … … 1746 1861 } 1747 1862 1863 /** 1864 * Returns the title of the given source entry. 1865 * @param entry source entry 1866 * @return the title of the given source entry, or null if empty 1867 */ 1748 1868 protected String getTitleForSourceEntry(SourceEntry entry) { 1749 1869 return "".equals(entry.title) ? null : entry.title;
Note:
See TracChangeset
for help on using the changeset viewer.