use of org.openide.filesystems.FileChooserBuilder in project netbeans-php-enhancements by beberlei.
the class CodeSnifferOptionsPanel method browseButtonActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_browseButtonActionPerformed
File codeSnifferScript = new FileChooserBuilder(CodeSnifferOptionsPanel.class.getName() + CODE_SNIFFER_LAST_FOLDER_SUFFIX).setTitle(NbBundle.getMessage(CodeSnifferOptionsPanel.class, "LBL_CodeSnifferSelect")).setFilesOnly(true).showOpenDialog();
if (codeSnifferScript != null) {
codeSnifferScript = FileUtil.normalizeFile(codeSnifferScript);
codeSnifferTextField.setText(codeSnifferScript.getAbsolutePath());
refresh();
}
}
use of org.openide.filesystems.FileChooserBuilder in project netbeans-mmd-plugin by raydac.
the class PlainTextEditor method buttonSaveActionPerformed.
// GEN-LAST:event_buttonLoadActionPerformed
private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonSaveActionPerformed
// NOI18N
final File home = new File(System.getProperty("user.home"));
final File toSave = new FileChooserBuilder("user-home-dir").setTitle(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonSaveActionPerformed.saveTitle")).addFileFilter(TEXT_FILE_FILTER).setFileFilter(TEXT_FILE_FILTER).setFilesOnly(true).setDefaultWorkingDirectory(home).showSaveDialog();
if (toSave != null) {
try {
final String text = getText();
// NOI18N
FileUtils.writeStringToFile(toSave, text, "UTF-8");
} catch (Exception ex) {
// NOI18N
LOGGER.error("Error during text file saving", ex);
NbUtils.msgError(null, java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonSaveActionPerformed.msgError"));
}
}
}
use of org.openide.filesystems.FileChooserBuilder in project netbeans-mmd-plugin by raydac.
the class PlainTextEditor method buttonLoadActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void buttonLoadActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_buttonLoadActionPerformed
// NOI18N
final File home = new File(System.getProperty("user.home"));
final File toOpen = // NOI18N
new FileChooserBuilder("user-home-dir").setTitle(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonLoadActionPerformed.title")).addFileFilter(TEXT_FILE_FILTER).setFileFilter(TEXT_FILE_FILTER).setFilesOnly(true).setDefaultWorkingDirectory(home).showOpenDialog();
if (toOpen != null) {
try {
// NOI18N
final String text = FileUtils.readFileToString(toOpen, "UTF-8");
setText(text);
} catch (Exception ex) {
// NOI18N
LOGGER.error("Error during text file loading", ex);
NbUtils.msgError(null, java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("PlainTextEditor.buttonLoadActionPerformed.msgError"));
}
}
}
use of org.openide.filesystems.FileChooserBuilder in project Universal-G-Code-Sender by winder.
the class NewDesignAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
try {
FileChooserBuilder fcb = new FileChooserBuilder(OpenAction.class);
fcb.setFileFilter(OpenAction.DESIGN_FILE_FILTER);
JFileChooser fileChooser = fcb.createFileChooser();
fileChooser.setFileHidingEnabled(true);
if (fileChooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
File file = new File(StringUtils.appendIfMissing(fileChooser.getSelectedFile().getAbsolutePath(), ".ugsd"));
FileObject dir = FileUtil.toFileObject(fileChooser.getSelectedFile().getParentFile());
// Removing the old file
if (file.exists()) {
if (JOptionPane.showConfirmDialog(SwingUtilities.getRoot((Component) e.getSource()), "Are you sure you want to overwrite the file " + file.getName(), "Overwrite existing file", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
file.delete();
} else {
return;
}
}
FileObject fileObject = dir.createData(file.getName());
DataObject.find(fileObject).getLookup().lookup(OpenCookie.class).open();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
Aggregations