Changeset 16979 in josm


Ignore:
Timestamp:
2020-08-30T10:03:00+02:00 (4 years ago)
Author:
simon04
Message:

fix #19734 - Autofilter: clicking active rule/key opens GPS settings instead of OSM settings

Extract GPXPreference from DrawingPreference

Location:
trunk
Files:
1 added
4 edited
1 copied

Legend:

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

    r16966 r16979  
    4545import org.openstreetmap.josm.gui.preferences.display.DisplayPreference;
    4646import org.openstreetmap.josm.gui.preferences.display.DrawingPreference;
     47import org.openstreetmap.josm.gui.preferences.display.GPXPreference;
    4748import org.openstreetmap.josm.gui.preferences.display.LafPreference;
    4849import org.openstreetmap.josm.gui.preferences.display.LanguagePreference;
     
    572573        SETTINGS_FACTORIES.add(new DisplayPreference.Factory());
    573574        SETTINGS_FACTORIES.add(new DrawingPreference.Factory());
     575        SETTINGS_FACTORIES.add(new GPXPreference.Factory());
    574576        SETTINGS_FACTORIES.add(new ColorPreference.Factory());
    575577        SETTINGS_FACTORIES.add(new LafPreference.Factory());
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java

    r15880 r16979  
    2929
    3030/**
    31  * Map drawing preferences.
     31 * "OSM Data" drawing preferences.
    3232 */
    3333public class DrawingPreference implements SubPreferenceSetting {
     
    4949    public static final BooleanProperty SOURCE_BOUNDS_PROP = new BooleanProperty("draw.data.downloaded_area", true);
    5050
    51     private GPXSettingsPanel gpxPanel;
    5251    private final JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows"));
    5352    private final JCheckBox headArrow = new JCheckBox(tr("Only on the head of a way."));
     
    7473    @Override
    7574    public void addGui(PreferenceTabbedPane gui) {
    76         addOsmPane(gui);
    77         addGpxPane(gui);
    78     }
    79 
    80     private void addGpxPane(PreferenceTabbedPane gui) {
    81         gpxPanel = new GPXSettingsPanel();
    82         gui.addValidationListener(gpxPanel);
    83         JPanel panel = gpxPanel;
    84 
    85         JScrollPane scrollpane = new JScrollPane(panel);
    86         scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    87         GuiHelper.setDefaultIncrement(scrollpane);
    88         gui.getDisplayPreference().addSubTab(this, tr("GPS Points"), scrollpane);
    89     }
    90 
    91     private void addOsmPane(PreferenceTabbedPane gui) {
    9275        JPanel panel = new JPanel(new GridBagLayout());
    9376        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
     
    217200    @Override
    218201    public boolean ok() {
    219         boolean restart = gpxPanel.savePreferences();
    220202        OsmDataLayer.PROPERTY_HIDE_LABELS_WHILE_DRAGGING.put(hideLabelsWhileDragging.isSelected());
    221203        Config.getPref().putBoolean("draw.data.area_outline_only", outlineOnly.isSelected());
     
    243225        }
    244226        Config.getPref().putInt("mappaint.node.virtual-size", vn);
    245         return restart;
     227        return false;
    246228    }
    247229
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/PreferencesTestUtils.java

    r10098 r16979  
    2020    public static void doTestPreferenceSettingAddGui(
    2121            PreferenceSettingFactory factory, Class<? extends DefaultTabPreferenceSetting> parentClass) {
    22         doTestPreferenceSettingAddGui(factory, parentClass, 1);
    23     }
    24 
    25     /**
    26      * Generic test for {@link PreferenceSetting#addGui(PreferenceTabbedPane)}.
    27      * @param factory setting factory to test
    28      * @param parentClass optional parent setting, can be {@code null}
    29      * @param increment expected tab number increment
    30      */
    31     public static void doTestPreferenceSettingAddGui(
    32             PreferenceSettingFactory factory, Class<? extends DefaultTabPreferenceSetting> parentClass, int increment) {
    3322        PreferenceSetting setting = factory.createPreferenceSetting();
    3423        PreferenceTabbedPane tabPane = new PreferenceTabbedPane();
     
    3726        setting.addGui(tabPane);
    3827        if (parentClass != null) {
    39             assertEquals(tabs + increment, tabPane.getSetting(parentClass).getTabPane().getTabCount());
     28            assertEquals(tabs + 1, tabPane.getSetting(parentClass).getTabPane().getTabCount());
    4029            assertEquals(tabPane.getSetting(parentClass), ((SubPreferenceSetting) setting).getTabPreferenceSetting(tabPane));
    4130        }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/display/DrawingPreferenceTest.java

    r10378 r16979  
    3535    @Test
    3636    public void testAddGui() {
    37         PreferencesTestUtils.doTestPreferenceSettingAddGui(new DrawingPreference.Factory(), DisplayPreference.class, 2);
     37        PreferencesTestUtils.doTestPreferenceSettingAddGui(new DrawingPreference.Factory(), DisplayPreference.class);
    3838    }
    3939}
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/display/GPXPreferenceTest.java

    r16978 r16979  
    1010
    1111/**
    12  * Unit tests of {@link DrawingPreference} class.
     12 * Unit tests of {@link GPXPreference} class.
    1313 */
    14 public class DrawingPreferenceTest {
     14public class GPXPreferenceTest {
    1515
    1616    /**
     
    2323
    2424    /**
    25      * Unit test of {@link DrawingPreference#DrawingPreference}.
     25     * Unit test of {@link GPXPreference.Factory}.
    2626     */
    2727    @Test
    28     public void testDrawingPreference() {
    29         assertNotNull(new DrawingPreference.Factory().createPreferenceSetting());
     28    public void testGPXPreference() {
     29        assertNotNull(new GPXPreference.Factory().createPreferenceSetting());
    3030    }
    3131
    3232    /**
    33      * Unit test of {@link DrawingPreference#addGui}.
     33     * Unit test of {@link GPXPreference#addGui}.
    3434     */
    3535    @Test
    3636    public void testAddGui() {
    37         PreferencesTestUtils.doTestPreferenceSettingAddGui(new DrawingPreference.Factory(), DisplayPreference.class, 2);
     37        PreferencesTestUtils.doTestPreferenceSettingAddGui(new GPXPreference.Factory(), DisplayPreference.class);
    3838    }
    3939}
Note: See TracChangeset for help on using the changeset viewer.