Changeset 6389 in osm
- Timestamp:
- 2008-01-14T19:59:57+01:00 (17 years ago)
- 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 31 31 public class ErrorLayer extends Layer implements LayerChangeListener 32 32 { 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; 40 38 Layer.listeners.add(this); 41 39 } … … 57 55 public void paint(final Graphics g, final MapView mv) 58 56 { 59 DefaultMutableTreeNode root = OSMValidatorPlugin.getPlugin().validationDialog.tree.getRoot();57 DefaultMutableTreeNode root = plugin.validationDialog.tree.getRoot(); 60 58 if( root == null || root.getChildCount() == 0) 61 59 return; … … 85 83 { 86 84 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(); 88 86 for(TestError e : errors) 89 87 { -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java
r6388 r6389 31 31 { 32 32 /** The validate action */ 33 ValidateAction validateAction = new ValidateAction( );33 ValidateAction validateAction = new ValidateAction(this); 34 34 35 35 /** The validation dialog */ … … 70 70 public PreferenceSetting getPreferenceSetting() 71 71 { 72 return new PreferenceEditor( );72 return new PreferenceEditor(this); 73 73 } 74 74 … … 78 78 if (newFrame != null) 79 79 { 80 validationDialog = new ValidatorDialog( );80 validationDialog = new ValidatorDialog(this); 81 81 newFrame.addToggleDialog(validationDialog); 82 Main.main.addLayer(new ErrorLayer(t r("Validation errors")));82 Main.main.addLayer(new ErrorLayer(this)); 83 83 if( Main.pref.hasKey(PreferenceEditor.PREF_DEBUG + ".grid") ) 84 84 Main.main.addLayer(new GridLayer(tr("Grid"))); … … 101 101 if( newFrame != null ) 102 102 hooks.add( 0, new ValidateUploadHook() ); 103 }104 105 106 /**107 * Utility method for classes that can't access the plugin directly108 *109 * @return The plugin object110 */111 public static OSMValidatorPlugin getPlugin()112 {113 return (OSMValidatorPlugin)Util.getPlugin(OSMValidatorPlugin.class);114 103 } 115 104 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/PreferenceEditor.java
r6388 r6389 24 24 public class PreferenceEditor implements PreferenceSetting 25 25 { 26 private OSMValidatorPlugin plugin; 27 26 28 /** The preferences prefix */ 27 29 public static final String PREFIX = "validator"; … … 38 40 /** The list of all tests */ 39 41 private Collection<Test> allTests; 42 43 public PreferenceEditor(OSMValidatorPlugin plugin) { 44 this.plugin = plugin; 45 } 40 46 41 47 public void addGui(PreferenceDialog gui) … … 81 87 if (testsBeforeUpload.length() > 0 ) testsBeforeUpload = testsBeforeUpload.deleteCharAt(0); 82 88 83 OSMValidatorPlugin.getPlugin().initializeTests( allTests );89 plugin.initializeTests( allTests ); 84 90 85 91 Main.pref.put( PREF_TESTS, tests.toString()); -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidateAction.java
r6388 r6389 23 23 public class ValidateAction extends JosmAction 24 24 { 25 private OSMValidatorPlugin plugin; 26 25 27 /** Serializable ID */ 26 28 private static final long serialVersionUID = -2304521273582574603L; … … 32 34 * Constructor 33 35 */ 34 public ValidateAction() 35 { 36 public ValidateAction(OSMValidatorPlugin plugin) { 36 37 super("Validation", "validator", "Performs the data validation", KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_MASK, true); 38 this.plugin = plugin; 37 39 } 38 40 … … 54 56 public void doValidate(@SuppressWarnings("unused") ActionEvent ev, boolean getSelectedItems) 55 57 { 56 OSMValidatorPlugin plugin = OSMValidatorPlugin.getPlugin();57 58 if( plugin.validateAction == null || Main.map == null || !Main.map.isVisible() ) 58 59 return; -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/ValidatorDialog.java
r6202 r6389 32 32 public class ValidatorDialog extends ToggleDialog implements ActionListener 33 33 { 34 private OSMValidatorPlugin plugin; 35 34 36 /** Serializable ID */ 35 37 private static final long serialVersionUID = 2952292777351992696L; … … 56 58 * Constructor 57 59 */ 58 public ValidatorDialog() 59 { 60 public ValidatorDialog(OSMValidatorPlugin plugin) { 60 61 super(tr("Validation errors"), "validator", tr("Open the validation window."), KeyEvent.VK_V, 150); 62 63 this.plugin = plugin; 61 64 62 65 tree = new ErrorTreePanel(); … … 134 137 DataSet.fireSelectionChanged(Main.ds.getSelected()); 135 138 136 OSMValidatorPlugin.getPlugin().validateAction.doValidate(e, false);139 plugin.validateAction.doValidate(e, false); 137 140 } 138 141 … … 177 180 setSelectedItems(); 178 181 else if( actionCommand.equals("Validate")) 179 OSMValidatorPlugin.getPlugin().validateAction.actionPerformed(e);182 plugin.validateAction.actionPerformed(e); 180 183 else if( actionCommand.equals("Fix")) 181 184 fixErrors(e); -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java
r4843 r6389 26 26 public class Util 27 27 { 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 class33 * @return The YWMS plugin34 */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 49 28 /** 50 29 * Returns the plugin's directory of the plugin
Note:
See TracChangeset
for help on using the changeset viewer.