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

The following are Jave code examples for showing how to use setAcceptAllFileFilterUsed() 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: SER316-Ingolstadt   File: Util.java   Source Code and License Vote up 6 votes
public static boolean checkBrowser() {
    AppList appList = MimeTypesList.getAppList();
    String bpath = appList.getBrowserExec();
    if (bpath != null)
        if (new File(bpath).isFile())
            return true;
    JFileChooser chooser = new JFileChooser();
    chooser.setFileHidingEnabled(false);
    chooser.setDialogTitle(Local.getString("Select the web-browser executable"));
    chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);*/
    if (chooser.showOpenDialog(App.getFrame()) != JFileChooser.APPROVE_OPTION)
        return false;
    appList.setBrowserExec(chooser.getSelectedFile().getPath());
    CurrentStorage.get().storeMimeTypesList();
    return true;
}
 
Example 2
Project: incubator-netbeans   File: AddWebServiceDlg.java   Source Code and License Vote up 6 votes
private void jBtnBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnBrowseActionPerformed

    jRbnFilesystem.setSelected(false);
    jRbnFilesystem.setSelected(true);
    enableControls();

    JFileChooser chooser = new JFileChooser(previousDirectory);
    chooser.setMultiSelectionEnabled(false);
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.addChoosableFileFilter(WSDL_FILE_FILTER);
    chooser.setFileFilter(WSDL_FILE_FILTER);

    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        File wsdlFile = chooser.getSelectedFile();
        jTxtLocalFilename.setText(wsdlFile.getAbsolutePath());
        previousDirectory = wsdlFile.getPath();
    }
}
 
Example 3
Project: SimQRI   File: ReportManager.java   Source Code and License Vote up 6 votes
@SuppressWarnings("unused")
private String selectDirectoryPath() {
	String path = "";
	JFileChooser chooser = new JFileChooser();
    // chooser.setCurrentDirectory(new java.io.File("."));
    chooser.setDialogTitle("Select a destination folder for your reports !");
    chooser.setCurrentDirectory(new File("current workspace ?"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
    	path = chooser.getSelectedFile().toString();
    else
    	path = "";
    return path;
}
 
Example 4
Project: Install_Builder_Universal   File: OpenDirectory.java   Source Code and License Vote up 5 votes
public void open(final JPanel panel) {
	JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
    chooser.setDialogTitle("Choose Directory");
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
      dir = chooser.getSelectedFile().toString();
    } else {
      System.err.println("Could not open Dir");
      return;
    }
}
 
Example 5
Project: guetzliconverter   File: GuetzliConverter.java   Source Code and License Vote up 5 votes
private void buttonChooseFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonChooseFolderActionPerformed
    String lastFile = ConfigManager.loadConfig(boxArch, boxLimit, sliderQuality, labelQualityValue, false, boxProcessCount);
    JFileChooser chooser = new JFileChooser(lastFile);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);
    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
        sourceFolderComplete.clear();
        ConfigManager.saveConfig(chooser.getSelectedFile().getAbsolutePath().toString(), boxArch.getSelectedIndex(), boxLimit.getSelectedIndex(), sliderQuality.getValue(), boxProcessCount.getSelectedIndex());
        displayDirectoryContents(chooser.getSelectedFile());
        textFieldSelectedFile.setText(chooser.getSelectedFile().getAbsolutePath().toString() + "\\*->*_guetzli.jpg");
        buttonConvert.setEnabled(true);
        convertType = "folder";
    }
}
 
