Changeset 4015 in josm
- Timestamp:
- 2011-04-06T14:19:29+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/AddWMSLayerPanel.java
r3927 r4015 11 11 import java.awt.event.ActionEvent; 12 12 import java.awt.event.ActionListener; 13 import java.awt.event.KeyAdapter; 14 import java.awt.event.KeyEvent; 13 15 import java.io.BufferedReader; 14 16 import java.io.IOException; … … 31 33 import javax.swing.JPanel; 32 34 import javax.swing.JScrollPane; 35 import javax.swing.JTabbedPane; 33 36 import javax.swing.JTextArea; 34 37 import javax.swing.JTextField; 35 38 import javax.swing.JTree; 39 import javax.swing.event.ChangeEvent; 40 import javax.swing.event.ChangeListener; 36 41 import javax.swing.event.TreeSelectionEvent; 37 42 import javax.swing.event.TreeSelectionListener; … … 47 52 import org.openstreetmap.josm.data.Bounds; 48 53 import org.openstreetmap.josm.data.projection.Projection; 54 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs; 49 55 import org.openstreetmap.josm.data.projection.Projections; 50 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs;51 56 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 52 57 import org.openstreetmap.josm.tools.GBC; … … 73 78 74 79 private boolean previouslyShownUnsupportedCrsError = false; 80 private JTextArea tmsURL; 75 81 76 82 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)); 78 85 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?"); 85 98 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, 87 100 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 88 101 JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); … … 95 108 try { 96 109 setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 97 attemptGetCapabilities(serviceUrl .getText());110 attemptGetCapabilities(serviceUrlText.getText()); 98 111 } finally { 99 112 setCursor(beforeCursor); … … 171 184 172 185 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)); 174 205 resultingLayerField = new JTextArea(3, 40); 175 206 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(); 179 230 } 180 231
Note:
See TracChangeset
for help on using the changeset viewer.