Show More
@@ -284,7 +284,8 b' define([' | |||
|
284 | 284 | return this.create_model({ |
|
285 | 285 |
model_name: msg.content.data.model_name, |
|
286 | 286 |
model_module: msg.content.data.model_module, |
|
287 | comm: comm}).catch(utils.reject("Couldn't create a model.", true)); | |
|
287 | comm: comm, | |
|
288 | }).catch(utils.reject("Couldn't create a model.", true)); | |
|
288 | 289 | }; |
|
289 | 290 | |
|
290 | 291 | WidgetManager.prototype.create_model = function (options) { |
@@ -299,7 +300,8 b' define([' | |||
|
299 | 300 | * JS: |
|
300 | 301 | * IPython.notebook.kernel.widget_manager.create_model({ |
|
301 | 302 |
* model_name: 'WidgetModel', |
|
302 |
* widget_class: 'IPython.html.widgets.widget_int.IntSlider' |
|
|
303 | * widget_class: 'IPython.html.widgets.widget_int.IntSlider' | |
|
304 | * }) | |
|
303 | 305 |
* |
|
304 | 306 |
* |
|
305 | 307 | * |
@@ -416,13 +418,8 b' define([' | |||
|
416 | 418 | var that = this; |
|
417 | 419 | return this._get_connected_kernel().then(function(kernel) { |
|
418 | 420 | |
|
419 |
// Recreate all the widget models for the given |
|
|
420 | // display the views. | |
|
421 | that.all_views = []; | |
|
422 | var model_ids = Object.keys(state); | |
|
423 | for (var i = 0; i < model_ids.length; i++) { | |
|
424 | var model_id = model_ids[i]; | |
|
425 | ||
|
421 | // Recreate all the widget models for the given notebook state. | |
|
422 | var all_models = Promise.all(_.map(Object.keys(state), function (model_id) { | |
|
426 | 423 | // Recreate a comm using the widget's model id (model_id == comm_id). |
|
427 | 424 | var new_comm = new comm.Comm(kernel.widget_manager.comm_target_name, model_id); |
|
428 | 425 | kernel.comm_manager.register_comm(new_comm); |
@@ -431,35 +428,30 b' define([' | |||
|
431 | 428 | // created we don't know yet if the comm is valid so set_comm_live |
|
432 | 429 | // false. Once we receive the first state push from the back-end |
|
433 | 430 | // we know the comm is alive. |
|
434 |
|
|
|
431 | return kernel.widget_manager.create_model({ | |
|
435 | 432 |
comm: new_comm, |
|
436 | 433 |
model_name: state[model_id].model_name, |
|
437 |
model_module: state[model_id].model_module |
|
|
438 | .then(function(model) { | |
|
439 | ||
|
434 | model_module: state[model_id].model_module, | |
|
435 | }).then(function(model) { | |
|
440 | 436 | model.set_comm_live(false); |
|
441 | var view_promise = Promise.resolve().then(function() { | |
|
442 |
|
|
|
443 | }).then(function() { | |
|
444 | model.request_state().then(function() { | |
|
437 | model.set_state(state[model.id].state); | |
|
438 | return model.request_state().then(function() { | |
|
445 | 439 |
|
|
440 | return model; | |
|
446 | 441 |
|
|
442 | }); | |
|
443 | }, this)); | |
|
447 | 444 | |
|
445 | // Display all the views | |
|
446 | return all_models.then(function(models) { | |
|
447 | return Promise.all(_.map(models, function(model) { | |
|
448 | 448 |
|
|
449 | var views = []; | |
|
450 | var model_views = state[model.id].views; | |
|
451 | for (var j=0; j<model_views.length; j++) { | |
|
452 | var cell_index = model_views[j]; | |
|
449 | return Promise.all(_.map(state[model.id].views, function(cell_index) { | |
|
453 | 450 |
|
|
454 |
|
|
|
455 |
|
|
|
456 | return Promise.all(views); | |
|
457 | }); | |
|
458 | return view_promise; | |
|
451 | return that.display_view_in_cell(cell, model); | |
|
452 | })); | |
|
453 | })); | |
|
459 | 454 |
|
|
460 | that.all_views.push(views); | |
|
461 | } | |
|
462 | return Promise.all(that.all_views); | |
|
463 | 455 |
}).catch(utils.reject('Could not set widget manager state.', true)); |
|
464 | 456 | }; |
|
465 | 457 |
General Comments 0
You need to be logged in to leave comments.
Login now