Ignore:
Timestamp:
2010-12-20T18:00:55+01:00 (14 years ago)
Author:
Upliner
Message:

Offset bookmarks: don't create submenus when only 1 choice is available.
Also, make possible to add TMS layers from "Getting started" screen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/Map_Rectifier_WMSmenuAction.java

    r3720 r3733  
    112112    @Override
    113113    public void actionPerformed(ActionEvent e) {
     114        if (!isEnabled()) return;
    114115        JPanel panel = new JPanel(new GridBagLayout());
    115116        panel.add(new JLabel(tr("Supported Rectifier Services:")), GBC.eol());
     
    123124        for(RectifierService s : services) {
    124125            JRadioButton serviceBtn = new JRadioButton(s.name);
    125             if(firstBtn == null)
     126            if(firstBtn == null) {
    126127                firstBtn = serviceBtn;
     128            }
    127129            // Checks clipboard contents against current service if no match has been found yet.
    128130            // If the contents match, they will be inserted into the text field and the corresponding
     
    138140                panel.add(serviceBtn, GBC.std());
    139141                panel.add(new UrlLabel(s.url, tr("Visit Homepage")), GBC.eol().anchor(GridBagConstraints.EAST));
    140             } else
     142            } else {
    141143                panel.add(serviceBtn, GBC.eol().anchor(GridBagConstraints.WEST));
     144            }
    142145        }
    143146
    144147        // Fallback in case no match was found
    145         if(tfWmsUrl.getText().equals("") && firstBtn != null)
     148        if(tfWmsUrl.getText().equals("") && firstBtn != null) {
    146149            firstBtn.setSelected(true);
     150        }
    147151
    148152        panel.add(new JLabel(tr("WMS URL or Image ID:")), GBC.eol());
     
    162166            int answer = diag.getValue();
    163167            // Break loop when the user cancels
    164             if(answer != 1)
     168            if(answer != 1) {
    165169                break;
     170            }
    166171
    167172            String text = tfWmsUrl.getText().trim();
    168173            // Loop all services until we find the selected one
    169174            for(RectifierService s : services) {
    170                 if(!s.isSelected())
     175                if(!s.isSelected()) {
    171176                    continue;
     177                }
    172178
    173179                // We've reached the custom WMS URL service
     
    237243        return result.trim();
    238244    }
     245
     246    @Override
     247    protected void updateEnabledState() {
     248        setEnabled(Main.map != null && Main.map.mapView != null && !Main.map.mapView.getAllLayers().isEmpty());
     249    }
    239250}
Note: See TracChangeset for help on using the changeset viewer.