Example 6
Project: brModelo   File: Dialogos.java   Source Code and License Vote up 5 votes
public static File ShowDlgSaveDiagrama(JComponent form, Diagrama diag) {
    JFileChooser f = new JFileChooser();
    //f.setDialogTitle(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
    f.setFileSelectionMode(JFileChooser.FILES_ONLY);

    FileFilter filter = new FileNameExtensionFilter("BrModelo(bin)", Arquivo.brM3);
    FileFilter filter2 = new FileNameExtensionFilter("BrModelo(xml)", Arquivo.xml);
    f.addChoosableFileFilter(filter);
    f.addChoosableFileFilter(filter2);
    f.setAcceptAllFileFilterUsed(false);
    f.setFileFilter(filter);
    if (dir.isEmpty()) dir = System.getProperty("user.dir");
    f.setCurrentDirectory(new File(dir + "."));
    f.setDialogTitle(Editor.fromConfiguracao.getValor("Controler.MSG_SAVE_TITLE") + " " + diag.getNomeFormatado());
    if (!diag.getNome().isEmpty()){ 
        f.setSelectedFile(new File(diag.getNome()));
    }
    //f.setApproveButtonText(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));
    int returnVal = f.showSaveDialog(form);
    //int returnVal = f.showDialog(form, Editor.fromConfiguracao.getValor("Controler.dlg.modelo.salvar"));

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();
        String ext = Arquivo.getExtension(file);
        if (ext == null) {
            ext = "";
        }
        String arq = file.getAbsolutePath();
        dir = f.getCurrentDirectory().getAbsolutePath();
        if (f.getFileFilter().equals(filter) && !Arquivo.brM3.toUpperCase().equals(ext.toUpperCase())) {
            return new File(arq + "." + Arquivo.brM3);
        }
        if (f.getFileFilter().equals(filter2) && !Arquivo.xml.toUpperCase().equals(ext.toUpperCase())) {
            return new File(arq + "." + Arquivo.xml);
        }
        return file;
    } else {
        return null;
    }
}
 
Example 7
Project: smile_1.5.0_java7   File: PlotPanel.java   Source Code and License Vote up 5 votes
/**
 * Shows a file chooser and exports the plot to the selected image file.
 * @throws IOException if an error occurs during writing.
 */
public void save() throws IOException {
    JFileChooser fc = FileChooser.getInstance();
    fc.setFileFilter(FileChooser.SimpleFileFilter.getWritableImageFIlter());
    fc.setAcceptAllFileFilterUsed(false);
    fc.setSelectedFiles(new File[0]);
    int returnVal = fc.showSaveDialog(this);

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        save(file);
    }        
}
 
Example 8
Project: SER316-Dresden   File: SetApplicationPanel.java   Source Code and License Vote up 5 votes
void selectAppBrowseB_actionPerformed(ActionEvent e) {
// Fix until Sun's JVM supports more locales...
UIManager.put("FileChooser.lookInLabelText", Local.getString("Look in:"));
UIManager.put("FileChooser.upFolderToolTipText", Local.getString("Up One Level"));
UIManager.put("FileChooser.newFolderToolTipText", Local.getString("Create New Folder"));
UIManager.put("FileChooser.listViewButtonToolTipText", Local.getString("List"));
UIManager.put("FileChooser.detailsViewButtonToolTipText", Local.getString("Details"));
UIManager.put("FileChooser.fileNameLabelText", Local.getString("File Name:"));
UIManager.put("FileChooser.filesOfTypeLabelText", Local.getString("Files of Type:"));
UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
UIManager.put("FileChooser.openButtonToolTipText", Local.getString("Open selected file"));
UIManager.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
UIManager.put("FileChooser.cancelButtonToolTipText", Local.getString("Cancel"));
UIManager.put("FileChooser.acceptAllFileFilterText", Local.getString("All Files") + " (*.*)");

JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(Local.getString("Path to executable"));
chooser.setFileHidingEnabled(false);
chooser.setAcceptAllFileFilterUsed(true);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (System.getProperty("os.name").startsWith("Win")) {
    chooser.setFileFilter(new AllFilesFilter(AllFilesFilter.EXE));
    chooser.setCurrentDirectory(new File("C:\\Program Files"));
}
chooser.setPreferredSize(new Dimension(550, 375));
/*
    java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_IMPORT_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);
*/
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
    applicationField.setText(chooser.getSelectedFile().getPath());
}
 
Example 9
Project: PekaED   File: PekaEDGUI.java   Source Code and License Vote up 5 votes
private boolean showSaveDialog() {
	JFileChooser fc = new JFileChooser(Settings.EPISODES_PATH);
	
	fc.setDialogTitle("Save level");
	
	fc.setAcceptAllFileFilterUsed(false);
	
	fc.setFileFilter(new FileFilter() {

		@Override
		public boolean accept(File f) {
			return f.isDirectory() || f.getName().endsWith("map") && f.getName().length() < 39;
		}

		@Override
		public String getDescription() {
			return "Pekka Kana 2 level";
		}
		
	});
	
	int res = fc.showSaveDialog(frame);
	
	if (res == JFileChooser.APPROVE_OPTION) {
		Data.currentFile = fc.getSelectedFile();
		saveLevel(fc.getSelectedFile());
		
		return true;
	}
	
	return false;
}
 
