Changeset 7578 in josm
- Timestamp:
- 2014-09-22T22:00:21+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 added
- 15 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java
r6889 r7578 7 7 import javax.swing.filechooser.FileFilter; 8 8 9 import org.openstreetmap.josm.gui.widgets.JFileChooserManager; 9 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 10 import org.openstreetmap.josm.gui.widgets.FileChooserManager; 10 11 import org.openstreetmap.josm.tools.Shortcut; 11 12 … … 46 47 47 48 /** 48 * Creates a new {@link JFileChooser} and makes it visible.49 * Creates a new {@link AbstractFileChooser} and makes it visible. 49 50 * @param open If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialog 50 51 * @param multiple If true, makes the dialog allow multiple file selections 51 52 * @param title The string that goes in the dialog window's title bar 52 * @return The {@code JFileChooser}.53 * @return The {@code AbstractFileChooser}. 53 54 * @since 1646 54 55 */ 55 public static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title) {56 public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title) { 56 57 return createAndOpenFileChooser(open, multiple, title, null); 57 58 } 58 59 59 60 /** 60 * Creates a new {@link JFileChooser} and makes it visible.61 * Creates a new {@link AbstractFileChooser} and makes it visible. 61 62 * @param open If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialog 62 63 * @param multiple If true, makes the dialog allow multiple file selections 63 64 * @param title The string that goes in the dialog window's title bar 64 65 * @param extension The file extension that will be selected as the default file filter 65 * @return The {@code JFileChooser}.66 * @return The {@code AbstractFileChooser}. 66 67 * @since 2020 67 68 */ 68 public static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, String extension) {69 public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, String extension) { 69 70 return createAndOpenFileChooser(open, multiple, title, extension, JFileChooser.FILES_ONLY, true, null); 70 71 } 71 72 72 73 /** 73 * Creates a new {@link JFileChooser} and makes it visible.74 * Creates a new {@link AbstractFileChooser} and makes it visible. 74 75 * @param open If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialog 75 76 * @param multiple If true, makes the dialog allow multiple file selections … … 82 83 * @param allTypes If true, all the files types known by JOSM will be proposed in the "file type" combobox. 83 84 * If false, only the file filters that include {@code extension} will be proposed 84 * @param lastDirProperty The name of the property used to setup the JFileChooser initial directory.85 * @param lastDirProperty The name of the property used to setup the AbstractFileChooser initial directory. 85 86 * This property will then be updated to the new "last directory" chosen by the user. If null, the default property "lastDirectory" will be used. 86 * @return The {@code JFileChooser}.87 * @return The {@code AbstractFileChooser}. 87 88 * @since 5438 88 89 */ 89 public static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, String extension, int selectionMode, boolean allTypes, String lastDirProperty) {90 return new JFileChooserManager(open, lastDirProperty).createFileChooser(multiple, title, extension, allTypes, selectionMode).openFileChooser();90 public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, String extension, int selectionMode, boolean allTypes, String lastDirProperty) { 91 return new FileChooserManager(open, lastDirProperty).createFileChooser(multiple, title, extension, allTypes, selectionMode).openFileChooser(); 91 92 } 92 93 93 94 /** 94 * Creates a new {@link JFileChooser} for a single {@link FileFilter} and makes it visible.95 * Creates a new {@link AbstractFileChooser} for a single {@link FileFilter} and makes it visible. 95 96 * @param open If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialog 96 97 * @param multiple If true, makes the dialog allow multiple file selections … … 101 102 * <li>just select directories ({@code JFileChooser.DIRECTORIES_ONLY})</li> 102 103 * <li>select both files and directories ({@code JFileChooser.FILES_AND_DIRECTORIES})</li></ul> 103 * @param lastDirProperty The name of the property used to setup the JFileChooser initial directory. This property will then be updated to the new "last directory" chosen by the user104 * @return The {@code JFileChooser}.104 * @param lastDirProperty The name of the property used to setup the AbstractFileChooser initial directory. This property will then be updated to the new "last directory" chosen by the user 105 * @return The {@code AbstractFileChooser}. 105 106 * @since 5438 106 107 */ 107 public static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, FileFilter filter, int selectionMode, String lastDirProperty) {108 return new JFileChooserManager(open, lastDirProperty).createFileChooser(multiple, title, filter, selectionMode).openFileChooser();108 public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, FileFilter filter, int selectionMode, String lastDirProperty) { 109 return new FileChooserManager(open, lastDirProperty).createFileChooser(multiple, title, filter, selectionMode).openFileChooser(); 109 110 } 110 111 111 112 /** 112 * Creates a new {@link JFileChooser} for several {@link FileFilter}s and makes it visible.113 * Creates a new {@link AbstractFileChooser} for several {@link FileFilter}s and makes it visible. 113 114 * @param open If true, pops up an "Open File" dialog. If false, pops up a "Save File" dialog 114 115 * @param multiple If true, makes the dialog allow multiple file selections … … 121 122 * <li>select both files and directories ({@code JFileChooser.FILES_AND_DIRECTORIES})</li></ul> 122 123 * @param lastDirProperty The name of the property used to setup the JFileChooser initial directory. This property will then be updated to the new "last directory" chosen by the user 123 * @return The {@code JFileChooser}.124 * @return The {@code AbstractFileChooser}. 124 125 * @since 5438 125 126 */ 126 public static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title,127 public static AbstractFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title, 127 128 Collection<? extends FileFilter> filters, FileFilter defaultFilter, int selectionMode, String lastDirProperty) { 128 return new JFileChooserManager(open, lastDirProperty).createFileChooser(multiple, title, filters, defaultFilter, selectionMode).openFileChooser();129 return new FileChooserManager(open, lastDirProperty).createFileChooser(multiple, title, filters, defaultFilter, selectionMode).openFileChooser(); 129 130 } 130 131 } -
trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
r7538 r7578 10 10 import java.util.ServiceConfigurationError; 11 11 12 import javax.swing.JFileChooser;13 12 import javax.swing.filechooser.FileFilter; 14 13 15 14 import org.openstreetmap.josm.Main; 16 15 import org.openstreetmap.josm.gui.MapView; 16 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 17 17 import org.openstreetmap.josm.io.AllFormatsImporter; 18 18 import org.openstreetmap.josm.io.FileExporter; … … 224 224 225 225 /** 226 * Applies the choosable {@link FileFilter} to a {@link JFileChooser} before using the226 * Applies the choosable {@link FileFilter} to a {@link AbstractFileChooser} before using the 227 227 * file chooser for selecting a file for reading. 228 228 * … … 233 233 * @since 5438 234 234 */ 235 public static void applyChoosableImportFileFilters( JFileChooser fileChooser, String extension, boolean allTypes) {235 public static void applyChoosableImportFileFilters(AbstractFileChooser fileChooser, String extension, boolean allTypes) { 236 236 for (ExtensionFileFilter filter: getImportExtensionFileFilters()) { 237 237 if (allTypes || filter.acceptName("file."+extension)) { … … 243 243 244 244 /** 245 * Applies the choosable {@link FileFilter} to a {@link JFileChooser} before using the245 * Applies the choosable {@link FileFilter} to a {@link AbstractFileChooser} before using the 246 246 * file chooser for selecting a file for writing. 247 247 * … … 252 252 * @since 5438 253 253 */ 254 public static void applyChoosableExportFileFilters( JFileChooser fileChooser, String extension, boolean allTypes) {254 public static void applyChoosableExportFileFilters(AbstractFileChooser fileChooser, String extension, boolean allTypes) { 255 255 for (ExtensionFileFilter filter: getExportExtensionFileFilters()) { 256 256 if (allTypes || filter.acceptName("file."+extension)) { -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r7453 r7578 25 25 import java.util.regex.Pattern; 26 26 27 import javax.swing.JFileChooser;28 27 import javax.swing.JOptionPane; 29 28 import javax.swing.SwingUtilities; … … 34 33 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 35 34 import org.openstreetmap.josm.gui.help.HelpUtil; 35 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 36 36 import org.openstreetmap.josm.io.AllFormatsImporter; 37 37 import org.openstreetmap.josm.io.FileImporter; … … 65 65 @Override 66 66 public void actionPerformed(ActionEvent e) { 67 JFileChooser fc = createAndOpenFileChooser(true, true, null);67 AbstractFileChooser fc = createAndOpenFileChooser(true, true, null); 68 68 if (fc == null) 69 69 return; -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r7204 r7578 19 19 import org.openstreetmap.josm.gui.layer.Layer; 20 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 21 22 import org.openstreetmap.josm.io.FileExporter; 22 23 import org.openstreetmap.josm.tools.Shortcut; … … 136 137 */ 137 138 public static File createAndOpenSaveFileChooser(String title, ExtensionFileFilter filter) { 138 JFileChooser fc = createAndOpenFileChooser(false, false, title, filter, JFileChooser.FILES_ONLY, null);139 AbstractFileChooser fc = createAndOpenFileChooser(false, false, title, filter, JFileChooser.FILES_ONLY, null); 139 140 return checkFileAndConfirmOverWrite(fc, filter.getDefaultExtension()); 140 141 } … … 150 151 */ 151 152 public static File createAndOpenSaveFileChooser(String title, String extension) { 152 JFileChooser fc = createAndOpenFileChooser(false, false, title, extension);153 AbstractFileChooser fc = createAndOpenFileChooser(false, false, title, extension); 153 154 return checkFileAndConfirmOverWrite(fc, extension); 154 155 } 155 156 156 private static File checkFileAndConfirmOverWrite( JFileChooser fc, String extension) {157 private static File checkFileAndConfirmOverWrite(AbstractFileChooser fc, String extension) { 157 158 if (fc == null) return null; 158 159 File file = fc.getSelectedFile(); -
trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
r7326 r7578 25 25 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 26 26 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; 27 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 27 28 import org.openstreetmap.josm.io.IllegalDataException; 28 29 import org.openstreetmap.josm.io.session.SessionImporter; … … 47 48 @Override 48 49 public void actionPerformed(ActionEvent e) { 49 JFileChooser fc = createAndOpenFileChooser(true, false, tr("Open session"),50 AbstractFileChooser fc = createAndOpenFileChooser(true, false, tr("Open session"), 50 51 Arrays.asList(SessionImporter.FILE_FILTER, FileFilterAllFiles.getInstance()), 51 52 SessionImporter.FILE_FILTER, JFileChooser.FILES_ONLY, "lastDirectory"); -
trunk/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java
r7509 r7578 36 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 37 37 import org.openstreetmap.josm.gui.layer.Layer; 38 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 38 39 import org.openstreetmap.josm.io.session.SessionLayerExporter; 39 40 import org.openstreetmap.josm.io.session.SessionWriter; … … 82 83 FileFilter jos = new ExtensionFileFilter("jos", "jos", tr("Session file (*.jos)")); 83 84 84 JFileChooser fc;85 AbstractFileChooser fc; 85 86 86 87 if (zipRequired) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r7553 r7578 73 73 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 74 74 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; 75 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 76 import org.openstreetmap.josm.gui.widgets.FileChooserManager; 75 77 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 76 import org.openstreetmap.josm.gui.widgets.JFileChooserManager;77 78 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 78 79 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 443 444 final StyleSource s = model.getRow(sel); 444 445 445 JFileChooserManager fcm = new JFileChooserManager(false, "mappaint.clone-style.lastDirectory", System.getProperty("user.home"));446 FileChooserManager fcm = new FileChooserManager(false, "mappaint.clone-style.lastDirectory", System.getProperty("user.home")); 446 447 String suggestion = fcm.getInitialDirectory() + File.separator + s.getFileNamePart(); 447 448 … … 454 455 fcm.createFileChooser(false, null, Arrays.asList(ff, FileFilterAllFiles.getInstance()), ff, JFileChooser.FILES_ONLY) 455 456 .getFileChooser().setSelectedFile(new File(suggestion)); 456 JFileChooser fc = fcm.openFileChooser();457 AbstractFileChooser fc = fcm.openFileChooser(); 457 458 if (fc == null) 458 459 return; -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r7518 r7578 72 72 import org.openstreetmap.josm.gui.layer.GpxLayer; 73 73 import org.openstreetmap.josm.gui.layer.Layer; 74 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 74 75 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 75 76 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … 151 152 } 152 153 }; 153 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, false, null, filter, JFileChooser.FILES_ONLY, null);154 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, false, null, filter, JFileChooser.FILES_ONLY, null); 154 155 if (fc == null) 155 156 return; … … 383 384 @Override 384 385 public void actionPerformed(ActionEvent ae) { 385 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, false, null, JpegFileFilter.getInstance(),386 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, false, null, JpegFileFilter.getInstance(), 386 387 JFileChooser.FILES_ONLY, "geoimage.lastdirectory"); 387 388 if (fc == null) -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r7518 r7578 30 30 import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker; 31 31 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 32 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 32 33 import org.openstreetmap.josm.tools.AudioUtil; 33 34 import org.openstreetmap.josm.tools.ImageProvider; … … 78 79 } 79 80 }; 80 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, true, null, filter, JFileChooser.FILES_ONLY, "markers.lastaudiodirectory");81 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, true, null, filter, JFileChooser.FILES_ONLY, "markers.lastaudiodirectory"); 81 82 if (fc != null) { 82 83 File[] sel = fc.getSelectedFiles(); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportImagesAction.java
r7005 r7578 18 18 import org.openstreetmap.josm.gui.layer.GpxLayer; 19 19 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 20 import org.openstreetmap.josm.gui.widgets.JFileChooserManager; 20 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 21 import org.openstreetmap.josm.gui.widgets.FileChooserManager; 21 22 import org.openstreetmap.josm.io.JpgImporter; 22 23 import org.openstreetmap.josm.tools.ImageProvider; … … 53 54 } 54 55 JpgImporter importer = new JpgImporter(layer); 55 JFileChooser fc = new JFileChooserManager(true, "geoimage.lastdirectory", Main.pref.get("lastDirectory")).createFileChooser(true, null, importer.filter, JFileChooser.FILES_AND_DIRECTORIES).openFileChooser(); 56 AbstractFileChooser fc = new FileChooserManager(true, "geoimage.lastdirectory", Main.pref.get("lastDirectory")). 57 createFileChooser(true, null, importer.filter, JFileChooser.FILES_AND_DIRECTORIES).openFileChooser(); 56 58 if (fc != null) { 57 59 File[] sel = fc.getSelectedFiles(); -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r7434 r7578 89 89 import org.openstreetmap.josm.gui.util.GuiHelper; 90 90 import org.openstreetmap.josm.gui.util.TableHelper; 91 import org.openstreetmap.josm.gui.widgets.JFileChooserManager; 91 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 92 import org.openstreetmap.josm.gui.widgets.FileChooserManager; 92 93 import org.openstreetmap.josm.gui.widgets.JosmTextField; 93 94 import org.openstreetmap.josm.io.CachedFile; … … 701 702 } 702 703 703 private static void prepareFileChooser(String url, JFileChooser fc) {704 private static void prepareFileChooser(String url, AbstractFileChooser fc) { 704 705 if (url == null || url.trim().length() == 0) return; 705 706 URL sourceUrl = null; … … 813 814 return; 814 815 } 815 JFileChooserManager fcm = new JFileChooserManager(true)816 FileChooserManager fcm = new FileChooserManager(true) 816 817 .createFileChooser(true, null, Arrays.asList(ff, FileFilterAllFiles.getInstance()), ff, JFileChooser.FILES_ONLY); 817 818 prepareFileChooser(tfURL.getText(), fcm.getFileChooser()); 818 JFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this));819 AbstractFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this)); 819 820 if (fc != null) { 820 821 tfURL.setText(fc.getSelectedFile().toString()); … … 1512 1513 @Override 1513 1514 public void actionPerformed(ActionEvent e) { 1514 JFileChooserManager fcm = new JFileChooserManager(true).createFileChooser();1515 FileChooserManager fcm = new FileChooserManager(true).createFileChooser(); 1515 1516 if (!isFile) { 1516 1517 fcm.getFileChooser().setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 1517 1518 } 1518 1519 prepareFileChooser(tfFileName.getText(), fcm.getFileChooser()); 1519 JFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this));1520 AbstractFileChooser fc = fcm.openFileChooser(JOptionPane.getFrameForComponent(SourceEditor.this)); 1520 1521 if (fc != null) { 1521 1522 tfFileName.setText(fc.getSelectedFile().toString()); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java
r7536 r7578 46 46 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 47 47 import org.openstreetmap.josm.gui.util.GuiHelper; 48 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 48 49 import org.openstreetmap.josm.gui.widgets.JosmTextField; 49 50 import org.openstreetmap.josm.tools.GBC; … … 197 198 } 198 199 }; 199 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(!saveFileFlag, !saveFileFlag, title, filter, JFileChooser.FILES_ONLY, "customsettings.lastDirectory"); 200 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(!saveFileFlag, !saveFileFlag, title, filter, 201 JFileChooser.FILES_ONLY, "customsettings.lastDirectory"); 200 202 if (fc != null) { 201 203 File[] sel = fc.isMultiSelectionEnabled() ? fc.getSelectedFiles() : (new File[]{fc.getSelectedFile()}); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileAction.java
r7027 r7578 20 20 import org.openstreetmap.josm.data.Preferences; 21 21 import org.openstreetmap.josm.data.Preferences.Setting; 22 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 22 23 23 24 /** … … 71 72 } 72 73 }; 73 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(false, false, title, filter, JFileChooser.FILES_ONLY, "customsettings.lastDirectory");74 AbstractFileChooser fc = DiskAccessAction.createAndOpenFileChooser(false, false, title, filter, JFileChooser.FILES_ONLY, "customsettings.lastDirectory"); 74 75 if (fc != null) { 75 76 File sel = fc.getSelectedFile(); -
trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java
r7299 r7578 30 30 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 31 31 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 32 import org.openstreetmap.josm.gui.widgets.FileChooserManager; 32 33 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 33 34 import org.openstreetmap.josm.tools.GBC; … … 60 61 private JCheckBox dynamicButtons = new JCheckBox(tr("Dynamic buttons in side menus")); 61 62 private JCheckBox isoDates = new JCheckBox(tr("Display ISO dates")); 63 private JCheckBox nativeFileChoosers = new JCheckBox(tr("Use native file choosers (nicer, but do not support file filters)")); 62 64 63 65 @Override … … 134 136 panel.add(isoDates, GBC.eop().insets(20, 0, 0, 0)); 135 137 138 nativeFileChoosers.setToolTipText( 139 tr("Use file choosers that behave more like native ones. They look nicer but do not support some features like file filters")); 140 nativeFileChoosers.setSelected(FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG.get()); 141 panel.add(nativeFileChoosers, GBC.eop().insets(20, 0, 0, 0)); 142 136 143 panel.add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0)); 137 144 … … 154 161 Main.pref.put(ToggleDialog.PROP_DYNAMIC_BUTTONS.getKey(), dynamicButtons.isSelected()); 155 162 Main.pref.put(DateUtils.PROP_ISO_DATES.getKey(), isoDates.isSelected()); 163 Main.pref.put(FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG.getKey(), nativeFileChoosers.isSelected()); 156 164 mod |= Main.pref.put("laf", ((LookAndFeelInfo)lafCombo.getSelectedItem()).getClassName()); 157 165 return mod; -
trunk/src/org/openstreetmap/josm/gui/widgets/FileChooserManager.java
r7577 r7578 14 14 import org.openstreetmap.josm.actions.ExtensionFileFilter; 15 15 import org.openstreetmap.josm.actions.SaveActionBase; 16 import org.openstreetmap.josm.data.preferences.BooleanProperty; 16 17 17 18 /** 18 * A chained utility class used to create and open {@link JFileChooser} dialogs.<br>19 * Use only this class if you need to control specifically your JFileChooser dialog.<br>19 * A chained utility class used to create and open {@link AbstractFileChooser} dialogs.<br> 20 * Use only this class if you need to control specifically your AbstractFileChooser dialog.<br> 20 21 * <p> 21 22 * A simpler usage is to call the {@link DiskAccessAction#createAndOpenFileChooser} methods. 22 23 * 23 * @since 5438 24 * @since 5438 (creation) 25 * @since 7578 (rename) 24 26 */ 25 public class JFileChooserManager { 27 public class FileChooserManager { 28 29 /** 30 * Property to enable use of native file dialogs. 31 */ 32 public static final BooleanProperty PROP_USE_NATIVE_FILE_DIALOG = new BooleanProperty("use.native.file.dialog", false); 33 26 34 private final boolean open; 27 35 private final String lastDirProperty; 28 36 private final String curDir; 29 37 30 private JFileChooser fc;31 32 /** 33 * Creates a new {@code JFileChooserManager}.38 private AbstractFileChooser fc; 39 40 /** 41 * Creates a new {@code FileChooserManager}. 34 42 * @param open If true, "Open File" dialogs will be created. If false, "Save File" dialogs will be created. 35 43 * @see #createFileChooser 36 44 */ 37 public JFileChooserManager(boolean open) {45 public FileChooserManager(boolean open) { 38 46 this(open, null); 39 47 } 40 48 41 49 /** 42 * Creates a new {@code JFileChooserManager}.50 * Creates a new {@code FileChooserManager}. 43 51 * @param open If true, "Open File" dialogs will be created. If false, "Save File" dialogs will be created. 44 * @param lastDirProperty The name of the property used to get the last directory. This directory is used to initialize the JFileChooser.52 * @param lastDirProperty The name of the property used to get the last directory. This directory is used to initialize the AbstractFileChooser. 45 53 * Then, if the user effectively chooses a file or a directory, this property will be updated to the directory path. 46 54 * @see #createFileChooser 47 55 */ 48 public JFileChooserManager(boolean open, String lastDirProperty) {56 public FileChooserManager(boolean open, String lastDirProperty) { 49 57 this(open, lastDirProperty, null); 50 58 } 51 59 52 60 /** 53 * Creates a new {@code JFileChooserManager}.61 * Creates a new {@code FileChooserManager}. 54 62 * @param open If true, "Open File" dialogs will be created. If false, "Save File" dialogs will be created. 55 * @param lastDirProperty The name of the property used to get the last directory. This directory is used to initialize the JFileChooser.63 * @param lastDirProperty The name of the property used to get the last directory. This directory is used to initialize the AbstractFileChooser. 56 64 * Then, if the user effectively chooses a file or a directory, this property will be updated to the directory path. 57 * @param defaultDir The default directory used to initialize the JFileChooser if the {@code lastDirProperty} property value is missing.58 * @see #createFileChooser 59 */ 60 public JFileChooserManager(boolean open, String lastDirProperty, String defaultDir) {65 * @param defaultDir The default directory used to initialize the AbstractFileChooser if the {@code lastDirProperty} property value is missing. 66 * @see #createFileChooser 67 */ 68 public FileChooserManager(boolean open, String lastDirProperty, String defaultDir) { 61 69 this.open = open; 62 70 this.lastDirProperty = lastDirProperty == null || lastDirProperty.isEmpty() ? "lastDirectory" : lastDirProperty; … … 67 75 68 76 /** 69 * Replies the {@code JFileChooser} that has been previously created.70 * @return The {@code JFileChooser} that has been previously created, or {@code null} if it has not been created yet.71 * @see #createFileChooser 72 */ 73 public final JFileChooser getFileChooser() {77 * Replies the {@code AbstractFileChooser} that has been previously created. 78 * @return The {@code AbstractFileChooser} that has been previously created, or {@code null} if it has not been created yet. 79 * @see #createFileChooser 80 */ 81 public final AbstractFileChooser getFileChooser() { 74 82 return fc; 75 83 } 76 84 77 85 /** 78 * Replies the initial directory used to construct the {@code JFileChooser}.79 * @return The initial directory used to construct the {@code JFileChooser}.86 * Replies the initial directory used to construct the {@code AbstractFileChooser}. 87 * @return The initial directory used to construct the {@code AbstractFileChooser}. 80 88 */ 81 89 public final String getInitialDirectory() { … … 84 92 85 93 /** 86 * Creates a new {@link JFileChooser} with default settings. All files will be accepted.87 * @return this 88 */ 89 public final JFileChooserManager createFileChooser() {94 * Creates a new {@link AbstractFileChooser} with default settings. All files will be accepted. 95 * @return this 96 */ 97 public final FileChooserManager createFileChooser() { 90 98 return doCreateFileChooser(false, null, null, null, null, JFileChooser.FILES_ONLY, false); 91 99 } 92 100 93 101 /** 94 * Creates a new {@link JFileChooser} with given settings for a single {@code FileFilter}.102 * Creates a new {@link AbstractFileChooser} with given settings for a single {@code FileFilter}. 95 103 * 96 104 * @param multiple If true, makes the dialog allow multiple file selections … … 104 112 * @see DiskAccessAction#createAndOpenFileChooser(boolean, boolean, String, FileFilter, int, String) 105 113 */ 106 public final JFileChooserManager createFileChooser(boolean multiple, String title, FileFilter filter, int selectionMode) {114 public final FileChooserManager createFileChooser(boolean multiple, String title, FileFilter filter, int selectionMode) { 107 115 doCreateFileChooser(multiple, title, Collections.singleton(filter), filter, null, selectionMode, false); 108 116 getFileChooser().setAcceptAllFileFilterUsed(false); … … 111 119 112 120 /** 113 * Creates a new {@link JFileChooser} with given settings for a collection of {@code FileFilter}s.121 * Creates a new {@link AbstractFileChooser} with given settings for a collection of {@code FileFilter}s. 114 122 * 115 123 * @param multiple If true, makes the dialog allow multiple file selections … … 124 132 * @see DiskAccessAction#createAndOpenFileChooser(boolean, boolean, String, Collection, FileFilter, int, String) 125 133 */ 126 public final JFileChooserManager createFileChooser(boolean multiple, String title, Collection<? extends FileFilter> filters, FileFilter defaultFilter, int selectionMode) { 134 public final FileChooserManager createFileChooser(boolean multiple, String title, Collection<? extends FileFilter> filters, 135 FileFilter defaultFilter, int selectionMode) { 127 136 return doCreateFileChooser(multiple, title, filters, defaultFilter, null, selectionMode, false); 128 137 } 129 138 130 139 /** 131 * Creates a new {@link JFileChooser} with given settings for a file extension.140 * Creates a new {@link AbstractFileChooser} with given settings for a file extension. 132 141 * 133 142 * @param multiple If true, makes the dialog allow multiple file selections … … 143 152 * @see DiskAccessAction#createAndOpenFileChooser(boolean, boolean, String, FileFilter, int, String) 144 153 */ 145 public final JFileChooserManager createFileChooser(boolean multiple, String title, String extension, boolean allTypes, int selectionMode) {154 public final FileChooserManager createFileChooser(boolean multiple, String title, String extension, boolean allTypes, int selectionMode) { 146 155 return doCreateFileChooser(multiple, title, null, null, extension, selectionMode, allTypes); 147 156 } 148 157 149 private final JFileChooserManager doCreateFileChooser(boolean multiple, String title, Collection<? extends FileFilter> filters, FileFilter defaultFilter, String extension, int selectionMode, boolean allTypes) { 150 fc = new JFileChooser(new File(curDir)); 158 private final FileChooserManager doCreateFileChooser(boolean multiple, String title, Collection<? extends FileFilter> filters, 159 FileFilter defaultFilter, String extension, int selectionMode, boolean allTypes) { 160 File file = new File(curDir); 161 // Use native dialog is preference is set, unless an unsupported selection mode is specifically wanted 162 if (PROP_USE_NATIVE_FILE_DIALOG.get() && NativeFileChooser.supportsSelectionMode(selectionMode)) { 163 fc = new NativeFileChooser(file); 164 } else { 165 fc = new SwingFileChooser(file); 166 } 167 151 168 if (title != null) { 152 169 fc.setDialogTitle(title); … … 173 190 174 191 /** 175 * Opens the {@code JFileChooser} that has been created. Nothing happens if it has not been created yet.176 * @return the {@code JFileChooser} if the user effectively choses a file or directory. {@code null} if the user cancelled the dialog.177 */ 178 public final JFileChooser openFileChooser() {192 * Opens the {@code AbstractFileChooser} that has been created. Nothing happens if it has not been created yet. 193 * @return the {@code AbstractFileChooser} if the user effectively choses a file or directory. {@code null} if the user cancelled the dialog. 194 */ 195 public final AbstractFileChooser openFileChooser() { 179 196 return openFileChooser(null); 180 197 } 181 198 182 199 /** 183 * Opens the {@code JFileChooser} that has been created and waits for the user to choose a file/directory, or cancel the dialog.<br>200 * Opens the {@code AbstractFileChooser} that has been created and waits for the user to choose a file/directory, or cancel the dialog.<br> 184 201 * Nothing happens if the dialog has not been created yet.<br> 185 202 * When the user choses a file or directory, the {@code lastDirProperty} is updated to the chosen directory path. 186 203 * 187 * @param parent The Component used as the parent of the JFileChooser. If null, uses {@code Main.parent}.188 * @return the {@code JFileChooser} if the user effectively choses a file or directory. {@code null} if the user cancelled the dialog.189 */ 190 public JFileChooser openFileChooser(Component parent) {204 * @param parent The Component used as the parent of the AbstractFileChooser. If null, uses {@code Main.parent}. 205 * @return the {@code AbstractFileChooser} if the user effectively choses a file or directory. {@code null} if the user cancelled the dialog. 206 */ 207 public AbstractFileChooser openFileChooser(Component parent) { 191 208 if (fc != null) { 192 209 if (parent == null) { -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r7082 r7578 26 26 import org.openstreetmap.gui.jmapviewer.FeatureAdapter.TranslationAdapter; 27 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 28 29 29 30 /** … … 641 642 Locale l = Locale.getDefault(); 642 643 644 AbstractFileChooser.setDefaultLocale(l); 643 645 JFileChooser.setDefaultLocale(l); 644 646 JColorChooser.setDefaultLocale(l);
Note:
See TracChangeset
for help on using the changeset viewer.