NodeView displays an internal view model or data structure generated by the underlying
NodeModel. While the generated
DataTables and the user settings are stored automatically, the structure of the internal model is not predictable, thus, it has to be saved and loaded manually. Then the data for the view is available after re-opening an executed workflow. The first parameter is the directory to store the files into, the second is an
ExecutionMonitor to report progress during these operations. There are three possibilities to load and store the internal model:
Important: with the above mentioned methods only the data used by the view should be loaded and saved. These methods are not intended to load and save:
Note: there is a strong connection between the
load-/saveInternals and the
reset method. Everything which is necessary to restore the view and therefore has to be saved and loaded, has to be deleted in the
reset method, since the view displays the result of the
execute method and the
reset method should set the node to its initial state, i.e. as it was before execution.
NodeSettings as already known from the
NodeDialog can also be used for the loading and saving of the internal view model. This is especially useful, if the internal view model is not very large or fits the structure of the
NodeSettings well. Saving using the
NodeSettings is done in the following way:
// create a settings object with a config name NodeSettings settings =
newNodeSettings(CFG_SETTINGSNAME); // store your values under a certain key settings.addInt(CFG_INT, yourInt); // create a file in the given directory File f =
newFile(internDir, CFG_FILENAME); // and save it settings.saveToXML(
If your internal model is stored in a DataTable (as for example in a scatter plot), then it is recommended to use the following approach, using the load and save mechanism of the DataContainer.
// create the file File f =
newFile(internDir, CFG_FILENAME); // store the table as a zipped archive DataContainer.writeToZip(yourTable, f, exec);
Since only a directory is passed to the methods, theoretically any format is possible to store the internal model. However, the two above mentioned approaches are recommended. Defining you own format for the persistence of the internal model should only be done, if the internal model doesn't fit neither into the
NodeSettings nor into the
DataTable or if an own format increases the performance dramatically.