Changeset 6670 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2014-01-11T02:21:08+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r6656 r6670 1582 1582 "validator.TagChecker.useignorefile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source 1583 1583 "validator.TagChecker.usespellfile", // 01/2014 - can be removed mid-2014. Replaced by validator.TagChecker.source 1584 "validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.sources" // 01/2014 - can be removed mid-2014. Replaced by validator.org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.entries 1584 1585 }; 1585 1586 for (String key : obsolete) { -
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r6669 r6670 91 91 92 92 /** 93 * Replies true if east and north are different from Double.NaN and not in ifinite93 * Replies true if east and north are different from Double.NaN and not infinite 94 94 * 95 * @return true if east and north are different from Double.NaN and not in ifinite95 * @return true if east and north are different from Double.NaN and not infinite 96 96 */ 97 97 public boolean isValid() { -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r6648 r6670 222 222 return new HashMap<String, Test>(allTestsMap); 223 223 } 224 225 /** 226 * Returns the instance of the given test class. 227 * @param testClass The class of test to retrieve 228 * @return the instance of the given test class, if any, or {@code null} 229 * @since 6670 230 */ 231 @SuppressWarnings("unchecked") 232 public static <T extends Test> T getTest(Class<T> testClass) { 233 if (testClass == null) { 234 return null; 235 } 236 return (T) allTestsMap.get(testClass.getSimpleName()); 237 } 224 238 225 239 private static void applyPrefs(Map<String, Test> tests, boolean beforeUpload) { … … 283 297 * @param allTests The tests to initialize 284 298 */ 285 public static void initializeTests(Collection<Test> allTests) { 299 public static void initializeTests(Collection<? extends Test> allTests) { 286 300 for (Test test : allTests) { 287 301 try { -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r6651 r6670 5 5 6 6 import java.io.BufferedReader; 7 import java.io.I nputStreamReader;7 import java.io.IOException; 8 8 import java.io.Reader; 9 9 import java.util.ArrayList; 10 10 import java.util.Collection; 11 import java.util.Collections;12 11 import java.util.HashMap; 12 import java.util.Iterator; 13 13 import java.util.LinkedHashMap; 14 14 import java.util.LinkedList; … … 25 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 26 import org.openstreetmap.josm.data.osm.Tag; 27 import org.openstreetmap.josm.data.preferences.CollectionProperty;28 27 import org.openstreetmap.josm.data.validation.FixableTestError; 29 28 import org.openstreetmap.josm.data.validation.Severity; … … 38 37 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 39 38 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector; 39 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.GeneralSelector; 40 40 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser; 41 41 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException; 42 42 import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference; 43 import org.openstreetmap.josm.gui. widgets.EditableList;43 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference; 44 44 import org.openstreetmap.josm.io.MirroredInputStream; 45 45 import org.openstreetmap.josm.io.UTFInputStreamReader; 46 46 import org.openstreetmap.josm.tools.CheckParameterUtil; 47 import org.openstreetmap.josm.tools.GBC;48 47 import org.openstreetmap.josm.tools.Predicate; 49 48 import org.openstreetmap.josm.tools.Utils; 50 51 import javax.swing.JLabel;52 import javax.swing.JPanel;53 49 54 50 /** … … 57 53 */ 58 54 public class MapCSSTagChecker extends Test.TagTest { 55 56 /** 57 * The preference key for tag checker source entries. 58 * @since 6670 59 */ 60 public static final String ENTRIES_PREF_KEY = "validator." + MapCSSTagChecker.class.getName() + ".entries"; 59 61 60 62 /** … … 170 172 css.sheet(source); 171 173 assert source.getErrors().isEmpty(); 174 // Ignore "meta" rule(s) from external rules of JOSM wiki 175 removeMetaRules(source); 172 176 return new ArrayList<TagCheck>(Utils.transform(source.rules, new Utils.Function<MapCSSRule, TagCheck>() { 173 177 @Override … … 176 180 } 177 181 })); 182 } 183 184 private static void removeMetaRules(MapCSSStyleSource source) { 185 for (Iterator<MapCSSRule> it = source.rules.iterator(); it.hasNext(); ) { 186 MapCSSRule x = it.next(); 187 if (x.selectors.size() == 1) { 188 Selector sel = x.selectors.get(0); 189 if (sel instanceof GeneralSelector) { 190 GeneralSelector gs = (GeneralSelector) sel; 191 if ("meta".equals(gs.base) && gs.getConditions().isEmpty()) { 192 it.remove(); 193 } 194 } 195 } 196 } 178 197 } 179 198 … … 405 424 } 406 425 407 /**408 * Adds a new MapCSS config file from the given internal filename.409 * @param internalConfigFile the filename in data/validator410 * @throws ParseException if the config file does not match MapCSS syntax411 */412 private void addMapCSS(String internalConfigFile) throws ParseException {413 addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/" + internalConfigFile + ".mapcss"), Utils.UTF_8));414 }415 416 426 @Override 417 427 public synchronized void initialize() throws Exception { 418 428 checks.clear(); 419 addMapCSS("deprecated"); 420 addMapCSS("highway"); 421 addMapCSS("numeric"); 422 addMapCSS("religion"); 423 addMapCSS("relation"); 424 addMapCSS("combinations"); 425 addMapCSS("unnecessary"); 426 addMapCSS("wikipedia"); 427 addMapCSS("power"); 428 addMapCSS("geometry"); 429 for (final String i : sourcesProperty.get()) { 429 for (String i : new ValidatorTagCheckerRulesPreference.RulePrefHelper().getActiveUrls()) { 430 430 try { 431 431 Main.info(tr("Adding {0} to tag checker", i)); 432 addMapCSS(new BufferedReader(UTFInputStreamReader.create(new MirroredInputStream(i)))); 432 MirroredInputStream s = new MirroredInputStream(i); 433 try { 434 addMapCSS(new BufferedReader(UTFInputStreamReader.create(s))); 435 } finally { 436 Utils.close(s); 437 } 438 } catch (IOException ex) { 439 Main.warn(tr("Failed to add {0} to tag checker", i)); 440 Main.warn(ex, false); 433 441 } catch (Exception ex) { 434 Main.warn(new RuntimeException(tr("Failed to add {0} to tag checker", i), ex)); 435 } 436 } 437 } 438 439 protected EditableList sourcesList; 440 protected final CollectionProperty sourcesProperty = new CollectionProperty( 441 "validator." + this.getClass().getName() + ".sources", Collections.<String>emptyList()); 442 443 @Override 444 public void addGui(JPanel testPanel) { 445 super.addGui(testPanel); 446 sourcesList = new EditableList(tr("TagChecker source")); 447 sourcesList.setItems(sourcesProperty.get()); 448 testPanel.add(new JLabel(tr("Data sources ({0})", "*.validator.mapcss")), GBC.eol().insets(23, 0, 0, 0)); 449 testPanel.add(sourcesList, GBC.eol().fill(GBC.HORIZONTAL).insets(23, 0, 0, 0)); 450 } 451 452 @Override 453 public boolean ok() { 454 sourcesProperty.put(sourcesList.getItems()); 455 return super.ok(); 442 Main.warn(tr("Failed to add {0} to tag checker", i)); 443 Main.warn(ex); 444 } 445 } 456 446 } 457 447 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r6643 r6670 42 42 private static ElemStyles styles = new ElemStyles(); 43 43 44 /** 45 * Returns the {@link ElemStyles} instance. 46 * @return the {@code ElemStyles} instance 47 */ 44 48 public static ElemStyles getStyles() { 45 49 return styles; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r6643 r6670 34 34 35 35 public class MapCSSStyleSource extends StyleSource { 36 final publicList<MapCSSRule> rules;36 public final List<MapCSSRule> rules; 37 37 private Color backgroundColorOverride; 38 38 private String css = null; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r6623 r6670 346 346 347 347 public List<Condition> getConditions() { 348 if (conds == null) { 349 return Collections.emptyList(); 350 } 348 351 return Collections.unmodifiableList(conds); 349 352 } -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r6666 r6670 53 53 import org.openstreetmap.josm.gui.preferences.shortcut.ShortcutPreference; 54 54 import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference; 55 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference; 55 56 import org.openstreetmap.josm.gui.preferences.validator.ValidatorTestsPreference; 56 57 import org.openstreetmap.josm.plugins.PluginDownloadTask; … … 514 515 settingsFactory.add(new ValidatorPreference.Factory()); 515 516 settingsFactory.add(new ValidatorTestsPreference.Factory()); 517 settingsFactory.add(new ValidatorTagCheckerRulesPreference.Factory()); 516 518 settingsFactory.add(new RemoteControlPreference.Factory()); 517 519 settingsFactory.add(new ImageryPreference.Factory()); -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r6552 r6670 33 33 import java.util.EventObject; 34 34 import java.util.HashMap; 35 import java.util.HashSet; 35 36 import java.util.Iterator; 36 37 import java.util.List; 37 38 import java.util.Map; 39 import java.util.Set; 38 40 import java.util.concurrent.CopyOnWriteArrayList; 39 41 import java.util.regex.Matcher; … … 64 66 import javax.swing.event.CellEditorListener; 65 67 import javax.swing.event.ChangeEvent; 68 import javax.swing.event.ChangeListener; 66 69 import javax.swing.event.ListSelectionEvent; 67 70 import javax.swing.event.ListSelectionListener; … … 93 96 public abstract class SourceEditor extends JPanel { 94 97 95 final protected boolean isMapPaint; 98 protected final SourceType sourceType; 99 protected final boolean canEnable; 96 100 97 101 protected final JTable tblActiveSources; … … 99 103 protected final JList lstAvailableSources; 100 104 protected final AvailableSourcesListModel availableSourcesModel; 101 protected final JTable tblIconPaths;102 protected final IconPathTableModel iconPathsModel;103 105 protected final String availableSourcesUrl; 104 106 protected final List<SourceProvider> sourceProviders; 105 107 108 protected JTable tblIconPaths; 109 protected IconPathTableModel iconPathsModel; 110 106 111 protected boolean sourcesInitiallyLoaded; 107 112 108 113 /** 109 * constructor 110 * @param isMapPaint true for MapPaintPreference subclass, false 111 * for TaggingPresetPreference subclass 114 * Constructs a new {@code SourceEditor}. 115 * @param sourceType the type of source managed by this editor 112 116 * @param availableSourcesUrl the URL to the list of available sources 113 117 * @param sourceProviders the list of additional source providers, from plugins 118 * @param handleIcons {@code true} if icons may be managed, {@code false} otherwise 114 119 */ 115 public SourceEditor(final boolean isMapPaint, final String availableSourcesUrl, final List<SourceProvider> sourceProviders) { 116 117 this.isMapPaint = isMapPaint; 120 public SourceEditor(SourceType sourceType, String availableSourcesUrl, List<SourceProvider> sourceProviders, boolean handleIcons) { 121 122 this.sourceType = sourceType; 123 this.canEnable = sourceType.equals(SourceType.MAP_PAINT_STYLE) || sourceType.equals(SourceType.TAGCHECKER_RULE); 124 118 125 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 119 this.lstAvailableSources = new JList(availableSourcesModel = new AvailableSourcesListModel(selectionModel)); 126 this.availableSourcesModel = new AvailableSourcesListModel(selectionModel); 127 this.lstAvailableSources = new JList(availableSourcesModel); 120 128 this.lstAvailableSources.setSelectionModel(selectionModel); 121 129 this.lstAvailableSources.setCellRenderer(new SourceEntryListCellRenderer()); … … 124 132 125 133 selectionModel = new DefaultListSelectionModel(); 126 tblActiveSources = new JTable(activeSourcesModel = new ActiveSourcesModel(selectionModel)) { 134 activeSourcesModel = new ActiveSourcesModel(selectionModel); 135 tblActiveSources = new JTable(activeSourcesModel) { 127 136 // some kind of hack to prevent the table from scrolling slightly to the 128 137 // right when clicking on the text … … 140 149 tblActiveSources.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 141 150 SourceEntryTableCellRenderer sourceEntryRenderer = new SourceEntryTableCellRenderer(); 142 if ( isMapPaint) {151 if (canEnable) { 143 152 tblActiveSources.getColumnModel().getColumn(0).setMaxWidth(1); 144 153 tblActiveSources.getColumnModel().getColumn(0).setResizable(false); … … 153 162 @Override 154 163 public void tableChanged(TableModelEvent e) { 155 TableHelper.adjustColumnWidth(tblActiveSources, isMapPaint? 1 : 0, 800);164 TableHelper.adjustColumnWidth(tblActiveSources, canEnable ? 1 : 0, 800); 156 165 } 157 166 }); … … 168 177 if (row < 0 || row >= tblActiveSources.getRowCount()) 169 178 return; 170 if ( isMapPaint&& col != 1)179 if (canEnable && col != 1) 171 180 return; 172 181 editActiveSourceAction.actionPerformed(null); … … 182 191 MoveUpDownAction moveUp = null; 183 192 MoveUpDownAction moveDown = null; 184 if ( isMapPaint) {193 if (sourceType.equals(SourceType.MAP_PAINT_STYLE)) { 185 194 moveUp = new MoveUpDownAction(false); 186 195 moveDown = new MoveUpDownAction(true); … … 259 268 sideButtonTB.add(removeActiveSourcesAction); 260 269 sideButtonTB.addSeparator(new Dimension(12, 30)); 261 if ( isMapPaint) {270 if (sourceType.equals(SourceType.MAP_PAINT_STYLE)) { 262 271 sideButtonTB.add(moveUp); 263 272 sideButtonTB.add(moveDown); … … 297 306 **/ 298 307 299 selectionModel = new DefaultListSelectionModel(); 300 tblIconPaths = new JTable(iconPathsModel = new IconPathTableModel(selectionModel)); 308 if (handleIcons) { 309 buildIcons(gbc); 310 } 311 } 312 313 private void buildIcons(GridBagConstraints gbc) { 314 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 315 iconPathsModel = new IconPathTableModel(selectionModel); 316 tblIconPaths = new JTable(iconPathsModel); 301 317 tblIconPaths.setSelectionModel(selectionModel); 302 318 tblIconPaths.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); … … 334 350 gbc.insets = new Insets(0, 11, 0, 0); 335 351 336 add(sp = new JScrollPane(tblIconPaths), gbc); 352 JScrollPane sp = new JScrollPane(tblIconPaths); 353 add(sp, gbc); 337 354 sp.setColumnHeaderView(null); 338 355 … … 485 502 @Override 486 503 public int getColumnCount() { 487 return isMapPaint? 2 : 1;504 return canEnable ? 2 : 1; 488 505 } 489 506 … … 495 512 @Override 496 513 public Object getValueAt(int rowIndex, int columnIndex) { 497 if ( isMapPaint&& columnIndex == 0)514 if (canEnable && columnIndex == 0) 498 515 return data.get(rowIndex).active; 499 516 else … … 503 520 @Override 504 521 public boolean isCellEditable(int rowIndex, int columnIndex) { 505 return isMapPaint&& columnIndex == 0;522 return canEnable && columnIndex == 0; 506 523 } 507 524 508 525 @Override 509 526 public Class<?> getColumnClass(int column) { 510 if ( isMapPaint&& column == 0)527 if (canEnable && column == 0) 511 528 return Boolean.class; 512 529 else return SourceEntry.class; … … 517 534 if (row < 0 || row >= getRowCount() || aValue == null) 518 535 return; 519 if ( isMapPaint&& column == 0) {536 if (canEnable && column == 0) { 520 537 data.get(row).active = ! data.get(row).active; 521 538 } … … 709 726 } 710 727 711 if ( isMapPaint) {728 if (canEnable) { 712 729 cbActive = new JCheckBox(tr("active"), e != null ? e.active : true); 713 730 p.add(cbActive, GBC.eol().insets(15, 0, 5, 0)); … … 752 769 public void actionPerformed(ActionEvent e) { 753 770 FileFilter ff; 754 if (isMapPaint) { 771 switch (sourceType) { 772 case MAP_PAINT_STYLE: 755 773 ff = new ExtensionFileFilter("xml,mapcss,css,zip", "xml", tr("Map paint style file (*.xml, *.mapcss, *.zip)")); 756 } else { 774 break; 775 case TAGGING_PRESET: 757 776 ff = new ExtensionFileFilter("xml,zip", "xml", tr("Preset definition file (*.xml, *.zip)")); 777 break; 778 case TAGCHECKER_RULE: 779 ff = new ExtensionFileFilter("validator.mapcss,zip", "validator.mapcss", tr("Tag checker rule (*.validator.mapcss, *.zip)")); 780 break; 781 default: 782 Main.error("Unsupported source type: "+sourceType); 783 return; 758 784 } 759 785 JFileChooserManager fcm = new JFileChooserManager(true) … … 777 803 778 804 public boolean active() { 779 if (! isMapPaint)805 if (!canEnable) 780 806 throw new UnsupportedOperationException(); 781 807 return cbActive.isSelected(); … … 799 825 if (editEntryDialog.getValue() == 1) { 800 826 boolean active = true; 801 if ( isMapPaint) {827 if (canEnable) { 802 828 active = editEntryDialog.active(); 803 829 } … … 870 896 } 871 897 e.url = editEntryDialog.getURL(); 872 if ( isMapPaint) {898 if (canEnable) { 873 899 e.active = editEntryDialog.active(); 874 900 } … … 1495 1521 private final String pref; 1496 1522 1523 /** 1524 * Constructs a new {@code SourcePrefHelper} for the given preference key. 1525 * @param pref The preference key 1526 */ 1497 1527 public SourcePrefHelper(String pref) { 1498 1528 this.pref = pref; 1499 1529 } 1500 1530 1531 /** 1532 * Returns the default sources provided by JOSM core. 1533 * @return the default sources provided by JOSM core 1534 */ 1501 1535 abstract public Collection<ExtendedSourceEntry> getDefault(); 1502 1536 … … 1505 1539 abstract public SourceEntry deserialize(Map<String, String> entryStr); 1506 1540 1541 /** 1542 * Returns the list of sources. 1543 * @return The list of sources 1544 */ 1507 1545 public List<SourceEntry> get() { 1508 1546 … … 1528 1566 return Main.pref.putListOfStructs(pref, setting); 1529 1567 } 1530 } 1531 1568 1569 /** 1570 * Returns the set of active source URLs. 1571 * @return The set of active source URLs. 1572 */ 1573 public final Set<String> getActiveUrls() { 1574 Set<String> urls = new HashSet<String>(); 1575 for (SourceEntry e : get()) { 1576 if (e.active) { 1577 urls.add(e.url); 1578 } 1579 } 1580 return urls; 1581 } 1582 } 1583 1584 /** 1585 * Defers loading of sources to the first time the adequate tab is selected. 1586 * @param tab The preferences tab 1587 * @param component The tab component 1588 * @since 6670 1589 */ 1590 public final void deferLoading(final DefaultTabPreferenceSetting tab, final Component component) { 1591 tab.getTabPane().addChangeListener( 1592 new ChangeListener() { 1593 @Override 1594 public void stateChanged(ChangeEvent e) { 1595 if (tab.getTabPane().getSelectedComponent() == component) { 1596 SourceEditor.this.initiallyLoadAvailableSources(); 1597 } 1598 } 1599 } 1600 ); 1601 } 1532 1602 } -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEntry.java
r6248 r6670 50 50 51 51 /** 52 * active is a boolean flag that can be used to turn the style on or off 53 * at runtime. 52 * active is a boolean flag that can be used to turn the source on or off at runtime. 54 53 */ 55 54 public boolean active; -
trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java
r6529 r6670 26 26 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 27 27 import org.openstreetmap.josm.gui.preferences.SourceEditor; 28 import org.openstreetmap.josm.gui.preferences.SourceType; 28 29 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 29 30 import org.openstreetmap.josm.gui.preferences.SourceEntry; … … 41 42 private static final List<SourceProvider> styleSourceProviders = new ArrayList<SourceProvider>(); 42 43 44 /** 45 * Registers a new additional style source provider. 46 * @param provider The style source provider 47 * @return {@code true}, if the provider has been added, {@code false} otherwise 48 */ 43 49 public static boolean registerSourceProvider(SourceProvider provider) { 44 50 if (provider != null) … … 58 64 59 65 @Override 60 public void addGui( finalPreferenceTabbedPane gui) {66 public void addGui(PreferenceTabbedPane gui) { 61 67 enableIconDefault = new JCheckBox(tr("Enable built-in icon defaults"), 62 68 Main.pref.getBoolean("mappaint.icon.enable-defaults", true)); … … 70 76 panel.add(enableIconDefault, GBC.eol().insets(11,2,5,0)); 71 77 72 gui.getMapPreference().addSubTab(this, tr("Map Paint Styles"), panel); 73 74 // this defers loading of style sources to the first time the tab 75 // with the map paint preferences is selected by the user 76 // 77 gui.getMapPreference().getTabPane().addChangeListener( 78 new ChangeListener() { 79 @Override 80 public void stateChanged(ChangeEvent e) { 81 if (gui.getMapPreference().getTabPane().getSelectedComponent() == panel) { 82 sources.initiallyLoadAvailableSources(); 83 } 84 } 85 } 86 ); 78 final MapPreference mapPref = gui.getMapPreference(); 79 mapPref.addSubTab(this, tr("Map Paint Styles"), panel); 80 sources.deferLoading(mapPref, panel); 87 81 } 88 82 … … 92 86 93 87 public MapPaintSourceEditor() { 94 super( true, Main.JOSM_WEBSITE+"/styles", styleSourceProviders);88 super(SourceType.MAP_PAINT_STYLE, Main.JOSM_WEBSITE+"/styles", styleSourceProviders, true); 95 89 } 96 90 … … 186 180 } 187 181 182 /** 183 * Helper class for map paint styles preferences. 184 */ 188 185 public static class MapPaintPrefHelper extends SourceEditor.SourcePrefHelper { 189 186 -
trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java
r6605 r6670 35 35 import org.openstreetmap.josm.gui.preferences.SourceEntry; 36 36 import org.openstreetmap.josm.gui.preferences.SourceProvider; 37 import org.openstreetmap.josm.gui.preferences.SourceType; 37 38 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 38 39 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; … … 67 68 private JCheckBox sortMenu; 68 69 70 /** 71 * Registers a new additional preset source provider. 72 * @param provider The preset source provider 73 * @return {@code true}, if the provider has been added, {@code false} otherwise 74 */ 69 75 public static final boolean registerSourceProvider(SourceProvider provider) { 70 76 if (provider != null) … … 161 167 162 168 @Override 163 public void addGui( finalPreferenceTabbedPane gui) {169 public void addGui(PreferenceTabbedPane gui) { 164 170 sortMenu = new JCheckBox(tr("Sort presets menu"), 165 171 Main.pref.getBoolean("taggingpreset.sortmenu", false)); … … 170 176 sources = new TaggingPresetSourceEditor(); 171 177 panel.add(sources, GBC.eol().fill(GBC.BOTH)); 172 gui.getMapPreference().addSubTab(this, tr("Tagging Presets"), panel); 173 174 // this defers loading of tagging preset sources to the first time the tab 175 // with the tagging presets is selected by the user 176 // 177 gui.getMapPreference().getTabPane().addChangeListener( 178 new ChangeListener() { 179 @Override 180 public void stateChanged(ChangeEvent e) { 181 if (gui.getMapPreference().getTabPane().getSelectedComponent() == panel) { 182 sources.initiallyLoadAvailableSources(); 183 } 184 } 185 } 186 ); 178 final MapPreference mapPref = gui.getMapPreference(); 179 mapPref.addSubTab(this, tr("Tagging Presets"), panel); 180 sources.deferLoading(mapPref, panel); 187 181 gui.addValidationListener(validationListener); 188 182 } … … 193 187 194 188 public TaggingPresetSourceEditor() { 195 super( false, Main.JOSM_WEBSITE+"/presets", presetSourceProviders);189 super(SourceType.TAGGING_PRESET, Main.JOSM_WEBSITE+"/presets", presetSourceProviders, true); 196 190 } 197 191 … … 274 268 } 275 269 270 /** 271 * Initializes tagging presets from preferences. 272 */ 276 273 public static void readFromPreferences() { 277 274 taggingPresets = TaggingPresetReader.readFromPreferences(false); 278 275 } 279 276 280 281 282 277 /** 278 * Initialize the tagging presets (load and may display error) 279 */ 283 280 public static void initialize() { 284 281 readFromPreferences(); … … 315 312 } 316 313 314 /** 315 * Helper class for tagging presets preferences. 316 */ 317 317 public static class PresetPrefHelper extends SourceEditor.SourcePrefHelper { 318 318 -
trunk/src/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreference.java
r6666 r6670 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; 9 import java.util.ArrayList; 9 10 import java.util.Collection; 10 11 import java.util.LinkedList; 12 import java.util.List; 11 13 12 14 import javax.swing.BorderFactory; … … 18 20 import org.openstreetmap.josm.data.validation.OsmValidator; 19 21 import org.openstreetmap.josm.data.validation.Test; 22 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 20 23 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 21 24 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; … … 108 111 testsBeforeUpload.add(name); 109 112 } 110 OsmValidator.initializeTests(allTests); 113 114 // Initializes all tests but MapCSSTagChecker because it is initialized 115 // later in ValidatorTagCheckerRulesPreference.ok(), 116 // after its list of rules has been saved to preferences 117 List<Test> testsToInitialize = new ArrayList<Test>(allTests); 118 testsToInitialize.remove(OsmValidator.getTest(MapCSSTagChecker.class)); 119 OsmValidator.initializeTests(testsToInitialize); 111 120 112 121 Main.pref.putCollection(ValidatorPreference.PREF_SKIP_TESTS, tests); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java
r6572 r6670 17 17 import java.util.List; 18 18 import java.util.Map; 19 import java.util.Set; 19 20 import java.util.Stack; 20 21 … … 22 23 23 24 import org.openstreetmap.josm.Main; 24 import org.openstreetmap.josm.gui.preferences.SourceEntry;25 25 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 26 26 import org.openstreetmap.josm.io.MirroredInputStream; … … 41 41 private static File zipIcons = null; 42 42 43 public static List<String> getPresetSources() {44 LinkedList<String> sources = new LinkedList<String>();45 46 for (SourceEntry e : (new TaggingPresetPreference.PresetPrefHelper()).get()) {47 sources.add(e.url);48 }49 50 return sources;51 }52 53 43 /** 54 * Holds a reference to a chunk of items/objects. 44 * Returns the set of preset source URLs. 45 * @return The set of preset source URLs. 46 */ 47 public static Set<String> getPresetSources() { 48 return new TaggingPresetPreference.PresetPrefHelper().getActiveUrls(); 49 } 50 51 /** 52 * Holds a reference to a chunk of items/objects. 55 53 */ 56 54 public static class Chunk { 55 /** The chunk id, can be referenced later */ 57 56 public String id; 58 57 } … … 62 61 */ 63 62 public static class Reference { 63 /** Reference matching a chunk id defined earlier **/ 64 64 public String ref; 65 65 }
Note:
See TracChangeset
for help on using the changeset viewer.