Changeset 291 in josm for src/org/openstreetmap


Ignore:
Timestamp:
2007-07-19T11:51:22+02:00 (17 years ago)
Author:
imi
Message:
  • added PluginInformation.getLoaded to ease access between plugins
  • deprecated Plugin#copy(String,String) (use Plugin#copy(String,String,String) )
Location:
src/org/openstreetmap/josm/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/plugins/Plugin.java

    r267 r291  
    9292       
    9393        /**
     94         * @deprecated Use copy(String pluginName, String from, String to) instead
     95         */
     96        @Deprecated public void copy(String from, String to) throws FileNotFoundException, IOException {
     97                copy(name, from, to);
     98    }
     99
     100        /**
    94101         * Copies the ressource 'from' to the file in the plugin directory named 'to'.
    95102         */
    96         public void copy(String from, String to) throws FileNotFoundException, IOException {
    97                 File pluginDir = new File(getPluginDir());
     103        public void copy(String pluginName, String from, String to) throws FileNotFoundException, IOException {
     104            String pluginDirName = Main.pref.getPreferencesDir()+"plugins/"+pluginName+"/";
     105                File pluginDir = new File(pluginDirName);
    98106                if (!pluginDir.exists())
    99107                        pluginDir.mkdirs();
    100         FileOutputStream out = new FileOutputStream(getPluginDir()+to);
     108        FileOutputStream out = new FileOutputStream(pluginDirName+to);
    101109        InputStream in = getClass().getResourceAsStream(from);
    102110        byte[] buffer = new byte[8192];
  • src/org/openstreetmap/josm/plugins/PluginInformation.java

    r277 r291  
    187187            return all;
    188188    }
     189       
     190       
     191        /**
     192         * Return information about a loaded plugin.
     193         *
     194         * Note that if you call this in your plugins bootstrap, you may get <code>null</code> if
     195         * the plugin requested is not loaded yet.
     196         *
     197         * @return The PluginInformation to a specific plugin, but only if the plugin is loaded.
     198         * If it is not loaded, <code>null</code> is returned.
     199         */
     200        public static PluginInformation getLoaded(String pluginName) {
     201                for (PluginProxy p : Main.plugins)
     202                        if (p.info.name.equals(pluginName))
     203                                return p.info;
     204                return null;
     205        }
    189206}
    190207
Note: See TracChangeset for help on using the changeset viewer.