Commit 4929dde
committed
Bring back file URI support in open dialog
Before some of my older refactoring changes, FilePathPreProcessor was
used to allow to open "file:" URIs and to also decode URL-encoded file
names. But I've removed it in the Open dialog, as it was pretty hacky
and could result in not opening files in some cases.
So I've made some changes to the FilePathPreProcessor:
* If a file exists on disk at the specified path, no conversion happens.
* URL-decoding of paths only happens, if no file at the original path
exists and there is a file at the decoded path.
* File URI handling is now done via the URI and File classes, which
should make it more robust.
With that in mind, there was still a problem with the Open dialog.
JFileChooser only returns a File, not the path provided in the dialog.
And there doesn't seem to be a way to get it without UI class hackery.
In the original implementation it searched for "file:" within the path
and discarded everything before it. This comes from the fact, that if,
for example, you put "file:///C:/3142b600.pdf" in the dialog, you would
get something like this from the File API:
"C:\selected_dir\file:\C:\3142b600.pdf"
To handle this in a less hacky way, there is an EnhancedFileSystemView
now, which is passed to the JFileChooser. It just wraps the original
FileSystemView, but in the File creation methods, which involve String
file names or paths (createFileObject, getChild), they now go through
the FilePathPreProcessor. This way all the path transformation will
happen before File conversion, which is much cleaner.1 parent 984f9e0 commit 4929dde
File tree
7 files changed
+1179
-117
lines changed- src
- main/java/com/itextpdf/rups
- io
- model
- view
- test/java/com/itextpdf/rups
- mock
- model
- view
7 files changed
+1179
-117
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
87 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | | - | |
100 | | - | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | | - | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
Lines changed: 128 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
50 | 61 | | |
51 | 62 | | |
52 | | - | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
60 | 80 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
65 | 84 | | |
66 | | - | |
67 | | - | |
68 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
69 | 89 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
73 | 95 | | |
74 | | - | |
| 96 | + | |
| 97 | + | |
75 | 98 | | |
76 | 99 | | |
77 | | - | |
78 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
79 | 130 | | |
80 | | - | |
81 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
82 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
0 commit comments