author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 25536 | jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java@a1ba79d447e0 |
child 28546 | 47d9b4eb8fad |
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.*; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
39 |
|
2 | 40 |
import static sun.awt.shell.Win32ShellFolder2.*; |
41 |
import sun.awt.OSInfo; |
|
24520
e8afd90fcb69
8035169: Move ThreadGroupUtils from the sun.misc package
pchelko
parents:
23900
diff
changeset
|
42 |
import sun.awt.util.ThreadGroupUtils; |
2 | 43 |
|
44 |
// NOTE: This class supersedes Win32ShellFolderManager, which was removed |
|
45 |
// from distribution after version 1.4.2. |
|
46 |
||
47 |
/** |
|
48 |
* @author Michael Martak |
|
49 |
* @author Leif Samuelsson |
|
50 |
* @author Kenneth Russell |
|
51 |
* @since 1.4 |
|
52 |
*/ |
|
53 |
||
25209
e9902dc8b9a0
8042094: Test javax/swing/JFileChooser/7036025/bug7036025.java fails with java.lang.NullPointerException on Windows x86
azvegint
parents:
25192
diff
changeset
|
54 |
final class Win32ShellFolderManager2 extends ShellFolderManager { |
2 | 55 |
|
56 |
static { |
|
57 |
// Load library here |
|
23691
475a42c428e0
8035171: KSS: sun.awt.shell.Win32ShellFolderManager2
malenkov
parents:
23010
diff
changeset
|
58 |
sun.awt.windows.WToolkit.loadLibraries(); |
2 | 59 |
} |
60 |
||
61 |
public ShellFolder createShellFolder(File file) throws FileNotFoundException { |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
62 |
try { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
63 |
return createShellFolder(getDesktop(), file); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
64 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
65 |
throw new FileNotFoundException("Execution was interrupted"); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
66 |
} |
2 | 67 |
} |
68 |
||
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
69 |
static Win32ShellFolder2 createShellFolder(Win32ShellFolder2 parent, File file) |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
70 |
throws FileNotFoundException, InterruptedException { |
2 | 71 |
long pIDL; |
72 |
try { |
|
73 |
pIDL = parent.parseDisplayName(file.getCanonicalPath()); |
|
74 |
} catch (IOException ex) { |
|
75 |
pIDL = 0; |
|
76 |
} |
|
77 |
if (pIDL == 0) { |
|
78 |
// Shouldn't happen but watch for it anyway |
|
79 |
throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found"); |
|
80 |
} |
|
4275
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
81 |
|
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
82 |
try { |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
83 |
return createShellFolderFromRelativePIDL(parent, pIDL); |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
84 |
} finally { |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
85 |
Win32ShellFolder2.releasePIDL(pIDL); |
4c3444f1b9d8
6621569: Win32ShellFolder2 and Win32ShellFolderManager2 may leak native resources
rupashka
parents:
4271
diff
changeset
|
86 |
} |
2 | 87 |
} |
88 |
||
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
89 |
static Win32ShellFolder2 createShellFolderFromRelativePIDL(Win32ShellFolder2 parent, long pIDL) |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
90 |
throws InterruptedException { |
2 | 91 |
// Walk down this relative pIDL, creating new nodes for each of the entries |
92 |
while (pIDL != 0) { |
|
93 |
long curPIDL = Win32ShellFolder2.copyFirstPIDLEntry(pIDL); |
|
94 |
if (curPIDL != 0) { |
|
95 |
parent = new Win32ShellFolder2(parent, curPIDL); |
|
96 |
pIDL = Win32ShellFolder2.getNextPIDLEntry(pIDL); |
|
97 |
} else { |
|
98 |
// The list is empty if the parent is Desktop and pIDL is a shortcut to Desktop |
|
99 |
break; |
|
100 |
} |
|
101 |
} |
|
102 |
return parent; |
|
103 |
} |
|
104 |
||
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
110 |
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
|
111 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
112 |
private static Image getStandardViewButton(int iconIndex) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
113 |
Image result = STANDARD_VIEW_BUTTONS[iconIndex]; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
114 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
115 |
if (result != null) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
116 |
return result; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
117 |
} |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
118 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
119 |
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
|
120 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
121 |
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
|
122 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
123 |
STANDARD_VIEW_BUTTONS[iconIndex] = img; |
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 |
return 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 |
|
2 | 128 |
// Special folders |
129 |
private static Win32ShellFolder2 desktop; |
|
130 |
private static Win32ShellFolder2 drives; |
|
131 |
private static Win32ShellFolder2 recent; |
|
132 |
private static Win32ShellFolder2 network; |
|
133 |
private static Win32ShellFolder2 personal; |
|
134 |
||
135 |
static Win32ShellFolder2 getDesktop() { |
|
136 |
if (desktop == null) { |
|
137 |
try { |
|
138 |
desktop = new Win32ShellFolder2(DESKTOP); |
|
25536 | 139 |
} catch (SecurityException e) { |
140 |
// Ignore error |
|
2 | 141 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
142 |
// Ignore error |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
143 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
144 |
// Ignore error |
2 | 145 |
} |
146 |
} |
|
147 |
return desktop; |
|
148 |
} |
|
149 |
||
150 |
static Win32ShellFolder2 getDrives() { |
|
151 |
if (drives == null) { |
|
152 |
try { |
|
153 |
drives = new Win32ShellFolder2(DRIVES); |
|
25536 | 154 |
} catch (SecurityException e) { |
155 |
// Ignore error |
|
2 | 156 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
157 |
// Ignore error |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
158 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
159 |
// Ignore error |
2 | 160 |
} |
161 |
} |
|
162 |
return drives; |
|
163 |
} |
|
164 |
||
165 |
static Win32ShellFolder2 getRecent() { |
|
166 |
if (recent == null) { |
|
167 |
try { |
|
168 |
String path = Win32ShellFolder2.getFileSystemPath(RECENT); |
|
169 |
if (path != null) { |
|
170 |
recent = createShellFolder(getDesktop(), new File(path)); |
|
171 |
} |
|
25536 | 172 |
} catch (SecurityException e) { |
173 |
// Ignore error |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
174 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
175 |
// Ignore error |
2 | 176 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
177 |
// Ignore error |
2 | 178 |
} |
179 |
} |
|
180 |
return recent; |
|
181 |
} |
|
182 |
||
183 |
static Win32ShellFolder2 getNetwork() { |
|
184 |
if (network == null) { |
|
185 |
try { |
|
186 |
network = new Win32ShellFolder2(NETWORK); |
|
25536 | 187 |
} catch (SecurityException e) { |
188 |
// Ignore error |
|
2 | 189 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
190 |
// Ignore error |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
191 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
192 |
// Ignore error |
2 | 193 |
} |
194 |
} |
|
195 |
return network; |
|
196 |
} |
|
197 |
||
198 |
static Win32ShellFolder2 getPersonal() { |
|
199 |
if (personal == null) { |
|
200 |
try { |
|
201 |
String path = Win32ShellFolder2.getFileSystemPath(PERSONAL); |
|
202 |
if (path != null) { |
|
203 |
Win32ShellFolder2 desktop = getDesktop(); |
|
204 |
personal = desktop.getChildByPath(path); |
|
205 |
if (personal == null) { |
|
206 |
personal = createShellFolder(getDesktop(), new File(path)); |
|
207 |
} |
|
208 |
if (personal != null) { |
|
209 |
personal.setIsPersonal(); |
|
210 |
} |
|
211 |
} |
|
25536 | 212 |
} catch (SecurityException e) { |
213 |
// Ignore error |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
214 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
215 |
// Ignore error |
2 | 216 |
} catch (IOException e) { |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
217 |
// Ignore error |
2 | 218 |
} |
219 |
} |
|
220 |
return personal; |
|
221 |
} |
|
222 |
||
223 |
||
224 |
private static File[] roots; |
|
225 |
||
226 |
/** |
|
227 |
* @param key a <code>String</code> |
|
228 |
* "fileChooserDefaultFolder": |
|
229 |
* Returns a <code>File</code> - the default shellfolder for a new filechooser |
|
230 |
* "roots": |
|
231 |
* Returns a <code>File[]</code> - containing the root(s) of the displayable hierarchy |
|
232 |
* "fileChooserComboBoxFolders": |
|
233 |
* Returns a <code>File[]</code> - an array of shellfolders representing the list to |
|
234 |
* show by default in the file chooser's combobox |
|
235 |
* "fileChooserShortcutPanelFolders": |
|
236 |
* Returns a <code>File[]</code> - an array of shellfolders representing well-known |
|
237 |
* folders, such as Desktop, Documents, History, Network, Home, etc. |
|
238 |
* This is used in the shortcut panel of the filechooser on Windows 2000 |
|
239 |
* and Windows Me. |
|
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
240 |
* "fileChooserIcon <icon>": |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
241 |
* 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
|
242 |
* ViewMenu (Windows only). |
2 | 243 |
* "optionPaneIcon iconName": |
244 |
* Returns an <code>Image</code> - icon from the system icon list |
|
245 |
* |
|
246 |
* @return An Object matching the key string. |
|
247 |
*/ |
|
248 |
public Object get(String key) { |
|
249 |
if (key.equals("fileChooserDefaultFolder")) { |
|
250 |
File file = getPersonal(); |
|
251 |
if (file == null) { |
|
252 |
file = getDesktop(); |
|
253 |
} |
|
254 |
return file; |
|
255 |
} else if (key.equals("roots")) { |
|
256 |
// Should be "History" and "Desktop" ? |
|
257 |
if (roots == null) { |
|
258 |
File desktop = getDesktop(); |
|
259 |
if (desktop != null) { |
|
260 |
roots = new File[] { desktop }; |
|
261 |
} else { |
|
262 |
roots = (File[])super.get(key); |
|
263 |
} |
|
264 |
} |
|
265 |
return roots; |
|
266 |
} else if (key.equals("fileChooserComboBoxFolders")) { |
|
267 |
Win32ShellFolder2 desktop = getDesktop(); |
|
268 |
||
269 |
if (desktop != null) { |
|
270 |
ArrayList<File> folders = new ArrayList<File>(); |
|
271 |
Win32ShellFolder2 drives = getDrives(); |
|
272 |
||
273 |
Win32ShellFolder2 recentFolder = getRecent(); |
|
274 |
if (recentFolder != null && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_2000) >= 0) { |
|
275 |
folders.add(recentFolder); |
|
276 |
} |
|
277 |
||
278 |
folders.add(desktop); |
|
279 |
// Add all second level folders |
|
280 |
File[] secondLevelFolders = desktop.listFiles(); |
|
281 |
Arrays.sort(secondLevelFolders); |
|
282 |
for (File secondLevelFolder : secondLevelFolders) { |
|
283 |
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
|
284 |
if (!folder.isFileSystem() || (folder.isDirectory() && !folder.isLink())) { |
2 | 285 |
folders.add(folder); |
286 |
// Add third level for "My Computer" |
|
287 |
if (folder.equals(drives)) { |
|
288 |
File[] thirdLevelFolders = 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
|
289 |
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
|
290 |
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
|
291 |
|
7d331a53a753
6571802: 'Shared Documents' listed in-between C,D drives in the JFileChooser, does not match with native
rupashka
parents:
454
diff
changeset
|
292 |
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
|
293 |
folders.addAll(thirdLevelFoldersList); |
2 | 294 |
} |
295 |
} |
|
296 |
} |
|
297 |
} |
|
298 |
return folders.toArray(new File[folders.size()]); |
|
299 |
} else { |
|
300 |
return super.get(key); |
|
301 |
} |
|
302 |
} else if (key.equals("fileChooserShortcutPanelFolders")) { |
|
303 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
|
304 |
ArrayList<File> folders = new ArrayList<File>(); |
|
305 |
int i = 0; |
|
306 |
Object value; |
|
307 |
do { |
|
308 |
value = toolkit.getDesktopProperty("win.comdlg.placesBarPlace" + i++); |
|
309 |
try { |
|
310 |
if (value instanceof Integer) { |
|
311 |
// A CSIDL |
|
312 |
folders.add(new Win32ShellFolder2((Integer)value)); |
|
313 |
} else if (value instanceof String) { |
|
314 |
// A path |
|
315 |
folders.add(createShellFolder(new File((String)value))); |
|
316 |
} |
|
317 |
} catch (IOException e) { |
|
318 |
// Skip this value |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
319 |
} catch (InterruptedException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
320 |
// Return empty result |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
321 |
return new File[0]; |
2 | 322 |
} |
323 |
} while (value != null); |
|
324 |
||
325 |
if (folders.size() == 0) { |
|
326 |
// Use default list of places |
|
327 |
for (File f : new File[] { |
|
328 |
getRecent(), getDesktop(), getPersonal(), getDrives(), getNetwork() |
|
329 |
}) { |
|
330 |
if (f != null) { |
|
331 |
folders.add(f); |
|
332 |
} |
|
333 |
} |
|
334 |
} |
|
335 |
return folders.toArray(new File[folders.size()]); |
|
336 |
} else if (key.startsWith("fileChooserIcon ")) { |
|
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
337 |
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
|
338 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
339 |
int iconIndex; |
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 |
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
|
342 |
iconIndex = VIEW_LIST; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
343 |
} else if (name.equals("DetailsView")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
344 |
iconIndex = VIEW_DETAILS; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
345 |
} else if (name.equals("UpFolder")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
346 |
iconIndex = VIEW_PARENTFOLDER; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
347 |
} else if (name.equals("NewFolder")) { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
348 |
iconIndex = VIEW_NEWFOLDER; |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
349 |
} else { |
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
350 |
return null; |
2 | 351 |
} |
3978
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
352 |
|
b024e01b947a
6840086: JFileChooser lacks icons on top right when running on Windows 7
rupashka
parents:
3507
diff
changeset
|
353 |
return getStandardViewButton(iconIndex); |
2 | 354 |
} else if (key.startsWith("optionPaneIcon ")) { |
355 |
Win32ShellFolder2.SystemIcon iconType; |
|
356 |
if (key == "optionPaneIcon Error") { |
|
357 |
iconType = Win32ShellFolder2.SystemIcon.IDI_ERROR; |
|
358 |
} else if (key == "optionPaneIcon Information") { |
|
359 |
iconType = Win32ShellFolder2.SystemIcon.IDI_INFORMATION; |
|
360 |
} else if (key == "optionPaneIcon Question") { |
|
361 |
iconType = Win32ShellFolder2.SystemIcon.IDI_QUESTION; |
|
362 |
} else if (key == "optionPaneIcon Warning") { |
|
363 |
iconType = Win32ShellFolder2.SystemIcon.IDI_EXCLAMATION; |
|
364 |
} else { |
|
365 |
return null; |
|
366 |
} |
|
367 |
return Win32ShellFolder2.getSystemIcon(iconType); |
|
454
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
368 |
} 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
|
369 |
String name = key.substring(key.indexOf(" ") + 1); |
2 | 370 |
try { |
454
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
371 |
int i = Integer.parseInt(name); |
2 | 372 |
if (i >= 0) { |
454
2f4f4fef8880
6210674: FileChooser fails to load custom harddrive icon and gets NullPointerException
rupashka
parents:
2
diff
changeset
|
373 |
return Win32ShellFolder2.getShell32Icon(i, key.startsWith("shell32LargeIcon ")); |
2 | 374 |
} |
375 |
} catch (NumberFormatException ex) { |
|
376 |
} |
|
377 |
} |
|
378 |
return null; |
|
379 |
} |
|
380 |
||
381 |
/** |
|
382 |
* Does <code>dir</code> represent a "computer" such as a node on the network, or |
|
383 |
* "My Computer" on the desktop. |
|
384 |
*/ |
|
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
385 |
public boolean isComputerNode(final File dir) { |
2 | 386 |
if (dir != null && dir == getDrives()) { |
387 |
return true; |
|
388 |
} else { |
|
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
389 |
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
|
390 |
public String run() { |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
391 |
return dir.getAbsolutePath(); |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
392 |
} |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
393 |
}); |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
394 |
|
2 | 395 |
return (path.startsWith("\\\\") && path.indexOf("\\", 2) < 0); //Network path |
396 |
} |
|
397 |
} |
|
398 |
||
399 |
public boolean isFileSystemRoot(File dir) { |
|
400 |
//Note: Removable drives don't "exist" but are listed in "My Computer" |
|
401 |
if (dir != null) { |
|
402 |
Win32ShellFolder2 drives = getDrives(); |
|
403 |
if (dir instanceof Win32ShellFolder2) { |
|
404 |
Win32ShellFolder2 sf = (Win32ShellFolder2)dir; |
|
405 |
if (sf.isFileSystem()) { |
|
406 |
if (sf.parent != null) { |
|
407 |
return sf.parent.equals(drives); |
|
408 |
} |
|
409 |
// else fall through ... |
|
410 |
} else { |
|
411 |
return false; |
|
412 |
} |
|
413 |
} |
|
414 |
String path = dir.getPath(); |
|
5448
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
415 |
|
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
416 |
if (path.length() != 3 || path.charAt(1) != ':') { |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
417 |
return false; |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
418 |
} |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
419 |
|
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
420 |
File[] files = drives.listFiles(); |
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
421 |
|
96e9d2b5c719
6945316: The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
rupashka
parents:
4275
diff
changeset
|
422 |
return files != null && Arrays.asList(files).contains(dir); |
2 | 423 |
} |
424 |
return false; |
|
425 |
} |
|
426 |
||
25192
4e2dc0f8702d
8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents:
24520
diff
changeset
|
427 |
private static List<Win32ShellFolder2> topFolderList = null; |
2 | 428 |
static int compareShellFolders(Win32ShellFolder2 sf1, Win32ShellFolder2 sf2) { |
429 |
boolean special1 = sf1.isSpecial(); |
|
430 |
boolean special2 = sf2.isSpecial(); |
|
431 |
||
432 |
if (special1 || special2) { |
|
433 |
if (topFolderList == null) { |
|
25192
4e2dc0f8702d
8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents:
24520
diff
changeset
|
434 |
ArrayList<Win32ShellFolder2> tmpTopFolderList = new ArrayList<>(); |
2 | 435 |
tmpTopFolderList.add(Win32ShellFolderManager2.getPersonal()); |
436 |
tmpTopFolderList.add(Win32ShellFolderManager2.getDesktop()); |
|
437 |
tmpTopFolderList.add(Win32ShellFolderManager2.getDrives()); |
|
438 |
tmpTopFolderList.add(Win32ShellFolderManager2.getNetwork()); |
|
439 |
topFolderList = tmpTopFolderList; |
|
440 |
} |
|
441 |
int i1 = topFolderList.indexOf(sf1); |
|
442 |
int i2 = topFolderList.indexOf(sf2); |
|
443 |
if (i1 >= 0 && i2 >= 0) { |
|
444 |
return (i1 - i2); |
|
445 |
} else if (i1 >= 0) { |
|
446 |
return -1; |
|
447 |
} else if (i2 >= 0) { |
|
448 |
return 1; |
|
449 |
} |
|
450 |
} |
|
451 |
||
452 |
// Non-file shellfolders sort before files |
|
453 |
if (special1 && !special2) { |
|
454 |
return -1; |
|
455 |
} else if (special2 && !special1) { |
|
456 |
return 1; |
|
457 |
} |
|
458 |
||
459 |
return compareNames(sf1.getAbsolutePath(), sf2.getAbsolutePath()); |
|
460 |
} |
|
461 |
||
462 |
static int compareNames(String name1, String name2) { |
|
463 |
// 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
|
464 |
int diff = name1.compareToIgnoreCase(name2); |
2 | 465 |
if (diff != 0) { |
466 |
return diff; |
|
467 |
} else { |
|
468 |
// May differ in case (e.g. "mail" vs. "Mail") |
|
469 |
// We need this test for consistent sorting |
|
470 |
return name1.compareTo(name2); |
|
471 |
} |
|
472 |
} |
|
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
473 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
474 |
@Override |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
475 |
protected Invoker createInvoker() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
476 |
return new ComInvoker(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
477 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
478 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
479 |
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
|
480 |
private static Thread comThread; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
481 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
482 |
private ComInvoker() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
483 |
super(1, 1, 0, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>()); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
484 |
allowCoreThreadTimeOut(false); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
485 |
setThreadFactory(this); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
486 |
final Runnable shutdownHook = new Runnable() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
487 |
public void run() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
488 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
489 |
public Void run() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
490 |
shutdownNow(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
491 |
return null; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
492 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
493 |
}); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
494 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
495 |
}; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
496 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
497 |
public Void run() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
498 |
Runtime.getRuntime().addShutdownHook( |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
499 |
new Thread(shutdownHook) |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
500 |
); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
501 |
return null; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
502 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
503 |
}); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
504 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
505 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
506 |
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
|
507 |
final Runnable comRun = new Runnable() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
508 |
public void run() { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
509 |
try { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
510 |
initializeCom(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
511 |
task.run(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
512 |
} finally { |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
513 |
uninitializeCom(); |
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 |
}; |
23900
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
23691
diff
changeset
|
517 |
comThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> { |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
518 |
/* The thread must be a member of a thread group |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
519 |
* which will not get GCed before VM exit. |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
520 |
* Make its parent the top-level thread group. |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
521 |
*/ |
23900
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
23691
diff
changeset
|
522 |
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
23691
diff
changeset
|
523 |
Thread thread = new Thread(rootTG, comRun, "Swing-Shell"); |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
524 |
thread.setDaemon(true); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
525 |
return thread; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
526 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
527 |
); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
528 |
return comThread; |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
529 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
530 |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
531 |
public <T> T invoke(Callable<T> task) throws Exception { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
532 |
if (Thread.currentThread() == comThread) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
533 |
// if it's already called from the COM |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
534 |
// thread, we don't need to delegate the task |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
535 |
return task.call(); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
536 |
} else { |
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
537 |
final Future<T> future; |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
538 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
539 |
try { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
540 |
future = submit(task); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
541 |
} catch (RejectedExecutionException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
542 |
throw new InterruptedException(e.getMessage()); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
543 |
} |
2817
f171f2417978
6713352: Deadlock in JFileChooser with synchronized custom FileSystemView
rupashka
parents:
2489
diff
changeset
|
544 |
|
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
545 |
try { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
546 |
return future.get(); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
547 |
} catch (InterruptedException e) { |
3507
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
548 |
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
|
549 |
public Void run() { |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
550 |
future.cancel(true); |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
551 |
|
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
552 |
return null; |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
553 |
} |
1610d6f5a0e3
6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)
rupashka
parents:
3346
diff
changeset
|
554 |
}); |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
555 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
556 |
throw e; |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
557 |
} catch (ExecutionException e) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
558 |
Throwable cause = e.getCause(); |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
559 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
560 |
if (cause instanceof Exception) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
561 |
throw (Exception) cause; |
2489
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
562 |
} |
3346
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
563 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
564 |
if (cause instanceof Error) { |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
565 |
throw (Error) cause; |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
566 |
} |
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
567 |
|
1c65be97eaa2
6460525: javax/swing/JFileChooser/6396844/TwentyThousandTest.java times out
rupashka
parents:
2817
diff
changeset
|
568 |
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
|
569 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
570 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
571 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
572 |
} |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
573 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
574 |
static native void initializeCom(); |
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
575 |
|
5052722686e2
6491795: COM should be initialized for Shell API calls in ShellFolder2.cpp
rupashka
parents:
715
diff
changeset
|
576 |
static native void uninitializeCom(); |
2 | 577 |
} |