Changeset 3873 in josm


Ignore:
Timestamp:
Feb 9, 2011 12:30:01 AM (2 years ago)
Author:
framm
Message:

rather ugly hack to allow using plugin-defined projection classes.
this ought to be replaced by something that properly engages the plugin's
class loader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java

    r3872 r3873  
    206206            Main.proj = (Projection)Class.forName(name).newInstance(); 
    207207        } catch (final Exception e) { 
    208             JOptionPane.showMessageDialog( 
    209                     Main.parent, 
    210                     tr("The projection {0} could not be activated. Using Mercator", name), 
    211                     tr("Error"), 
    212                     JOptionPane.ERROR_MESSAGE 
    213             ); 
    214             coll = null; 
    215             Main.proj = new Mercator(); 
    216             name = Main.proj.getClass().getName(); 
     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_MESSAGE 
     221                ); 
     222                coll = null; 
     223                Main.proj = new Mercator(); 
     224                name = Main.proj.getClass().getName(); 
     225            } 
    217226        } 
    218227        PROP_SUB_PROJECTION.put(coll); 
Note: See TracChangeset for help on using the changeset viewer.