Java Code Examples for javax.swing.JFileChooser.setDialogType()

The following are Jave code examples for showing how to use setDialogType() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: SASS   File: ConstantBackground.java   Source Code and License Vote up 6 votes
/**
 * Load the background image by a file selection dialog
 * @param camera camera settings
 */
public ConstantBackground(Camera camera) {
    // initialize array with zeros
    pixels = new float[camera.res_x][camera.res_y];
    zeroPixels();
    
    // choose file
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("background.tif"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("TIF image","tif"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        throw new RuntimeException("Background image not selected");
    }
    File tif_file = fc.getSelectedFile();
    // load the file
    loadFile(tif_file);
    
    // verify that the image is larger or equal to camera resolution
    verifyDimensions(camera, pixels);
}
 
Example 2
Project: incubator-netbeans   File: RemoteRepository.java   Source Code and License Vote up 6 votes
private void onBrowse() {
    String path = settingsPanel.txtIdentityFile.getText();
    if (path.isEmpty()) {
        path = getDefaultIdentityFilePath();
    }
    File file = new File(path);
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(RemoteRepositoryPanel.class, "RepositoryPanel.IdentityFile.FileChooser.Descritpion"), //NOI18N
            path.isEmpty() ? null : file.getParentFile());
    if (!path.isEmpty()) {
        fileChooser.setSelectedFile(file);
    }
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setDialogTitle(NbBundle.getMessage(RemoteRepositoryPanel.class, "RepositoryPanel.IdentityFile.FileChooser.Title")); //NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    if (JFileChooser.APPROVE_OPTION == fileChooser.showDialog(panel, null)) {
        File f = fileChooser.getSelectedFile();
        settingsPanel.txtIdentityFile.setText(f.getAbsolutePath());
    }
}
 
Example 3
Project: incubator-netbeans   File: TemplateSelector.java   Source Code and License Vote up 6 votes
private File selectFile(int dialogType, String approveButtonText) {
        JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(TemplateSelector.class, "ACSD_SelectTemplate")/*, defaultDir*/);// NOI18N
        fileChooser.setDialogTitle(NbBundle.getMessage(TemplateSelector.class, "CTL_SelectTemplate"));// NOI18N
        fileChooser.setMultiSelectionEnabled(false);
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.setDialogType(dialogType);

        File file = getTemplateFile();

//        if(file.isFile() && dialogType == JFileChooser.OPEN_DIALOG) {
//            fileChooser.setSelectedFile(file);
//        } else {
//            fileChooser.setCurrentDirectory(file.isFile() ? file.getParentFile() : file);
//        }
        if(file.isFile() ) {
            fileChooser.setSelectedFile(file);
        } else {
            fileChooser.setCurrentDirectory(file);
        }

        fileChooser.showDialog(getPanel(), approveButtonText);
        File f = fileChooser.getSelectedFile();
        return f;
    }
 
Example 4
Project: incubator-netbeans   File: ExportSnapshotAction.java   Source Code and License Vote up 6 votes
private static JFileChooser createFileChooser() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogTitle(Bundle.ExportSnapshotAction_FileChooserCaption());
    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    fileChooser.setApproveButtonText(Bundle.ExportSnapshotAction_ExportButtonText());
    fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
    fileChooser.addChoosableFileFilter(new FileFilter() {
        public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(NPSS_EXT);
        }
        public String getDescription() {
            return Bundle.ExportSnapshotAction_NpssFileFilter(NPSS_EXT);
        }
    });
    return fileChooser;
}
 
Example 5
Project: FreeCol   File: SaveDialog.java   Source Code and License Vote up 6 votes
/**
 * Creates a dialog to choose a file to load.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param directory The directory to display when choosing the file.
 * @param fileFilters The available file filters in the dialog.
 * @param defaultName Name of the default save game file.
 */
public SaveDialog(FreeColClient freeColClient, JFrame frame,
        File directory, FileFilter[] fileFilters, String defaultName) {
    super(freeColClient, frame);

    final JFileChooser fileChooser = new JFileChooser(directory);
    if (fileFilters.length > 0) {
        for (FileFilter fileFilter : fileFilters) {
            fileChooser.addChoosableFileFilter(fileFilter);
        }
        fileChooser.setFileFilter(fileFilters[0]);
        fileChooser.setAcceptAllFileFilterUsed(false);
    }
    fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    fileChooser.setSelectedFile(new File(defaultName));
    fileChooser.addActionListener((ActionEvent ae) ->
            setValue((JFileChooser.APPROVE_SELECTION
                    .equals(ae.getActionCommand()))
                ? fileChooser.getSelectedFile() : cancelFile));
    
    List<ChoiceItem<File>> c = choices();
    initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
 
Example 6
Project: SASS   File: GUI.java   Source Code and License Vote up 6 votes
private void savePositionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savePositionsActionPerformed
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.SAVE_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("emitter_positions.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showSaveDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    File positionsCSVFile = fc.getSelectedFile();
    String filename = positionsCSVFile.getAbsolutePath();
    try {
        app.getPositionLogger().setFilename(filename);
        app.getPositionLogger().saveLogFile();
    } catch (IOException ex) {
        IJ.error("Could not save file: " + filename);
    }
}
 
Example 7
Project: incubator-netbeans   File: LoadGeneratorCustomizer.java   Source Code and License Vote up 5 votes
private JFileChooser getFileChooser() {
    if (fileChooser == null) {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        chooser.setDialogType(JFileChooser.OPEN_DIALOG);
        chooser.setDialogTitle(Bundle.LoadGeneratorCustomizer_ChooseScriptDialogCaption());

        chooser.setFileFilter(new FileFilter() {
                private Set<String> extensions = new HashSet<String>();

                {
                    LoadGenPlugin lg = Lookup.getDefault().lookup(LoadGenPlugin.class);
                    extensions = lg.getSupportedExtensions();
                }

                public boolean accept(File f) {
                    return f.isDirectory() || extensions.contains(FileUtil.getExtension(f.getPath()));
                }

                public String getDescription() {
                    return Bundle.LoadGeneratorCustomizer_SupportedFiles();
                }
            });

        fileChooser = chooser;
    }

    return fileChooser;
}
 
Example 8
Project: incubator-netbeans   File: SnapshotCustomizer.java   Source Code and License Vote up 5 votes
private JFileChooser getFileChooser() {
    if (fileChooser == null) {
        JFileChooser chooser = new JFileChooser();
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setMultiSelectionEnabled(false);
        chooser.setDialogType(JFileChooser.OPEN_DIALOG);
        chooser.setDialogTitle(Bundle.SnapshotCustomizer_SelectSnapshotDialogCaption());
        fileChooser = chooser;
    }

    return fileChooser;
}
 
Example 9
Project: SASS   File: InitializeSimulation.java   Source Code and License Vote up 5 votes
private void emittersChooseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emittersChooseFileActionPerformed
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename
    fc.setSelectedFile(new File("emitters.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    emittersCsvFile = fc.getSelectedFile();
    //emitter_file_label.setText(emittersCsvFile.getName());
}
 
Example 10
Project: SASS   File: FluorophoreReceiver.java   Source Code and License Vote up 5 votes
private static File getFileFromDialog() {
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("emitters.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        throw new RuntimeException("You need to select an emitter file!");
    }
    return fc.getSelectedFile();
}
 
Example 11
Project: openjdk-jdk10   File: SelectAllFilesFilterTest.java   Source Code and License Vote up 5 votes
private static void createAndShowGUI() {
    fileChooser = new JFileChooser();
    fileChooser.setAcceptAllFileFilterUsed(true);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);

    FileFilter txtFilter = new FileNameExtensionFilter("Text files", "txt");
    fileChooser.addChoosableFileFilter(txtFilter);
    fileChooser.setFileFilter(txtFilter);
    fileChooser.showOpenDialog(null);
}
 
Example 12
Project: GIFKR   File: SaveFrame.java   Source Code and License Vote up 5 votes
public void initializeComponents() {
	widthSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 99999, 100));
	heightSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 99999, 100));
	frameDelayLabel = new JLabel("Frame delay (ms):");
	frameDelaySpinner = new JSpinner(new SpinnerNumberModel(0, 0, 99999, 1));

	chooser	= new JFileChooser();
	chooser.setDialogType(JFileChooser.SAVE_DIALOG);
	chooser.setAcceptAllFileFilterUsed(false);
	//setAnimationMode(true);
	//		chooser.setSelectedFile(StringUtil.resolveConflictName(chooser.getSelectedFile(), "glitch", true));
}
 
Example 13
Project: SASS   File: FluorophoreGenerator.java   Source Code and License Vote up 5 votes
private static File getFileFromDialog() {
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("emitters.csv"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("CSV file","csv"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        throw new RuntimeException("You need to select an emitter file!");
    }
    return fc.getSelectedFile();
}
 
Example 14
Project: jaer   File: ITDFilter.java   Source Code and License Vote up 5 votes
public void setUseRidgeRegression(boolean useRidgeRegression) {
	if (useRidgeRegression) {
		if (freqBins == null) {
			freqBins = new ITDBins[64];
			for (int i = 0; i < 64; i++) {
				freqBins[i] = new ITDBins(averagingDecay * 1000000, 1, maxITD, numOfBins);
			}
		}
		JFileChooser fc = new JFileChooser();
		fc.setDialogType(JFileChooser.SAVE_DIALOG);
		int state = fc.showSaveDialog(null);
		if (state == JFileChooser.APPROVE_OPTION) {
			String path = fc.getSelectedFile().getPath();
			try {

				File file = new File(path);
				BufferedReader bufRdr = new BufferedReader(new FileReader(file));
				ridgeWeights = new double[65];
				for (int i = 0; i < 65; i++) {
					ridgeWeights[i] = Double.parseDouble(bufRdr.readLine());
				}
				bufRdr.close();
			} catch (IOException ex) {
				log.warning("while loading weights, caught exception " + ex);
				ex.printStackTrace();
			}
		}
	}
	getPrefs().putBoolean("ITDFilter.useRidgeRegression", useRidgeRegression);
	getSupport().firePropertyChange("useRidgeRegression", this.useRidgeRegression, useRidgeRegression);
	this.useRidgeRegression = useRidgeRegression;
}
 
Example 15
Project: FreeCol   File: LoadDialog.java   Source Code and License Vote up 5 votes
/**
 * Creates a dialog to choose a file to load.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param directory The directory to display when choosing the file.
 * @param fileFilters The available file filters in the dialog.
 */
public LoadDialog(FreeColClient freeColClient, JFrame frame,
        File directory, FileFilter[] fileFilters) {
    super(freeColClient, frame);

    final JFileChooser fileChooser = new JFileChooser(directory);
    if (fileFilters.length > 0) {
        for (FileFilter fileFilter : fileFilters) {
            fileChooser.addChoosableFileFilter(fileFilter);
        }
        fileChooser.setFileFilter(fileFilters[0]);
        fileChooser.setAcceptAllFileFilterUsed(false);
    }
    fileChooser.setControlButtonsAreShown(true);
    fileChooser.setApproveButtonText(Messages.message("ok"));
    //fileChooser.setCancelButtonText(Messages.message("cancel"));
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    fileChooser.addActionListener((ActionEvent ae) -> {
            final String cmd = ae.getActionCommand();
            File value = (JFileChooser.APPROVE_SELECTION.equals(cmd))
                ? ((JFileChooser)ae.getSource()).getSelectedFile()
                : cancelFile;
            setValue(value);
        });

    List<ChoiceItem<File>> c = choices();
    initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
 
Example 16
Project: freecol   File: LoadDialog.java   Source Code and License Vote up 5 votes
/**
 * Creates a dialog to choose a file to load.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 * @param frame The owner frame.
 * @param directory The directory to display when choosing the file.
 * @param fileFilters The available file filters in the dialog.
 */
public LoadDialog(FreeColClient freeColClient, JFrame frame,
        File directory, FileFilter[] fileFilters) {
    super(freeColClient, frame);

    final JFileChooser fileChooser = new JFileChooser(directory);
    if (fileFilters.length > 0) {
        for (FileFilter fileFilter : fileFilters) {
            fileChooser.addChoosableFileFilter(fileFilter);
        }
        fileChooser.setFileFilter(fileFilters[0]);
        fileChooser.setAcceptAllFileFilterUsed(false);
    }
    fileChooser.setControlButtonsAreShown(true);
    fileChooser.setApproveButtonText(Messages.message("ok"));
    //fileChooser.setCancelButtonText(Messages.message("cancel"));
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileChooser.setFileHidingEnabled(false);
    fileChooser.addActionListener((ActionEvent ae) -> {
            final String cmd = ae.getActionCommand();
            File value = (JFileChooser.APPROVE_SELECTION.equals(cmd))
                ? ((JFileChooser)ae.getSource()).getSelectedFile()
                : cancelFile;
            setValue(value);
        });

    List<ChoiceItem<File>> c = choices();
    initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
 
Example 17
Project: SASS   File: InitializeSimulation.java   Source Code and License Vote up 5 votes
private void backgroundChooseFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backgroundChooseFileActionPerformed
    JFileChooser fc = new JFileChooser();
    int returnVal;
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    //set a default filename 
    fc.setSelectedFile(new File("background.tif"));
    //Set an extension filter
    fc.setFileFilter(new FileNameExtensionFilter("Tif file","tif"));
    returnVal = fc.showOpenDialog(null);
    if  (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    backgroundTifFile = fc.getSelectedFile();
    // background_file_label.setText(backgroundTifFile.getName());
}
 
Example 18
Project: incubator-netbeans   File: ExportDiffSupport.java   Source Code and License Vote up 4 votes
private JFileChooser createFileChooser(File curentDir) {
    final JFileChooser chooser = new AccessibleJFileChooser(NbBundle.getMessage(ExportDiffSupport.class, "ACSD_Export"));
    chooser.setDialogTitle(NbBundle.getMessage(ExportDiffSupport.class, "CTL_Export_Title"));
    chooser.setMultiSelectionEnabled(false);
    javax.swing.filechooser.FileFilter[] old = chooser.getChoosableFileFilters();
    for (int i = 0; i < old.length; i++) {
        javax.swing.filechooser.FileFilter fileFilter = old[i];
        chooser.removeChoosableFileFilter(fileFilter);

    }
    chooser.setCurrentDirectory(curentDir); // NOI18N
    chooser.addChoosableFileFilter(getFileFilter());

    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setApproveButtonMnemonic(NbBundle.getMessage(ExportDiffSupport.class, "MNE_Export_ExportAction").charAt(0));
    chooser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                File destination = chooser.getSelectedFile();
                destination = getTargetFile(destination);
                if (destination.exists()) {
                    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(NbBundle.getMessage(ExportDiffSupport.class, "BK3005", destination.getAbsolutePath()));
                    nd.setOptionType(NotifyDescriptor.YES_NO_OPTION);
                    DialogDisplayer.getDefault().notify(nd);
                    if (nd.getValue().equals(NotifyDescriptor.OK_OPTION) == false) {
                        return;
                    }
                }
                preferences.put("ExportDiff.saveFolder", destination.getParent()); // NOI18N
                panel.setOutputFileText(destination.getAbsolutePath());
            } else {
                dd.setValue(null);
            }
            if(dialog != null) {
                dialog.dispose();
            }
        }
    });
    return chooser;
}
 
