Saving node view configurations

Hello

Since I have a rather complex interactive UI useres would like to save the view configurations. Unitl now I am doing this in the "saveInternals" method of the node model, but there is one problem to it:
If I open a workflow, open the node view and then close it again, the workflow is not flagged as modified (dirty). Accordingling if I now close the workflow and reopen it the changes in the UI are not saved.
So I was looking for a way to tell the workflow, that changes have been made. but I did not find a way from the node view or the nodemodel to accesss for instance the dirty-flag. Is there a way to access the flag? or is there another way to tell the workflow it has changes to save?

Best, 

Felix

Hi Felix, we are currently working on a new interactive API for NodeViews which I guess will also cover your case, that is, you will be able to load/save view configurations and most importantly trigger re-executions from within the view. In the long run, all those view will be web-enabled, that means it will also be possible expose them in the KNIME WebPortal. We are working on it to have the API and the first view(s) ready for 2.8.

Hi Garbriel

Thanks for the info. Looking forwared to the next major release.

Best, 

Felix

Hi Felix, I came across the same problem.

My solution was to create in the NodeModel class a method dedicated for the view data storage in a dedicated file (let's call it saveViewSettings), and then call this method within the saveInternals().

Then, the onClose method of the view calls this saveViewSettings().

Notice that the file path used to save the view settings file can only be obtained from saveInternals() of loadInternals() first parameter.

So, if the node has just been added to the workflow by the user (loadInternals never called) and saveInternals() has not been called before the view gets closed, you cannot save your view settings.

The workaround I found is to set this path in a dedicated field (let's call it nodeInternDir) of the node model class, the first time saveInternals() (or loadInternals) is called. The saveViewSettings() should use this field to build the full path of the file to create.

I found useful to use a ViewModel class containing all view settings, together with the dirty status handling.

If the nodeInternDir field has never been set (i.e. it is null), then the view setting storage should be postponed at the first next call of saveInternals(), by setting dirty the ViewModel.

The saveInternals() method sets the nodeInternDir field and checks the ViewModel dirty status to decide whether to call saveViewSettings() method.