Example 10
Project: Equella   File: DialogUtils.java   Source Code and License Vote up 5 votes
private static DialogResult doDialog(Component parent, boolean isOpenDialog, String title, FileFilter filter,
	boolean acceptAllFilter, File defaultFile)
{
	JFileChooser chooser = new JFileChooser(getDirectory());
	if( title != null )
	{
		chooser.setDialogTitle(title);
	}
	if( filter != null )
	{
		chooser.setFileFilter(filter);
	}
	if( defaultFile != null )
	{
		chooser.setSelectedFile(defaultFile);
	}
	if( !acceptAllFilter )
	{
		chooser.setAcceptAllFileFilterUsed(false);
	}

	int result = 0;
	if( isOpenDialog )
	{
		result = chooser.showOpenDialog(parent);
	}
	else
	{
		result = chooser.showSaveDialog(parent);
	}
	return new DialogResult(result, chooser.getSelectedFile(), chooser.getCurrentDirectory());
}
 
Example 11
Project: incubator-netbeans   File: NbPlatformCustomizerJavadoc.java   Source Code and License Vote up 5 votes
private void addZipFolder(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addZipFolder
    JFileChooser chooser = new JFileChooser(ModuleUISettings.getDefault().getLastUsedNbPlatformLocation());
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setFileFilter(new FileFilter() {
        public boolean accept(File f)  {
            return f.isDirectory() ||
                    f.getName().toLowerCase(Locale.US).endsWith(".jar") || // NOI18N
                    f.getName().toLowerCase(Locale.US).endsWith(".zip"); // NOI18N
        }
        public String getDescription() {
            return getMessage("CTL_JavadocTab");
        }
    });
    int ret = chooser.showOpenDialog(this);
    if (ret == JFileChooser.APPROVE_OPTION) {
        File javadocRoot = FileUtil.normalizeFile(chooser.getSelectedFile());
        URL newUrl = FileUtil.urlForArchiveOrDir(javadocRoot);
        if (model.containsRoot(newUrl)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                getMessage("MSG_ExistingJavadocRoot")));
        } else {
            ModuleUISettings.getDefault().setLastUsedNbPlatformLocation(javadocRoot.getParentFile().getAbsolutePath());
            model.addJavadocRoot(newUrl);
            javadocList.setSelectedValue(newUrl, true);
        }
    }
    // XXX support adding Javadoc URL too (see java.j2seplatform)
}
 
Example 12
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 13
Project: brModelo   File: Dialogos.java   Source Code and License Vote up 5 votes
/**
 * param preDir = pode ser diretório ou arquivo (não importa)
 * @param preDir
 * @param master
 * @return 
 */
public static File ShowDlgLoadDiagrama(String preDir, Editor master) {
    JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.FILES_ONLY);

    f.setFileFilter(new FileNameExtensionFilter("BrModelo", Arquivo.brM3, Arquivo.xml));
    f.addChoosableFileFilter(new FileNameExtensionFilter("BrModelo(bin)", Arquivo.brM3));
    f.addChoosableFileFilter(new FileNameExtensionFilter("BrModelo(xml)", Arquivo.xml));
    f.setAcceptAllFileFilterUsed(true);
    
    if (preDir == null || "".equals(preDir)) {
        f.setCurrentDirectory(new File(System.getProperty("user.dir")));
    } else {
        File f2 = new File(preDir);
        if (f2.isDirectory()) {
            f.setCurrentDirectory(f2);
        } else {
            f.setCurrentDirectory(new File(f2.getPath()));
        }
    }

    //f.setApproveButtonText(Editor.fromConfiguracao.getValor("Controler.dlg.modelo.abrir"));
    int returnVal = f.showOpenDialog((Component) master.getFramePrincipal());

    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = f.getSelectedFile();
        if (!file.exists()) {
            return null;
        }
        return file;
    } else {
        return null;
    }
}
 
Example 14
Project: Idea-Plagiarism   File: GUI.java   Source Code and License Vote up 5 votes
static String getDirectory() {
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new java.io.File("~"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        return chooser.getSelectedFile().getAbsolutePath();
    }
    return null;
}
 
