Commit 717e12b3 authored by Arnold Hendriks's avatar Arnold Hendriks

Support setting/clearing dirty on dirtylisteners without components

parent 958648d5
......@@ -14,8 +14,12 @@ PUBLIC STATIC OBJECTTYPE TolliumDirtyListener EXTEND TolliumSpecialComponent
// Variables
//
//watched components
RECORD ARRAY components;
//local dirty status, used if we're explicitly made dirty
BOOLEAN manualdirty;
// ---------------------------------------------------------------------------
//
......@@ -140,33 +144,36 @@ PUBLIC STATIC OBJECTTYPE TolliumDirtyListener EXTEND TolliumSpecialComponent
PUBLIC MACRO SetDirty()
{
IF (RecordExists(SELECT FROM this->components WHERE NOT isdirty))
{
UPDATE this->components
SET isdirty := TRUE;
IF(this->manualdirty AND NOT RecordExists(SELECT FROM this->components WHERE NOT isdirty)) //already full dirty
RETURN;
this->ExtUpdatedDirtyComponents();
IF (this->ondirty != DEFAULT FUNCTION PTR)
this->ondirty();
}
this->manualdirty := TRUE;
UPDATE this->components
SET isdirty := TRUE;
this->ExtUpdatedDirtyComponents();
IF (this->ondirty != DEFAULT FUNCTION PTR)
this->ondirty();
}
PUBLIC MACRO ClearDirty()
{
IF (this->dirty)
IF(NOT this->manualdirty AND NOT RecordExists(SELECT FROM this->components WHERE isdirty)) //already full clean
RETURN;
this->manualdirty := FALSE;
FOREVERY (RECORD comp FROM this->components)
{
FOREVERY (RECORD comp FROM this->components)
IF (comp.isdirty)
{
IF (comp.isdirty)
{
this->components[#comp].isdirty := FALSE;
comp.comp->DirtyCleared();
}
this->components[#comp].isdirty := FALSE;
comp.comp->DirtyCleared();
}
this->ExtUpdatedDirtyComponents();
IF (this->ondirty != DEFAULT FUNCTION PTR)
this->ondirty();
}
this->ExtUpdatedDirtyComponents();
IF (this->ondirty != DEFAULT FUNCTION PTR)
this->ondirty();
}
PUBLIC MACRO SetDirtyComponent(OBJECT obj)
......@@ -194,10 +201,6 @@ PUBLIC STATIC OBJECTTYPE TolliumDirtyListener EXTEND TolliumSpecialComponent
//
// Helper functions
//
BOOLEAN FUNCTION IsDirtyInternal(OBJECT obj)
{
RETURN SELECT AS BOOLEAN isdirty FROM this->components WHERE comp = obj;
}
BOOLEAN FUNCTION SetDirtyInternal(OBJECT obj)
{
IF (RecordExists(SELECT FROM this->components WHERE comp = obj AND NOT isdirty))
......@@ -229,7 +232,7 @@ PUBLIC STATIC OBJECTTYPE TolliumDirtyListener EXTEND TolliumSpecialComponent
BOOLEAN FUNCTION GetDirty()
{
RETURN RecordExists(SELECT FROM this->components WHERE isdirty);
RETURN this->manualdirty OR RecordExists(SELECT FROM this->components WHERE isdirty);
}
......
......@@ -8,6 +8,7 @@ PUBLIC OBJECTTYPE DirtyTest EXTEND TolliumScreenBase
MACRO Init(RECORD data)
{
this->OnDirty();
this->OnLonelyDirty();
}
MACRO DoSetDirty()
......@@ -25,6 +26,11 @@ PUBLIC OBJECTTYPE DirtyTest EXTEND TolliumScreenBase
this->dirtystatus->value := this->dirtylistener->dirty ? "YES" : "NO";
}
MACRO OnLonelyDirty()
{
^lonelydirtystatus->value := ^lonelydirtylistener->dirty ? "YES" : "NO";
}
MACRO OnCheckboxClick()
{
this->radiobutton->visible := this->checkbox->value;
......
......@@ -9,6 +9,7 @@
</actions>
<compositions>
<dirtylistener name="dirtylistener" ondirty="ondirty" />
<dirtylistener name="lonelydirtylistener" ondirty="onlonelydirty" />
<record name="composition" dirtylistener="dirtylistener" />
<radiogroup name="radiogroup" />
<radiogroup name="radiogroup_listener" dirtylistener="dirtylistener" />
......@@ -19,6 +20,9 @@
<button name="setbutton" action="setdirty" />
<button name="clearbutton" action="cleardirty" />
</line>
<line>
<text name="lonelydirtystatus" title="lonelydirty?" width="1pr" />
</line>
<textedit name="textedit" title="textedit" dirtylistener="dirtylistener" />
<textedit name="textedit_composition" title="composition" composition="composition" cellname="textedit" />
<combobox name="combobox" title="combobox" dirtylistener="dirtylistener">
......
<?wh
LOADLIB "mod::system/lib/testframework.whlib";
LOADLIB "mod::tollium/lib/testframework.whlib";
ASYNC MACRO TestDirtyListener()
{
AWAIT ExpectScreenChange(+1, PTR TTLaunchApp("webhare_testsuite:runscreen", [ params := ["tests/dirty.dirtytest"]]));
TestEq("NO", TT(":lonelydirty?")->value);
TestEq(FALSE, TT("lonelydirtylistener")->dirty);
TT("lonelydirtylistener")->SetDirty();
TestEq("YES", TT(":lonelydirty?")->value);
TestEq(TRUE, TT("lonelydirtylistener")->dirty);
TT("lonelydirtylistener")->ClearDirty();
TestEq("NO", TT(":lonelydirty?")->value);
TestEq(FALSE, TT("lonelydirtylistener")->dirty);
AWAIT ExpectScreenChange(-1, PTR TTEscape);
}
RunTestframework([ PTR TestDirtyListener
], [ testusers := [[ login := "sysop", grantrights := ["system:sysop"]]]]);
......@@ -5,4 +5,5 @@
<jstest file="testeventserver.es" exclusive="true" />
<test script="testsvg.whscr" />
<jstest file="testdirty.es" />
<test script="testdirty-hs.whscr" />
</group>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment