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

The following are Jave code examples for showing how to use removeChoosableFileFilter() 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.
+ Save this method
Example 1
Project: incubator-netbeans   File: ExportSnapshotAction.java   View Source Code 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 2
Project: incubator-netbeans   File: OpenHeapWalkerAction.java   View Source Code Vote up 6 votes
private static File getHeapDumpFile() {
    JFileChooser chooser = new JFileChooser();

    if (importDir != null) {
        chooser.setCurrentDirectory(importDir);
    }

    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);
    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
    chooser.addChoosableFileFilter(new FileFilterImpl());
    chooser.setDialogTitle(
        Bundle.OpenHeapWalkerAction_DialogCaption()
    );

    if (chooser.showOpenDialog(WindowManager.getDefault().getMainWindow()) == JFileChooser.APPROVE_OPTION) {
        importDir = chooser.getCurrentDirectory();

        return chooser.getSelectedFile();
    }

    return null;
}
 
Example 3
Project: incubator-netbeans   File: MercurialOptionsPanelController.java   View Source Code Vote up 6 votes
private void onExportFilenameBrowseClick() {
    File oldFile = getExecutableFile();
    JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(MercurialOptionsPanelController.class, "ACSD_ExportBrowseFolder"), oldFile);   // NOI18N
    fileChooser.setDialogTitle(NbBundle.getMessage(MercurialOptionsPanelController.class, "ExportBrowse_title"));                                            // NOI18N
    fileChooser.setMultiSelectionEnabled(false);
    FileFilter[] old = fileChooser.getChoosableFileFilters();
    for (int i = 0; i < old.length; i++) {
        FileFilter fileFilter = old[i];
        fileChooser.removeChoosableFileFilter(fileFilter);
    }
    fileChooser.showDialog(panel, NbBundle.getMessage(MercurialOptionsPanelController.class, "OK_Button"));                                            // NOI18N
    File f = fileChooser.getSelectedFile();
    if (f != null) {
        panel.exportFilenameTextField.setText(f.getAbsolutePath());
    }
}
 
Example 4
Project: geomapapp   File: ImportImage.java   View Source Code Vote up 6 votes
void open() throws IOException {
	JFileChooser chooser = haxby.map.MapApp.getFileChooser();
	int mode = chooser.getFileSelectionMode();
	boolean multi = chooser.isMultiSelectionEnabled();
	chooser.setMultiSelectionEnabled( true );
	chooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
	chooser.addChoosableFileFilter(imageFileFilter);
	
	int ok = chooser.showOpenDialog(frame);
	File[] choice = null;
	if( ok!=chooser.CANCEL_OPTION ) choice = chooser.getSelectedFiles();
	chooser.setMultiSelectionEnabled(multi);
	chooser.setFileSelectionMode( mode );
	chooser.removeChoosableFileFilter(imageFileFilter);

	if( ok==chooser.CANCEL_OPTION ) {
		return;
	}
	
	if (mapType == MapApp.MERCATOR_MAP)
		openImagesMercator(choice);
	else
		openImagesPolar(choice);
}
 
Example 5
Project: VISNode   File: FileFilterFactory.java   View Source Code Vote up 5 votes
/**
 * Applies the file filter list
 * 
 * @param chooser 
 */
public void apply(JFileChooser chooser) {
    for (FileFilter choosableFileFilter : chooser.getChoosableFileFilters()) {
        chooser.removeChoosableFileFilter(choosableFileFilter);
    }
    for (FileFilter fileFilter : this) {
        chooser.addChoosableFileFilter(fileFilter);
    }
}
 
Example 6
Project: incubator-netbeans   File: SvnProperties.java   View Source Code Vote up 4 votes
public void loadFromFile() {
    final JFileChooser chooser = new AccessibleJFileChooser(NbBundle.getMessage(SvnProperties.class, "ACSD_Properties"));
    chooser.setDialogTitle(NbBundle.getMessage(SvnProperties.class, "CTL_Load_Value_Title"));
    chooser.setMultiSelectionEnabled(false);
    javax.swing.filechooser.FileFilter[] fileFilters = chooser.getChoosableFileFilters();
    for (int i = 0; i < fileFilters.length; i++) {
        javax.swing.filechooser.FileFilter fileFilter = fileFilters[i];
        chooser.removeChoosableFileFilter(fileFilter);
    }

    chooser.setCurrentDirectory(roots[0].getParentFile()); // NOI18N
    chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() {
        @Override
        public boolean accept(File f) {
            return f.exists();
        }
        @Override
        public String getDescription() {
            return "";
        }
    });

    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    chooser.setApproveButtonMnemonic(NbBundle.getMessage(SvnProperties.class, "MNE_LoadValue").charAt(0));
    chooser.setApproveButtonText(NbBundle.getMessage(SvnProperties.class, "CTL_LoadValue"));
    DialogDescriptor dd = new DialogDescriptor(chooser, NbBundle.getMessage(SvnProperties.class, "CTL_Load_Value_Title"));
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                File source = chooser.getSelectedFile();

                if (Utils.isFileContentText(source)) {
                    if (source.canRead()) {
                        StringWriter sw = new StringWriter();
                        try {
                            Utils.copyStreamsCloseAll(sw, new FileReader(source));
                            panel.txtAreaValue.setText(sw.toString());
                        } catch (IOException ex) {
                            Subversion.LOG.log(Level.SEVERE, null, ex);
                        }
                    }
                } else {
                    handleBinaryFile(source);
                }
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);

}
 
Example 7
Project: incubator-netbeans   File: ExportDiffSupport.java   View Source Code 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;
}