Changeset 3077 in osm


Ignore:
Timestamp:
2007-06-01T10:39:16+02:00 (17 years ago)
Author:
christofd
Message:

do not derive from livegpsplugin anymore, only use it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorPlugin.java

    r2945 r3077  
    44package at.dallermassl.josm.plugin.surveyor;
    55
     6import static org.openstreetmap.josm.tools.I18n.tr;
     7
     8import java.util.Iterator;
     9
    610import javax.swing.AbstractAction;
    711import javax.swing.JCheckBoxMenuItem;
    812import javax.swing.JFrame;
    913import javax.swing.JMenuItem;
     14import javax.swing.JOptionPane;
    1015import javax.swing.KeyStroke;
     16
     17import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.plugins.PluginProxy;
    1119
    1220import livegps.LiveGpsPlugin;
     
    2129 *
    2230 */
    23 public class SurveyorPlugin extends LiveGpsPlugin {
     31public class SurveyorPlugin {
    2432   
    2533    private static JFrame surveyorFrame;
     34    public static final String PREF_KEY_STREET_NAME_FONT_SIZE = "surveyor.way.fontsize";
    2635
    2736    /**
     
    3039    public SurveyorPlugin() {
    3140        super();
    32         SurveyorShowAction surveyorAction = new SurveyorShowAction("Surveyor", this);
     41       
     42        // try to determine if the livegps plugin was already loaded:
     43        try {
     44            Class.forName("livegps.LiveGpsPlugin");
     45        } catch(ClassNotFoundException cnfe) {
     46            String message =
     47                tr("SurveyorPlugin depends on LiveGpsPlugin!") + "\n" +
     48                tr("LiveGpsPlugin not found, please install and activate.") + "\n" +
     49                tr("SurveyorPlugin is disabled for the moment");
     50            JOptionPane.showMessageDialog(Main.parent, message, tr("SurveyorPlugin"), JOptionPane.ERROR_MESSAGE);
     51            return;
     52        }
     53       
     54       
     55        LiveGpsPlugin gpsPlugin = null;
     56        Iterator<PluginProxy> proxyIter = Main.plugins.iterator();
     57        while(proxyIter.hasNext()) {
     58            Object plugin = proxyIter.next().plugin;
     59            if(plugin instanceof LiveGpsPlugin) {
     60                gpsPlugin = (LiveGpsPlugin) plugin;
     61                break;
     62            }
     63        }
     64        if(gpsPlugin == null) {
     65            throw new IllegalStateException("SurveyorPlugin needs LiveGpsPlugin, but could not find it!");
     66        }
     67        SurveyorShowAction surveyorAction = new SurveyorShowAction("Surveyor", gpsPlugin);
    3368        JMenuItem surveyorMenuItem = new JMenuItem(surveyorAction);
    3469        surveyorAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt S"));
    3570//        surveyorMenuItem.addActionListener(new ActionListener() {
    36         getLgpsMenu().addSeparator();
    37         getLgpsMenu().add(surveyorMenuItem);
     71        gpsPlugin.getLgpsMenu().addSeparator();
     72        gpsPlugin.getLgpsMenu().add(surveyorMenuItem);
    3873       
    3974        AutoSaveAction autoSaveAction = new AutoSaveAction("AutoSave LiveData");
    4075        JCheckBoxMenuItem autoSaveMenu = new JCheckBoxMenuItem(autoSaveAction);
    41         getLgpsMenu().add(autoSaveMenu);
     76        gpsPlugin.getLgpsMenu().add(autoSaveMenu);
    4277       
    4378    }
Note: See TracChangeset for help on using the changeset viewer.