Changeset 3669 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2010-11-25T00:07:52+01:00 (14 years ago)
Author:
bastiK
Message:

add validator plugin to josm core. Original author: Francisco R. Santos (frsantos); major contributions by bilbo, daeron, delta_foxtrot, imi, jttt, jrreid, gabriel, guggis, pieren, rrankin, skela, stoecker, stotz and others

Location:
trunk/src/org/openstreetmap/josm
Files:
43 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r3542 r3669  
    5252import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;
    5353import org.openstreetmap.josm.data.projection.Projection;
     54import org.openstreetmap.josm.data.validation.OsmValidator;
    5455import org.openstreetmap.josm.gui.GettingStarted;
    5556import org.openstreetmap.josm.gui.MainMenu;
    5657import org.openstreetmap.josm.gui.MapFrame;
     58import org.openstreetmap.josm.gui.MapView;
    5759import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    5860import org.openstreetmap.josm.gui.io.SaveLayersDialog;
     
    136138    public final MainMenu menu;
    137139
     140    public final OsmValidator validator;
    138141    /**
    139142     * The MOTD Layer.
    140143     */
    141     private GettingStarted gettingStarted=new GettingStarted();
     144    private GettingStarted gettingStarted = new GettingStarted();
    142145
    143146    /**
     
    217220        TaggingPresetPreference.initialize();
    218221        MapPaintPreference.initialize();
     222
     223        validator = new OsmValidator();
     224        MapView.addLayerChangeListener(validator);
    219225
    220226        toolbar.refreshToolbarControl();
     
    387393        if (args.containsKey("geometry")) {
    388394            geometry = args.get("geometry").iterator().next();
    389             // Main.debug("Main window geometry from args: \""+geometry+"\"");
    390395        } else {
    391396            geometry = Main.pref.get("gui.geometry");
    392             // Main.debug("Main window geometry from preferences: \""+geometry+"\"");
    393397        }
    394398        if (geometry.length() != 0) {
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r3530 r3669  
    1616import org.openstreetmap.josm.actions.upload.RelationUploadOrderHook;
    1717import org.openstreetmap.josm.actions.upload.UploadHook;
     18import org.openstreetmap.josm.actions.upload.ValidateUploadHook;
    1819import org.openstreetmap.josm.data.APIDataSet;
    1920import org.openstreetmap.josm.data.conflict.ConflictCollection;
     
    5051    private static final LinkedList<UploadHook> uploadHooks = new LinkedList<UploadHook>();
    5152    static {
     53        uploadHooks.add(new ValidateUploadHook());
    5254        /**
    5355         * Checks server capabilities before upload.
  • trunk/src/org/openstreetmap/josm/gui/MainMenu.java

    r3431 r3669  
    7777import org.openstreetmap.josm.actions.ZoomOutAction;
    7878import org.openstreetmap.josm.actions.OrthogonalizeAction.Undo;
     79import org.openstreetmap.josm.actions.ValidateAction;
    7980import org.openstreetmap.josm.actions.audio.AudioBackAction;
    8081import org.openstreetmap.josm.actions.audio.AudioFasterAction;
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r3666 r3669  
    5555import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    5656import org.openstreetmap.josm.gui.dialogs.UserListDialog;
     57import org.openstreetmap.josm.gui.dialogs.ValidatorDialog;
    5758import org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog;
    5859import org.openstreetmap.josm.gui.layer.Layer;
     
    9293    public FilterDialog filterDialog;
    9394    public RelationListDialog relationListDialog;
     95    public ValidatorDialog validatorDialog;
    9496    public SelectionListDialog selectionListDialog;
    9597    /**
     
    180182        addToggleDialog(new HistoryDialog());
    181183        addToggleDialog(conflictDialog = new ConflictDialog());
     184        addToggleDialog(validatorDialog = new ValidatorDialog());
    182185        addToggleDialog(filterDialog = new FilterDialog());
    183186        addToggleDialog(new ChangesetDialog(this));
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r3594 r3669  
    113113
    114114    /**
    115      * Adds a edit layer change listener
     115     * Adds an edit layer change listener
    116116     *
    117117     * @param listener the listener. Ignored if null or already registered.
    118      * @param initialFire Fire an edit-layer-changed-event right after adding the listener.
     118     * @param initialFire Fire an edit-layer-changed-event right after adding
     119     * the listener in case there is an edit layer present
    119120     */
    120121    public static void addEditLayerChangeListener(EditLayerChangeListener listener, boolean initialFire) {
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r3426 r3669  
    2424import java.util.HashMap;
    2525import java.util.HashSet;
     26import java.util.List;
    2627import java.util.Map;
    2728
     
    6364import org.openstreetmap.josm.data.osm.visitor.paint.PaintVisitor;
    6465import org.openstreetmap.josm.data.osm.visitor.paint.SimplePaintVisitor;
     66import org.openstreetmap.josm.data.validation.TestError;
    6567import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    6668import org.openstreetmap.josm.gui.MapView;
     
    8688    private boolean isChanged = true;
    8789    private int highlightUpdateCount;
     90
     91    public List<TestError> validationErrors = new ArrayList<TestError>();
    8892
    8993    protected void setRequiresSaveToFile(boolean newValue) {
     
    483487            }
    484488
    485             ArrayList<WayPoint> trkseg = null;
     489            List<WayPoint> trkseg = null;
    486490            for (Node n : w.getNodes()) {
    487491                if (!n.isUsable()) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java

    r3507 r3669  
    4444
    4545    /**
    46      * Allows PreferenceSettings to do validation of entered values when ok was pressed. If data are invalid then event can
    47      * return false to cancel closing of preferences dialog
     46     * Allows PreferenceSettings to do validation of entered values when ok was pressed.
     47     * If data is invalid then event can return false to cancel closing of preferences dialog.
    4848     *
    4949     */
     
    168168                // to restart JOSM
    169169                //
    170                 StringBuffer sb = new StringBuffer();
     170                StringBuilder sb = new StringBuilder();
    171171                sb.append("<html>");
    172172                if (task != null && !task.isCanceled()) {
     
    222222
    223223    public void buildGui() {
    224         for (PreferenceSettingFactory factory:settingsFactory) {
     224        for (PreferenceSettingFactory factory : settingsFactory) {
    225225            // logger.info("creating settings: " + factory);
    226226            PreferenceSetting setting = factory.createPreferenceSetting();
     
    276276        settingsFactory.add(new AudioPreference.Factory());
    277277        settingsFactory.add(new ShortcutPreference.Factory());
     278        settingsFactory.add(new ValidatorPreference.Factory());
    278279
    279280        PluginHandler.getPreferenceSetting(settingsFactory);
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r3487 r3669  
    2828import java.util.Set;
    2929import java.util.Map.Entry;
     30import java.util.TreeMap;
     31import java.util.TreeSet;
    3032import java.util.concurrent.ExecutionException;
    3133import java.util.concurrent.ExecutorService;
     
    6769public class PluginHandler {
    6870
    69     final public static String [] DEPRECATED_PLUGINS = new String[] {"mappaint", "unglueplugin",
    70         "lang-de", "lang-en_GB", "lang-fr", "lang-it", "lang-pl", "lang-ro",
    71         "lang-ru", "ewmsplugin", "ywms", "tways-0.2", "geotagged", "landsat",
    72         "namefinder", "waypoints", "slippy_map_chooser", "tcx-support", "usertools",
    73         "AgPifoJ", "utilsplugin", "ghost"};
     71    /* deprecated plugins that are removed on start
     72       key - plugin name; value - explanation for deprecation (optional, can be null) */
     73    public final static Map<String, String> DEPRECATED_PLUGINS = new TreeMap<String, String>();
     74    static {
     75        String IN_CORE = tr("integrated into main program");
     76        for (String[] depr : new String[][] {
     77            {"mappaint"}, {"unglueplugin"}, {"lang-de"}, {"lang-en_GB"}, {"lang-fr"},
     78            {"lang-it"}, {"lang-pl"}, {"lang-ro"}, {"lang-ru"}, {"ewmsplugin"},
     79            {"ywms"}, {"tways-0.2"}, {"geotagged"}, {"landsat"}, {"namefinder"},
     80            {"waypoints"}, {"slippy_map_chooser"}, {"tcx-support"}, {"usertools"},
     81            {"AgPifoJ", IN_CORE}, {"utilsplugin", IN_CORE}, {"ghost"},
     82            {"validator", IN_CORE}}) {
     83            DEPRECATED_PLUGINS.put(depr[0], depr.length >= 2 ? depr[1] : null);
     84        }
     85    }
    7486
    7587    final public static String [] UNMAINTAINED_PLUGINS = new String[] {"gpsbabelgui", "Intersect_way"};
     
    90102     */
    91103    private static void filterDeprecatedPlugins(Window parent, Collection<String> plugins) {
    92         Set<String> removedPlugins = new HashSet<String>();
    93         for (String p : DEPRECATED_PLUGINS) {
     104        Set<String> removedPlugins = new TreeSet<String>();
     105        for (String p : DEPRECATED_PLUGINS.keySet()) {
    94106            if (plugins.contains(p)) {
    95107                plugins.remove(p);
     
    103115        // notify user about removed deprecated plugins
    104116        //
    105         StringBuffer sb = new StringBuffer();
     117        StringBuilder sb = new StringBuilder();
    106118        sb.append("<html>");
    107119        sb.append(trn(
     
    112124        sb.append("<ul>");
    113125        for (String name: removedPlugins) {
    114             sb.append("<li>").append(name).append("</li>");
     126            sb.append("<li>").append(name);
     127            String explanation = DEPRECATED_PLUGINS.get(name);
     128            if (explanation != null) {
     129                sb.append(" ("+explanation+")");
     130            }
     131            sb.append("</li>");
    115132        }
    116133        sb.append("</ul>");
  • trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java

    r3530 r3669  
    201201
    202202    protected void filterOldPlugins() {
    203         for (String p : PluginHandler.DEPRECATED_PLUGINS) {
     203        for (String p : PluginHandler.DEPRECATED_PLUGINS.keySet()) {
    204204            if (canceled)return;
    205205            if (availablePlugins.containsKey(p)) {
  • trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java

    r3479 r3669  
    295295    protected List<PluginInformation> filterDeprecatedPlugins(List<PluginInformation> plugins) {
    296296        List<PluginInformation> ret = new ArrayList<PluginInformation>(plugins.size());
    297         HashSet<String> deprecatedPluginNames = new HashSet<String>(Arrays.asList(PluginHandler.DEPRECATED_PLUGINS));
     297        HashSet<String> deprecatedPluginNames = new HashSet<String>(PluginHandler.DEPRECATED_PLUGINS.keySet());
    298298        for (PluginInformation plugin: plugins) {
    299299            if (deprecatedPluginNames.contains(plugin.name)) {
Note: See TracChangeset for help on using the changeset viewer.