Ignore:
Timestamp:
2007-07-14T21:03:50+02:00 (17 years ago)
Author:
ulf
Message:

bugfix: getPluginDir() is deprecated and in fact doesn't work with current josm versions (it returns the path of the latest loaded plugin, which is often wrong). So external styles are not found.

I've replaced getPluginDir() with the now recommended: "Main.pref.getPreferencesDir()+"plugins/mappaint/""

In addition, I've also added a warning message, if loading of the style failed. When I first started to experiment with the styles, it drove me mad not to get this information ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mappaint/src/mappaint/MapPaintPlugin.java

    r2768 r3587  
    2727        public MapPaintPlugin() {
    2828                String styleName = Main.pref.get("mappaint.style", "standard");
    29                 styleDir = getPluginDir()+styleName+"/"; //some day we will support diferent icon directories over options
     29                styleDir = Main.pref.getPreferencesDir()+"plugins/mappaint/"+styleName+"/"; //some day we will support different icon directories over options
    3030                String elemStylesFile = getStyleDir()+"elemstyles.xml";
     31               
     32                // System.out.println("mappaint: Using style: " + styleName);
     33                // System.out.println("mappaint: Using style dir: " + styleDir);
     34                // System.out.println("mappaint: Using style file: " + elemStylesFile);
     35               
    3136                File f = new File(elemStylesFile);
    3237                if (f.exists())
    3338                {
    34                         try
     39                        try     // reading file from file system
    3540                        {
     41                                // System.out.println("mappaint: Using style file: \"" + f + "\"");
    3642                                XMLReader xmlReader = XMLReaderFactory.createXMLReader();
    3743                                ElemStyleHandler handler = new ElemStyleHandler();
     
    4753                        }
    4854                }
    49                 else{ //use the standart elemstyle of this style
     55                else{   // reading the builtin file from the plugin jar file
    5056                        URL elemStylesPath = getClass().getResource("/"+styleName+"/elemstyles.xml");
     57                       
     58                        // System.out.println("mappaint: Using jar's elemstyles.xml: \"" + elemStylesPath + "\"");
    5159                        if (elemStylesPath != null)
    5260                        {
     
    6573                                        throw new RuntimeException(e);
    6674                                }
    67                         }
     75                        } else {
     76                                System.out.println("mappaint: Couldn't find style: \"" + styleDir + "\"elemstyles.xml");
     77                        }
    6878                }
    6979        }
Note: See TracChangeset for help on using the changeset viewer.