Changeset 7578 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2014-09-22T22:00:21+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 6 edited
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) {
Note:
See TracChangeset
for help on using the changeset viewer.