List of usage examples for javax.swing.filechooser FileView FileView
FileView
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuOpenProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuOpenProjectActionPerformed final JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileView(new FileView() { private Icon KNOWLEDGE_FOLDER_ICO = null; @Override/* w w w . j a v a 2 s. c o m*/ public Icon getIcon(final File f) { if (f.isDirectory()) { final File knowledge = new File(f, ".projectKnowledge"); if (knowledge.isDirectory()) { if (KNOWLEDGE_FOLDER_ICO == null) { final Icon icon = UIManager.getIcon("FileView.directoryIcon"); if (icon != null) { KNOWLEDGE_FOLDER_ICO = new ImageIcon( UiUtils.makeBadgedRightBottom(UiUtils.iconToImage(fileChooser, icon), Icons.MMDBADGE.getIcon().getImage())); } } return KNOWLEDGE_FOLDER_ICO; } else { return super.getIcon(f); } } else if (f.isFile() && f.getName().toLowerCase(Locale.ENGLISH).endsWith(".mmd")) { return Icons.DOCUMENT.getIcon(); } else { return super.getIcon(f); } } }); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setMultiSelectionEnabled(false); fileChooser.setDialogTitle("Open project folder"); if (fileChooser.showOpenDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) { openProject(fileChooser.getSelectedFile(), false); } }
From source file:org.panbox.desktop.common.gui.RestoreRevisionDialog.java
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseButtonActionPerformed JFileChooser fileChooser = new JFileChooser(PANBOX_DIR + "/" + shareName); fileChooser.setFileView(new FileView() { @Override//from w w w .jav a2 s .co m public Boolean isTraversable(File f) { try { return f.isDirectory() && FilenameUtils.directoryContains(PANBOX_DIR.getAbsolutePath(), f.getAbsolutePath()); } catch (IOException e) { logger.error("Error determining folder parent status!"); return true; } } }); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int ret = fileChooser.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION && fileChooser.getSelectedFile().getParentFile().getAbsolutePath() .startsWith(PANBOX_DIR.getAbsolutePath())) { String path = getCSPSupportedPath(fileChooser.getSelectedFile().getPath()); fileTextField.setText(path); fillRevisionsForFileName(path); } }