Skip to content

Commit

Permalink
Added filter in saveFileDialog in order to save files with siard ext #…
Browse files Browse the repository at this point in the history
…167 [skip ci]
  • Loading branch information
006627 authored and hmiguim committed Sep 11, 2019
1 parent 2a1a18e commit 1ac7dd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public class ViewerConstants {
public static final String SHA256 = "SHA-256";
public static final String MD5 = "MD5";
public static final Long MILLISECONDS_IN_A_DAY = 86400000L;
public static final String SIARD_FILES = "SIARD files";

/*
* Application Environment
Expand All @@ -252,6 +253,7 @@ public class ViewerConstants {
*/
public static final String TXT_SUFFIX = ".txt";
public static final String YAML_SUFFIX = ".yaml";
public static final String SIARD_SUFFIX = "siard";

/*
* DBPTK Input Types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ public static native void showItemInFolder(String path) /*-{
shell.showItemInFolder(path);
}-*/;

public static native String saveFileDialog() /*-{
public static native String saveFileDialog(JavaScriptObject options) /*-{
var dialog = $wnd.nodeRequire('electron').remote.dialog
var result = dialog.showSaveDialog();
var result = dialog.showSaveDialog(options);
if (typeof result != "undefined") { return result; }
else return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.databasepreservation.main.desktop.client.common.FileUploadField;
import com.databasepreservation.main.desktop.client.common.GenericField;
import com.databasepreservation.main.desktop.shared.models.DBPTKModule;
import com.databasepreservation.main.desktop.shared.models.Filter;
import com.databasepreservation.main.desktop.shared.models.PreservationParameter;
import com.databasepreservation.main.desktop.shared.models.wizardParameters.ExportOptionsParameters;
import com.google.gwt.core.client.GWT;
Expand Down Expand Up @@ -75,7 +76,7 @@ private SIARDExportOptionsCurrent(String version, DBPTKModule dbptkModule) {
if (p.getExportOption().equals(ViewerConstants.SIARD_EXPORT_OPTIONS)) {
buildGenericWidget(p);
} else if (p.getExportOption().equals(ViewerConstants.EXTERNAL_LOBS_EXPORT_OPTIONS)) {
buildExternalLobs(p, panel);
buildExternalLobs(p, panel);
}
}
}
Expand Down Expand Up @@ -285,7 +286,14 @@ private void buildGenericWidget(PreservationParameter parameter) {
fileUploadField.setRequired(parameter.isRequired());
fileUploadField.buttonAction(() -> {
if (ApplicationType.getType().equals(ViewerConstants.ELECTRON)) {
String path = JavascriptUtils.saveFileDialog();
JavaScriptObject.createArray();
Filter filter = new Filter();
filter.setName(ViewerConstants.SIARD_FILES);
filter.setExtensions(Collections.singletonList(ViewerConstants.SIARD_SUFFIX));
GWT.log("filter: " + filter);
JavaScriptObject options = JSOUtils.getOpenDialogOptions(Collections.emptyList(),
Collections.singletonList(filter));
String path = JavascriptUtils.saveFileDialog(options);
if (path != null) {
fileInputs.put(parameter.getName(), path);
fileUploadField.setPathLocation(path, path);
Expand Down Expand Up @@ -336,7 +344,8 @@ private void buildGenericWidget(PreservationParameter parameter) {
TextBox defaultTextBox = new TextBox();
defaultTextBox.addStyleName("form-textbox");
textBoxInputs.put(parameter.getName(), defaultTextBox);
genericField = GenericField.createInstance(messages.wizardExportOptionsLabels(parameter.getName()), defaultTextBox);
genericField = GenericField.createInstance(messages.wizardExportOptionsLabels(parameter.getName()),
defaultTextBox);
break;
}

Expand Down

0 comments on commit 1ac7dd3

Please sign in to comment.