Changeset 4273 in josm for trunk/src/org


Ignore:
Timestamp:
2011-07-28T18:32:13+02:00 (13 years ago)
Author:
stoecker
Message:

see #6629 - fix layer setting save for multiple layers

File:
1 edited

Legend:

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

    r4270 r4273  
    4848    private JComboBox waypointLabel = new JComboBox(new String[] {tr("Auto"), /* gpx data field name */ trc("gpx_field", "Name"),
    4949            /* gpx data field name */ trc("gpx_field", "Desc(ription)"), tr("Both"), tr("None")});
    50     private String spec;
    51     private String specSp = "";
     50    private String layerName;
    5251
    5352    public GPXSettingsPanel(String layerName) {
    5453        super(new GridBagLayout());
    55         this.spec="layer "+layerName;
    56         specSp = ".layer "+spec;
     54        this.layerName = "layer "+layerName;
    5755        initComponents();
    5856        loadPreferences();
     
    7371        // drawRawGpsLines
    7472        ButtonGroup gpsLinesGroup = new ButtonGroup();
    75         if (spec!=null) gpsLinesGroup.add(drawRawGpsLinesGlobal);
     73        if (layerName!=null) gpsLinesGroup.add(drawRawGpsLinesGlobal);
    7674        gpsLinesGroup.add(drawRawGpsLinesNone);
    7775        gpsLinesGroup.add(drawRawGpsLinesLocal);
     
    8179
    8280        add(new JLabel(tr("Draw lines between raw GPS points")), GBC.eol().insets(20,0,0,0));
    83         if (spec!=null) add(drawRawGpsLinesGlobal, GBC.eol().insets(40,0,0,0));
     81        if (layerName!=null) add(drawRawGpsLinesGlobal, GBC.eol().insets(40,0,0,0));
    8482        add(drawRawGpsLinesNone, GBC.eol().insets(40,0,0,0));
    8583        add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0));
     
    146144        // colorTracks
    147145        colorGroup = new ButtonGroup();
    148         if (spec!=null) colorGroup.add(colorTypeGlobal);
     146        if (layerName!=null) colorGroup.add(colorTypeGlobal);
    149147        colorGroup.add(colorTypeNone);
    150148        colorGroup.add(colorTypeVelocity);
     
    177175
    178176        add(new JLabel(tr("Track and Point Coloring")), GBC.eol().insets(20,0,0,0));
    179         if (spec!=null) add(colorTypeGlobal, GBC.eol().insets(40,0,0,0));
     177        if (layerName!=null) add(colorTypeGlobal, GBC.eol().insets(40,0,0,0));
    180178        add(colorTypeNone, GBC.eol().insets(40,0,0,0));
    181179        add(colorTypeVelocity, GBC.std().insets(40,0,0,0));
     
    191189        add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0));
    192190        add(new JLabel(tr("Waypoint labelling")), GBC.std().insets(20,0,0,0));
    193         if(spec!= null)
     191        if(layerName!= null)
    194192            waypointLabel.addItem(tr("Global settings"));
    195193        add(waypointLabel, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     
    202200    public void loadPreferences () {
    203201        makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
    204         if(spec!=null && !Main.pref.hasKey("draw.rawgps.lines."+spec)
    205                 && !Main.pref.hasKey("draw.rawgps.lines.local"+spec)){
     202        if(layerName!=null && !Main.pref.hasKey("draw.rawgps.lines."+layerName)
     203                && !Main.pref.hasKey("draw.rawgps.lines.local"+layerName)){
    206204            // no line preferences for layer is found
    207205            drawRawGpsLinesGlobal.setSelected(true);
    208206        } else {
    209             Boolean lf = Main.pref.getBoolean("draw.rawgps.lines.local",spec, true);
    210             if(Main.pref.getBoolean("draw.rawgps.lines",spec, true)) {
     207            Boolean lf = Main.pref.getBoolean("draw.rawgps.lines.local",layerName, true);
     208            if(Main.pref.getBoolean("draw.rawgps.lines",layerName, true)) {
    211209                drawRawGpsLinesAll.setSelected(true);
    212210            } else if (lf) {
     
    217215        }
    218216
    219         drawRawGpsMaxLineLengthLocal.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length.local",spec, -1)));
    220         drawRawGpsMaxLineLength.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length",spec, 200)));
    221         forceRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines.force",spec, false));
    222         drawGpsArrows.setSelected(Main.pref.getBoolean("draw.rawgps.direction",spec, false));
    223         drawGpsArrowsFast.setSelected(Main.pref.getBoolean("draw.rawgps.alternatedirection",spec, false));
    224         drawGpsArrowsMinDist.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.min-arrow-distance",spec, 40)));
    225         hdopCircleGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.hdopcircle",spec, false));
    226         largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large",spec, false));
     217        drawRawGpsMaxLineLengthLocal.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length.local",layerName, -1)));
     218        drawRawGpsMaxLineLength.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.max-line-length",layerName, 200)));
     219        forceRawGpsLines.setSelected(Main.pref.getBoolean("draw.rawgps.lines.force",layerName, false));
     220        drawGpsArrows.setSelected(Main.pref.getBoolean("draw.rawgps.direction",layerName, false));
     221        drawGpsArrowsFast.setSelected(Main.pref.getBoolean("draw.rawgps.alternatedirection",layerName, false));
     222        drawGpsArrowsMinDist.setText(Integer.toString(Main.pref.getInteger("draw.rawgps.min-arrow-distance",layerName, 40)));
     223        hdopCircleGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.hdopcircle",layerName, false));
     224        largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large",layerName, false));
    227225        drawRawGpsLinesActionListener.actionPerformed(null);
    228226
    229         if(spec!=null && !Main.pref.hasKey("draw.rawgps.colors."+spec)) {
     227        if(layerName!=null && !Main.pref.hasKey("draw.rawgps.colors."+layerName)) {
    230228            colorTypeGlobal.setSelected(true);
    231229            colorDynamic.setSelected(false);
    232230            colorDynamic.setEnabled(false);
    233231        } else {
    234          switch(Main.pref.getInteger("draw.rawgps.colors",spec, 0)) {
     232         switch(Main.pref.getInteger("draw.rawgps.colors",layerName, 0)) {
    235233            case 0: colorTypeNone.setSelected(true);   break;
    236234            case 1: colorTypeVelocity.setSelected(true);  break;
     
    239237            case 4: colorTypeTime.setSelected(true);  break;
    240238            }
    241             int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune",spec, 45);
     239            int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune",layerName, 45);
    242240            colorTypeVelocityTune.setSelectedIndex(ccts==10 ? 2 : (ccts==20 ? 1 : 0));
    243241            colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected() && colorTypeVelocity.isEnabled());
    244             colorDynamic.setSelected(Main.pref.getBoolean("draw.rawgps.colors.dynamic",spec, false));
     242            colorDynamic.setSelected(Main.pref.getBoolean("draw.rawgps.colors.dynamic",layerName, false));
    245243            colorDynamic.setEnabled(colorTypeVelocity.isSelected() || colorTypeDilution.isSelected());
    246244        }
    247         if(spec != null)
    248           waypointLabel.setSelectedIndex(Main.pref.getInteger("draw.rawgps.layer.wpt"+specSp, 5));
     245        if(layerName != null)
     246          waypointLabel.setSelectedIndex(Main.pref.getInteger("draw.rawgps.layer.wpt."+layerName, 5));
    249247        else
    250248          waypointLabel.setSelectedIndex(Main.pref.getInteger("draw.rawgps.layer.wpt", 0));
     
    253251
    254252    /**
    255      * Save preferences from UI controls for specified layer
    256      * if spec==null, global preferences are written
     253     * Save preferences from UI controls for layerNameified layer
     254     * if layerName==null, global preferences are written
    257255     */
    258     public boolean savePreferences (String spec) {
    259         Main.pref.put("marker.makeautomarkers"+specSp, makeAutoMarkers.isSelected());
     256    public boolean savePreferences (String layerName) {
     257        String layerNameDot = ".layer "+layerName;
     258        Main.pref.put("marker.makeautomarkers"+layerNameDot, makeAutoMarkers.isSelected());
    260259        if (drawRawGpsLinesGlobal.isSelected()) {
    261             Main.pref.put("draw.rawgps.lines"+specSp, null);
    262             Main.pref.put("draw.rawgps.lines.local"+specSp, null);
    263             Main.pref.put("draw.rawgps.max-line-length"+specSp, null);
    264             Main.pref.put("draw.rawgps.max-line-length.local"+specSp, null);
    265             Main.pref.put("draw.rawgps.lines.force"+specSp, null);
    266             Main.pref.put("draw.rawgps.direction"+specSp, null);
    267             Main.pref.put("draw.rawgps.alternatedirection"+specSp, null);
    268             Main.pref.put("draw.rawgps.min-arrow-distance"+specSp, null);
     260            Main.pref.put("draw.rawgps.lines"+layerNameDot, null);
     261            Main.pref.put("draw.rawgps.lines.local"+layerNameDot, null);
     262            Main.pref.put("draw.rawgps.max-line-length"+layerNameDot, null);
     263            Main.pref.put("draw.rawgps.max-line-length.local"+layerNameDot, null);
     264            Main.pref.put("draw.rawgps.lines.force"+layerNameDot, null);
     265            Main.pref.put("draw.rawgps.direction"+layerNameDot, null);
     266            Main.pref.put("draw.rawgps.alternatedirection"+layerNameDot, null);
     267            Main.pref.put("draw.rawgps.min-arrow-distance"+layerNameDot, null);
    269268        } else {
    270             Main.pref.put("draw.rawgps.lines"+specSp, drawRawGpsLinesAll.isSelected());
    271             Main.pref.put("draw.rawgps.lines.local"+specSp, drawRawGpsLinesAll.isSelected() || drawRawGpsLinesLocal.isSelected());
    272             Main.pref.put("draw.rawgps.max-line-length"+specSp, drawRawGpsMaxLineLength.getText());
    273             Main.pref.put("draw.rawgps.max-line-length.local"+specSp, drawRawGpsMaxLineLengthLocal.getText());
    274             Main.pref.put("draw.rawgps.lines.force"+specSp, forceRawGpsLines.isSelected());
    275             Main.pref.put("draw.rawgps.direction"+specSp, drawGpsArrows.isSelected());
    276             Main.pref.put("draw.rawgps.alternatedirection"+specSp, drawGpsArrowsFast.isSelected());
    277             Main.pref.put("draw.rawgps.min-arrow-distance"+specSp, drawGpsArrowsMinDist.getText());
     269            Main.pref.put("draw.rawgps.lines"+layerNameDot, drawRawGpsLinesAll.isSelected());
     270            Main.pref.put("draw.rawgps.lines.local"+layerNameDot, drawRawGpsLinesAll.isSelected() || drawRawGpsLinesLocal.isSelected());
     271            Main.pref.put("draw.rawgps.max-line-length"+layerNameDot, drawRawGpsMaxLineLength.getText());
     272            Main.pref.put("draw.rawgps.max-line-length.local"+layerNameDot, drawRawGpsMaxLineLengthLocal.getText());
     273            Main.pref.put("draw.rawgps.lines.force"+layerNameDot, forceRawGpsLines.isSelected());
     274            Main.pref.put("draw.rawgps.direction"+layerNameDot, drawGpsArrows.isSelected());
     275            Main.pref.put("draw.rawgps.alternatedirection"+layerNameDot, drawGpsArrowsFast.isSelected());
     276            Main.pref.put("draw.rawgps.min-arrow-distance"+layerNameDot, drawGpsArrowsMinDist.getText());
    278277        }
    279278
    280         Main.pref.put("draw.rawgps.hdopcircle"+specSp, hdopCircleGpsPoints.isSelected());
    281         Main.pref.put("draw.rawgps.large"+specSp, largeGpsPoints.isSelected());
    282         if (waypointLabel.getSelectedIndex()==5) Main.pref.put("draw.rawgps.layer.wpt"+specSp,null);
    283         else Main.pref.putInteger("draw.rawgps.layer.wpt"+specSp, waypointLabel.getSelectedIndex());
     279        Main.pref.put("draw.rawgps.hdopcircle"+layerNameDot, hdopCircleGpsPoints.isSelected());
     280        Main.pref.put("draw.rawgps.large"+layerNameDot, largeGpsPoints.isSelected());
     281        if (waypointLabel.getSelectedIndex()==5) Main.pref.put("draw.rawgps.layer.wpt"+layerNameDot,null);
     282        else Main.pref.putInteger("draw.rawgps.layer.wpt"+layerNameDot, waypointLabel.getSelectedIndex());
    284283
    285284        if(colorTypeGlobal.isSelected()) {
    286             Main.pref.put("draw.rawgps.colors"+specSp, null);
    287             Main.pref.put("draw.rawgps.colors.dynamic"+specSp, null);
    288             Main.pref.put("draw.rawgps.colorTracksTunec"+specSp, null);
     285            Main.pref.put("draw.rawgps.colors"+layerNameDot, null);
     286            Main.pref.put("draw.rawgps.colors.dynamic"+layerNameDot, null);
     287            Main.pref.put("draw.rawgps.colorTracksTunec"+layerNameDot, null);
    289288            return false;
    290289        } else if(colorTypeVelocity.isSelected()) {
    291             Main.pref.putInteger("draw.rawgps.colors"+specSp, 1);
     290            Main.pref.putInteger("draw.rawgps.colors"+layerNameDot, 1);
    292291        } else if(colorTypeDilution.isSelected()) {
    293             Main.pref.putInteger("draw.rawgps.colors"+specSp, 2);
     292            Main.pref.putInteger("draw.rawgps.colors"+layerNameDot, 2);
    294293        } else if(colorTypeDirection.isSelected()) {
    295             Main.pref.putInteger("draw.rawgps.colors"+specSp, 3);
     294            Main.pref.putInteger("draw.rawgps.colors"+layerNameDot, 3);
    296295        } else if(colorTypeTime.isSelected()) {
    297             Main.pref.putInteger("draw.rawgps.colors"+specSp, 4);
     296            Main.pref.putInteger("draw.rawgps.colors"+layerNameDot, 4);
    298297        } else {
    299             Main.pref.putInteger("draw.rawgps.colors"+specSp, 0);
     298            Main.pref.putInteger("draw.rawgps.colors"+layerNameDot, 0);
    300299        }
    301         Main.pref.put("draw.rawgps.colors.dynamic"+specSp, colorDynamic.isSelected());
     300        Main.pref.put("draw.rawgps.colors.dynamic"+layerNameDot, colorDynamic.isSelected());
    302301        int ccti=colorTypeVelocityTune.getSelectedIndex();
    303         Main.pref.putInteger("draw.rawgps.colorTracksTune"+specSp, ccti==2 ? 10 : (ccti==1 ? 20 : 45));
     302        Main.pref.putInteger("draw.rawgps.colorTracksTune"+layerNameDot, ccti==2 ? 10 : (ccti==1 ? 20 : 45));
    304303        return false;
    305304    }
Note: See TracChangeset for help on using the changeset viewer.