author | serb |
Fri, 03 Apr 2015 17:17:36 +0300 | |
changeset 29922 | 7b9c1e1532cf |
parent 28556 | cebfefd140cc |
child 31430 | 66b012d00bd3 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
12559
diff
changeset
|
2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.awt.shell; |
|
27 |
||
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
28 |
import java.awt.*; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
29 |
import java.awt.image.BufferedImage; |
2 | 30 |
|
31 |
import java.io.File; |
|
32 |
import java.io.FileNotFoundException; |
|
33 |
import java.io.IOException; |
|
34 |
import java.security.AccessController; |
|
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
35 |
import java.security.PrivilegedAction; |
2 | 36 |
import java.util.*; |
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
37 |
import java.util.List; |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
38 |
import java.util.concurrent.*; |
28546 | 39 |
import java.util.stream.Stream; |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
40 |
|
2 | 41 |
import static sun.awt.shell.Win32ShellFolder2.*; |
42 |
import sun.awt.OSInfo; |
|
24520
e8afd90fcb69
8035169: Move ThreadGroupUtils from the sun.misc package
pchelko
parents:
23900
diff
changeset
|
43 |
import sun.awt.util.ThreadGroupUtils; |
29922 | 44 |
import sun.misc.InnocuousThread; |
2 | 45 |
|
46 |
// NOTE: This class supersedes Win32ShellFolderManager, which was removed |
|
47 |
// from distribution after version 1.4.2. |
|
48 |
||
49 |
/** |
|
50 |
* @author Michael Martak |
|
51 |
* @author Leif Samuelsson |
|
52 |
* @author Kenneth Russell |
|
53 |
* @since 1.4 |
|
54 |
*/ |
|
55 |
||
25209
e9902dc8b9a0
8042094: Test javax/swing/JFileChooser/7036025/bug7036025.java fails with java.lang.NullPointerException on Windows x86
azvegint
parents:
25192
diff
changeset
|
56 |
final class Win32ShellFolderManager2 extends ShellFolderManager { |
2 | 57 |
|
58 |
static { |
|
59 |
// Load library here |
|
23691
475a42c428e0
8035171: KSS: sun.awt.shell.Win32ShellFolderManager2
malenkov
parents:
23010
diff
changeset
|
60 |
sun.awt.windows.WToolkit.loadLibraries(); |
2 | 61 |
} |
62 |
||
63 |
public ShellFolder createShellFolder(File file) throws FileNotFoundException { |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
64 |
try { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
65 |
return createShellFolder(getDesktop(), file); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
66 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
67 |
throw new FileNotFoundException("Execution was interrupted"); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
68 |
} |
2 | 69 |
} |
70 |
||
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
71 |
static Win32ShellFolder2 createShellFolder(Win32ShellFolder2 parent, File file) |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
72 |
throws FileNotFoundException, InterruptedException { |
2 | 73 |
long pIDL; |
74 |
try { |
|
75 |
pIDL = parent.parseDisplayName(file.getCanonicalPath()); |
|
76 |
} catch (IOException ex) { |
|
77 |
pIDL = 0; |
|
78 |
} |
|
79 |
if (pIDL == 0) { |
|
80 |
// Shouldn't happen but watch for it anyway |
|
81 |
throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found"); |
|
82 |
} |
|
4275
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
83 |
|
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
84 |
try { |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
85 |
return createShellFolderFromRelativePIDL(parent, pIDL); |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
86 |
} finally { |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
87 |
Win32ShellFolder2.releasePIDL(pIDL); |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
88 |
} |
2 | 89 |
} |
90 |
||
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
91 |
static Win32ShellFolder2 createShellFolderFromRelativePIDL(Win32ShellFolder2 parent, long pIDL) |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
92 |
throws InterruptedException { |
2 | 93 |
// Walk down this relative pIDL, creating new nodes for each of the entries |
94 |
while (pIDL != 0) { |
|
95 |
long curPIDL = Win32ShellFolder2.copyFirstPIDLEntry(pIDL); |
|
96 |
if (curPIDL != 0) { |
|
97 |
parent = new Win32ShellFolder2(parent, curPIDL); |
|
98 |
pIDL = Win32ShellFolder2.getNextPIDLEntry(pIDL); |
|
99 |
} else { |
|
100 |
// The list is empty if the parent is Desktop and pIDL is a shortcut to Desktop |
|
101 |
break; |
|
102 |
} |
|
103 |
} |
|
104 |
return parent; |
|
105 |
} |
|
106 |
||
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
107 |
private static final int VIEW_LIST = 2; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
108 |
private static final int VIEW_DETAILS = 3; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
109 |
private static final int VIEW_PARENTFOLDER = 8; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
110 |
private static final int VIEW_NEWFOLDER = 11; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
111 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
112 |
private static final Image[] STANDARD_VIEW_BUTTONS = new Image[12]; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
113 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
114 |
private static Image getStandardViewButton(int iconIndex) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
115 |
Image result = STANDARD_VIEW_BUTTONS[iconIndex]; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
116 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
117 |
if (result != null) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
118 |
return result; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
119 |
} |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
120 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
121 |
BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
122 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
123 |
img.setRGB(0, 0, 16, 16, Win32ShellFolder2.getStandardViewButton0(iconIndex), 0, 16); |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
124 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
125 |
STANDARD_VIEW_BUTTONS[iconIndex] = img; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
126 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
127 |
return img; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
128 |
} |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
129 |
|
2 | 130 |
// Special folders |
131 |
private static Win32ShellFolder2 desktop; |
|
132 |
private static Win32ShellFolder2 drives; |
|
133 |
private static Win32ShellFolder2 recent; |
|
134 |
private static Win32ShellFolder2 network; |
|
135 |
private static Win32ShellFolder2 personal; |
|
136 |
||
137 |
static Win32ShellFolder2 getDesktop() { |
|
138 |
if (desktop == null) { |
|
139 |
try { |
|
140 |
desktop = new Win32ShellFolder2(DESKTOP); |
|
25536 | 141 |
} catch (SecurityException e) { |
142 |
// Ignore error |
|
2 | 143 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
144 |
// Ignore error |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
145 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
146 |
// Ignore error |
2 | 147 |
} |
148 |
} |
|
149 |
return desktop; |
|
150 |
} |
|
151 |
||
152 |
static Win32ShellFolder2 getDrives() { |
|
153 |
if (drives == null) { |
|
154 |
try { |
|
155 |
drives = new Win32ShellFolder2(DRIVES); |
|
25536 | 156 |
} catch (SecurityException e) { |
157 |
// Ignore error |
|
2 | 158 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
159 |
// Ignore error |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
160 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
161 |
// Ignore error |
2 | 162 |
} |
163 |
} |
|
164 |
return drives; |
|
165 |
} |
|
166 |
||
167 |
static Win32ShellFolder2 getRecent() { |
|
168 |
if (recent == null) { |
|
169 |
try { |
|
170 |
String path = Win32ShellFolder2.getFileSystemPath(RECENT); |
|
171 |
if (path != null) { |
|
172 |
recent = createShellFolder(getDesktop(), new File(path)); |
|
173 |
} |
|
25536 | 174 |
} catch (SecurityException e) { |
175 |
// Ignore error |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
176 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
177 |
// Ignore error |
2 | 178 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
179 |
// Ignore error |
2 | 180 |
} |
181 |
} |
|
182 |
return recent; |
|
183 |
} |
|
184 |
||
185 |
static Win32ShellFolder2 getNetwork() { |
|
186 |
if (network == null) { |
|
187 |
try { |
|
188 |
network = new Win32ShellFolder2(NETWORK); |
|
25536 | 189 |
} catch (SecurityException e) { |
190 |
// Ignore error |
|
2 | 191 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
192 |
// Ignore error |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
193 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
194 |
// Ignore error |
2 | 195 |
} |
196 |
} |
|
197 |
return network; |
|
198 |
} |
|
199 |
||
200 |
static Win32ShellFolder2 getPersonal() { |
|
201 |
if (personal == null) { |
|
202 |
try { |
|
203 |
String path = Win32ShellFolder2.getFileSystemPath(PERSONAL); |
|
204 |
if (path != null) { |
|
205 |
Win32ShellFolder2 desktop = getDesktop(); |
|
206 |
personal = desktop.getChildByPath(path); |
|
207 |
if (personal == null) { |
|
208 |
personal = createShellFolder(getDesktop(), new File(path)); |
|
209 |
} |
|
210 |
if (personal != null) { |
|
211 |
personal.setIsPersonal(); |
|
212 |
} |
|
213 |
} |
|
25536 | 214 |
} catch (SecurityException e) { |
215 |
// Ignore error |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
216 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
217 |
// Ignore error |
2 | 218 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
219 |
// Ignore error |
2 | 220 |
} |
221 |
} |
|
222 |
return personal; |
|
223 |
} |
|
224 |
||
225 |
||
226 |
private static File[] roots; |
|
227 |
||
228 |
/** |
|
229 |
* @param key a <code>String</code> |
|
230 |
* "fileChooserDefaultFolder": |
|
231 |
* Returns a <code>File</code> - the default shellfolder for a new filechooser |
|
232 |
* "roots": |
|
233 |
* Returns a <code>File[]</code> - containing the root(s) of the displayable hierarchy |
|
234 |
* "fileChooserComboBoxFolders": |
|
235 |
* Returns a <code>File[]</code> - an array of shellfolders representing the list to |
|
236 |
* show by default in the file chooser's combobox |
|
237 |
* "fileChooserShortcutPanelFolders": |
|
238 |
* Returns a <code>File[]</code> - an array of shellfolders representing well-known |
|
239 |
* folders, such as Desktop, Documents, History, Network, Home, etc. |
|
240 |
* This is used in the shortcut panel of the filechooser on Windows 2000 |
|
241 |
* and Windows Me. |
|
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
242 |
* "fileChooserIcon <icon>": |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
243 |
* Returns an <code>Image</code> - icon can be ListView, DetailsView, UpFolder, NewFolder or |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
244 |
* ViewMenu (Windows only). |
2 | 245 |
* "optionPaneIcon iconName": |
246 |
* Returns an <code>Image</code> - icon from the system icon list |
|
247 |
* |
|
248 |
* @return An Object matching the key string. |
|
249 |
*/ |
|
250 |
public Object get(String key) { |
|
251 |
if (key.equals("fileChooserDefaultFolder")) { |
|
252 |
File file = getPersonal(); |
|
253 |
if (file == null) { |
|
254 |
file = getDesktop(); |
|
255 |
} |
|
28546 | 256 |
return checkFile(file); |
2 | 257 |
} else if (key.equals("roots")) { |
258 |
// Should be "History" and "Desktop" ? |
|
259 |
if (roots == null) { |
|
260 |
File desktop = getDesktop(); |
|
261 |
if (desktop != null) { |
|
262 |
roots = new File[] { desktop }; |
|
263 |
} else { |
|
264 |
roots = (File[])super.get(key); |
|
265 |
} |
|
266 |
} |
|
28546 | 267 |
return checkFiles(roots); |
2 | 268 |
} else if (key.equals("fileChooserComboBoxFolders")) { |
269 |
Win32ShellFolder2 desktop = getDesktop(); |
|
270 |
||
28546 | 271 |
if (desktop != null && checkFile(desktop) != null) { |
2 | 272 |
ArrayList<File> folders = new ArrayList<File>(); |
273 |
Win32ShellFolder2 drives = getDrives(); |
|
274 |
||
275 |
Win32ShellFolder2 recentFolder = getRecent(); |
|
276 |
if (recentFolder != null && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_2000) >= 0) { |
|
277 |
folders.add(recentFolder); |
|
278 |
} |
|
279 |
||
280 |
folders.add(desktop); |
|
281 |
// Add all second level folders |
|
28556
cebfefd140cc
8062561: Test bug8055304 fails if file system default directory has read access
alexsch
parents:
28546
diff
changeset
|
282 |
File[] secondLevelFolders = checkFiles(desktop.listFiles()); |
2 | 283 |
Arrays.sort(secondLevelFolders); |
284 |
for (File secondLevelFolder : secondLevelFolders) { |
|
285 |
Win32ShellFolder2 folder = (Win32ShellFolder2) secondLevelFolder; |
|
4271
35fc7add4925
6550546: Win LAF: JFileChooser -> Look in Drop down should not display any shortcuts created on desktop
rupashka
parents:
3978
diff
changeset
|
286 |
if (!folder.isFileSystem() || (folder.isDirectory() && !folder.isLink())) { |
2 | 287 |
folders.add(folder); |
288 |
// Add third level for "My Computer" |
|
289 |
if (folder.equals(drives)) { |
|
28556
cebfefd140cc
8062561: Test bug8055304 fails if file system default directory has read access
alexsch
parents:
28546
diff
changeset
|
290 |
File[] thirdLevelFolders = checkFiles(folder.listFiles()); |
678
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
291 |
if (thirdLevelFolders != null && thirdLevelFolders.length > 0) { |
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
292 |
List<File> thirdLevelFoldersList = Arrays.asList(thirdLevelFolders); |
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
293 |
|
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
294 |
folder.sortChildren(thirdLevelFoldersList); |
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
295 |
folders.addAll(thirdLevelFoldersList); |
2 | 296 |
} |
297 |
} |
|
298 |
} |
|
299 |
} |
|
28546 | 300 |
return checkFiles(folders); |
2 | 301 |
} else { |
302 |
return super.get(key); |
|
303 |
} |
|
304 |
} else if (key.equals("fileChooserShortcutPanelFolders")) { |
|
305 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
|
306 |
ArrayList<File> folders = new ArrayList<File>(); |
|
307 |
int i = 0; |
|
308 |
Object value; |
|
309 |
do { |
|
310 |
value = toolkit.getDesktopProperty("win.comdlg.placesBarPlace" + i++); |
|
311 |
try { |
|
312 |
if (value instanceof Integer) { |
|
313 |
// A CSIDL |
|
314 |
folders.add(new Win32ShellFolder2((Integer)value)); |
|
315 |
} else if (value instanceof String) { |
|
316 |
// A path |
|
317 |
folders.add(createShellFolder(new File((String)value))); |
|
318 |
} |
|
319 |
} catch (IOException e) { |
|
320 |
// Skip this value |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
321 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
322 |
// Return empty result |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
323 |
return new File[0]; |
2 | 324 |
} |
325 |
} while (value != null); |
|
326 |
||
327 |
if (folders.size() == 0) { |
|
328 |
// Use default list of places |
|
329 |
for (File f : new File[] { |
|
330 |
getRecent(), getDesktop(), getPersonal(), getDrives(), getNetwork() |
|
331 |
}) { |
|
332 |
if (f != null) { |
|
333 |
folders.add(f); |
|
334 |
} |
|
335 |
} |
|
336 |
} |
|
28546 | 337 |
return checkFiles(folders); |
2 | 338 |
} else if (key.startsWith("fileChooserIcon ")) { |
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
339 |
String name = key.substring(key.indexOf(" ") + 1); |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
340 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
341 |
int iconIndex; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
342 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
343 |
if (name.equals("ListView") || name.equals("ViewMenu")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
344 |
iconIndex = VIEW_LIST; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
345 |
} else if (name.equals("DetailsView")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
346 |
iconIndex = VIEW_DETAILS; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
347 |
} else if (name.equals("UpFolder")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
348 |
iconIndex = VIEW_PARENTFOLDER; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
349 |
} else if (name.equals("NewFolder")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
350 |
iconIndex = VIEW_NEWFOLDER; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
351 |
} else { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
352 |
return null; |
2 | 353 |
} |
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
354 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
355 |
return getStandardViewButton(iconIndex); |
2 | 356 |
} else if (key.startsWith("optionPaneIcon ")) { |
357 |
Win32ShellFolder2.SystemIcon iconType; |
|
358 |
if (key == "optionPaneIcon Error") { |
|
359 |
iconType = Win32ShellFolder2.SystemIcon.IDI_ERROR; |
|
360 |
} else if (key == "optionPaneIcon Information") { |
|
361 |
iconType = Win32ShellFolder2.SystemIcon.IDI_INFORMATION; |
|
362 |
} else if (key == "optionPaneIcon Question") { |
|
363 |
iconType = Win32ShellFolder2.SystemIcon.IDI_QUESTION; |
|
364 |
} else if (key == "optionPaneIcon Warning") { |
|
365 |
iconType = Win32ShellFolder2.SystemIcon.IDI_EXCLAMATION; |
|
366 |
} else { |
|
367 |
return null; |
|
368 |
} |
|
369 |
return Win32ShellFolder2.getSystemIcon(iconType); |
|
454
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
370 |
} else if (key.startsWith("shell32Icon ") || key.startsWith("shell32LargeIcon ")) { |
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
371 |
String name = key.substring(key.indexOf(" ") + 1); |
2 | 372 |
try { |
454
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
373 |
int i = Integer.parseInt(name); |
2 | 374 |
if (i >= 0) { |
454
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
375 |
return Win32ShellFolder2.getShell32Icon(i, key.startsWith("shell32LargeIcon ")); |
2 | 376 |
} |
377 |
} catch (NumberFormatException ex) { |
|
378 |
} |
|
379 |
} |
|
380 |
return null; |
|
381 |
} |
|
382 |
||
28546 | 383 |
private File checkFile(File file) { |
384 |
SecurityManager sm = System.getSecurityManager(); |
|
385 |
return (sm == null || file == null) ? file : checkFile(file, sm); |
|
386 |
} |
|
387 |
||
388 |
private File checkFile(File file, SecurityManager sm) { |
|
389 |
try { |
|
390 |
sm.checkRead(file.getPath()); |
|
391 |
return file; |
|
392 |
} catch (SecurityException se) { |
|
393 |
return null; |
|
394 |
} |
|
395 |
} |
|
396 |
||
397 |
private File[] checkFiles(File[] files) { |
|
398 |
SecurityManager sm = System.getSecurityManager(); |
|
399 |
if (sm == null || files == null || files.length == 0) { |
|
400 |
return files; |
|
401 |
} |
|
402 |
return checkFiles(Arrays.stream(files), sm); |
|
403 |
} |
|
404 |
||
405 |
private File[] checkFiles(List<File> files) { |
|
406 |
SecurityManager sm = System.getSecurityManager(); |
|
407 |
if (sm == null || files.isEmpty()) { |
|
408 |
return files.toArray(new File[files.size()]); |
|
409 |
} |
|
410 |
return checkFiles(files.stream(), sm); |
|
411 |
} |
|
412 |
||
413 |
private File[] checkFiles(Stream<File> filesStream, SecurityManager sm) { |
|
414 |
return filesStream.filter((file) -> checkFile(file, sm) != null) |
|
415 |
.toArray(File[]::new); |
|
416 |
} |
|
417 |
||
2 | 418 |
/** |
419 |
* Does <code>dir</code> represent a "computer" such as a node on the network, or |
|
420 |
* "My Computer" on the desktop. |
|
421 |
*/ |
|
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
422 |
public boolean isComputerNode(final File dir) { |
2 | 423 |
if (dir != null && dir == getDrives()) { |
424 |
return true; |
|
425 |
} else { |
|
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
426 |
String path = AccessController.doPrivileged(new PrivilegedAction<String>() { |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
427 |
public String run() { |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
428 |
return dir.getAbsolutePath(); |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
429 |
} |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
430 |
}); |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
431 |
|
2 | 432 |
return (path.startsWith("\\\\") && path.indexOf("\\", 2) < 0); //Network path |
433 |
} |
|
434 |
} |
|
435 |
||
436 |
public boolean isFileSystemRoot(File dir) { |
|
437 |
//Note: Removable drives don't "exist" but are listed in "My Computer" |
|
438 |
if (dir != null) { |
|
439 |
Win32ShellFolder2 drives = getDrives(); |
|
440 |
if (dir instanceof Win32ShellFolder2) { |
|
441 |
Win32ShellFolder2 sf = (Win32ShellFolder2)dir; |
|
442 |
if (sf.isFileSystem()) { |
|
443 |
if (sf.parent != null) { |
|
444 |
return sf.parent.equals(drives); |
|
445 |
} |
|
446 |
// else fall through ... |
|
447 |
} else { |
|
448 |
return false; |
|
449 |
} |
|
450 |
} |
|
451 |
String path = dir.getPath(); |
|
5448
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
452 |
|
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
453 |
if (path.length() != 3 || path.charAt(1) != ':') { |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
454 |
return false; |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
455 |
} |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
456 |
|
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
457 |
File[] files = drives.listFiles(); |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
458 |
|
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
459 |
return files != null && Arrays.asList(files).contains(dir); |
2 | 460 |
} |
461 |
return false; |
|
462 |
} |
|
463 |
||
25192
4e2dc0f8702d
8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents:
24520
diff
changeset
|
464 |
private static List<Win32ShellFolder2> topFolderList = null; |
2 | 465 |
static int compareShellFolders(Win32ShellFolder2 sf1, Win32ShellFolder2 sf2) { |
466 |
boolean special1 = sf1.isSpecial(); |
|
467 |
boolean special2 = sf2.isSpecial(); |
|
468 |
||
469 |
if (special1 || special2) { |
|
470 |
if (topFolderList == null) { |
|
25192
4e2dc0f8702d
8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents:
24520
diff
changeset
|
471 |
ArrayList<Win32ShellFolder2> tmpTopFolderList = new ArrayList<>(); |
2 | 472 |
tmpTopFolderList.add(Win32ShellFolderManager2.getPersonal()); |
473 |
tmpTopFolderList.add(Win32ShellFolderManager2.getDesktop()); |
|
474 |
tmpTopFolderList.add(Win32ShellFolderManager2.getDrives()); |
|
475 |
tmpTopFolderList.add(Win32ShellFolderManager2.getNetwork()); |
|
476 |
topFolderList = tmpTopFolderList; |
|
477 |
} |
|
478 |
int i1 = topFolderList.indexOf(sf1); |
|
479 |
int i2 = topFolderList.indexOf(sf2); |
|
480 |
if (i1 >= 0 && i2 >= 0) { |
|
481 |
return (i1 - i2); |
|
482 |
} else if (i1 >= 0) { |
|
483 |
return -1; |
|
484 |
} else if (i2 >= 0) { |
|
485 |
return 1; |
|
486 |
} |
|
487 |
} |
|
488 |
||
489 |
// Non-file shellfolders sort before files |
|
490 |
if (special1 && !special2) { |
|
491 |
return -1; |
|
492 |
} else if (special2 && !special1) { |
|
493 |
return 1; |
|
494 |
} |
|
495 |
||
496 |
return compareNames(sf1.getAbsolutePath(), sf2.getAbsolutePath()); |
|
497 |
} |
|
498 |
||
499 |
static int compareNames(String name1, String name2) { |
|
500 |
// First ignore case when comparing |
|
678
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
501 |
int diff = name1.compareToIgnoreCase(name2); |
2 | 502 |
if (diff != 0) { |
503 |
return diff; |
|
504 |
} else { |
|
505 |
// May differ in case (e.g. "mail" vs. "Mail") |
|
506 |
// We need this test for consistent sorting |
|
507 |
return name1.compareTo(name2); |
|
508 |
} |
|
509 |
} |
|
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
510 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
511 |
@Override |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
512 |
protected Invoker createInvoker() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
513 |
return new ComInvoker(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
514 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
515 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
516 |
private static class ComInvoker extends ThreadPoolExecutor implements ThreadFactory, ShellFolder.Invoker { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
517 |
private static Thread comThread; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
518 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
519 |
private ComInvoker() { |
29922 | 520 |
super(1, 1, 0, TimeUnit.DAYS, new LinkedBlockingQueue<>()); |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
521 |
allowCoreThreadTimeOut(false); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
522 |
setThreadFactory(this); |
29922 | 523 |
final Runnable shutdownHook = () -> AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
524 |
shutdownNow(); |
|
525 |
return null; |
|
526 |
}); |
|
527 |
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
|
528 |
Thread t; |
|
529 |
if (System.getSecurityManager() == null) { |
|
530 |
t = new Thread(ThreadGroupUtils.getRootThreadGroup(), shutdownHook); |
|
531 |
} else { |
|
532 |
t = new InnocuousThread(shutdownHook); |
|
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
533 |
} |
29922 | 534 |
Runtime.getRuntime().addShutdownHook(t); |
535 |
return null; |
|
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
536 |
}); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
537 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
538 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
539 |
public synchronized Thread newThread(final Runnable task) { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
540 |
final Runnable comRun = new Runnable() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
541 |
public void run() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
542 |
try { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
543 |
initializeCom(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
544 |
task.run(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
545 |
} finally { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
546 |
uninitializeCom(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
547 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
548 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
549 |
}; |
29922 | 550 |
comThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> { |
551 |
String name = "Swing-Shell"; |
|
552 |
Thread thread; |
|
553 |
if (System.getSecurityManager() == null) { |
|
554 |
/* The thread must be a member of a thread group |
|
555 |
* which will not get GCed before VM exit. |
|
556 |
* Make its parent the top-level thread group. |
|
557 |
*/ |
|
558 |
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), comRun, name); |
|
559 |
} else { |
|
560 |
/* InnocuousThread is a member of a correct TG by default */ |
|
561 |
thread = new InnocuousThread(comRun, name); |
|
562 |
} |
|
563 |
thread.setDaemon(true); |
|
564 |
return thread; |
|
565 |
}); |
|
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
566 |
return comThread; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
567 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
568 |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
569 |
public <T> T invoke(Callable<T> task) throws Exception { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
570 |
if (Thread.currentThread() == comThread) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
571 |
// if it's already called from the COM |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
572 |
// thread, we don't need to delegate the task |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
573 |
return task.call(); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
574 |
} else { |
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
575 |
final Future<T> future; |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
576 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
577 |
try { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
578 |
future = submit(task); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
579 |
} catch (RejectedExecutionException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
580 |
throw new InterruptedException(e.getMessage()); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
581 |
} |
2817
f171f2417978
6713352: Deadlock in JFileChooser with synchronized custom FileSystemView
rupashka
parents:
2489
diff
changeset
|
582 |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
583 |
try { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
584 |
return future.get(); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
585 |
} catch (InterruptedException e) { |
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
586 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
587 |
public Void run() { |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
588 |
future.cancel(true); |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
589 |
|
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
590 |
return null; |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
591 |
} |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
592 |
}); |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
593 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
594 |
throw e; |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
595 |
} catch (ExecutionException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
596 |
Throwable cause = e.getCause(); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
597 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
598 |
if (cause instanceof Exception) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
599 |
throw (Exception) cause; |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
600 |
} |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
601 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
602 |
if (cause instanceof Error) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
603 |
throw (Error) cause; |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
604 |
} |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
605 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
606 |
throw new RuntimeException("Unexpected error", cause); |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
607 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
608 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
609 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
610 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
611 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
612 |
static native void initializeCom(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
613 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
614 |
static native void uninitializeCom(); |
2 | 615 |
} |