Example 15
Project: incubator-netbeans   File: PanelProjectLocationVisual.java   Source Code and License Vote up 5 votes
private static JFileChooser createChooser() {
    JFileChooser chooser = new JFileChooser();
    FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
    chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
    chooser.setAcceptAllFileFilterUsed( false );
    chooser.setName( "Select Project Directory" ); // XXX // NOI18N
    return chooser;
}
 
Example 16
Project: AgentWorkbench   File: ChartEditorJPanel.java   Source Code and License Vote up 4 votes
private void saveAsImage(){
	
	// --- Determine image size ----------------------------
	Integer imageWidth = Integer.parseInt(this.getTfImageWidth().getText());
	if (imageWidth==0) {
		JOptionPane.showMessageDialog(this, Language.translate("Bitte nur ganze Zahlen größer 0 eingeben!"), Language.translate("Fehlerhafte Eingabe"), JOptionPane.ERROR_MESSAGE);
		this.setImageDefaultValues();
		return;
	}
	Integer imageHeight = Integer.parseInt(this.getTfImageHeight().getText());
	if (imageHeight==0) {
		JOptionPane.showMessageDialog(this, Language.translate("Bitte nur ganze Zahlen größer 0 eingeben!"), Language.translate("Fehlerhafte Eingabe"), JOptionPane.ERROR_MESSAGE);
		this.setImageDefaultValues();
		return;
	}
	
	String currentFolder = null;
	if (Application.getGlobalInfo()!=null) {
		// --- Get the last selected folder of Agent.GUI ---
		currentFolder = Application.getGlobalInfo().getLastSelectedFolderAsString();
	}

	// --- Create instance of JFileChooser -----------------
	JFileChooser jfc = new JFileChooser();
	jfc.setMultiSelectionEnabled(false);
	jfc.setAcceptAllFileFilterUsed(false);

	// --- Add custom icons for file types. ----------------
	jfc.setFileView(new ImageFileView());
	// --- Add the preview pane. ---------------------------
	jfc.setAccessory(new ImagePreview(jfc));

	// --- Set the file filter -----------------------------
	String[] extensionsJPEG = {ImageUtils.jpg, ImageUtils.jpeg};

	ConfigurableFileFilter filterJPG = new ConfigurableFileFilter(extensionsJPEG, "JPEG - Image");
	ConfigurableFileFilter filterPNG = new ConfigurableFileFilter(ImageUtils.png, "PNG - File");
	ConfigurableFileFilter filterGIF = new ConfigurableFileFilter(ImageUtils.gif, "GIF - Image");

	jfc.addChoosableFileFilter(filterGIF);
	jfc.addChoosableFileFilter(filterJPG);
	jfc.addChoosableFileFilter(filterPNG);

	jfc.setFileFilter(filterPNG);

	// --- Maybe set the current directory -----------------
	if (currentFolder != null) {
		jfc.setCurrentDirectory(new File(currentFolder));
	}
	
	// === Show dialog and wait on user action =============
	int state = jfc.showSaveDialog(this);
	
	if (state == JFileChooser.APPROVE_OPTION) {
		ConfigurableFileFilter cff = (ConfigurableFileFilter) jfc.getFileFilter();
		String selectedExtension = cff.getFileExtension()[0];
		String mustExtension = "." + selectedExtension;

		File selectedFile = jfc.getSelectedFile();
		if (selectedFile != null) {
			String selectedPath = selectedFile.getAbsolutePath();
			if (selectedPath.endsWith(mustExtension) == false) {
				selectedPath = selectedPath + mustExtension;
			}
			
			BufferedImage image = this.exportChartAsImage(imageWidth, imageHeight);
			this.writeImageFile(image, selectedPath, selectedExtension);
			
			if (Application.getGlobalInfo() != null) {
				Application.getGlobalInfo().setLastSelectedFolder(jfc.getCurrentDirectory());
			}
		}
	}
}
 
