コード例 #1
0
    /**
     * Show the selector for selecting the default folder.
     *
     * @return true if the user selected a default folder and false if not.
     */
    protected boolean showDefaultFolderSelector() throws Exception {
      final JFileChooser selector = new JFileChooser(_activeFileChooser.getCurrentDirectory());
      selector.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      final String title =
          (_subfolderName == null)
              ? "Default Folder"
              : "Default Parent Folder of " + _subfolderName;
      selector.setDialogTitle(title);
      final int status = selector.showDialog(_view, "Make Default");

      switch (status) {
        case JFileChooser.APPROVE_OPTION:
          final File defaultFolder = selector.getSelectedFile();
          if (defaultFolder != null) {
            _folderTracker.cacheURL(defaultFolder.toURI().toURL());
            return true;
          } else {
            return false;
          }
        default:
          return false;
      }
    }