本文整理汇总了Java中sun.awt.shell.ShellFolder.getShellFolder方法的典型用法代码示例。如果您正苦于以下问题:Java ShellFolder.getShellFolder方法的具体用法?Java ShellFolder.getShellFolder怎么用?Java ShellFolder.getShellFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.shell.ShellFolder
的用法示例。
在下文中一共展示了ShellFolder.getShellFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeDirectory
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private void changeDirectory(File dir) {
JFileChooser fc = getFileChooser();
// Traverse shortcuts on Windows
if (dir != null && FilePane.usesShellFolder(fc)) {
try {
ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
if (shellFolder.isLink()) {
File linkedTo = shellFolder.getLinkLocation();
// If linkedTo is null we try to use dir
if (linkedTo != null) {
if (fc.isTraversable(linkedTo)) {
dir = linkedTo;
} else {
return;
}
} else {
dir = shellFolder;
}
}
} catch (FileNotFoundException ex) {
return;
}
}
fc.setCurrentDirectory(dir);
if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
fc.getFileSystemView().isFileSystem(dir)) {
setFileName(dir.getAbsolutePath());
}
}
示例2: MyThread
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private MyThread(int delay, String link) {
this.delay = delay;
ShellFolder linkFolder;
try {
linkFolder = ShellFolder.getShellFolder(new File(link));
} catch (FileNotFoundException e) {
e.printStackTrace();
linkFolder = null;
}
this.link = linkFolder;
}
示例3: test
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private static void test() throws Exception {
FileSystemView fsv = FileSystemView.getFileSystemView();
File def = new File(fsv.getDefaultDirectory().getAbsolutePath());
ShellFolderColumnInfo[] defColumns =
ShellFolder.getShellFolder(def).getFolderColumns();
File[] files = fsv.getHomeDirectory().listFiles();
for (File file : files) {
if( "Libraries".equals(ShellFolder.getShellFolder( file ).getDisplayName())) {
File[] libs = file.listFiles();
for (File lib : libs) {
ShellFolder libFolder =
ShellFolder.getShellFolder(lib);
if( "Library".equals(libFolder.getFolderType() ) ) {
ShellFolderColumnInfo[] folderColumns =
libFolder.getFolderColumns();
for (int i = 0; i < defColumns.length; i++) {
if (!defColumns[i].getTitle()
.equals(folderColumns[i].getTitle()))
throw new RuntimeException("Columnn " +
folderColumns[i].getTitle() +
" doesn't match " +
defColumns[i].getTitle());
}
}
}
}
}
}
示例4: changeDirectory
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private void changeDirectory(File dir) {
JFileChooser fc = getFileChooser();
// Traverse shortcuts on Windows
if (dir != null && FilePane.usesShellFolder(fc)) {
try {
ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
if (shellFolder.isLink()) {
File linkedTo = shellFolder.getLinkLocation();
if (linkedTo != null && fc.isTraversable(linkedTo)) {
dir = linkedTo;
} else {
return;
}
}
} catch (FileNotFoundException ex) {
return;
}
}
fc.setCurrentDirectory(dir);
if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
fc.getFileSystemView().isFileSystem(dir)) {
setFileName(dir.getAbsolutePath());
}
}
示例5: changeDirectory
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private void changeDirectory(File dir) {
JFileChooser fc = getFileChooser();
// Traverse shortcuts on Windows
if (null != dir && FilePane.usesShellFolder(fc)) {
try {
ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
if (shellFolder.isLink()) {
File linkedTo = shellFolder.getLinkLocation();
// If linkedTo is null we try to use dir
if (linkedTo != null) {
if (fc.isTraversable(linkedTo)) {
dir = linkedTo;
} else {
return;
}
} else {
dir = shellFolder;
}
}
} catch (FileNotFoundException ex) {
return;
}
}
fc.setCurrentDirectory(dir);
if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES
&& fc.getFileSystemView().isFileSystem(dir)) {
setFileName(dir.getAbsolutePath());
}
}
示例6: setIconTo
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private void setIconTo(JLabel label, File file ) {
if ( file.exists() ) try {
ShellFolder shellFolder = ShellFolder.getShellFolder(file);
Image icon = shellFolder.getIcon(false);
if ( icon != null ) {
label.setIcon( new ImageIcon( icon ) );
}
} catch ( FileNotFoundException fnfe ){
System.err.println("Ignoring fnfe: "+ fnfe.getMessage());
}
}
示例7: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private void addItem(File directory) {
if (directory == null) {
return;
}
this.directories.clear();
File[] baseFolders = this.fileSystemView.getRoots();
this.directories.addAll(Arrays.asList(baseFolders));
File canonical = null;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
canonical = directory;
}
File sf;
if (!(this.fileSystemView instanceof RemoteFileSystemView)) {
try {
sf = ShellFolder.getShellFolder(canonical);
} catch (FileNotFoundException ex) {
sf = canonical;
}
} else {
sf = canonical;
}
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = fileSystemView.getParentDirectory(f)) != null);
int pathCount = path.size();
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (this.directories.contains(f)) {
int topIndex = this.directories.indexOf(f);
for (int j = i - 1; j >= 0; j--) {
this.directories.insertElementAt(path.get(j), topIndex + i - j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
}
示例8: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
public void addItem(File directory) {
if (directory == null) {
return;
}
boolean useShellFolder = FilePane.usesShellFolder(chooser);
int oldSize = directories.size();
directories.clear();
if (oldSize > 0) {
fireIntervalRemoved(this, 0, oldSize);
}
File[] baseFolders = (useShellFolder)
? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
: fsv.getRoots();
directories.addAll(Arrays.asList(baseFolders));
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = ShellFolder.getNormalizedFile(directory);
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
try {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
directories.insertElementAt(path.get(j), topIndex+i-j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}
示例9: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
private void addItem(File directory) {
if(directory == null) {
return;
}
boolean useShellFolder = FilePane.usesShellFolder(chooser);
directories.clear();
File[] baseFolders = (useShellFolder)
? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
: fsv.getRoots();
directories.addAll(Arrays.asList(baseFolders));
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
try {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
directories.insertElementAt(path.get(j), topIndex+i-j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}
示例10: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
private void addItem(File directory) {
if(directory == null) {
return;
}
boolean useShellFolder = FilePane.usesShellFolder(chooser);
directories.clear();
File[] baseFolders = (useShellFolder)
? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
: fsv.getRoots();
directories.addAll(Arrays.asList(baseFolders));
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = ShellFolder.getNormalizedFile(directory);
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
try {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
directories.insertElementAt(path.get(j), topIndex+i-j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}
示例11: main
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
System.out.println("The test is applicable only for Windows. Skipped.");
return;
}
String tmpDir = System.getProperty("java.io.tmpdir");
if (tmpDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
tmpDir = System.getProperty("user.home");
}
final ShellFolder tmpFile = ShellFolder.getShellFolder(new File(tmpDir));
System.out.println("Temp directory: " + tmpDir);
System.out.println("Stress test was run");
Thread thread = new Thread() {
public void run() {
while (!isInterrupted()) {
ShellFolder.invoke(new Callable<Void>() {
public Void call() throws Exception {
synchronized (mux) {
tmpFile.isFileSystem();
tmpFile.isLink();
}
return null;
}
});
}
}
};
thread.start();
for (int i = 0; i < COUNT; i++) {
synchronized (mux) {
clearField(tmpFile, "cachedIsLink");
clearField(tmpFile, "cachedIsFileSystem");
}
tmpFile.isFileSystem();
tmpFile.isLink();
}
thread.interrupt();
thread.join();
System.out.println("Test passed successfully");
}
示例12: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
public void addItem(File directory) {
if (directory == null) {
return;
}
boolean useShellFolder = FilePane.usesShellFolder(chooser);
int oldSize = directories.size();
directories.clear();
if (oldSize > 0) {
fireIntervalRemoved(this, 0, oldSize);
}
File[] baseFolders;
if (useShellFolder) {
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
public File[] run() {
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
}
});
} else {
baseFolders = fsv.getRoots();
}
directories.addAll(Arrays.asList(baseFolders));
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = ShellFolder.getNormalizedFile(directory);
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
try {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
directories.insertElementAt(path.get(j), topIndex+i-j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}
示例13: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
private void addItem(File directory) {
if(directory == null) {
return;
}
boolean useShellFolder = FilePane.usesShellFolder(chooser);
directories.clear();
File[] baseFolders;
if (useShellFolder) {
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
public File[] run() {
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
}
});
} else {
baseFolders = fsv.getRoots();
}
directories.addAll(Arrays.asList(baseFolders));
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
try {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
directories.insertElementAt(path.get(j), topIndex+i-j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}
示例14: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
/**
* Adds the directory to the model and sets it to be selected,
* additionally clears out the previous selected directory and
* the paths leading up to it, if any.
*/
private void addItem(File directory) {
if(directory == null) {
return;
}
boolean useShellFolder = FilePane.usesShellFolder(chooser);
directories.clear();
File[] baseFolders;
if (useShellFolder) {
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
public File[] run() {
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
}
});
} else {
baseFolders = fsv.getRoots();
}
directories.addAll(Arrays.asList(baseFolders));
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical;
try {
canonical = ShellFolder.getNormalizedFile(directory);
} catch (IOException e) {
// Maybe drive is not ready. Can't abort here.
canonical = directory;
}
// create File instances of each directory leading up to the top
try {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
directories.insertElementAt(path.get(j), topIndex+i-j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}
示例15: addItem
import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
private void addItem(File directory) {
if (directory == null) {
return;
}
this.directories.clear();
File[] baseFolders = this.fileSystemView.getRoots();
this.directories.addAll(Arrays.asList(baseFolders));
File canonical = null;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
canonical = directory;
}
try {
File sf = ShellFolder.getShellFolder(canonical);
File f = sf;
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
int pathCount = path.size();
for (int i = 0; i < pathCount; i++) {
f = path.get(i);
if (this.directories.contains(f)) {
int topIndex = this.directories.indexOf(f);
for (int j = i - 1; j >= 0; j--) {
this.directories.insertElementAt(path.get(j), topIndex + i - j);
}
break;
}
}
calculateDepths();
setSelectedItem(sf);
} catch (FileNotFoundException ex) {
calculateDepths();
}
}