Changeset 2285 in josm for trunk/src/org
- Timestamp:
- 2009-10-13T20:34:11+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 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 } -
trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
r2206 r2285 104 104 * @param role Can be null, in this case it's save as "" 105 105 * @param member Cannot be null 106 * @throw IllegalArgumentException thrown if member is null 106 107 */ 107 public RelationMember(String role, OsmPrimitive member) {108 public RelationMember(String role, OsmPrimitive member) throws IllegalArgumentException{ 108 109 if (role == null) { 109 110 role = ""; 110 111 } 111 if (member == null) {112 if (member == null) 112 113 throw new IllegalArgumentException("Relation member cannot be null"); 113 }114 114 this.role = role; 115 115 this.member = member; … … 154 154 RelationMember other = (RelationMember) obj; 155 155 return member.equals(other.getMember()) && role.equals(other.getRole()); 156 } else {156 } else 157 157 return false; 158 }159 158 } 160 159 } -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r2168 r2285 23 23 24 24 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.gui.help.HelpBrowserProxy; 26 import org.openstreetmap.josm.gui.help.HelpBuilder; 25 27 import org.openstreetmap.josm.tools.GBC; 26 28 import org.openstreetmap.josm.tools.ImageProvider; … … 41 43 private Component content; 42 44 private final String[] bTexts; 45 private String[] bToolTipTexts; 43 46 private String[] bIcons; 47 48 /** true, if the dialog should include a help button */ 49 private boolean showHelpButton; 50 /** the help topic */ 51 private String helpTopic; 52 44 53 /** 45 54 * set to true if the content of the extended dialog should … … 99 108 100 109 /** 110 * Allows decorating the buttons with tooltips. Expects an String[] with translated 111 * tooltip texts. 112 * 113 * @param toolTipTexts the tool tip texts. Ignored, if null. 114 */ 115 public void setToolTipTexts(String[] toolTipTexts) { 116 this.bToolTipTexts = toolTipTexts; 117 } 118 119 /** 101 120 * Sets the content that will be displayed in the message dialog. 102 121 * … … 187 206 button.setIcon(ImageProvider.get(bIcons[i])); 188 207 } 208 if (bToolTipTexts != null && i < bToolTipTexts.length && bToolTipTexts[i] != null) { 209 button.setToolTipText(bToolTipTexts[i]); 210 } 189 211 190 212 if(i == 0) { … … 193 215 buttonsPanel.add(button, GBC.std().insets(2,2,2,2)); 194 216 buttons.add(button); 217 } 218 if (showHelpButton) { 219 buttonsPanel.add(new JButton(new HelpAction()), GBC.std().insets(2,2,2,2)); 220 HelpBuilder.setHelpContext(getRootPane(),helpTopic); 195 221 } 196 222 … … 396 422 return lbl; 397 423 } 424 425 /** 426 * Configures how this dialog support for context sensitive help. 427 * <ul> 428 * <li>if helpTopic is null, the dialog doesn't provide context sensitive help</li> 429 * <li>if helpTopic != null, the dialog redirect user to the help page for this helpTopic when 430 * the user clicks F1 in the dialog</li> 431 * <li>if showHelpButton is true, the dialog displays "Help" button (rightmost button in 432 * the button row)</li> 433 * </ul> 434 * 435 * @param helpTopic the help topic 436 * @param showHelpButton true, if the dialog displays a help button 437 */ 438 public void configureContextsensitiveHelp(String helpTopic, boolean showHelpButton) { 439 this.helpTopic = helpTopic; 440 this.showHelpButton = showHelpButton; 441 } 442 443 444 class HelpAction extends AbstractAction { 445 public HelpAction() { 446 putValue(SHORT_DESCRIPTION, tr("Show help information")); 447 putValue(NAME, tr("Help")); 448 putValue(SMALL_ICON, ImageProvider.get("help")); 449 } 450 451 public void actionPerformed(ActionEvent e) { 452 HelpBrowserProxy.getInstance().setUrlForHelpTopic(helpTopic); 453 } 454 } 398 455 } -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r2181 r2285 6 6 import java.awt.Color; 7 7 import java.awt.Component; 8 import java.text.DecimalFormat;9 8 import java.util.ArrayList; 10 9 import java.util.Collections; 11 import java.util.logging.Logger;12 10 13 11 import javax.swing.BorderFactory; -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2281 r2285 46 46 import javax.swing.event.ListDataEvent; 47 47 import javax.swing.event.ListDataListener; 48 import javax.swing.text.JTextComponent;49 48 50 49 import org.openstreetmap.josm.Main;
Note:
See TracChangeset
for help on using the changeset viewer.