Changeset 31832 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-12-15T20:51:39+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Improve initialization of the menu items in MapillaryPlugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31829 r31832  
    7575
    7676  /** Menu button for the {@link MapillaryDownloadAction} action. */
    77   private JMenuItem downloadMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false);
     77  private static final JMenuItem downloadMenu;
    7878  /** Menu button for the {@link MapillaryExportAction} action. */
    79   private static JMenuItem exportMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14);
     79  private static final  JMenuItem exportMenu;
    8080  /** Menu button for the {@link MapillaryImportAction} action. */
    81   private JMenuItem importMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14);
     81  private static final JMenuItem importMenu;
    8282  /** Menu button for the {@link MapillaryZoomAction} action. */
    83   private static JMenuItem zoomMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
     83  private static final JMenuItem zoomMenu;
    8484  /** Menu button for the {@link MapillaryDownloadViewAction} action. */
    85   private static JMenuItem downloadViewMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, downloadViewAction, false, 14);
     85  private static final JMenuItem downloadViewMenu;
    8686  /** Menu button for the {@link MapillaryImportIntoSequenceAction} action. */
    87   private JMenuItem importIntoSequenceMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14);
     87  private static final JMenuItem importIntoSequenceMenu;
    8888  /** Menu button for the {@link MapillaryJoinAction} action. */
    89   private static JMenuItem joinMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.dataMenu, joinAction, false);
     89  private static final JMenuItem joinMenu;
    9090  /** Menu button for the {@link MapillaryWalkAction} action. */
    91   private static JMenuItem walkMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
     91  private static final JMenuItem walkMenu;
    9292  /** Menu button for the {@link MapillaryUploadAction} action. */
    93   private static JMenuItem uploadMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14);
     93  private static final JMenuItem uploadMenu;
     94
     95  static {
     96    if (Main.main != null) {
     97      exportMenu = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14);
     98      exportMenu.setEnabled(false);
     99      downloadMenu = MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false);
     100      downloadMenu.setEnabled(false);
     101      importMenu = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14);
     102      importMenu.setEnabled(false);
     103      zoomMenu = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
     104      zoomMenu.setEnabled(false);
     105      downloadViewMenu = MainMenu.add(Main.main.menu.fileMenu, downloadViewAction, false, 14);
     106      downloadViewMenu.setEnabled(false);
     107      importIntoSequenceMenu = MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14);
     108      importIntoSequenceMenu.setEnabled(false);
     109      joinMenu = MainMenu.add(Main.main.menu.dataMenu, joinAction, false);
     110      joinMenu.setEnabled(false);
     111      walkMenu = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
     112      walkMenu.setEnabled(false);
     113      uploadMenu = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14);
     114      uploadMenu.setEnabled(false);
     115    } else {
     116      exportMenu = null;
     117      downloadMenu = null;
     118      importMenu = null;
     119      zoomMenu = null;
     120      downloadViewMenu = null;
     121      importIntoSequenceMenu = null;
     122      joinMenu = null;
     123      walkMenu = null;
     124      uploadMenu = null;
     125    }
     126  }
    94127
    95128  /**
     
    101134  public MapillaryPlugin(PluginInformation info) {
    102135    super(info);
    103 
    104     if (Main.main != null) { // important for headless mode
    105       exportMenu.setEnabled(false);
    106       downloadMenu.setEnabled(false);
    107       importMenu.setEnabled(false);
    108       importIntoSequenceMenu.setEnabled(false);
    109       zoomMenu.setEnabled(false);
    110       downloadViewMenu.setEnabled(false);
    111       joinMenu.setEnabled(false);
    112       walkMenu.setEnabled(false);
    113     }
    114136
    115137    try {
Note: See TracChangeset for help on using the changeset viewer.