Hi
SmartClient v9.1p_2014-03-25/Enterprise Deployment (2014-03-25)
Chrome Version 33.0.1750.154 m
Chromium 18.0.1004.0 (Developer Build 117091 Windows)
I am trying to build up what will eventually become a complex
collection of instances of SmartClient classes (each wrapped in an
EditNode) whose state needs to be persistable using a common global
EditContext to which they are all added.
In trying to do this for a more complicated structure than i present
below, i encountered a problem that the visibility property of the
various objects involved (whose "inherit" vs "hidden" value i rely on
for certain functionality) is not preserved across a "reincarnation"
of the object collection.
The code i present below is a very stripped-down version of the sort
of system i need to work with, which illustrates:
- in microcosm how i'm using the EditContext and EditNode
functionality,
- what specifically i'm trying but currently failing to accomplish.
- how i'm implementing reincarnation.
- how reincarnation interferes with the state of the system and causes
the functionality to break.
The code is a qunit test which interleaves a sequence of actions and
state checks. Between actions, certain things about the state should
be true. A reincarnate is just a special kind of action which is
supposed in all circumstances to preserve the state of the system.
We can see that if all the reincarnate actions are commented out, that
all the tests pass. If we uncomment either or both of the reincarnate
actions that could be performed when the system is in the "shown"
state (i.e., the first and third), then all the tests continue to
pass. But if we uncomment the reincarnate action that could be
performed when the system is in the "hidden" state (the second), then
the test immediately following it fails. And this is because the
second reincarnation fails to preserve the fact that the visibility
property of the Canvas should be "hidden", instead of being
reincarnated with this property reverted to "inherit".
What can you suggest i fix about how i'm using your
EditContext/EditNode functionality to allow the current state of a
built-in property like visibility to be persisted in a manner that
will allow these tests to pass with the second reincarnate action
uncommented?
What other general recommendations can you make about how i should
change the way i am trying to use this functionality?
SCP_ForumATest.html:
SCP_ForumATest.js:
SmartClient v9.1p_2014-03-25/Enterprise Deployment (2014-03-25)
Chrome Version 33.0.1750.154 m
Chromium 18.0.1004.0 (Developer Build 117091 Windows)
I am trying to build up what will eventually become a complex
collection of instances of SmartClient classes (each wrapped in an
EditNode) whose state needs to be persistable using a common global
EditContext to which they are all added.
In trying to do this for a more complicated structure than i present
below, i encountered a problem that the visibility property of the
various objects involved (whose "inherit" vs "hidden" value i rely on
for certain functionality) is not preserved across a "reincarnation"
of the object collection.
The code i present below is a very stripped-down version of the sort
of system i need to work with, which illustrates:
- in microcosm how i'm using the EditContext and EditNode
functionality,
- what specifically i'm trying but currently failing to accomplish.
- how i'm implementing reincarnation.
- how reincarnation interferes with the state of the system and causes
the functionality to break.
The code is a qunit test which interleaves a sequence of actions and
state checks. Between actions, certain things about the state should
be true. A reincarnate is just a special kind of action which is
supposed in all circumstances to preserve the state of the system.
We can see that if all the reincarnate actions are commented out, that
all the tests pass. If we uncomment either or both of the reincarnate
actions that could be performed when the system is in the "shown"
state (i.e., the first and third), then all the tests continue to
pass. But if we uncomment the reincarnate action that could be
performed when the system is in the "hidden" state (the second), then
the test immediately following it fails. And this is because the
second reincarnation fails to preserve the fact that the visibility
property of the Canvas should be "hidden", instead of being
reincarnated with this property reverted to "inherit".
What can you suggest i fix about how i'm using your
EditContext/EditNode functionality to allow the current state of a
built-in property like visibility to be persisted in a manner that
will allow these tests to pass with the second reincarnate action
uncommented?
What other general recommendations can you make about how i should
change the way i am trying to use this functionality?
SCP_ForumATest.html:
Code:
<!DOCTYPE html> <html> <head> <title>ForumATest</title> <script>var isomorphicDir = "isomorphic/";</script> <script src="isomorphic/system/modules-debug/ISC_Core.js"></script> <script src="isomorphic/system/modules-debug/ISC_Foundation.js"></script> <script src="isomorphic/system/modules-debug/ISC_Containers.js"></script> <script src="isomorphic/system/modules-debug/ISC_Grids.js"></script> <script src="isomorphic/system/modules-debug/ISC_Forms.js"></script> <script src="isomorphic/system/modules-debug/ISC_DataBinding.js"></script> <script src="isomorphic/system/modules-debug/ISC_Drawing.js"></script> <script src="isomorphic/system/modules-debug/ISC_Charts.js"></script> <script src="isomorphic/system/development/ISC_Tools.js"></script> </head> <body> <div id="qunit" style="display:block"></div> <div id="qunit-fixture" style="display:block"></div> <script src="js/qunit.js"></script> <link rel="stylesheet" href="js/qunit.css"> <script src="SCP_ForumATest.js"></script> </body> </html>
Code:
test("persistingVisibility", function(assert){ Fixture = { editPane : isc.EditPane.create({}), getLiveObjectArray : function() { return Fixture.editPane.getEditNodeTree().getChildren().map(function(x){return x.liveObject;}); }, serialize : function() { return Fixture.editPane.serializeAllEditNodesAsJSON(false); } }; ClassFactory.defineClass("SCP_CanvasA",isc.Canvas).addProperties({ initWidget : function(args) { this.Super("initWidget", arguments); } }); ClassFactory.defineClass("SCP_LayoutA",isc.Layout).addProperties({ initWidget : function(args) { this.Super("initWidget", arguments); var canvasNode = Fixture.editPane.makeEditNode({type:"SCP_CanvasA",defaults:{backgroundColor:"#070",width:90,height:90}}); this.canvas = canvasNode.liveObject; this.addMember(this.canvas); Fixture.editPane.addNode(canvasNode,undefined,undefined,undefined,true); this.show(); }, showCanvas : function() { this.canvas.show(); }, hideCanvas : function() { this.canvas.hide(); } }); TestSequenceA = { actionCreate : function(liveObjectArray) { var layoutNode = Fixture.editPane.makeEditNode({type:"SCP_LayoutA",defaults:{backgroundColor:"#700",width:100,height:100}}); Fixture.editPane.addNode(layoutNode,undefined,undefined,undefined,true); }, actionShow : function(liveObjectArray) { var layout = liveObjectArray.filter(function(x){ return x.isA("SCP_LayoutA"); }); layout[0].showCanvas(); }, actionHide : function(liveObjectArray) { var layout = liveObjectArray.filter(function(x){ return x.isA("SCP_LayoutA"); }); layout[0].hideCanvas(); }, checkShownState : function(liveObjectArray) { var layout = liveObjectArray.filter(function(x){ return x.isA("SCP_LayoutA"); }); equal(layout[0].canvas.visibility,isc.Canvas.INHERIT,"canvas should be visible"); }, checkHiddenState : function(liveObjectArray) { var layout = liveObjectArray.filter(function(x){ return x.isA("SCP_LayoutA"); }); equal(layout[0].canvas.visibility,isc.Canvas.HIDDEN,"canvas should be invisible"); } }; var reincarnate = function(s11n) { ok(true,"before reincarnation, serialization=="+Fixture.serialize() ); Fixture.editPane.destroyAll(); ok(true,"during reincarnation, serialization=="+Fixture.serialize() ); Fixture.editPane.addPaletteNodesFromJSON(s11n); ok(true," after reincarnation, serialization=="+Fixture.serialize() ); }; TestSequenceA.actionCreate (Fixture.getLiveObjectArray()); TestSequenceA.actionShow (Fixture.getLiveObjectArray()); TestSequenceA.checkShownState (Fixture.getLiveObjectArray()); // reincarnate (Fixture.serialize()); // first TestSequenceA.checkShownState (Fixture.getLiveObjectArray()); TestSequenceA.actionHide (Fixture.getLiveObjectArray()); TestSequenceA.checkHiddenState (Fixture.getLiveObjectArray()); // reincarnate (Fixture.serialize()); // second TestSequenceA.checkHiddenState (Fixture.getLiveObjectArray()); TestSequenceA.actionShow (Fixture.getLiveObjectArray()); TestSequenceA.checkShownState (Fixture.getLiveObjectArray()); // reincarnate (Fixture.serialize()); // third TestSequenceA.checkShownState (Fixture.getLiveObjectArray()); });
Comment