Changeset 3874 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
- Timestamp:
- 2011-02-09T09:53:35+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 instancealready.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() {
Note:
See TracChangeset
for help on using the changeset viewer.
