Ignore:
Timestamp:
2011-04-06T14:19:29+02:00 (13 years ago)
Author:
Upliner
Message:

applied #6134 Update Add Layer Dialog After Imagery Merge (patch by Ian Dees)

File:
1 edited

Legend:

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

    r3927 r4015  
    1111import java.awt.event.ActionEvent;
    1212import java.awt.event.ActionListener;
     13import java.awt.event.KeyAdapter;
     14import java.awt.event.KeyEvent;
    1315import java.io.BufferedReader;
    1416import java.io.IOException;
     
    3133import javax.swing.JPanel;
    3234import javax.swing.JScrollPane;
     35import javax.swing.JTabbedPane;
    3336import javax.swing.JTextArea;
    3437import javax.swing.JTextField;
    3538import javax.swing.JTree;
     39import javax.swing.event.ChangeEvent;
     40import javax.swing.event.ChangeListener;
    3641import javax.swing.event.TreeSelectionEvent;
    3742import javax.swing.event.TreeSelectionListener;
     
    4752import org.openstreetmap.josm.data.Bounds;
    4853import org.openstreetmap.josm.data.projection.Projection;
     54import org.openstreetmap.josm.data.projection.ProjectionSubPrefs;
    4955import org.openstreetmap.josm.data.projection.Projections;
    50 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs;
    5156import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
    5257import org.openstreetmap.josm.tools.GBC;
     
    7378
    7479    private boolean previouslyShownUnsupportedCrsError = false;
     80    private JTextArea tmsURL;
    7581
    7682    public AddWMSLayerPanel() {
    77         JPanel wmsFetchPanel = new JPanel(new GridBagLayout());
     83        JPanel imageryAddPanel = new JPanel(new GridBagLayout());
     84        imageryAddPanel.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
    7885        menuName = new JTextField(40);
    79         menuName.setText(tr("Unnamed WMS Layer"));
    80         final JTextArea serviceUrl = new JTextArea(3, 40);
    81         serviceUrl.setLineWrap(true);
    82         serviceUrl.setText("http://sample.com/wms?");
    83         wmsFetchPanel.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
    84         wmsFetchPanel.add(menuName, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     86        menuName.setText(tr("Unnamed Imagery Layer"));
     87        imageryAddPanel.add(menuName, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     88
     89        final JTabbedPane tabbedPane = new JTabbedPane();
     90
     91        final JPanel wmsFetchPanel = new JPanel(new GridBagLayout());
     92        tabbedPane.addTab(tr("WMS"), wmsFetchPanel);
     93        imageryAddPanel.add(tabbedPane, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     94
     95        final JTextArea serviceUrlText = new JTextArea(3, 40);
     96        serviceUrlText.setLineWrap(true);
     97        serviceUrlText.setText("http://sample.com/wms?");
    8598        wmsFetchPanel.add(new JLabel(tr("Service URL")), GBC.std().insets(0,0,5,0));
    86         JScrollPane scrollPane = new JScrollPane(serviceUrl,
     99        JScrollPane scrollPane = new JScrollPane(serviceUrlText,
    87100                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    88101                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     
    95108                try {
    96109                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    97                     attemptGetCapabilities(serviceUrl.getText());
     110                    attemptGetCapabilities(serviceUrlText.getText());
    98111                } finally {
    99112                    setCursor(beforeCursor);
     
    171184
    172185        wmsFetchPanel.add(layerManipulationButtons, GBC.eol().insets(0,0,5,0));
    173         wmsFetchPanel.add(new JLabel(tr("WMS URL")), GBC.std().insets(0,0,5,0));
     186
     187        final JPanel tmsView = new JPanel(new GridBagLayout());
     188        tmsView.add(new JLabel(tr("TMS URL")), GBC.std().insets(0,0,5,0));
     189        tmsURL = new JTextArea(3, 40);
     190        tmsURL.setLineWrap(true);
     191        tmsURL.setText("http://sample.com/tms/{zoom}/{x}/{y}.jpg");
     192        tmsURL.addKeyListener(new KeyAdapter() {
     193            @Override
     194            public void keyReleased(KeyEvent e) {
     195                resultingLayerField.setText(buildTMSUrl());
     196            }
     197        });
     198        JScrollPane tmsUrlScrollPane = new JScrollPane(tmsURL,
     199                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
     200                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     201        tmsView.add(tmsUrlScrollPane, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     202        tabbedPane.addTab(tr("TMS"), tmsView);
     203
     204        imageryAddPanel.add(new JLabel(tr("Imagery URL")), GBC.std().insets(0,0,5,0));
    174205        resultingLayerField = new JTextArea(3, 40);
    175206        resultingLayerField.setLineWrap(true);
    176         wmsFetchPanel.add(new JScrollPane(resultingLayerField, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
    177 
    178         add(wmsFetchPanel);
     207        imageryAddPanel.add(new JScrollPane(resultingLayerField, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     208
     209        tabbedPane.addChangeListener(new ChangeListener() {
     210            @Override
     211            public void stateChanged(ChangeEvent e) {
     212                Component sel = tabbedPane.getSelectedComponent();
     213                if(tmsView == sel) {
     214                    resultingLayerField.setText(buildTMSUrl());
     215                } else if(wmsFetchPanel == sel) {
     216                    if(serviceUrl != null) {
     217                        resultingLayerField.setText(buildGetMapUrl());
     218                    }
     219                }
     220            }
     221        });
     222
     223        add(imageryAddPanel);
     224    }
     225
     226    private String buildTMSUrl() {
     227        StringBuilder a = new StringBuilder("tms:");
     228        a.append(tmsURL.getText());
     229        return a.toString();
    179230    }
    180231
Note: See TracChangeset for help on using the changeset viewer.