Example 19
Project: incubator-netbeans   File: ApplyDiffPatchAction.java   Source Code and License Vote up 4 votes
@Override
protected void performContextAction(Node[] nodes) {
    VCSContext ctx = HgUtils.getCurrentContext(nodes);
    final File roots[] = HgUtils.getActionRoots(ctx);
    if (roots == null || roots.length == 0) {
        return;
    }
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    final JFileChooser fileChooser = new AccessibleJFileChooser(Bundle.ACSD_ApplyDiffPatchBrowseFolder(), null);
    fileChooser.setDialogTitle(Bundle.ApplyDiffPatchBrowse_title());
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setApproveButtonMnemonic(Bundle.ApplyDiffPatch_Apply().charAt(0));
    fileChooser.setApproveButtonText(Bundle.ApplyDiffPatch_Apply());
    fileChooser.setCurrentDirectory(new File(HgModuleConfig.getDefault().getImportFolder()));
    // setup filters, default one filters patch files
    FileFilter patchFilter = new javax.swing.filechooser.FileFilter() {
        @Override
        public boolean accept(File f) {
            return f.getName().endsWith("diff") || f.getName().endsWith("patch") || f.isDirectory();  // NOI18N
        }
        @Override
        public String getDescription() {
            return Bundle.CTL_PatchDialog_FileFilter();
        }
    };
    fileChooser.addChoosableFileFilter(patchFilter);
    fileChooser.setFileFilter(patchFilter);

    DialogDescriptor dd = new DialogDescriptor(fileChooser, Bundle.ApplyDiffPatchBrowse_title());
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    
    fileChooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                final File patchFile = fileChooser.getSelectedFile();
                final RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root);
                new HgProgressSupport() {

                    @Override
                    protected void perform () {
                        if (isNetBeansPatch(patchFile)) {
                            PatchAction.performPatch(patchFile, roots[0]);
                        } else {
                            new ImportDiffAction.ImportDiffProgressSupport(root, patchFile, false, ImportDiffAction.ImportDiffProgressSupport.Kind.PATCH)
                                    .start(rp, root, Bundle.MSG_ApplyDiffPatch_importingPatch());
                        }
                    }
                }.start(rp, root, Bundle.MSG_ApplyDiffPatch_checkingFile());
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);
}
 
