Commit c7a616ee authored by Marian Dovgialo's avatar Marian Dovgialo

#46055 svarog saving dialog will now correctly ignore signal file extensions

parent f0d6f1ad
......@@ -138,7 +138,7 @@ public String getVideoRecordingFilePathWithExtension() {
* will be recorded.
*/
public void setVideoRecordingFilePath(String videoRecordingFilePath) {
this.videoRecordingFilePath = videoRecordingFilePath;
this.videoRecordingFilePath = videoRecordingFilePath;
}
/**
......
......@@ -23,6 +23,8 @@
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.log4j.Logger;
import static org.signalml.app.view.document.monitor.ChooseFilesForMonitorRecordingPanel.OBCI_SERVER_RAW_EXTENSION;
import static org.signalml.app.view.document.monitor.ChooseFilesForMonitorRecordingPanel.OBCI_SERVER_VIDEO_EXTENSION;
/**
* This class represents a panel which may be used to select a file.
......@@ -154,7 +156,20 @@ public void setFileName(String fileName) {
* @return a file name which was selected using this panel.
*/
public String getFileName() {
return this.fileNameField.getText();
String fileName = this.fileNameField.getText();
if (fileName.endsWith(OBCI_SERVER_VIDEO_EXTENSION))
{
int last_letter_index = fileName.length() - OBCI_SERVER_VIDEO_EXTENSION.length();
fileName = fileName.substring(0, last_letter_index);
}
if (fileName.endsWith(OBCI_SERVER_RAW_EXTENSION))
{
int last_letter_index = fileName.length() - OBCI_SERVER_RAW_EXTENSION.length();
fileName = fileName.substring(0, last_letter_index);
}
return fileName;
}
/**
......@@ -309,14 +324,7 @@ private String getRelativePath(String absolutePath) {
public void actionPerformed(ActionEvent e) {
File file_textbox = new File(getFileNameField().getText());
if (file_textbox.isDirectory())
{
fileChooser.setCurrentDirectory(file_textbox);
}
else
{
}
fileChooser.setCurrentDirectory(file_textbox);
int returnVal = fileChooser.showSaveDialog(FileSelectPanel.this);
......
......@@ -47,7 +47,7 @@
* @param message the error
*/
public static void showError(final String message) {
showError("Error", message);
showError(_("Error"), message);
}
public static void showError(final String title, final String message) {
......@@ -55,7 +55,7 @@ public static void showError(final String title, final String message) {
@Override
public void run() {
Window dialogParent = SvarogApplication.getSharedInstance().getViewerElementManager().getDialogParent();
JOptionPane.showMessageDialog(dialogParent, message, _(title), JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(dialogParent, message, title, JOptionPane.ERROR_MESSAGE);
}
});
}
......
......@@ -69,6 +69,10 @@
*/
private EnableRecordingPanel enableVideoRecordingPanel;
static final public String OBCI_SERVER_RAW_EXTENSION = ".obci.raw";
static final public String OBCI_SERVER_VIDEO_EXTENSION = ".mkv";
/**
* Constructor.
*
......@@ -221,11 +225,11 @@ public void resetFileNames() {
public void validatePanel(Object model, ValidationErrors errors) {
String recordingFileName = getSelectSignalRecordingFilePanel().getFileName();
validateRecordingFileName("Signal", recordingFileName, errors, ".obci.raw");
validateRecordingFileName("Signal", recordingFileName, errors, OBCI_SERVER_RAW_EXTENSION);
if (getEnableVideoRecordingPanel().isRecordingEnabled()) {
String videoRecordingFileName = getSelectVideoRecordingFilePanel().getFileName();
validateRecordingFileName("Video", videoRecordingFileName, errors, ".mkv");
validateRecordingFileName("Video", videoRecordingFileName, errors, OBCI_SERVER_VIDEO_EXTENSION);
}
}
......
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