@Nullable public static PsiDirectory selectDirectory( Project project, PsiDirectory[] packageDirectories, PsiDirectory defaultDirectory, String postfixToShow) { ProjectFileIndex projectFileIndex = getInstance(project).getFileIndex(); ArrayList<PsiDirectory> possibleDirs = new ArrayList<>(); for (PsiDirectory dir : packageDirectories) { if (!dir.isValid()) continue; if (!dir.isWritable()) continue; if (possibleDirs.contains(dir)) continue; if (!projectFileIndex.isInContent(dir.getVirtualFile())) continue; possibleDirs.add(dir); } if (possibleDirs.isEmpty()) return null; if (possibleDirs.size() == 1) return possibleDirs.get(0); if (getApplication().isUnitTestMode()) return possibleDirs.get(0); DirectoryChooser chooser = new DirectoryChooser(project); chooser.setTitle(message("title.choose.destination.directory")); chooser.fillList( possibleDirs.toArray(new PsiDirectory[possibleDirs.size()]), defaultDirectory, project, postfixToShow); return chooser.showAndGet() ? chooser.getSelectedDirectory() : null; }
@Nullable public static PsiDirectory chooseDirectory( PsiDirectory[] targetDirectories, @Nullable PsiDirectory initialDirectory, @NotNull Project project, Map<PsiDirectory, String> relativePathsToCreate) { final DirectoryChooser chooser = new DirectoryChooser(project, new DirectoryChooserModuleTreeView(project)); chooser.setTitle(RefactoringBundle.message("choose.destination.directory")); chooser.fillList(targetDirectories, initialDirectory, project, relativePathsToCreate); if (!chooser.showAndGet()) { return null; } return chooser.getSelectedDirectory(); }
private void openDirectory(File f, String path) { if (path == null) return; if (!(path.endsWith(File.separator) || path.endsWith("/"))) path += File.separator; String[] names = f.list(); names = (new FolderOpener()).trimFileList(names); if (names == null) return; String msg = "Open all " + names.length + " images in \"" + f.getName() + "\" as a stack?"; GenericDialog gd = new GenericDialog("Open Folder"); gd.setInsets(10, 5, 0); gd.addMessage(msg); gd.setInsets(15, 35, 0); gd.addCheckbox("Convert to RGB", convertToRGB); gd.setInsets(0, 35, 0); gd.addCheckbox("Use Virtual Stack", virtualStack); gd.enableYesNoCancel(); gd.showDialog(); if (gd.wasCanceled()) return; if (gd.wasOKed()) { convertToRGB = gd.getNextBoolean(); virtualStack = gd.getNextBoolean(); String options = " sort"; if (convertToRGB) options += " convert_to_rgb"; if (virtualStack) options += " use"; IJ.run("Image Sequence...", "open=[" + path + "]" + options); DirectoryChooser.setDefaultDirectory(path); } else { for (int k = 0; k < names.length; k++) { IJ.redirectErrorMessages(); if (!names[k].startsWith(".")) (new Opener()).open(path + names[k]); } } IJ.register(DragAndDrop.class); }
public static File creSaveToFoldDialog(Window parent, String initFileName) { DirectoryChooser dir = new DirectoryChooser(); return dir.showDialog(parent); }
public boolean getImageDirectory() { DirectoryChooser chooser = new DirectoryChooser("Choose directory to process"); imagedir = chooser.getDirectory(); return true; }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { DirictoryFrame = new javax.swing.JFrame(); DirectoryChooser = new javax.swing.JFileChooser(); jButton1 = new javax.swing.JButton(); DirictoryFrame.setTitle("Выберите каталог для сохранения"); DirictoryFrame.setAlwaysOnTop(true); DirictoryFrame.setBounds(new java.awt.Rectangle(50, 50, 582, 397)); DirictoryFrame.setResizable(false); DirectoryChooser.setAcceptAllFileFilterUsed(false); DirectoryChooser.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG); DirectoryChooser.setControlButtonsAreShown(false); DirectoryChooser.setDialogTitle(""); DirectoryChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY); DirectoryChooser.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DirectoryChooserActionPerformed(evt); } }); javax.swing.GroupLayout DirictoryFrameLayout = new javax.swing.GroupLayout(DirictoryFrame.getContentPane()); DirictoryFrame.getContentPane().setLayout(DirictoryFrameLayout); DirictoryFrameLayout.setHorizontalGroup( DirictoryFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( DirectoryChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)); DirictoryFrameLayout.setVerticalGroup( DirictoryFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, DirictoryFrameLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent( DirectoryChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("jButton1"); jButton1.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(40, 40, 40) .addComponent( jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(1175, Short.MAX_VALUE))); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGap(56, 56, 56) .addComponent( jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(435, Short.MAX_VALUE))); pack(); } // </editor-fold>//GEN-END:initComponents