Changeset 6389 in osm for applications


Ignore:
Timestamp:
2008-01-14T19:59:57+01:00 (17 years ago)
Author:
gabriel
Message:

Validator plugin: Remove Util.getPlugin() hack.

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

Legend:

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

    r4843 r6389  
    3131public class ErrorLayer extends Layer implements LayerChangeListener
    3232{
    33         /**
    34          * Constructor
    35          * @param name
    36          */
    37         public ErrorLayer(String name)
    38     {
    39                 super(name);
     33        private OSMValidatorPlugin plugin;
     34
     35        public ErrorLayer(OSMValidatorPlugin plugin) {
     36                super(tr("Validation errors"));
     37                this.plugin = plugin;
    4038        Layer.listeners.add(this);
    4139        }
     
    5755    public void paint(final Graphics g, final MapView mv)
    5856    {
    59         DefaultMutableTreeNode root = OSMValidatorPlugin.getPlugin().validationDialog.tree.getRoot();
     57        DefaultMutableTreeNode root = plugin.validationDialog.tree.getRoot();
    6058        if( root == null || root.getChildCount() == 0)
    6159            return;
     
    8583    {
    8684        Bag<Severity, TestError> errorTree = new Bag<Severity, TestError>();
    87         List<TestError> errors = OSMValidatorPlugin.getPlugin().validationDialog.tree.getErrors();
     85        List<TestError> errors = plugin.validationDialog.tree.getErrors();
    8886        for(TestError e : errors)
    8987        {
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java

    r6388 r6389  
    3131{
    3232    /** The validate action */
    33     ValidateAction validateAction = new ValidateAction();
     33    ValidateAction validateAction = new ValidateAction(this);
    3434   
    3535    /** The validation dialog */
     
    7070        public PreferenceSetting getPreferenceSetting()
    7171        {
    72                 return new PreferenceEditor();
     72                return new PreferenceEditor(this);
    7373        }
    7474       
     
    7878                if (newFrame != null)
    7979                {
    80                     validationDialog = new ValidatorDialog();
     80                    validationDialog = new ValidatorDialog(this);
    8181                newFrame.addToggleDialog(validationDialog);
    82             Main.main.addLayer(new ErrorLayer(tr("Validation errors")));
     82            Main.main.addLayer(new ErrorLayer(this));
    8383                if( Main.pref.hasKey(PreferenceEditor.PREF_DEBUG + ".grid") )
    8484                        Main.main.addLayer(new GridLayer(tr("Grid")));
     
    101101                if( newFrame != null )
    102102                        hooks.add( 0, new ValidateUploadHook() );
    103         }
    104 
    105        
    106         /**
    107          * Utility method for classes that can't access the plugin directly
    108          *
    109          * @return The plugin object
    110          */
    111         public static OSMValidatorPlugin getPlugin()
    112         {
    113                 return (OSMValidatorPlugin)Util.getPlugin(OSMValidatorPlugin.class);
    114103        }
    115104
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/PreferenceEditor.java

    r6388 r6389  
    2424public class PreferenceEditor implements PreferenceSetting
    2525{
     26        private OSMValidatorPlugin plugin;
     27
    2628        /** The preferences prefix */
    2729        public static final String PREFIX = "validator";
     
    3840        /** The list of all tests */
    3941        private Collection<Test> allTests;
     42
     43        public PreferenceEditor(OSMValidatorPlugin plugin) {
     44                this.plugin = plugin;
     45        }
    4046
    4147    public void addGui(PreferenceDialog gui)
     
    8187                if (testsBeforeUpload.length() > 0 ) testsBeforeUpload = testsBeforeUpload.deleteCharAt(0);
    8288               
    83                 OSMValidatorPlugin.getPlugin().initializeTests( allTests );
     89                plugin.initializeTests( allTests );
    8490               
    8591                Main.pref.put( PREF_TESTS, tests.toString());
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java

    r6388 r6389  
    2323public class ValidateAction extends JosmAction
    2424{
     25        private OSMValidatorPlugin plugin;
     26
    2527        /** Serializable ID */
    2628    private static final long serialVersionUID = -2304521273582574603L;
     
    3234         * Constructor
    3335         */
    34         public ValidateAction()
    35         {
     36        public ValidateAction(OSMValidatorPlugin plugin) {
    3637                super("Validation", "validator", "Performs the data validation", KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_MASK, true);
     38                this.plugin = plugin;
    3739        }
    3840
     
    5456        public void doValidate(@SuppressWarnings("unused") ActionEvent ev, boolean getSelectedItems)
    5557        {
    56                 OSMValidatorPlugin plugin = OSMValidatorPlugin.getPlugin();
    5758        if( plugin.validateAction == null || Main.map == null || !Main.map.isVisible() )
    5859            return;
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java

    r6202 r6389  
    3232public class ValidatorDialog extends ToggleDialog implements ActionListener
    3333{
     34        private OSMValidatorPlugin plugin;
     35
    3436    /** Serializable ID */
    3537    private static final long serialVersionUID = 2952292777351992696L;
     
    5658     * Constructor
    5759     */
    58     public ValidatorDialog()
    59     {
     60    public ValidatorDialog(OSMValidatorPlugin plugin) {
    6061        super(tr("Validation errors"), "validator", tr("Open the validation window."), KeyEvent.VK_V, 150);
     62
     63                this.plugin = plugin;
    6164       
    6265        tree = new ErrorTreePanel();
     
    134137                DataSet.fireSelectionChanged(Main.ds.getSelected());
    135138                       
    136         OSMValidatorPlugin.getPlugin().validateAction.doValidate(e, false);
     139        plugin.validateAction.doValidate(e, false);
    137140        }       
    138141       
     
    177180                        setSelectedItems();
    178181                else if( actionCommand.equals("Validate"))
    179                 OSMValidatorPlugin.getPlugin().validateAction.actionPerformed(e);
     182                plugin.validateAction.actionPerformed(e);
    180183                else if( actionCommand.equals("Fix"))
    181184                fixErrors(e);
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java

    r4843 r6389  
    2626public class Util
    2727{
    28 
    29     /**
    30      * Utility method to retrieve the plugin for classes that can't access to the plugin object directly.
    31      *
    32      * @param clazz The plugin class
    33      * @return The YWMS plugin
    34      */
    35     public static Plugin getPlugin(Class<? extends Plugin> clazz)
    36     {
    37         String classname = clazz.getName();
    38         for (PluginProxy plugin : Main.plugins)
    39         {
    40             if( plugin.info.className.equals(classname) )
    41             {
    42                 return (Plugin)plugin.plugin;
    43             }
    44         }
    45        
    46         return null;
    47     }
    48    
    4928        /**
    5029         * Returns the plugin's directory of the plugin
Note: See TracChangeset for help on using the changeset viewer.