Example 17
Project: incubator-netbeans   File: J2SEPlatformCustomizer.java   Source Code and License Vote up 4 votes
private static boolean select(
    final PathModel model,
    final File[] currentDir,
    final Component parentComponent) {
    final JFileChooser chooser = new JFileChooser ();
    chooser.setMultiSelectionEnabled (true);
    String title = null;
    String message = null;
    String approveButtonName = null;
    String approveButtonNameMne = null;
    if (model.type == SOURCES) {
        title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
        message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Sources");
        approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenSources");
        approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenSources");
    } else if (model.type == JAVADOC) {
        title = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
        message = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_Javadoc");
        approveButtonName = NbBundle.getMessage (J2SEPlatformCustomizer.class,"TXT_OpenJavadoc");
        approveButtonNameMne = NbBundle.getMessage (J2SEPlatformCustomizer.class,"MNE_OpenJavadoc");
    }
    chooser.setDialogTitle(title);
    chooser.setApproveButtonText(approveButtonName);
    chooser.setApproveButtonMnemonic (approveButtonNameMne.charAt(0));
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    if (Utilities.isMac()) {
        //New JDKs and JREs are bundled into package, allow JFileChooser to navigate in
        chooser.putClientProperty("JFileChooser.packageIsTraversable", "always");   //NOI18N
    }
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed( false );
    chooser.setFileFilter (new ArchiveFileFilter(message,new String[] {"ZIP","JAR"}));   //NOI18N
    if (currentDir[0] != null) {
        chooser.setCurrentDirectory(currentDir[0]);
    }
    if (chooser.showOpenDialog(parentComponent) == JFileChooser.APPROVE_OPTION) {
        File[] fs = chooser.getSelectedFiles();
        boolean addingFailed = false;
        for (File f : fs) {
            //XXX: JFileChooser workaround (JDK bug #5075580), double click on folder returns wrong file
            // E.g. for /foo/src it returns /foo/src/src
            // Try to convert it back by removing last invalid name component
            if (!f.exists()) {
                File parent = f.getParentFile();
                if (parent != null && f.getName().equals(parent.getName()) && parent.exists()) {
                    f = parent;
                }
            }
            if (f.exists()) {
                addingFailed|=!model.addPath (f);
            }
        }
        if (addingFailed) {
            new NotifyDescriptor.Message (NbBundle.getMessage(J2SEPlatformCustomizer.class,"TXT_CanNotAddResolve"),
                    NotifyDescriptor.ERROR_MESSAGE);
        }
        currentDir[0] = FileUtil.normalizeFile(chooser.getCurrentDirectory());
        return true;
    }
    return false;
}
 
Example 18
Project: SER316-Ingolstadt   File: EditorPanel.java   Source Code and License Vote up 4 votes
void importB_actionPerformed(ActionEvent e) {
	// Fix until Sun's JVM supports more locales...
	UIManager.put("FileChooser.lookInLabelText", Local
			.getString("Look in:"));
	UIManager.put("FileChooser.upFolderToolTipText", Local
			.getString("Up One Level"));
	UIManager.put("FileChooser.newFolderToolTipText", Local
			.getString("Create New Folder"));
	UIManager.put("FileChooser.listViewButtonToolTipText", Local
			.getString("List"));
	UIManager.put("FileChooser.detailsViewButtonToolTipText", Local
			.getString("Details"));
	UIManager.put("FileChooser.fileNameLabelText", Local
			.getString("File Name:"));
	UIManager.put("FileChooser.filesOfTypeLabelText", Local
			.getString("Files of Type:"));
	UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
	UIManager.put("FileChooser.openButtonToolTipText", Local
			.getString("Open selected file"));
	UIManager
			.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
	UIManager.put("FileChooser.cancelButtonToolTipText", Local
			.getString("Cancel"));

	JFileChooser chooser = new JFileChooser();
	chooser.setFileHidingEnabled(false);
	chooser.setDialogTitle(Local.getString("Insert file"));
	chooser.setAcceptAllFileFilterUsed(false);
	chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
	chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.HTML));
	chooser.setPreferredSize(new Dimension(550, 375));
	String lastSel = (String) Context.get("LAST_SELECTED_IMPORT_FILE");
	if (lastSel != null)
		chooser.setCurrentDirectory(new java.io.File(lastSel));
	if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
		return;

	Context.put("LAST_SELECTED_IMPORT_FILE", chooser.getSelectedFile()
			.getPath());

	File f = chooser.getSelectedFile();
	new HTMLFileImport(f, editor);
}
 
