Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit 36b9ae8

Browse files
committed
Add save method which must be called from dialog
1 parent 9a7c1d8 commit 36b9ae8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ pythonOptions = new PythonOptionsPanel<PredictMetabolitesConfig>();
6464
addTab("Python options", pythonOptions);
6565
```
6666

67-
To save the Python options to disk you must call the `pythonOptions.saveSettingsTo(config)` followed by `config.saveTo(settings)` in the `save*To()` method of the dialog.
68-
To load the Python options from disk you must call the `config.loadFrom(settings)` followed by `pythonOptions.loadSettingsFrom(config)` in the `load*From()` methods of the dialog.
67+
To save the Python options to disk you must call the `pythonOptions.saveSettingsTo(config)` followed by `config.saveToInDialog(settings)` in the `save*To()` method of the dialog.
68+
To load the Python options from disk you must call the `config.loadFromInDialog(settings)` followed by `pythonOptions.loadSettingsFrom(config)` in the `load*From()` methods of the dialog.
6969

7070
### Python script
7171

plugin/src/java/nl/esciencecenter/e3dchem/python/PythonWrapperNodeConfig.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,24 @@ public String getWarningMessageFlowVariable() {
8383
* The settings to save to
8484
*/
8585
public void saveTo(final NodeSettingsWO settings) {
86+
saveToInDialog(settings);
87+
}
88+
89+
/**
90+
* Save configuration to the given node settings.
91+
*
92+
* @param settings
93+
* The settings to save to
94+
*/
95+
public void saveToInDialog(NodeSettingsWO settings) {
8696
settings.addString(CFG_PYTHON_VERSION_OPTION, kernelOptions.getPythonVersionOption().name());
8797
settings.addBoolean(CFG_CONVERT_MISSING_TO_PYTHON, kernelOptions.getConvertMissingToPython());
8898
settings.addBoolean(CFG_CONVERT_MISSING_FROM_PYTHON, kernelOptions.getConvertMissingFromPython());
8999
settings.addString(CFG_SENTINEL_OPTION, kernelOptions.getSentinelOption().name());
90100
settings.addInt(CFG_SENTINEL_VALUE, kernelOptions.getSentinelValue());
91101
settings.addInt(CFG_CHUNK_SIZE, kernelOptions.getChunkSize());
92102
}
93-
103+
94104
/**
95105
* Load configuration from the given node settings.
96106
*
@@ -100,17 +110,7 @@ public void saveTo(final NodeSettingsWO settings) {
100110
* If the settings are invalid
101111
*/
102112
public void loadFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
103-
kernelOptions.setPythonVersionOption(PythonVersionOption.valueOf(
104-
settings.getString(CFG_PYTHON_VERSION_OPTION, kernelOptions.getPreferencePythonVersion().name())));
105-
kernelOptions.setConvertMissingToPython(settings.getBoolean(CFG_CONVERT_MISSING_TO_PYTHON,
106-
SerializationOptions.DEFAULT_CONVERT_MISSING_TO_PYTHON));
107-
kernelOptions.setConvertMissingFromPython(settings.getBoolean(CFG_CONVERT_MISSING_FROM_PYTHON,
108-
SerializationOptions.DEFAULT_CONVERT_MISSING_FROM_PYTHON));
109-
kernelOptions.setSentinelOption(SentinelOption
110-
.valueOf(settings.getString(CFG_SENTINEL_OPTION, SerializationOptions.DEFAULT_SENTINEL_OPTION.name())));
111-
kernelOptions
112-
.setSentinelValue(settings.getInt(CFG_SENTINEL_VALUE, SerializationOptions.DEFAULT_SENTINEL_VALUE));
113-
kernelOptions.setChunkSize(settings.getInt(CFG_CHUNK_SIZE, PythonKernelOptions.DEFAULT_CHUNK_SIZE));
113+
loadFromInDialog(settings);
114114
}
115115

116116
/**

0 commit comments

Comments
 (0)