Changeset 14337 in josm for trunk/src


Ignore:
Timestamp:
2018-10-15T23:43:03+02:00 (14 months ago)
Author:
Don-vip
Message:

fix #16845 - ChooseTrackVisibilityActionTest: fix for non-headless mode by properly mocking dialogs (patch by ris)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java

    r14153 r14337  
    77import java.awt.Component;
    88import java.awt.Dimension;
    9 import java.awt.GraphicsEnvironment;
    109import java.awt.GridBagLayout;
    1110import java.awt.event.ActionEvent;
     
    263262
    264263        int v = 1;
    265         if (!GraphicsEnvironment.isHeadless()) {
    266             // build dialog
    267             ExtendedDialog ed = new ExtendedDialog(MainApplication.getMainFrame(), tr("Set track visibility for {0}", layer.getName()),
    268                     tr("Show all"), tr("Show selected only"), tr("Cancel"));
    269             ed.setButtonIcons("eye", "dialogs/filter", "cancel");
    270             ed.setContent(msg, false);
    271             ed.setDefaultButton(2);
    272             ed.setCancelButton(3);
    273             ed.configureContextsensitiveHelp("/Action/ChooseTrackVisibility", true);
    274             ed.setRememberWindowGeometry(getClass().getName() + ".geometry",
    275                     WindowGeometry.centerInWindow(MainApplication.getMainFrame(), new Dimension(1000, 500)));
    276             ed.showDialog();
    277             dateFilter.saveInPrefs();
    278             v = ed.getValue();
    279             // cancel for unknown buttons and copy back original settings
    280             if (v != 1 && v != 2) {
    281                 layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length);
    282                 MainApplication.getMap().repaint();
    283                 return;
    284             }
     264        // build dialog
     265        ExtendedDialog ed = new ExtendedDialog(MainApplication.getMainFrame(), tr("Set track visibility for {0}", layer.getName()),
     266                tr("Show all"), tr("Show selected only"), tr("Cancel"));
     267        ed.setButtonIcons("eye", "dialogs/filter", "cancel");
     268        ed.setContent(msg, false);
     269        ed.setDefaultButton(2);
     270        ed.setCancelButton(3);
     271        ed.configureContextsensitiveHelp("/Action/ChooseTrackVisibility", true);
     272        ed.setRememberWindowGeometry(getClass().getName() + ".geometry",
     273                WindowGeometry.centerInWindow(MainApplication.getMainFrame(), new Dimension(1000, 500)));
     274        ed.showDialog();
     275        dateFilter.saveInPrefs();
     276        v = ed.getValue();
     277        // cancel for unknown buttons and copy back original settings
     278        if (v != 1 && v != 2) {
     279            layer.trackVisibility = Arrays.copyOf(trackVisibilityBackup, layer.trackVisibility.length);
     280            MainApplication.getMap().repaint();
     281            return;
    285282        }
    286283        // set visibility (1 = show all, 2 = filter). If no tracks are selected
Note: See TracChangeset for help on using the changeset viewer.