Changeset 31829 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-12-15T16:32:35+01:00 (9 years ago)
Author:
floscher
Message:

[mapillary] Fix NullPointerExceptions that occur in headless unit tests

File:
1 edited

Legend:

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

    r31828 r31829  
    7575
    7676  /** Menu button for the {@link MapillaryDownloadAction} action. */
    77   private JMenuItem downloadMenu;
     77  private JMenuItem downloadMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false);
    7878  /** Menu button for the {@link MapillaryExportAction} action. */
    79   private static JMenuItem exportMenu;
     79  private static JMenuItem exportMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14);
    8080  /** Menu button for the {@link MapillaryImportAction} action. */
    81   private JMenuItem importMenu;
     81  private JMenuItem importMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14);
    8282  /** Menu button for the {@link MapillaryZoomAction} action. */
    83   private static JMenuItem zoomMenu;
     83  private static JMenuItem zoomMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
    8484  /** Menu button for the {@link MapillaryDownloadViewAction} action. */
    85   private static JMenuItem downloadViewMenu;
     85  private static JMenuItem downloadViewMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, downloadViewAction, false, 14);
    8686  /** Menu button for the {@link MapillaryImportIntoSequenceAction} action. */
    87   private JMenuItem importIntoSequenceMenu;
     87  private JMenuItem importIntoSequenceMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14);
    8888  /** Menu button for the {@link MapillaryJoinAction} action. */
    89   private static JMenuItem joinMenu;
     89  private static JMenuItem joinMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.dataMenu, joinAction, false);
    9090  /** Menu button for the {@link MapillaryWalkAction} action. */
    91   private static JMenuItem walkMenu;
     91  private static JMenuItem walkMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
    9292  /** Menu button for the {@link MapillaryUploadAction} action. */
    93   private static JMenuItem uploadMenu;
     93  private static JMenuItem uploadMenu = Main.main == null ? null : MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14);
    9494
    9595  /**
     
    103103
    104104    if (Main.main != null) { // important for headless mode
    105       downloadMenu = MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false);
    106       exportMenu = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14);
    107       importIntoSequenceMenu = MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14);
    108       importMenu = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14);
    109       uploadMenu = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14);
    110       zoomMenu = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
    111       downloadViewMenu = MainMenu.add(Main.main.menu.fileMenu, downloadViewAction, false, 14);
    112       joinMenu = MainMenu.add(Main.main.menu.dataMenu, joinAction, false);
    113       walkMenu = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
    114 
    115105      exportMenu.setEnabled(false);
    116106      downloadMenu.setEnabled(false);
     
    231221   */
    232222  public static void setMenuEnabled(final JMenuItem menu, final boolean value) {
     223    if (menu == null) { // In headless mode the menu items are initialized to null
     224      return;
     225    }
    233226    if (!SwingUtilities.isEventDispatchThread()) {
    234227      SwingUtilities.invokeLater(new Runnable() {
Note: See TracChangeset for help on using the changeset viewer.