当前位置: 首页>>代码示例>>Java>>正文


Java ShellFolder.getNormalizedFile方法代码示例

本文整理汇总了Java中sun.awt.shell.ShellFolder.getNormalizedFile方法的典型用法代码示例。如果您正苦于以下问题:Java ShellFolder.getNormalizedFile方法的具体用法?Java ShellFolder.getNormalizedFile怎么用?Java ShellFolder.getNormalizedFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.awt.shell.ShellFolder的用法示例。


在下文中一共展示了ShellFolder.getNormalizedFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseClicked

import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
    if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
        int index = list.locationToIndex(e.getPoint());
        if (index >= 0) {
            File f = (File) list.getModel().getElementAt(index);
            try {
                // Strip trailing ".."
                f = ShellFolder.getNormalizedFile(f);
            } catch (IOException ex) {
                // That's ok, we'll use f as is
            }
            if (getFileChooser().isTraversable(f)) {
                list.clearSelection();
                if (getFileChooser().getCurrentDirectory().equals(f)){
                    rescanCurrentDirectory(getFileChooser());
                } else {
                    getFileChooser().setCurrentDirectory(f);
                }
            } else {
                getFileChooser().approveSelection();
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:GTKFileChooserUI.java

示例2: actionPerformed

import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
    if (isDirectorySelected()) {
        File dir = getDirectory();
        try {
            // Strip trailing ".."
            if (dir != null) {
                dir = ShellFolder.getNormalizedFile(dir);
            }
        } catch (IOException ex) {
            // Ok, use f as is
        }
        if (getFileChooser().getCurrentDirectory().equals(dir)) {
            directoryList.clearSelection();
            fileList.clearSelection();
            ListSelectionModel sm = fileList.getSelectionModel();
            if (sm instanceof DefaultListSelectionModel) {
                ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
                sm.setAnchorSelectionIndex(0);
            }
            rescanCurrentDirectory(getFileChooser());
            return;
        }
    }
    super.actionPerformed(e);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:GTKFileChooserUI.java

示例3: mouseClicked

import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent evt) {
    // Note: we can't depend on evt.getSource() because of backward
    // compatibility
    if (list != null &&
        SwingUtilities.isLeftMouseButton(evt) &&
        (evt.getClickCount()%2 == 0)) {

        int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint());
        if (index >= 0) {
            File f = (File)list.getModel().getElementAt(index);
            try {
                // Strip trailing ".."
                f = ShellFolder.getNormalizedFile(f);
            } catch (IOException ex) {
                // That's ok, we'll use f as is
            }
            if(getFileChooser().isTraversable(f)) {
                list.clearSelection();
                changeDirectory(f);
            } else {
                getFileChooser().approveSelection();
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:BasicFileChooserUI.java

示例4: mouseClicked

import sun.awt.shell.ShellFolder; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent evt) {
    // Note: we can't depend on evt.getSource() because of backward
    // compatability
    if (list != null &&
        SwingUtilities.isLeftMouseButton(evt) &&
        (evt.getClickCount()%2 == 0)) {

        int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint());
        if (index >= 0) {
            File f = (File)list.getModel().getElementAt(index);
            try {
                // Strip trailing ".."
                f = ShellFolder.getNormalizedFile(f);
            } catch (IOException ex) {
                // That's ok, we'll use f as is
            }
            if(getFileChooser().isTraversable(f)) {
                list.clearSelection();
                changeDirectory(f);
            } else {
                getFileChooser().approveSelection();
            }
        }
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:26,代码来源:BasicFileChooserUI.java

示例5: 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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:64,代码来源:SynthFileChooserUIImpl.java

示例6: 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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:60,代码来源:MetalFileChooserUI.java

示例7: 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();
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:71,代码来源:SynthFileChooserUIImpl.java

示例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.
 */
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();
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:67,代码来源:MetalFileChooserUI.java


注:本文中的sun.awt.shell.ShellFolder.getNormalizedFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。