Changeset 4276 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2011-07-29T13:04:04+02:00 (13 years ago)
Author:
stoecker
Message:

fix #6629 - patch by akks - fix gpx layer settings changes

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r4270 r4276  
    14071407        @Override
    14081408        public void actionPerformed(ActionEvent e) {
    1409             GPXSettingsPanel panel=new GPXSettingsPanel(getName());
     1409            boolean hasLocal = false, hasNonlocal = false;
     1410            for (Layer layer : layers) {
     1411                if (layer instanceof GpxLayer) {
     1412                    if (((GpxLayer) layer).isLocalFile) hasLocal = true;
     1413                    else hasNonlocal = true;
     1414                }
     1415            }
     1416            GPXSettingsPanel panel=new GPXSettingsPanel(getName(), hasLocal, hasNonlocal);
     1417
    14101418            int answer = JOptionPane.showConfirmDialog(Main.parent, panel,
    14111419                    tr("Customize track drawing"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
     
    14131421            for(Layer layer : layers) {
    14141422                // save preferences for all layers
    1415                 panel.savePreferences(layer.getName());
     1423                boolean f=false;
     1424                if (layer instanceof GpxLayer) f=((GpxLayer)layer).isLocalFile;
     1425                    panel.savePreferences(layer.getName(),f);
    14161426            }
    14171427            Main.map.repaint();
     
    14191429    }
    14201430
    1421       private class MarkersFromNamedPoins extends AbstractAction {
     1431    private class MarkersFromNamedPoins extends AbstractAction {
    14221432
    14231433        public MarkersFromNamedPoins() {
  • trunk/src/org/openstreetmap/josm/gui/preferences/GPXSettingsPanel.java

    r4274 r4276  
    4949            /* gpx data field name */ trc("gpx_field", "Desc(ription)"), tr("Both"), tr("None")});
    5050    private String layerName;
    51 
    52     public GPXSettingsPanel(String layerName) {
     51    private boolean local; // flag to display LocalOnly checkbox
     52    private boolean nonlocal; // flag to display AllLines checkbox
     53
     54    public GPXSettingsPanel(String layerName, boolean local, boolean nonlocal) {
    5355        super(new GridBagLayout());
     56        this.local=local; this.nonlocal=nonlocal;
    5457        this.layerName = "layer "+layerName;
    5558        initComponents();
     
    6063        super(new GridBagLayout());
    6164        initComponents();
     65        local=false; nonlocal=false;
    6266        loadPreferences(); // preferences -> controls
    6367    }
     68
    6469    private void initComponents() {
    6570        setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     
    8186        if (layerName!=null) add(drawRawGpsLinesGlobal, GBC.eol().insets(40,0,0,0));
    8287        add(drawRawGpsLinesNone, GBC.eol().insets(40,0,0,0));
    83         add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0));
    84         add(drawRawGpsLinesAll, GBC.eol().insets(40,0,0,0));
     88        if (layerName==null || local) add(drawRawGpsLinesLocal, GBC.eol().insets(40,0,0,0));
     89        if (layerName==null || nonlocal) add(drawRawGpsLinesAll, GBC.eol().insets(40,0,0,0));
    8590
    8691        drawRawGpsLinesActionListener = new ActionListener(){
     
    201206        makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
    202207        if(layerName!=null && !Main.pref.hasKey("draw.rawgps.lines."+layerName)
    203                 && !Main.pref.hasKey("draw.rawgps.lines.local"+layerName)){
     208                && !Main.pref.hasKey("draw.rawgps.lines.local."+layerName)){
    204209            // no line preferences for layer is found
    205210            drawRawGpsLinesGlobal.setSelected(true);
     
    254259     * if layerName==null, global preferences are written
    255260     */
    256     public boolean savePreferences (String layerName) {
     261    public boolean savePreferences (String layerName, boolean locLayer) {
    257262        String layerNameDot = ".layer "+layerName;
     263        if (layerName==null) layerNameDot="";
    258264        Main.pref.put("marker.makeautomarkers"+layerNameDot, makeAutoMarkers.isSelected());
    259265        if (drawRawGpsLinesGlobal.isSelected()) {
    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);
     266            Main.pref.put("draw.rawgps.lines" + layerNameDot, null);
     267            Main.pref.put("draw.rawgps.max-line-length" + layerNameDot, null);
     268            Main.pref.put("draw.rawgps.lines.local" + layerNameDot, null);
     269            Main.pref.put("draw.rawgps.max-line-length.local" + layerNameDot, null);
    264270            Main.pref.put("draw.rawgps.lines.force"+layerNameDot, null);
    265271            Main.pref.put("draw.rawgps.direction"+layerNameDot, null);
     
    267273            Main.pref.put("draw.rawgps.min-arrow-distance"+layerNameDot, null);
    268274        } else {
    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());
     275            if (layerName==null || !locLayer) {
     276                Main.pref.put("draw.rawgps.lines" +  layerNameDot, drawRawGpsLinesAll.isSelected());
     277                Main.pref.put("draw.rawgps.max-line-length" + layerNameDot, drawRawGpsMaxLineLength.getText());
     278            }
     279            if (layerName==null || locLayer) {
     280                Main.pref.put("draw.rawgps.lines.local" + layerNameDot, drawRawGpsLinesAll.isSelected() || drawRawGpsLinesLocal.isSelected());
     281                Main.pref.put("draw.rawgps.max-line-length.local" + layerNameDot, drawRawGpsMaxLineLengthLocal.getText());
     282            }
    273283            Main.pref.put("draw.rawgps.lines.force"+layerNameDot, forceRawGpsLines.isSelected());
    274284            Main.pref.put("draw.rawgps.direction"+layerNameDot, drawGpsArrows.isSelected());
     
    308318     */
    309319    public void savePreferences() {
    310         savePreferences(null);
     320        savePreferences(null, false);
    311321    }
    312322}
Note: See TracChangeset for help on using the changeset viewer.