-
Notifications
You must be signed in to change notification settings - Fork 145
Suggest-name option in file-chooser #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iref
wants to merge
4
commits into
clj-commons:develop
Choose a base branch
from
iref:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
50f718b
#156 Add suggest-name option to file chooser
iref 2cda9e0
Merge branch 'develop' of github.com:iref/seesaw into develop
iref 80f6a16
Change option suggest-name name to selected-file and allow file as se…
iref 15dec6a
Add file chooser examples
iref File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,11 +72,15 @@ | |
| (default-option :dir | ||
| (fn [^JFileChooser chooser dir] | ||
| (.setCurrentDirectory chooser (if (instance? java.io.File dir) dir | ||
| (java.io.File. (str dir)))))) | ||
| (java.io.File. (str dir)))))) | ||
| (bean-option [:multi? :multi-selection-enabled] JFileChooser boolean) | ||
| (bean-option [:selection-mode :file-selection-mode] JFileChooser file-selection-modes) | ||
| (default-option :filters set-file-filters) | ||
| (bean-option [:all-files? :accept-all-file-filter-used] JFileChooser boolean))) | ||
| (bean-option [:all-files? :accept-all-file-filter-used] JFileChooser boolean) | ||
| (default-option :suggest-name | ||
| (fn [^JFileChooser chooser suggest-name] | ||
| (.setSelectedFile chooser (java.io.File. (str suggest-name))))))) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd allow the name to be either a |
||
|
|
||
|
|
||
| (option-provider JFileChooser file-chooser-options) | ||
|
|
||
|
|
@@ -147,6 +151,8 @@ | |
| :cancel-fn Function which will be called with the JFileChooser on user abort of the dialog. | ||
| Its result will be returned. Default: returns nil. | ||
|
|
||
| :suggest-name The default name of file. | ||
|
|
||
| Examples: | ||
|
|
||
| ; ask & return single file | ||
|
|
@@ -168,11 +174,12 @@ | |
| See http://download.oracle.com/javase/6/docs/api/javax/swing/JFileChooser.html | ||
| " | ||
| [& args] | ||
| (let [[parent & {:keys [type remember-directory? success-fn cancel-fn] | ||
| :or {type :open | ||
| (let [[parent & {:keys [type remember-directory? success-fn cancel-fn suggest-name] | ||
| :or {type :open | ||
| remember-directory? true | ||
| success-fn (fn [fc files] files) | ||
| cancel-fn (fn [fc])} | ||
| cancel-fn (fn [fc]) | ||
| suggest-name ""} | ||
| :as opts}] (if (keyword? (first args)) (cons nil args) args) | ||
| parent (if (keyword? parent) nil parent) | ||
| ^JFileChooser chooser (configure-file-chooser | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
:selected-filebe a better name since this can also be used to set the initial selection to an existing file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Especially if it should also accept
java.io.File.