Example 20
Project: incubator-netbeans   File: ImportDiffAction.java   Source Code and License Vote up 4 votes
private static void importDiff(VCSContext ctx) {
    final File roots[] = HgUtils.getActionRoots(ctx);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    final JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(ImportDiffAction.class, "ACSD_ImportBrowseFolder"), null);   // NO I18N
    fileChooser.setDialogTitle(NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));                                            // NO I18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setApproveButtonMnemonic(NbBundle.getMessage(ImportDiffAction.class, "Import").charAt(0));                      // NO I18N
    fileChooser.setApproveButtonText(NbBundle.getMessage(ImportDiffAction.class, "Import"));                                        // NO I18N
    fileChooser.setCurrentDirectory(new File(HgModuleConfig.getDefault().getImportFolder()));
    JPanel panel = new JPanel();
    final JRadioButton asPatch = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_PatchOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asPatch, asPatch.getText()); // NOI18N
    final JRadioButton asBundle = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_BundleOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asBundle, asBundle.getText()); // NOI18N
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(asBundle);
    buttonGroup.add(asPatch);
    asPatch.setSelected(true);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(asPatch);
    panel.add(asBundle);
    fileChooser.setAccessory(panel);

    DialogDescriptor dd = new DialogDescriptor(fileChooser, NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));              // NO I18N
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    fileChooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                final File patchFile = fileChooser.getSelectedFile();

                HgModuleConfig.getDefault().setImportFolder(patchFile.getParent());
                RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root);
                ImportDiffProgressSupport.Kind kind;
                if (asBundle.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.BUNDLE;
                } else if (asPatch.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.PATCH;
                } else {
                    kind = null;
                }
                HgProgressSupport support = new ImportDiffProgressSupport(root, patchFile, true, kind);
                support.start(rp, root, org.openide.util.NbBundle.getMessage(ImportDiffAction.class, "LBL_ImportDiff_Progress")); // NOI18N
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);
}