use of blue.ui.utilities.FileChooserManager in project blue by kunstmusik.
the class FrozenSoundObjectEditor method saveCopy.
protected void saveCopy() {
File f = BlueSystem.findFile(fso.getFrozenWaveFileName());
if (f == null) {
NotifyDescriptor descriptor = new NotifyDescriptor.Message("Could not locate frozen file:\n\n" + fso.getFrozenWaveFileName(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
return;
}
final FileChooserManager fcm = FileChooserManager.getDefault();
fcm.setCurrentDirectory(this, BlueSystem.getCurrentProjectDirectory());
File retVal = fcm.showSaveDialog(this, WindowManager.getDefault().getMainWindow());
if (retVal != null) {
File dest = retVal;
if (dest.exists()) {
if (dest.isDirectory()) {
NotifyDescriptor descriptor = new NotifyDescriptor.Message("Destination is a directory.", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
return;
}
if (dest.getName().startsWith("freeze")) {
NotifyDescriptor descriptor = new NotifyDescriptor.Message("Can not overwrite freeze files.", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
return;
}
NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation("Overwrite file " + dest.getName() + "?", NotifyDescriptor.OK_CANCEL_OPTION);
Object conf = DialogDisplayer.getDefault().notify(descriptor);
if (!NotifyDescriptor.OK_OPTION.equals(conf)) {
return;
}
}
try {
FileUtilities.copyFile(f, dest);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
use of blue.ui.utilities.FileChooserManager in project blue by kunstmusik.
the class ScannedMatrixEditor method saveMatrix.
public void saveMatrix() {
if (matrixGridEditor.matrix == null) {
return;
}
final FileChooserManager fcm = FileChooserManager.getDefault();
File rValue = fcm.showSaveDialog(FILE_SAVE, null);
if (rValue != null) {
try {
File temp = rValue;
try (PrintWriter out = new PrintWriter(new FileWriter(temp))) {
int val = 0;
for (int i = 0; i < matrixGridEditor.matrix.length; i++) {
val = matrixGridEditor.matrix[i] ? 1 : 0;
out.write(val + "\n");
}
out.flush();
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, BlueSystem.getString("message.saveError.message"), BlueSystem.getString("message.saveError.title"), JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
}
use of blue.ui.utilities.FileChooserManager in project blue by kunstmusik.
the class TrackEditor method initScaleFileSelector.
// GEN-LAST:event_addColumnButtonActionPerformed
private void initScaleFileSelector() {
final FileChooserManager fcm = FileChooserManager.getDefault();
if (fcm.isDialogDefined(FILE_CHOOSER_ID)) {
return;
}
fcm.setDialogTitle(FILE_CHOOSER_ID, BlueSystem.getString("pianoRoll.selectScalaFile"));
fcm.addFilter(FILE_CHOOSER_ID, new ExtensionFilter("Scala File (*.scl)", "*.scl"));
// SET DEFAULT DIR
String fileName = BlueSystem.getUserConfigurationDirectory();
fileName += File.separator + "scl";
File defaultDir = new File(fileName);
if (defaultDir.exists() && defaultDir.isDirectory()) {
fcm.setSelectedFile(FILE_CHOOSER_ID, defaultDir);
}
}
use of blue.ui.utilities.FileChooserManager in project blue by kunstmusik.
the class ScaleSelectionPanel method initScaleFileSelector.
private void initScaleFileSelector() {
final FileChooserManager fcm = FileChooserManager.getDefault();
if (fcm.isDialogDefined(FILE_CHOOSER_ID)) {
return;
}
fcm.setDialogTitle(FILE_CHOOSER_ID, BlueSystem.getString("pianoRoll.selectScalaFile"));
fcm.addFilter(FILE_CHOOSER_ID, new ExtensionFilter("Scala File (*.scl)", "*.scl"));
// SET DEFAULT DIR
String fileName = BlueSystem.getUserConfigurationDirectory();
fileName += File.separator + "scl";
File defaultDir = new File(fileName);
if (defaultDir.exists() && defaultDir.isDirectory()) {
fcm.setSelectedFile(FILE_CHOOSER_ID, defaultDir);
}
}
use of blue.ui.utilities.FileChooserManager in project blue by kunstmusik.
the class BlueProjectManager method saveAs.
public boolean saveAs() {
FileChooserManager fcm = FileChooserManager.getDefault();
if (getCurrentProject().getDataFile() != null) {
fcm.setSelectedFile(this.getClass(), getCurrentProject().getDataFile());
} else {
fcm.setSelectedFile(this.getClass(), new File(GeneralSettings.getInstance().getDefaultDirectory() + File.separator + "default.blue"));
}
File rValue = fcm.showSaveDialog(this.getClass(), WindowManager.getDefault().getMainWindow());
if (rValue != null) {
File temp = rValue;
if (!(temp.getName().trim().endsWith(".blue"))) {
temp = new File(temp.getAbsolutePath() + ".blue");
}
if (temp.exists()) {
NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation("Are you sure you would like to overwite the project file: " + temp.getAbsolutePath(), "Overwrite Project?");
Object retVal = DialogDisplayer.getDefault().notify(descriptor);
if (retVal != NotifyDescriptor.YES_OPTION) {
return false;
}
}
if (getCurrentProject().isOpenedFromTempFile()) {
getCurrentProject().getTempFile().delete();
getCurrentProject().setOpenedFromTempFile(false);
}
try (PrintWriter out = new PrintWriter(new FileWriter(temp))) {
BlueData data = getCurrentProject().getData();
out.print(data.saveAsXML().toString());
out.flush();
} catch (Exception e) {
NotifyDescriptor descriptor = new NotifyDescriptor.Message("Could not save file:\n\n" + e.getLocalizedMessage(), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
}
StatusDisplayer.getDefault().setStatusText("File saved: " + temp.getName());
// ProgramOptions.addRecentFile(temp);
// blueMenuBar.resetRecentFiles();
// ProgramOptions.save();
//
RecentProjectsList.getInstance().addFile(temp.getAbsolutePath());
// fileName = temp;
getCurrentProject().setDataFile(temp);
BlueSystem.setCurrentProjectDirectory(temp.getParentFile());
temp = null;
fireProjectFileChanged();
// setRevertEnabled();
return true;
// }
// else if (rValue == JFileChooser.CANCEL_OPTION) {
// StatusBar.updateStatus(BlueSystem.getString(
// "message.actionCancelled"));
// return false;
} else {
return false;
}
}
Aggregations