|
| 1 | +/* ************************************************************************ |
| 2 | +
|
| 3 | + osparc - the simcore frontend |
| 4 | +
|
| 5 | + https://osparc.io |
| 6 | +
|
| 7 | + Copyright: |
| 8 | + 2021 IT'IS Foundation, https://itis.swiss |
| 9 | +
|
| 10 | + License: |
| 11 | + MIT: https://opensource.org/licenses/MIT |
| 12 | +
|
| 13 | + Authors: |
| 14 | + * Odei Maiz (odeimaiz) |
| 15 | +
|
| 16 | +************************************************************************ */ |
| 17 | + |
| 18 | +/** |
| 19 | + * @ignore(SVGElement) |
| 20 | + */ |
| 21 | + |
| 22 | +/** |
| 23 | + * *Example* |
| 24 | + * |
| 25 | + * Here is a little example of how to use the widget. |
| 26 | + * |
| 27 | + * <pre class='javascript'> |
| 28 | + * let workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview(); |
| 29 | + * this.getRoot().add(workbenchUIPreview); |
| 30 | + * </pre> |
| 31 | + */ |
| 32 | + |
| 33 | +qx.Class.define("osparc.workbench.WorkbenchUIPreview2", { |
| 34 | + extend: osparc.workbench.WorkbenchUI, |
| 35 | + |
| 36 | + construct: function(wbData, wbDataUi) { |
| 37 | + this.base(arguments); |
| 38 | + |
| 39 | + this.set({ |
| 40 | + backgroundColor: "background-main" |
| 41 | + }); |
| 42 | + }, |
| 43 | + |
| 44 | + members: { |
| 45 | + // overridden |
| 46 | + _addItemsToLayout: function() { |
| 47 | + this._addWorkbenchLayer(); |
| 48 | + }, |
| 49 | + |
| 50 | + // overridden |
| 51 | + _loadModel: function(model) { |
| 52 | + this._clearAll(); |
| 53 | + this.resetSelection(); |
| 54 | + this._currentModel = model; |
| 55 | + if (model) { |
| 56 | + qx.ui.core.queue.Visibility.flush(); |
| 57 | + |
| 58 | + // create nodes |
| 59 | + const nodes = model.getNodes(); |
| 60 | + for (const nodeId in nodes) { |
| 61 | + const node = nodes[nodeId]; |
| 62 | + const nodeUI = this._createNodeUI(nodeId); |
| 63 | + nodeUI.setIsMovable(false); |
| 64 | + this._addNodeUIToWorkbench(nodeUI, node.getPosition()); |
| 65 | + } |
| 66 | + qx.ui.core.queue.Layout.flush(); |
| 67 | + |
| 68 | + // create edges |
| 69 | + for (const nodeId in nodes) { |
| 70 | + const node = nodes[nodeId]; |
| 71 | + const inputNodeIDs = node.getInputNodes(); |
| 72 | + inputNodeIDs.forEach(inputNodeId => { |
| 73 | + if (inputNodeId in nodes) { |
| 74 | + this._createEdgeBetweenNodes(inputNodeId, nodeId, false); |
| 75 | + } |
| 76 | + }); |
| 77 | + } |
| 78 | + |
| 79 | + const maxScale = 0.7; |
| 80 | + this._fitScaleToNodes(maxScale); |
| 81 | + } |
| 82 | + }, |
| 83 | + |
| 84 | + // overridden |
| 85 | + _addEventListeners: function() { |
| 86 | + this.addListenerOnce("appear", this._listenToMouseWheel, this); |
| 87 | + } |
| 88 | + } |
| 89 | +}); |
0 commit comments