Changeset 2387 in josm
- Timestamp:
- 2009-11-02T19:26:51+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r2289 r2387 2 2 package org.openstreetmap.josm.gui; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 36 37 */ 37 38 public static void explainOsmApiInitializationException(OsmApiInitializationException e) { 38 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainOsmApiInitializationException(e), tr("Error"), 39 JOptionPane.ERROR_MESSAGE); 39 HelpAwareOptionPane.showOptionDialog( 40 Main.parent, 41 ExceptionUtil.explainOsmApiInitializationException(e), 42 tr("Error"), 43 JOptionPane.ERROR_MESSAGE, 44 ht("/ErrorMessages#OsmApiInitializationException") 45 ); 40 46 } 41 47 … … 46 52 */ 47 53 public static void explainOsmChangesetCloseException(OsmChangesetCloseException e) { 48 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainOsmChangesetCloseException(e), tr("Error"), 49 JOptionPane.ERROR_MESSAGE); 54 HelpAwareOptionPane.showOptionDialog( 55 Main.parent, 56 ExceptionUtil.explainOsmChangesetCloseException(e), 57 tr("Error"), 58 JOptionPane.ERROR_MESSAGE, 59 ht("/ErrorMessages#OsmChangesetCloseException") 60 ); 50 61 } 51 62 … … 56 67 */ 57 68 public static void explainPreconditionFailed(OsmApiException e) { 58 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainPreconditionFailed(e), 59 tr("Precondition violation"), JOptionPane.ERROR_MESSAGE); 69 HelpAwareOptionPane.showOptionDialog( 70 Main.parent, 71 ExceptionUtil.explainPreconditionFailed(e), 72 tr("Precondition violation"), 73 JOptionPane.ERROR_MESSAGE, 74 ht("/ErrorMessages#OsmApiException") 75 ); 60 76 } 61 77 … … 66 82 */ 67 83 public static void explainGeneric(Exception e) { 68 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainGeneric(e), tr("Error"), 69 JOptionPane.ERROR_MESSAGE); 84 HelpAwareOptionPane.showOptionDialog( 85 Main.parent, 86 ExceptionUtil.explainGeneric(e), 87 tr("Error"), 88 JOptionPane.ERROR_MESSAGE, 89 ht("/ErrorMessages#GenericException") 90 ); 70 91 } 71 92 … … 79 100 80 101 public static void explainSecurityException(OsmTransferException e) { 81 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainSecurityException(e), tr("Security exception"), 82 JOptionPane.ERROR_MESSAGE); 102 HelpAwareOptionPane.showOptionDialog( 103 Main.parent, 104 ExceptionUtil.explainSecurityException(e), 105 tr("Security exception"), 106 JOptionPane.ERROR_MESSAGE, 107 ht("/ErrorMessages#SecurityException") 108 ); 83 109 } 84 110 … … 92 118 93 119 public static void explainNestedSocketException(OsmTransferException e) { 94 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainNestedSocketException(e), 95 tr("Network exception"), JOptionPane.ERROR_MESSAGE); 120 HelpAwareOptionPane.showOptionDialog( 121 Main.parent, 122 ExceptionUtil.explainNestedSocketException(e), 123 tr("Network exception"), 124 JOptionPane.ERROR_MESSAGE, 125 ht("/ErrorMessages#NestedSocketException") 126 ); 96 127 } 97 128 … … 105 136 106 137 public static void explainNestedIOException(OsmTransferException e) { 107 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainNestedIOException(e), tr("IO Exception"), 108 JOptionPane.ERROR_MESSAGE); 138 HelpAwareOptionPane.showOptionDialog( 139 Main.parent, 140 ExceptionUtil.explainNestedIOException(e), 141 tr("IO Exception"), 142 JOptionPane.ERROR_MESSAGE, 143 ht("/ErrorMessages#NestedIOException") 144 ); 109 145 } 110 146 … … 117 153 118 154 public static void explainInternalServerError(OsmTransferException e) { 119 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainInternalServerError(e), 120 tr("Internal Server Error"), JOptionPane.ERROR_MESSAGE); 155 HelpAwareOptionPane.showOptionDialog( 156 Main.parent, 157 ExceptionUtil.explainInternalServerError(e), 158 tr("Internal Server Error"), 159 JOptionPane.ERROR_MESSAGE, 160 ht("/ErrorMessages#InternalServerError") 161 ); 121 162 } 122 163 … … 128 169 */ 129 170 public static void explainBadRequest(OsmApiException e) { 130 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainBadRequest(e), tr("Bad Request"), 131 JOptionPane.ERROR_MESSAGE); 171 HelpAwareOptionPane.showOptionDialog( 172 Main.parent, 173 ExceptionUtil.explainBadRequest(e), 174 tr("Bad Request"), 175 JOptionPane.ERROR_MESSAGE, 176 ht("/ErrorMessages#BadRequest") 177 ); 132 178 } 133 179 … … 139 185 */ 140 186 public static void explainNotFound(OsmApiException e) { 141 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainNotFound(e), tr("Not Found"), 142 JOptionPane.ERROR_MESSAGE); 187 HelpAwareOptionPane.showOptionDialog( 188 Main.parent, 189 ExceptionUtil.explainNotFound(e), 190 tr("Not Found"), 191 JOptionPane.ERROR_MESSAGE, 192 ht("/ErrorMessages#NotFound") 193 ); 143 194 } 144 195 … … 149 200 */ 150 201 public static void explainConflict(OsmApiException e) { 151 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainConflict(e), tr("Conflict"), 152 JOptionPane.ERROR_MESSAGE); 202 HelpAwareOptionPane.showOptionDialog( 203 Main.parent, 204 ExceptionUtil.explainConflict(e), 205 tr("Conflict"), 206 JOptionPane.ERROR_MESSAGE, 207 ht("/ErrorMessages#Conflict") 208 ); 153 209 } 154 210 … … 162 218 163 219 public static void explainNestedUnkonwnHostException(OsmTransferException e) { 164 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainNestedUnkonwnHostException(e), 165 tr("Unknown host"), JOptionPane.ERROR_MESSAGE); 220 HelpAwareOptionPane.showOptionDialog( 221 Main.parent, 222 ExceptionUtil.explainNestedUnkonwnHostException(e), 223 tr("Unknown host"), 224 JOptionPane.ERROR_MESSAGE, 225 ht("/ErrorMessages#UnknownHost") 226 ); 166 227 } 167 228 … … 258 319 */ 259 320 public static void explainGoneForUnknownPrimitive(OsmApiException e) { 260 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainGoneForUnknownPrimitive(e), 261 tr("Object deleted"), JOptionPane.ERROR_MESSAGE); 262 321 HelpAwareOptionPane.showOptionDialog( 322 Main.parent, 323 ExceptionUtil.explainGoneForUnknownPrimitive(e), 324 tr("Object deleted"), 325 JOptionPane.ERROR_MESSAGE, 326 ht("/ErrorMessages#GoneForUnknownPrimitive") 327 ); 263 328 } 264 329 -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r2315 r2387 6 6 import java.awt.Component; 7 7 import java.awt.event.ActionEvent; 8 import java.awt.event.ActionListener;9 8 import java.awt.event.KeyEvent; 10 9 import java.awt.event.WindowAdapter; … … 14 13 15 14 import javax.swing.AbstractAction; 15 import javax.swing.Action; 16 16 import javax.swing.Icon; 17 17 import javax.swing.JButton; 18 import javax.swing.JComponent; 18 19 import javax.swing.JDialog; 19 20 import javax.swing.JLabel; … … 108 109 b.setToolTipText(tr("Show help information")); 109 110 HelpUtil.setHelpContext(b, helpTopic); 110 b.addActionListener( 111 new ActionListener() { 112 public void actionPerformed(ActionEvent e) { 113 HelpBrowserProxy.getInstance().setUrlForHelpTopic(helpTopic); 114 } 115 } 116 ); 111 Action a = new AbstractAction() { 112 public void actionPerformed(ActionEvent e) { 113 HelpBrowserProxy.getInstance().setUrlForHelpTopic(helpTopic); 114 } 115 }; 116 b.addActionListener(a); 117 b.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 118 b.getActionMap().put("enter", a); 117 119 return b; 118 120 } … … 126 128 * <code>helpTopic</code> is the trailing part of a JOSM online help URL, i.e. the part after the leading 127 129 * <code>http://josm.openstreetmap.de/wiki/Help</code>. It should start with a leading '/' and it 128 * may include an danchor after a '#'.130 * may include an anchor after a '#'. 129 131 * 130 132 * <strong>Examples</strong> … … 210 212 } 211 213 ); 214 dialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), "close"); 215 dialog.getRootPane().getActionMap().put("close", new AbstractAction() { 216 public void actionPerformed(ActionEvent e) { 217 pane.setValue(JOptionPane.CLOSED_OPTION); 218 dialog.setVisible(false); 219 }} 220 ); 221 212 222 if (options != null) { 213 223 for (int i=0; i < options.length;i++) { 214 224 final DefaultAction action = new DefaultAction(dialog, pane, i); 215 225 buttons.get(i).addActionListener(action); 216 buttons.get(i).getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 226 buttons.get(i).getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 217 227 buttons.get(i).getActionMap().put("enter", action); 218 228 } … … 220 230 final DefaultAction action = new DefaultAction(dialog, pane, 0); 221 231 buttons.get(0).addActionListener(action); 222 buttons.get(0).getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 232 buttons.get(0).getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0), "enter"); 223 233 buttons.get(0).getActionMap().put("enter", action); 224 234 } … … 232 242 return (Integer)pane.getValue(); 233 243 } 244 245 /** 246 * 247 * @param parentComponent 248 * @param msg 249 * @param title 250 * @param messageType 251 * @param helpTopic 252 * @return 253 * @see #showOptionDialog(Component, Object, String, int, Icon, ButtonSpec[], ButtonSpec, String) 254 */ 255 static public int showOptionDialog(Component parentComponent, Object msg, String title, int messageType,final String helpTopic) { 256 return showOptionDialog(parentComponent, msg, title, messageType, null,null,null, helpTopic); 257 } 234 258 } -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java
r2344 r2387 61 61 pnl.setLayout(new GridBagLayout()); 62 62 GridBagConstraints gc = new GridBagConstraints(); 63 // gc.fill = GridBagConstraints.HORIZONTAL;64 // gc.weightx = 1.0;65 // gc.weighty = 0.0;66 // pnl.add(new JButton(actAdd = new AddAction()), gc);67 68 63 gc.gridy = 0; 69 64 RemoveAction removeAction = new RemoveAction(); -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r2289 r2387 18 18 19 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;21 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;22 20 import org.openstreetmap.josm.io.OsmApi; 23 21 import org.openstreetmap.josm.io.OsmApiException; … … 144 142 msg = tr( 145 143 "<html>The server reported that it has detected a conflict.<br>" + 146 "Error message (untranslated):<br>" + 147 "{0}", 144 "Error message (untranslated):<br>{0}</html>", 148 145 msg 149 146 );
Note:
See TracChangeset
for help on using the changeset viewer.