Example 19
Project: SER316-Aachen   File: EditorPanel.java   Source Code and License Vote up 4 votes
void importB_actionPerformed(ActionEvent e) {
	// Fix until Sun's JVM supports more locales...
	UIManager.put("FileChooser.lookInLabelText", Local
			.getString("Look in:"));
	UIManager.put("FileChooser.upFolderToolTipText", Local
			.getString("Up One Level"));
	UIManager.put("FileChooser.newFolderToolTipText", Local
			.getString("Create New Folder"));
	UIManager.put("FileChooser.listViewButtonToolTipText", Local
			.getString("List"));
	UIManager.put("FileChooser.detailsViewButtonToolTipText", Local
			.getString("Details"));
	UIManager.put("FileChooser.fileNameLabelText", Local
			.getString("File Name:"));
	UIManager.put("FileChooser.filesOfTypeLabelText", Local
			.getString("Files of Type:"));
	UIManager.put("FileChooser.openButtonText", Local.getString("Open"));
	UIManager.put("FileChooser.openButtonToolTipText", Local
			.getString("Open selected file"));
	UIManager
			.put("FileChooser.cancelButtonText", Local.getString("Cancel"));
	UIManager.put("FileChooser.cancelButtonToolTipText", Local
			.getString("Cancel"));

	JFileChooser chooser = new JFileChooser();
	chooser.setFileHidingEnabled(false);
	chooser.setDialogTitle(Local.getString("Insert file"));
	chooser.setAcceptAllFileFilterUsed(false);
	chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
	chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.TXT));
	chooser.addChoosableFileFilter(new AllFilesFilter(AllFilesFilter.HTML));
	chooser.setPreferredSize(new Dimension(550, 375));
	String lastSel = (String) Context.get("LAST_SELECTED_IMPORT_FILE");
	if (lastSel != null)
		chooser.setCurrentDirectory(new java.io.File(lastSel));
	if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
		return;

	Context.put("LAST_SELECTED_IMPORT_FILE", chooser.getSelectedFile()
			.getPath());

	File f = chooser.getSelectedFile();
	new HTMLFileImport(f, editor);
}
 
Example 20
Project: incubator-netbeans   File: ProjectChooserAccessory.java   Source Code and License Vote up 4 votes
/** Factory method for project chooser
 */
public static JFileChooser createProjectChooser( boolean defaultAccessory ) {

    ProjectManager.getDefault().clearNonProjectCache(); // #41882

    OpenProjectListSettings opls = OpenProjectListSettings.getInstance();
    JFileChooser chooser = new ProjectFileChooser();
    chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );

    if ("GTK".equals(javax.swing.UIManager.getLookAndFeel().getID())) { // NOI18N
        // see BugTraq #5027268
        chooser.putClientProperty("GTKFileChooser.showDirectoryIcons", Boolean.TRUE); // NOI18N
        //chooser.putClientProperty("GTKFileChooser.showFileIcons", Boolean.TRUE); // NOI18N
    }

    chooser.setApproveButtonText( NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonText" ) ); // NOI18N
    chooser.setApproveButtonMnemonic( NbBundle.getMessage( ProjectChooserAccessory.class, "MNM_PrjChooser_ApproveButtonText" ).charAt (0) ); // NOI18N
    chooser.setApproveButtonToolTipText (NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonTooltipText")); // NOI18N
    // chooser.setMultiSelectionEnabled( true );
    chooser.setDialogTitle( NbBundle.getMessage( ProjectChooserAccessory.class, "LBL_PrjChooser_Title" ) ); // NOI18N
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed( false );
    chooser.setFileFilter( ProjectDirFilter.INSTANCE );

    // A11Y
    chooser.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AN_ProjectChooserAccessory"));
    chooser.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AD_ProjectChooserAccessory"));


    if ( defaultAccessory ) {
        chooser.setAccessory(new ProjectChooserAccessory(chooser, opls.isOpenSubprojects()));
    }

    File currDir = null;
    String dir = opls.getLastOpenProjectDir();
    if ( dir != null ) {
        File d = new File( dir );
        if ( d.exists() && d.isDirectory() ) {
            currDir = d;
        }
    }

    FileUtil.preventFileChooserSymlinkTraversal(chooser, currDir);
    new ProjectFileView(chooser);

    return chooser;

}