Changeset 19505 in osm for applications


Ignore:
Timestamp:
2010-01-13T21:33:51+01:00 (15 years ago)
Author:
jttt
Message:

Cleanup test initialization

Location:
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java

    r19485 r19505  
    1010import java.io.IOException;
    1111import java.io.PrintWriter;
    12 import java.lang.reflect.InvocationTargetException;
    1312import java.util.ArrayList;
    1413import java.util.Collection;
     
    6261public class OSMValidatorPlugin extends Plugin implements LayerChangeListener {
    6362
    64     protected static OSMValidatorPlugin plugin;
    65 
    6663    protected static ErrorLayer errorLayer = null;
    6764
     
    109106    public OSMValidatorPlugin(PluginInformation info) {
    110107        super(info);
    111         plugin = this;
    112108        checkPluginDir();
    113109        initializeGridDetail();
     
    273269            try {
    274270                if (test.enabled) {
    275                     test.getClass().getMethod("initialize", new Class[] { OSMValidatorPlugin.class }).invoke(null,
    276                             new Object[] { this });
     271                    test.initialize(this);
    277272                }
    278             } catch (InvocationTargetException ite) {
    279                 ite.getCause().printStackTrace();
    280                 JOptionPane.showMessageDialog(Main.parent,
    281                                 tr("Error initializing test {0}:\n {1}", test.getClass()
    282                         .getSimpleName(), ite.getCause().getMessage()),
    283                         tr("Error"),
    284                         JOptionPane.ERROR_MESSAGE);
    285273            } catch (Exception e) {
    286274                e.printStackTrace();
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/Test.java

    r19335 r19505  
    8686     * @throws Exception When cannot initialize the test
    8787     */
    88     public static void initialize(OSMValidatorPlugin plugin) throws Exception {}
     88    public void initialize(OSMValidatorPlugin plugin) throws Exception {}
    8989
    9090    /**
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java

    r18377 r19505  
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.actions.JosmAction;
    16 import org.openstreetmap.josm.data.osm.DataSet;
    1716import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1817import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    6665            return;
    6766
    68         OSMValidatorPlugin.plugin.initializeErrorLayer();
     67        plugin.initializeErrorLayer();
    6968
    7069        Collection<Test> tests = OSMValidatorPlugin.getEnabledTests(false);
     
    9190
    9291        ValidationTask task = new ValidationTask(tests, selection, lastSelection);
    93         Main.worker.submit(task);       
     92        Main.worker.submit(task);
    9493    }
    9594
     
    9897        setEnabled(getEditLayer() != null);
    9998    }
    100    
     99
    101100    /**
    102101     * Asynchronous task for running a collection of tests against a collection
    103      * of primitives 
     102     * of primitives
    104103     *
    105104     */
    106    
     105
    107106    class ValidationTask extends PleaseWaitRunnable {
    108107        private Collection<Test> tests;
     
    111110        private boolean canceled;
    112111        private List<TestError> errors;
    113        
     112
    114113        /**
    115          * 
    116          * @param tests  the tests to run 
    117          * @param validatedPrimitives the collection of primitives to validate. 
     114         *
     115         * @param tests  the tests to run
     116         * @param validatedPrimitives the collection of primitives to validate.
    118117         * @param formerValidatedPrimitives the last collection of primitives being validates. May be null.
    119118         */
     
    124123                this.tests = tests;
    125124        }
    126        
     125
    127126                @Override
    128127                protected void cancel() {
    129                         this.canceled = true;                   
     128                        this.canceled = true;
    130129                }
    131130
     
    133132                protected void finish() {
    134133                        if (canceled) return;
    135                        
     134
    136135                        // update GUI on Swing EDT
    137136                        //
     
    141140                                plugin.validationDialog.setVisible(true);
    142141                                Main.main.getCurrentDataSet().fireSelectionChanged();
    143                                 }                               
     142                                }
    144143                        };
    145144                        if (SwingUtilities.isEventDispatchThread()) {
    146                                 r.run();                               
     145                                r.run();
    147146                        } else {
    148147                                SwingUtilities.invokeLater(r);
     
    153152                protected void realRun() throws SAXException, IOException,
    154153                                OsmTransferException {
    155                         if (tests == null || tests.isEmpty()) return;           
     154                        if (tests == null || tests.isEmpty()) return;
    156155                errors = new ArrayList<TestError>(200);
    157156                getProgressMonitor().setTicksCount(tests.size() * validatedPrimitmives.size());
    158157                int testCounter = 0;
    159                         for (Test test : tests) {                               
     158                        for (Test test : tests) {
    160159                                if (canceled) return;
    161160                                testCounter++;
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/TagChecker.java

    r19335 r19505  
    7676    /** The TagChecker data */
    7777    protected static List<CheckerData> checkerData = new ArrayList<CheckerData>();
    78     protected static ArrayList<String> ignoreDataStartsWith = new ArrayList<String>();
    79     protected static ArrayList<String> ignoreDataEquals = new ArrayList<String>();
    80     protected static ArrayList<String> ignoreDataEndsWith = new ArrayList<String>();
    81     protected static ArrayList<IgnoreKeyPair> ignoreDataKeyPair = new ArrayList<IgnoreKeyPair>();
    82     protected static ArrayList<IgnoreTwoKeyPair> ignoreDataTwoKeyPair = new ArrayList<IgnoreTwoKeyPair>();
     78    protected static List<String> ignoreDataStartsWith = new ArrayList<String>();
     79    protected static List<String> ignoreDataEquals = new ArrayList<String>();
     80    protected static List<String> ignoreDataEndsWith = new ArrayList<String>();
     81    protected static List<IgnoreKeyPair> ignoreDataKeyPair = new ArrayList<IgnoreKeyPair>();
     82    protected static List<IgnoreTwoKeyPair> ignoreDataTwoKeyPair = new ArrayList<IgnoreTwoKeyPair>();
    8383
    8484    /** The preferences prefix */
     
    152152    }
    153153
    154     public static void initialize(OSMValidatorPlugin plugin) throws Exception
     154    @Override
     155    public void initialize(OSMValidatorPlugin plugin) throws Exception
    155156    {
    156157        initializeData();
Note: See TracChangeset for help on using the changeset viewer.