Changeset 2994 in josm
- Timestamp:
- 2010-02-15T20:47:41+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r2980 r2994 19 19 import javax.swing.JFileChooser; 20 20 import javax.swing.JOptionPane; 21 import javax.swing.SwingUtilities; 21 22 import javax.swing.filechooser.FileFilter; 22 23 … … 94 95 95 96 protected void alertFilesNotMatchingWithImporter(Collection<File> files, FileImporter importer) { 96 StringBuffer msg = new StringBuffer();97 final StringBuffer msg = new StringBuffer(); 97 98 msg.append("<html>"); 98 99 msg.append( 99 100 trn( 100 "Cannot open {0} file with the file importer ''{1}''. Skipping the following files:",101 "Cannot open {0} files with the file importer ''{1}''. Skipping the following files:",101 "Cannot open {0} file with the file importer ''{1}''.", 102 "Cannot open {0} files with the file importer ''{1}''.", 102 103 files.size(), 103 104 files.size(), … … 111 112 msg.append("</ul>"); 112 113 113 HelpAwareOptionPane.showOptionDialog( 114 Main.parent, 115 msg.toString(), 116 tr("Warning"), 117 JOptionPane.WARNING_MESSAGE, 118 HelpUtil.ht("/Action/OpenFile#ImporterCantImportFiles") 119 ); 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 }); 120 125 } 121 126 122 127 protected void alertFilesWithUnknownImporter(Collection<File> files) { 123 StringBuffer msg = new StringBuffer();128 final StringBuffer msg = new StringBuffer(); 124 129 msg.append("<html>"); 125 130 msg.append( 126 131 trn( 127 "Cannot open {0} file because no suitable file importer is available. Skipping the following files:",128 "Cannot open {0} files because no suitable file importer is available. Skipping the following files:",132 "Cannot open {0} file because no suitable file importer is available.", 133 "Cannot open {0} files because no suitable file importer is available.", 129 134 files.size(), 130 135 files.size() … … 136 141 } 137 142 msg.append("</ul>"); 138 139 HelpAwareOptionPane.showOptionDialog( 140 Main.parent, 141 msg.toString(), 142 tr("Warning"), 143 JOptionPane.WARNING_MESSAGE, 144 HelpUtil.ht("/Action/OpenFile#MissingImporterForFiles") 145 ); 143 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 }); 146 155 } 147 156 … … 172 181 List<File> filesNotMatchingWithImporter = new LinkedList<File>(); 173 182 List<File> filesMatchingWithImporter = new LinkedList<File>(); 174 for ( File f : files) {183 for (final File f : files) { 175 184 if (!chosenImporter.acceptFile(f)) { 176 185 if (f.isDirectory()) { 177 JOptionPane.showMessageDialog(Main.parent, tr( 178 "<html>Cannot open directory ''{0}''.<br>Please select a file.</html>", f 179 .getAbsolutePath()), tr("Open file"), JOptionPane.ERROR_MESSAGE); 186 SwingUtilities.invokeLater(new Runnable() { 187 public void run() { 188 JOptionPane.showMessageDialog(Main.parent, tr( 189 "<html>Cannot open directory ''{0}''.<br>Please select a file.</html>", 190 f.getAbsolutePath()), tr("Open file"), JOptionPane.ERROR_MESSAGE); 191 } 192 }); 193 // TODO when changing to Java 6: Don't cancel the 194 // task here but use different modality. (Currently 2 dialogs 195 // would block each other.) 196 return; 180 197 } else { 181 198 filesNotMatchingWithImporter.add(f); … … 188 205 if (!filesNotMatchingWithImporter.isEmpty()) { 189 206 alertFilesNotMatchingWithImporter(filesNotMatchingWithImporter, chosenImporter); 190 } 191 if (!filesNotMatchingWithImporter.isEmpty()) { 207 // TODO when changing to Java 6: Don't cancel the 208 // task here but use different modality. (Currently 2 dialogs 209 // would block each other.) 210 return; 211 } 212 if (!filesMatchingWithImporter.isEmpty()) { 192 213 importData(chosenImporter, filesMatchingWithImporter); 193 214 } … … 209 230 if (!filesWithUnknownImporter.isEmpty()) { 210 231 alertFilesWithUnknownImporter(filesWithUnknownImporter); 232 // TODO when changing to Java 6: Don't cancel the 233 // task here but use different modality. (Currently 2 dialogs 234 // would block each other.) 235 return; 211 236 } 212 237 List<FileImporter> ims = new ArrayList<FileImporter>(map.keySet());
Note:
See TracChangeset
for help on using the changeset viewer.