Java Code Examples for sun.awt.shell.ShellFolder#getNormalizedFile()
The following examples show how to use
sun.awt.shell.ShellFolder#getNormalizedFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GTKFileChooserUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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); }
Example 2
Source File: BasicFileChooserUI.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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(); } } } }
Example 3
Source File: GTKFileChooserUI.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); }
Example 4
Source File: GTKFileChooserUI.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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(); } } } }
Example 5
Source File: GTKFileChooserUI.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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); }
Example 6
Source File: BasicFileChooserUI.java From JDKSourceCode1.8 with MIT License | 6 votes |
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(); } } } }
Example 7
Source File: GTKFileChooserUI.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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); }
Example 8
Source File: BasicFileChooserUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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(); } } } }
Example 9
Source File: GTKFileChooserUI.java From JDKSourceCode1.8 with MIT License | 6 votes |
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(); } } } }
Example 10
Source File: BasicFileChooserUI.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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(); } } } }
Example 11
Source File: GTKFileChooserUI.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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(); } } } }
Example 12
Source File: GTKFileChooserUI.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
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); }
Example 13
Source File: GTKFileChooserUI.java From JDKSourceCode1.8 with MIT License | 6 votes |
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); }
Example 14
Source File: SynthFileChooserUIImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } }
Example 15
Source File: MetalFileChooserUI.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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(); } }
Example 16
Source File: DarkFileChooserUIBridge.java From darklaf with MIT License | 4 votes |
/** * 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. * * @param directory the directory */ protected void addItem(final 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<>(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(); } }
Example 17
Source File: SynthFileChooserUIImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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(); } }
Example 18
Source File: SynthFileChooserUIImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } }
Example 19
Source File: SynthFileChooserUIImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } }
Example 20
Source File: MetalFileChooserUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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(); } }