Commit ccc9e1d4 authored by Marian Dovgialo's avatar Marian Dovgialo

#45567 signal saving validation check and more userfriendly browse button

parent 29e7f92a
......@@ -3,6 +3,7 @@
*/
package org.signalml.app.model.monitor;
import java.io.File;
import org.signalml.app.video.VideoStreamSpecification;
/**
......@@ -27,19 +28,22 @@
* null and recording is disabled.
*/
public MonitorRecordingDescriptor() {
String default_path = System.getProperty("user.home") + File.separator;
this.signalRecordingFilePath = default_path;
this.videoRecordingFilePath = default_path;
}
/**
* Creates a {@link MonitorRecordingDescriptor} with the given parameters.
*
* @param signalRecordingFilePath a file path to record signal to
* @param tagsRecordingFilePath a file path to record tags to
* @param isTagsRecordingEnabled determines if the tags should be recorded
* @param videoRecordingFilePath a file path to record video to
* @param videoStreamSpecification video stream selected by the user
*/
public MonitorRecordingDescriptor(String signalRecordingFilePath,
String tagsRecordingFilePath, boolean isTagsRecordingEnabled,
boolean isTagsRecordingEnabled,
String videoRecordingFilePath, VideoStreamSpecification videoStreamSpecification) {
this.signalRecordingFilePath = signalRecordingFilePath;
this.tagsRecordingEnabled = isTagsRecordingEnabled;
......
......@@ -307,6 +307,16 @@ private String getRelativePath(String absolutePath) {
@Override
public void actionPerformed(ActionEvent e) {
File file_textbox = new File(getFileNameField().getText());
if (file_textbox.isDirectory())
{
fileChooser.setCurrentDirectory(file_textbox);
}
else
{
}
int returnVal = fileChooser.showSaveDialog(FileSelectPanel.this);
......
......@@ -18,6 +18,8 @@
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import static javax.swing.JOptionPane.YES_NO_OPTION;
import javax.swing.UIManager;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
......@@ -208,7 +210,6 @@ public void setEnabled(boolean enabled) {
* Resets the signal and tag recording filenames to default.
*/
public void resetFileNames() {
// TODO: GET HOME DIR
getSelectSignalRecordingFilePanel().setFileName("");
}
......@@ -220,23 +221,24 @@ public void resetFileNames() {
public void validatePanel(Object model, ValidationErrors errors) {
String recordingFileName = getSelectSignalRecordingFilePanel().getFileName();
validateRecordingFileName("Signal", recordingFileName, errors);
validateRecordingFileName("Signal", recordingFileName, errors, ".obci.raw");
if (getEnableVideoRecordingPanel().isRecordingEnabled()) {
String videoRecordingFileName = getSelectVideoRecordingFilePanel().getFileName();
validateRecordingFileName("Video", videoRecordingFileName, errors);
validateRecordingFileName("Video", videoRecordingFileName, errors, ".mkv");
}
}
private static void validateRecordingFileName(String type, String recordingFileName, ValidationErrors errors) {
private static void validateRecordingFileName(String type, String recordingFileName, ValidationErrors errors, String ext) {
if (recordingFileName.isEmpty()) {
errors.addError(_R("Please input a correct {0} filename", type.toLowerCase()));
}
else if ((new File(recordingFileName)).exists()) {
else if ((new File(recordingFileName + ext)).exists()) {
int answer = JOptionPane.showConfirmDialog(null,
_R("{0} recording target file already exists! Do you want to overwrite?", type));
if (answer == JOptionPane.CANCEL_OPTION || answer == JOptionPane.NO_OPTION)
errors.addError("");
_R("{0} recording target file already exists! Do you want to overwrite?", type),
UIManager.getString("OptionPane.titleText"),YES_NO_OPTION);
if (answer == JOptionPane.NO_OPTION)
errors.addError(_R("Please choose different filename for {0} file", type.toLowerCase()));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment