Changeset 3501 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-08-30T23:22:28+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r3083 r3501 112 112 msg.append("</ul>"); 113 113 114 SwingUtilities.invokeLater(new Runnable() { 115 public void run() { 116 HelpAwareOptionPane.showOptionDialog( 117 Main.parent, 118 msg.toString(), 119 tr("Warning"), 120 JOptionPane.WARNING_MESSAGE, 121 HelpUtil.ht("/Action/OpenFile#ImporterCantImportFiles") 122 ); 123 } 124 }); 114 HelpAwareOptionPane.showMessageDialogInEDT( 115 Main.parent, 116 msg.toString(), 117 tr("Warning"), 118 JOptionPane.WARNING_MESSAGE, 119 HelpUtil.ht("/Action/OpenFile#ImporterCantImportFiles") 120 ); 125 121 } 126 122 … … 142 138 msg.append("</ul>"); 143 139 144 SwingUtilities.invokeLater(new Runnable() { 145 public void run() { 146 HelpAwareOptionPane.showOptionDialog( 147 Main.parent, 148 msg.toString(), 149 tr("Warning"), 150 JOptionPane.WARNING_MESSAGE, 151 HelpUtil.ht("/Action/OpenFile#MissingImporterForFiles") 152 ); 153 } 154 }); 140 HelpAwareOptionPane.showMessageDialogInEDT( 141 Main.parent, 142 msg.toString(), 143 tr("Warning"), 144 JOptionPane.WARNING_MESSAGE, 145 HelpUtil.ht("/Action/OpenFile#MissingImporterForFiles") 146 ); 155 147 } 156 148 … … 205 197 if (!filesNotMatchingWithImporter.isEmpty()) { 206 198 alertFilesNotMatchingWithImporter(filesNotMatchingWithImporter, chosenImporter); 207 // TODO when changing to Java 6: Don't cancel the208 // task here but use different modality. (Currently 2 dialogs209 // would block each other.)210 return;211 199 } 212 200 if (!filesMatchingWithImporter.isEmpty()) { … … 230 218 if (!filesWithUnknownImporter.isEmpty()) { 231 219 alertFilesWithUnknownImporter(filesWithUnknownImporter); 232 // TODO when changing to Java 6: Don't cancel the233 // task here but use different modality. (Currently 2 dialogs234 // would block each other.)235 return;236 220 } 237 221 List<FileImporter> ims = new ArrayList<FileImporter>(map.keySet()); -
trunk/src/org/openstreetmap/josm/actions/RenameLayerAction.java
r2512 r3501 5 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 6 6 7 import java.awt.Dialog.ModalityType; 7 8 import java.awt.event.ActionEvent; 8 9 import java.io.File; … … 64 65 }; 65 66 final JDialog dlg = optionPane.createDialog(Main.parent, tr("Rename layer")); 66 dlg.setModal (true);67 dlg.setModalityType(ModalityType.DOCUMENT_MODAL); 67 68 dlg.setVisible(true); 68 69 -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r3404 r3501 125 125 public ExtendedDialog(Component parent, String title, String[] buttonTexts, 126 126 boolean modal, boolean disposeOnClose) { 127 super(JOptionPane.getFrameForComponent(parent), title, modal );127 super(JOptionPane.getFrameForComponent(parent), title, modal ? ModalityType.DOCUMENT_MODAL : ModalityType.MODELESS); 128 128 this.parent = parent; 129 129 this.modal = modal; -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r3083 r3501 5 5 6 6 import java.awt.Component; 7 import java.awt.Dialog.ModalityType; 7 8 import java.awt.event.ActionEvent; 8 9 import java.awt.event.KeyEvent; … … 21 22 import javax.swing.JOptionPane; 22 23 import javax.swing.KeyStroke; 24 import javax.swing.SwingUtilities; 23 25 24 26 import org.openstreetmap.josm.gui.help.HelpBrowser; … … 181 183 JOptionPane.getFrameForComponent(parentComponent), 182 184 title, 183 true185 ModalityType.DOCUMENT_MODAL 184 186 ); 185 187 dialog.setContentPane(pane); 186 dialog.addWindowListener( 187 new WindowAdapter() { 188 189 @Override 190 public void windowClosing(WindowEvent e) { 191 pane.setValue(JOptionPane.CLOSED_OPTION); 192 super.windowClosed(e); 193 } 194 195 @Override 196 public void windowOpened(WindowEvent e) { 197 if (defaultOption != null && options != null && options.length > 0) { 198 int i; 199 for (i=0; i<options.length;i++) { 200 if (options[i] == defaultOption) { 201 break; 202 } 203 } 204 if (i >= options.length) { 205 buttons.get(0).requestFocusInWindow(); 206 } 207 buttons.get(i).requestFocusInWindow(); 208 } else { 209 buttons.get(0).requestFocusInWindow(); 188 dialog.addWindowListener(new WindowAdapter() { 189 @Override 190 public void windowClosing(WindowEvent e) { 191 pane.setValue(JOptionPane.CLOSED_OPTION); 192 super.windowClosed(e); 193 } 194 195 @Override 196 public void windowOpened(WindowEvent e) { 197 if (defaultOption != null && options != null && options.length > 0) { 198 int i; 199 for (i=0; i<options.length;i++) { 200 if (options[i] == defaultOption) { 201 break; 210 202 } 211 203 } 204 if (i >= options.length) { 205 buttons.get(0).requestFocusInWindow(); 206 } 207 buttons.get(i).requestFocusInWindow(); 208 } else { 209 buttons.get(0).requestFocusInWindow(); 212 210 } 213 ); 211 } 212 }); 214 213 dialog.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0), "close"); 215 214 dialog.getRootPane().getActionMap().put("close", new AbstractAction() { … … 256 255 return showOptionDialog(parentComponent, msg, title, messageType, null,null,null, helpTopic); 257 256 } 257 258 /** 259 * Run it in Event Dispatch Thread. 260 * This version does not return anything, so it is more like showMessageDialog. 261 * 262 * It can be used, when you need to show a message dialog from a worker thread, 263 * e.g. from PleaseWaitRunnable 264 */ 265 static public void showMessageDialogInEDT(final Component parentComponent, final Object msg, final String title, final int messageType, final String helpTopic) { 266 SwingUtilities.invokeLater(new Runnable() { 267 public void run() { 268 showOptionDialog(parentComponent, msg, title, messageType, null, null, null, helpTopic); 269 } 270 }); 271 } 258 272 } -
trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java
r2582 r3501 72 72 73 73 public PleaseWaitDialog(Component parent) { 74 super(JOptionPane.getFrameForComponent(parent), true);74 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 75 75 initDialog(); 76 76 } -
trunk/src/org/openstreetmap/josm/gui/actionsupport/DeleteFromRelationConfirmationDialog.java
r3083 r3501 170 170 171 171 public DeleteFromRelationConfirmationDialog() { 172 super(JOptionPane.getFrameForComponent(Main.parent), "", true /* modal */);172 super(JOptionPane.getFrameForComponent(Main.parent), "", ModalityType.DOCUMENT_MODAL); 173 173 build(); 174 174 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r3083 r3501 190 190 191 191 public CombinePrimitiveResolverDialog(Component owner) { 192 super(JOptionPane.getFrameForComponent(owner), true /* modal */);192 super(JOptionPane.getFrameForComponent(owner), ModalityType.DOCUMENT_MODAL); 193 193 build(); 194 194 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java
r3385 r3501 69 69 70 70 public PasteTagsConflictResolverDialog(Component owner) { 71 super(JOptionPane.getFrameForComponent(owner), true);71 super(JOptionPane.getFrameForComponent(owner), ModalityType.DOCUMENT_MODAL); 72 72 build(); 73 73 iconResolved = ImageProvider.get("dialogs/conflict", "tagconflictresolved"); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r3362 r3501 176 176 177 177 public ConflictResolutionDialog(Component parent) { 178 super(JOptionPane.getFrameForComponent(parent), true /* modal */);178 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 179 179 build(); 180 180 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/LatLonDialog.java
r3479 r3501 118 118 119 119 public LatLonDialog(Component parent, String title, String help) { 120 super(JOptionPane.getFrameForComponent(parent), true /* modal */);120 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 121 121 this.help = help; 122 122 setTitle(title); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java
r3083 r3501 98 98 99 99 public ChangesetQueryDialog(Dialog parent) { 100 super(parent, true /* modal */);100 super(parent, ModalityType.DOCUMENT_MODAL); 101 101 build(); 102 102 } 103 103 104 104 public ChangesetQueryDialog(Frame parent) { 105 super(parent, true /* modal */);105 super(parent, ModalityType.DOCUMENT_MODAL); 106 106 build(); 107 107 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r3444 r3501 8 8 import java.awt.Component; 9 9 import java.awt.Cursor; 10 import java.awt.Dialog.ModalityType; 10 11 import java.awt.Dimension; 11 12 import java.awt.Font; … … 260 261 }; 261 262 final JDialog dlg = optionPane.createDialog(Main.parent, tr("Change values?")); 263 dlg.setModalityType(ModalityType.DOCUMENT_MODAL); 262 264 263 265 values.getEditor().addActionListener(new ActionListener() { … … 401 403 }; 402 404 JDialog dialog = pane.createDialog(Main.parent, tr("Change values?")); 405 dialog.setModalityType(ModalityType.DOCUMENT_MODAL); 403 406 dialog.setVisible(true); 404 407 -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r3104 r3501 177 177 178 178 public DownloadDialog(Component parent) { 179 super(JOptionPane.getFrameForComponent(parent),tr("Download"), true /* modal */);179 super(JOptionPane.getFrameForComponent(parent),tr("Download"), ModalityType.DOCUMENT_MODAL); 180 180 getContentPane().setLayout(new BorderLayout()); 181 181 getContentPane().add(buildMainPanel(), BorderLayout.CENTER); -
trunk/src/org/openstreetmap/josm/gui/help/HelpBrowser.java
r3238 r3501 24 24 import javax.swing.JButton; 25 25 import javax.swing.JComponent; 26 import javax.swing.JDialog; 26 27 import javax.swing.JEditorPane; 27 import javax.swing.JFrame;28 28 import javax.swing.JOptionPane; 29 29 import javax.swing.JPanel; … … 51 51 import org.openstreetmap.josm.tools.WindowGeometry; 52 52 53 public class HelpBrowser extends J Frame{53 public class HelpBrowser extends JDialog { 54 54 static private final Logger logger = Logger.getLogger(HelpBrowser.class.getName()); 55 55 -
trunk/src/org/openstreetmap/josm/gui/io/CloseChangesetDialog.java
r3083 r3501 111 111 112 112 public CloseChangesetDialog() { 113 super(JOptionPane.getFrameForComponent(Main.parent), true /* modal */);113 super(JOptionPane.getFrameForComponent(Main.parent), ModalityType.DOCUMENT_MODAL); 114 114 build(); 115 115 } -
trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java
r3083 r3501 93 93 94 94 public CredentialDialog() { 95 setModal (true);95 setModalityType(ModalityType.DOCUMENT_MODAL); 96 96 try { 97 97 setAlwaysOnTop(true); -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r3441 r3501 126 126 127 127 public SaveLayersDialog(Component parent) { 128 super(JOptionPane.getFrameForComponent(parent), true /* modal */);128 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 129 129 build(); 130 130 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r3403 r3501 231 231 */ 232 232 public UploadDialog() { 233 super(JOptionPane.getFrameForComponent(Main.parent), true /* modal */);233 super(JOptionPane.getFrameForComponent(Main.parent), ModalityType.DOCUMENT_MODAL); 234 234 build(); 235 235 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java
r3083 r3501 115 115 116 116 public UploadSelectionDialog() { 117 super(JOptionPane.getFrameForComponent(Main.parent), true /* modal */);117 super(JOptionPane.getFrameForComponent(Main.parent), ModalityType.DOCUMENT_MODAL); 118 118 build(); 119 119 } -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r3385 r3501 212 212 */ 213 213 public OAuthAuthorizationWizard(String apiUrl) throws IllegalArgumentException { 214 super(JOptionPane.getFrameForComponent(Main.parent), true /* modal */);214 super(JOptionPane.getFrameForComponent(Main.parent), ModalityType.DOCUMENT_MODAL); 215 215 CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl"); 216 216 build(); … … 226 226 */ 227 227 public OAuthAuthorizationWizard(Component parent, String apiUrl) { 228 super(JOptionPane.getFrameForComponent(parent), true /* modal */);228 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 229 229 CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl"); 230 230 build(); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r3461 r3501 59 59 60 60 public PreferenceDialog(Component parent) { 61 super(JOptionPane.getFrameForComponent(parent), tr("Preferences"), true /* modal */);61 super(JOptionPane.getFrameForComponent(parent), tr("Preferences"), ModalityType.DOCUMENT_MODAL); 62 62 build(); 63 63 } -
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r3083 r3501 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; 14 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 14 15 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 15 16 … … 58 59 } catch (Exception e) { 59 60 e.printStackTrace(); 60 JOptionPane.showMessageDialog(61 HelpAwareOptionPane.showMessageDialogInEDT( 61 62 Main.parent, 62 63 tr("<html>Could not read file ''{0}''.<br>Error is:<br>{1}</html>", f.getName(), e.getMessage()), 63 64 tr("Error"), 64 JOptionPane.ERROR_MESSAGE 65 JOptionPane.ERROR_MESSAGE, null 65 66 ); 66 67 } … … 72 73 } catch (Exception e) { 73 74 e.printStackTrace(); 74 JOptionPane.showMessageDialog(75 HelpAwareOptionPane.showMessageDialogInEDT( 75 76 Main.parent, 76 77 tr("<html>Could not read files.<br>Error is:<br>{0}</html>", e.getMessage()), 77 78 tr("Error"), 78 JOptionPane.ERROR_MESSAGE 79 JOptionPane.ERROR_MESSAGE, null 79 80 ); 80 81 } -
trunk/src/org/openstreetmap/josm/io/NMEAImporter.java
r3083 r3501 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; 14 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 14 15 import org.openstreetmap.josm.gui.layer.GpxLayer; 15 16 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; … … 42 43 43 44 private void showNmeaInfobox(boolean success, NmeaReader r) { 44 String msg = tr("Coordinates imported: ") + r.getNumberOfCoordinates() + "\n" + tr("Malformed sentences: ") 45 + r.getParserMalformed() + "\n" + tr("Checksum errors: ") + r.getParserChecksumErrors() + "\n"; 45 final StringBuilder msg = new StringBuilder().append("<html>"); 46 msg.append(tr("Coordinates imported: {0}", r.getNumberOfCoordinates()) + "<br>"); 47 msg.append(tr("Malformed sentences: {0}", r.getParserMalformed()) + "<br>"); 48 msg.append(tr("Checksum errors: {0}", r.getParserChecksumErrors()) + "<br>"); 46 49 if (!success) { 47 msg += tr("Unknown sentences: ") + r.getParserUnknown() + "\n";50 msg.append(tr("Unknown sentences: {0}", r.getParserUnknown()) + "<br>"); 48 51 } 49 msg += tr("Zero coordinates: ") + r.getParserZeroCoordinates(); 52 msg.append(tr("Zero coordinates: {0}", r.getParserZeroCoordinates())); 53 msg.append("</html>"); 50 54 if (success) { 51 JOptionPane.showMessageDialog(55 HelpAwareOptionPane.showMessageDialogInEDT( 52 56 Main.parent, 53 msg ,57 msg.toString(), 54 58 tr("NMEA import success"), 55 JOptionPane.INFORMATION_MESSAGE );59 JOptionPane.INFORMATION_MESSAGE, null); 56 60 } else { 57 JOptionPane.showMessageDialog(Main.parent, msg, tr("NMEA import failure!"), JOptionPane.ERROR_MESSAGE); 61 HelpAwareOptionPane.showMessageDialogInEDT( 62 Main.parent, 63 msg.toString(), 64 tr("NMEA import failure!"), 65 JOptionPane.ERROR_MESSAGE, null); 58 66 } 59 67 } 60 61 68 }
Note:
See TracChangeset
for help on using the changeset viewer.