Changeset 4839 in josm
- Timestamp:
- 2012-01-21T22:12:13+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/MapPaintPreference.java
r4616 r4839 6 6 7 7 import java.awt.GridBagLayout; 8 import java.util.ArrayList; 8 9 import java.util.Arrays; 9 10 import java.util.Collection; … … 28 29 private JCheckBox enableIconDefault; 29 30 31 private static final List<SourceProvider> styleSourceProviders = new ArrayList<SourceProvider>(); 32 33 public static final boolean registerSourceProvider(SourceProvider provider) { 34 if (provider != null) { 35 return styleSourceProviders.add(provider); 36 } 37 return false; 38 } 39 30 40 public static class Factory implements PreferenceSettingFactory { 31 41 public PreferenceSetting createPreferenceSetting() { … … 67 77 68 78 public MapPaintSourceEditor() { 69 super(true, "http://josm.openstreetmap.de/styles" );79 super(true, "http://josm.openstreetmap.de/styles", styleSourceProviders); 70 80 } 71 81 -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r4727 r4839 85 85 final protected boolean isMapPaint; 86 86 87 protected JTable tblActiveSources; 88 protected ActiveSourcesModel activeSourcesModel; 89 protected JList lstAvailableSources; 90 protected AvailableSourcesListModel availableSourcesModel; 91 protected JTable tblIconPaths = null; 92 protected IconPathTableModel iconPathsModel; 87 protected final JTable tblActiveSources; 88 protected final ActiveSourcesModel activeSourcesModel; 89 protected final JList lstAvailableSources; 90 protected final AvailableSourcesListModel availableSourcesModel; 91 protected final JTable tblIconPaths; 92 protected final IconPathTableModel iconPathsModel; 93 protected final String availableSourcesUrl; 94 protected final List<SourceProvider> sourceProviders; 95 93 96 protected boolean sourcesInitiallyLoaded; 94 protected String availableSourcesUrl;95 97 96 98 /** … … 99 101 * for TaggingPresetPreference subclass 100 102 * @param availableSourcesUrl the URL to the list of available sources 103 * @param sourceProviders the list of additional source providers, from plugins 101 104 */ 102 public SourceEditor(final boolean isMapPaint, final String availableSourcesUrl ) {105 public SourceEditor(final boolean isMapPaint, final String availableSourcesUrl, final List<SourceProvider> sourceProviders) { 103 106 104 107 this.isMapPaint = isMapPaint; 105 108 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 106 lstAvailableSources = new JList(availableSourcesModel = new AvailableSourcesListModel(selectionModel));107 lstAvailableSources.setSelectionModel(selectionModel);108 lstAvailableSources.setCellRenderer(new SourceEntryListCellRenderer());109 this.lstAvailableSources = new JList(availableSourcesModel = new AvailableSourcesListModel(selectionModel)); 110 this.lstAvailableSources.setSelectionModel(selectionModel); 111 this.lstAvailableSources.setCellRenderer(new SourceEntryListCellRenderer()); 109 112 this.availableSourcesUrl = availableSourcesUrl; 113 this.sourceProviders = sourceProviders; 110 114 111 115 selectionModel = new DefaultListSelectionModel(); … … 263 267 bottomLeftTB.setBorderPainted(false); 264 268 bottomLeftTB.setOpaque(false); 265 bottomLeftTB.add(new ReloadSourcesAction(availableSourcesUrl ));269 bottomLeftTB.add(new ReloadSourcesAction(availableSourcesUrl, sourceProviders)); 266 270 bottomLeftTB.add(Box.createHorizontalGlue()); 267 271 add(bottomLeftTB, gbc); … … 412 416 } 413 417 414 protected void reloadAvailableSources(String url ) {415 Main.worker.submit(new SourceLoader(url ));418 protected void reloadAvailableSources(String url, List<SourceProvider> sourceProviders) { 419 Main.worker.submit(new SourceLoader(url, sourceProviders)); 416 420 } 417 421 418 422 public void initiallyLoadAvailableSources() { 419 423 if (!sourcesInitiallyLoaded) { 420 reloadAvailableSources( this.availableSourcesUrl);424 reloadAvailableSources(availableSourcesUrl, sourceProviders); 421 425 } 422 426 sourcesInitiallyLoaded = true; … … 907 911 908 912 class ReloadSourcesAction extends AbstractAction { 909 private String url; 910 public ReloadSourcesAction(String url) { 913 private final String url; 914 private final List<SourceProvider> sourceProviders; 915 public ReloadSourcesAction(String url, List<SourceProvider> sourceProviders) { 911 916 putValue(NAME, tr("Reload")); 912 917 putValue(SHORT_DESCRIPTION, tr(getStr(I18nString.RELOAD_ALL_AVAILABLE), url)); 913 918 putValue(SMALL_ICON, ImageProvider.get("dialogs", "refresh")); 914 919 this.url = url; 920 this.sourceProviders = sourceProviders; 915 921 } 916 922 917 923 public void actionPerformed(ActionEvent e) { 918 924 MirroredInputStream.cleanup(url); 919 reloadAvailableSources(url );925 reloadAvailableSources(url, sourceProviders); 920 926 } 921 927 } … … 1096 1102 1097 1103 class SourceLoader extends PleaseWaitRunnable { 1098 private String url; 1104 private final String url; 1105 private final List<SourceProvider> sourceProviders; 1099 1106 private BufferedReader reader; 1100 1107 private boolean canceled; 1101 1108 private final List<ExtendedSourceEntry> sources = new ArrayList<ExtendedSourceEntry>(); 1102 1109 1103 public SourceLoader(String url ) {1110 public SourceLoader(String url, List<SourceProvider> sourceProviders) { 1104 1111 super(tr(getStr(I18nString.LOADING_SOURCES_FROM), url)); 1105 1112 this.url = url; 1113 this.sourceProviders = sourceProviders; 1106 1114 } 1107 1115 … … 1138 1146 try { 1139 1147 sources.addAll(getDefault()); 1148 1149 for (SourceProvider provider : sourceProviders) { 1150 for (SourceEntry src : provider.getSources()) { 1151 if (src instanceof ExtendedSourceEntry) { 1152 sources.add((ExtendedSourceEntry) src); 1153 } 1154 } 1155 } 1156 1140 1157 MirroredInputStream stream = new MirroredInputStream(url); 1141 1158 InputStreamReader r; -
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r4616 r4839 46 46 } 47 47 48 private static final List<SourceProvider> presetSourceProviders = new ArrayList<SourceProvider>(); 48 49 public static Collection<TaggingPreset> taggingPresets; 49 50 private SourceEditor sources; 50 51 private JCheckBox sortMenu; 52 53 public static final boolean registerSourceProvider(SourceProvider provider) { 54 if (provider != null) { 55 return presetSourceProviders.add(provider); 56 } 57 return false; 58 } 51 59 52 60 private ValidationListener validationListener = new ValidationListener() { … … 167 175 168 176 public TaggingPresetSourceEditor() { 169 super(false, "http://josm.openstreetmap.de/presets" );177 super(false, "http://josm.openstreetmap.de/presets", presetSourceProviders); 170 178 } 171 179
Note:
See TracChangeset
for help on using the changeset viewer.