Changeset 2285 in josm for trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
- Timestamp:
- 2009-10-13T20:34:11+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r2215 r2285 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.GridBagConstraints; 6 7 import java.awt.GridBagLayout; 7 8 import java.awt.event.ActionEvent; 8 9 import java.awt.event.KeyEvent; 10 import java.util.Collections; 11 import java.util.LinkedList; 12 import java.util.List; 9 13 10 14 import javax.swing.JCheckBox; 11 15 import javax.swing.JLabel; 12 16 import javax.swing.JPanel; 13 import javax.swing.JTextField;14 17 15 18 import org.openstreetmap.josm.Main; 16 19 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 17 20 import org.openstreetmap.josm.gui.ExtendedDialog; 21 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 18 22 import org.openstreetmap.josm.tools.GBC; 19 23 import org.openstreetmap.josm.tools.Shortcut; … … 34 38 } 35 39 40 /** 41 * Restore the current history from the preferences 42 * 43 * @param cbHistory 44 */ 45 protected void restoreUploadAddressHistory(HistoryComboBox cbHistory) { 46 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(getClass().getName() + ".uploadAddressHistory", new LinkedList<String>())); 47 // we have to reverse the history, because ComboBoxHistory will reverse it again 48 // in addElement() 49 // 50 Collections.reverse(cmtHistory); 51 cbHistory.setPossibleItems(cmtHistory); 52 } 53 54 /** 55 * Remind the current history in the preferences 56 * @param cbHistory 57 */ 58 protected void remindUploadAddressHistory(HistoryComboBox cbHistory) { 59 cbHistory.addCurrentItemToHistory(); 60 Main.pref.putCollection(getClass().getName() + ".uploadAddressHistory", cbHistory.getHistory()); 61 } 62 36 63 public void actionPerformed(ActionEvent e) { 37 64 38 65 JCheckBox layer = new JCheckBox(tr("Separate Layer")); 66 layer.setToolTipText(tr("Select if the data should be downloaded in a new layer")); 39 67 layer.setSelected(Main.pref.getBoolean("download.newlayer")); 40 68 JPanel all = new JPanel(new GridBagLayout()); 41 all.add(new JLabel(tr("Enter URL to download:")), GBC.eol()); 42 JTextField urltext = new JTextField(40); 43 all.add(urltext, GBC.eol()); 44 all.add(layer, GBC.eol()); 69 GridBagConstraints gc = new GridBagConstraints(); 70 gc.fill = GridBagConstraints.HORIZONTAL; 71 gc.weightx = 1.0; 72 gc.anchor = GridBagConstraints.FIRST_LINE_START; 73 all.add(new JLabel(tr("Enter URL to download:")), gc); 74 HistoryComboBox uploadAdresses = new HistoryComboBox(); 75 uploadAdresses.setToolTipText(tr("Enter an URL from where data should be downloaded")); 76 restoreUploadAddressHistory(uploadAdresses); 77 gc.gridy = 1; 78 all.add(uploadAdresses, gc); 79 gc.gridy = 2; 80 gc.fill = GridBagConstraints.BOTH; 81 gc.weighty = 1.0; 82 all.add(layer, gc); 45 83 ExtendedDialog dialog = new ExtendedDialog(Main.parent, 46 84 tr("Download Location"), 47 85 new String[] {tr("Download URL"), tr("Cancel")} 48 86 ); 49 dialog.setContent(all );87 dialog.setContent(all, false /* don't embedded content in JScrollpane */); 50 88 dialog.setButtonIcons(new String[] {"download.png", "cancel.png"}); 89 dialog.setToolTipTexts(new String[] { 90 tr("Start downloading data"), 91 tr("Close dialog and cancel downloading") 92 }); 93 dialog.configureContextsensitiveHelp("Help/Action/OpenLocation", true /* show help button */); 51 94 dialog.showDialog(); 52 95 if (dialog.getValue() != 1) return; 53 openUrl(layer.isSelected(), urltext.getText()); 96 remindUploadAddressHistory(uploadAdresses); 97 openUrl(layer.isSelected(), uploadAdresses.getText()); 54 98 } 55 99 … … 60 104 new DownloadOsmTask().loadUrl(new_layer, url, null); 61 105 } 62 63 106 }
Note:
See TracChangeset
for help on using the changeset viewer.