Changeset 3874 in josm for trunk/src/org
- Timestamp:
- 2011-02-09T09:53:35+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r3872 r3874 34 34 } 35 35 36 /** 37 * Adds a new projection to the list of known projections. 38 * 39 * For Plugins authors: make sure your plugin is an early plugin, i.e. put 40 * Plugin-Early=true in your Manifest. 41 */ 36 42 public static void addProjection(Projection proj) { 37 43 allProjections.add(proj); -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r3873 r3874 30 30 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs; 31 31 import org.openstreetmap.josm.gui.NavigatableComponent; 32 import org.openstreetmap.josm.plugins.PluginHandler; 32 33 import org.openstreetmap.josm.tools.GBC; 33 34 … … 203 204 Projection oldProj = Main.proj; 204 205 205 try {206 Main.proj = (Projection)Class.forName(name).newInstance();207 } catch (final Exception e){208 // backup plan: if we cannot instantiate this, maybe we have an instance already.209 Main.proj = null;210 for (Projection p : Projections.getProjections()) {211 if (p.getClass().getName().equals(name)) {212 Main.proj = p; break;213 }214 } 215 if (Main.proj == null) {216 JOptionPane.showMessageDialog(217 Main.parent,218 tr("The projection {0} could not be activated. Using Mercator", name),219 tr("Error"),220 JOptionPane.ERROR_MESSAGE221 );222 coll = null;223 Main.proj = new Mercator();224 name = Main.proj.getClass().getName();225 }206 Projection p = null; 207 for (ClassLoader cl : PluginHandler.getResourceClassLoaders()) { 208 try { 209 p = (Projection) Class.forName(name, true, cl).newInstance(); 210 } catch (final Exception e) { 211 } 212 if (p != null) { 213 Main.proj = p; 214 break; 215 } 216 } 217 if (p == null) { 218 JOptionPane.showMessageDialog( 219 Main.parent, 220 tr("The projection {0} could not be activated. Using Mercator", name), 221 tr("Error"), 222 JOptionPane.ERROR_MESSAGE 223 ); 224 coll = null; 225 Main.proj = new Mercator(); 226 name = Main.proj.getClass().getName(); 226 227 } 227 228 PROP_SUB_PROJECTION.put(coll); … … 285 286 */ 286 287 private void setupProjectionCombo() { 288 boolean found = false; 287 289 for (int i = 0; i < projectionCombo.getItemCount(); ++i) { 288 290 Projection proj = (Projection)projectionCombo.getItemAt(i); … … 294 296 projectionCombo.setSelectedIndex(i); 295 297 selectedProjectionChanged(proj); 298 found = true; 296 299 break; 297 300 } 298 301 } 302 if (!found) 303 throw new RuntimeException("Couldn't find the current projection in the list of available projections!"); 299 304 300 305 projectionCombo.addActionListener(new ActionListener() { -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r3730 r3874 159 159 160 160 /** 161 * Add here all ClassLoader whose resource should be searched. 162 */ 163 private static final List<ClassLoader> sources = new LinkedList<ClassLoader>(); 164 165 static { 166 try { 167 sources.add(ClassLoader.getSystemClassLoader()); 168 sources.add(org.openstreetmap.josm.gui.MainApplication.class.getClassLoader()); 169 } catch (SecurityException ex) { 170 sources.add(ImageProvider.class.getClassLoader()); 171 } 172 } 173 174 public static Collection<ClassLoader> getResourceClassLoaders() { 175 return Collections.unmodifiableCollection(sources); 176 } 177 178 /** 161 179 * Removes deprecated plugins from a collection of plugins. Modifies the 162 180 * collection <code>plugins</code>. … … 516 534 517 535 ClassLoader pluginClassLoader = createClassLoader(toLoad); 518 ImageProvider.sources.add(0, pluginClassLoader);536 sources.add(0, pluginClassLoader); 519 537 monitor.setTicksCount(toLoad.size()); 520 538 for (PluginInformation info : toLoad) { -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r3730 r3874 65 65 availablePlugins.put(info.getName(), info); 66 66 } else { 67 availablePlugins.get(info.getName()).localversion = info.version; 67 PluginInformation current = availablePlugins.get(info.getName()); 68 current.localversion = info.version; 68 69 if (info.icon != null) { 69 availablePlugins.get(info.getName()).icon = info.icon; 70 } 70 current.icon = info.icon; 71 } 72 current.early = info.early; 73 current.className = info.className; 74 current.libraries = info.libraries; 75 current.stage = info.stage; 76 current.requires = info.requires; 71 77 } 72 78 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r3862 r3874 24 24 import java.util.Collection; 25 25 import java.util.HashMap; 26 import java.util.LinkedList;27 import java.util.List;28 26 import java.util.Map; 29 27 import java.util.zip.ZipEntry; … … 36 34 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 37 35 import org.openstreetmap.josm.io.MirroredInputStream; 36 import org.openstreetmap.josm.plugins.PluginHandler; 38 37 39 38 /** … … 68 67 */ 69 68 private static Map<String, ImageWrapper> cache = new HashMap<String, ImageWrapper>(); 70 71 /**72 * Add here all ClassLoader whose resource should be searched. Plugin's class loaders are added73 * by main.74 */75 public static final List<ClassLoader> sources = new LinkedList<ClassLoader>();76 69 77 70 /** … … 234 227 if (path.startsWith("resource://")) { 235 228 String p = path.substring("resource://".length()); 236 for (ClassLoader source : sources) {229 for (ClassLoader source : PluginHandler.getResourceClassLoaders()) { 237 230 URL res; 238 231 if ((res = source.getResource(p + name)) != null) … … 355 348 } 356 349 357 static {358 try {359 sources.add(ClassLoader.getSystemClassLoader());360 sources.add(org.openstreetmap.josm.gui.MainApplication.class.getClassLoader());361 } catch (SecurityException ex) {362 sources.add(ImageProvider.class.getClassLoader());363 }364 }365 366 350 /* 367 351 * from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/ License:
Note:
See TracChangeset
for help on using the changeset viewer.