You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Hugo Ferreira <hf...@gmail.com> on 2020/08/31 12:54:56 UTC

ArrayList filterFunction

Hello,

There is already a bead or a way to add filterFunction to Royale ArrayList
as we have with ArrayCollection in Flex ?

Re: ArrayList filterFunction

Posted by Hugo Ferreira <hf...@gmail.com>.
Here's my class (original using Flex - ArrayCollection and now Royale -
ArrayList + ArrayListView):

package pt.solidsoft.framework.datamanager.model
{
import org.apache.royale.collections.ArrayListView;
import org.apache.royale.collections.ArrayList;
public class EntityList extends ArrayListView
{
public function EntityList(source:ArrayList = null)
{
super(source);
this.filterFunction = hideDeletedEntities;
}
private function hideDeletedEntities(item:Object):Boolean
{
if (item is Entity)
return item.EntityState != Entity.DELETED;
return true;
}
public function addEntity(item:IEntity):void
{
item.markAsAdded();
this.addItem(item);
}
public function addEntityAt(item:Entity, index:int):void
{
item.markAsAdded();
this.addItemAt(item, index);
}
public function addEntities(items:EntityList):void
{
for each (var item:Entity in items)
addEntity(item);
}
public function merge(items:EntityList):void
{
for each (var item:Entity in items.source)
{
addItem(item);
}
}
public function createEntity(item:Class):void
{
addEntity(new item as Entity);
}
public function deleteEntity(item:Entity):void
{
for (var i:int = this.length - 1; i >= 0; i--)
{
if (this[i] == item)
{
deleteEntityAt(i);
break;
}
}
}
public function deleteEntityAt(index:int):Object
{
//check if the index is valid
if (index < 0 || index > this.length)
return null;
//get the entity item
var item:Entity = this[index] as Entity;
//if the entity can me marked as deleted, then refresh the list
if (item.markAsDeleted())
{
this.refresh();
return item;
}
//real remove the item
return this.removeItemAt(index);
}
//remove of entities marked as deleted
public function compact():void
{
this.filterFunction = null;
for (var i:int = this.length - 1; i >= 0; i--)
{
if ((this.getItemAt(i) as Entity).isDeleted())
this.removeItemAt(i);
}
this.filterFunction = hideDeletedEntities;
this.refresh();
}

[Bindable("collectionChange")]
public function getFirstEntity():Object
{
if (this.length == 0)
return null;
return this[0] as Entity;
}

[Bindable("collectionChange")]
public function getLastEntity():Object
{
if (this.length == 0)
return null;
return this[this.length - 1] as Entity;
}
public function anyPending():Boolean
{
for each (var entity:Entity in this)
{
if (entity.EntityState != Entity.UNCHANGED)
return true;
}
return false;
}
public function haveEntities():Boolean
{
return this.length > 0;
}
}
}

Carlos Rovira <ca...@apache.org> escreveu no dia segunda, 31/08/2020
à(s) 17:04:

> I know Greg will be glad to hear about that since he was the man behind the
> ArrayListView! ;-)
>
> El lun., 31 ago. 2020 a las 17:30, Hugo Ferreira (<hferreira.80@gmail.com
> >)
> escribió:
>
> > I have a EntityList that extends from ArrayCollection.
> > Now extends from ArrayListView without any change !
> >
> > I use it on my framework to hide deleted item (change the state of object
> > to DELETE before remove and the list is automatically filter to hide this
> > itens).
> > When I save, the server delete the itens from the database, update the
> > opens that changed and insert the others.
> > It works perfectly.
> >
> > Carlos Rovira <ca...@apache.org> escreveu no dia segunda,
> > 31/08/2020
> > à(s) 16:25:
> >
> > > Yeah,
> > > we used it in all our Flex migrations ;)
> > >
> > > El lun., 31 ago. 2020 a las 17:23, Hugo Ferreira (<
> > hferreira.80@gmail.com
> > > >)
> > > escribió:
> > >
> > > > Thank you.
> > > > This new ArraListView + ArraList, seems to 100% replace my previous
> use
> > > of
> > > > ArrayCollection.
> > > > Now only on real scenarios that I can full test it but at list at
> > compile
> > > > time and a simple use case, it works.
> > > >
> > > > Carlos Rovira <ca...@apache.org> escreveu no dia segunda,
> > > > 31/08/2020
> > > > à(s) 16:16:
> > > >
> > > > > Hi Hugo,
> > > > >
> > > > > also check TDJ for a page (at the end of the drawer menu) with some
> > > > > ArrayListView examples for filtering and sorting.
> > > > >
> > > > > El lun., 31 ago. 2020 a las 16:33, Hugo Ferreira (<
> > > > hferreira.80@gmail.com
> > > > > >)
> > > > > escribió:
> > > > >
> > > > > > Fanstastic.
> > > > > > One more issue solved.
> > > > > > Thank you.
> > > > > >
> > > > > > Harbs <ha...@gmail.com> escreveu no dia segunda,
> 31/08/2020
> > > à(s)
> > > > > > 15:01:
> > > > > >
> > > > > > > Try ArrayListView instead of ArrayList.
> > > > > > >
> > > > > > > > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <
> > > hferreira.80@gmail.com
> > > > >
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > There is already a bead or a way to add filterFunction to
> > Royale
> > > > > > > ArrayList
> > > > > > > > as we have with ArrayCollection in Flex ?
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Carlos Rovira
> > > > > http://about.me/carlosrovira
> > > > >
> > > >
> > >
> > >
> > > --
> > > Carlos Rovira
> > > http://about.me/carlosrovira
> > >
> >
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>

Re: ArrayList filterFunction

Posted by Carlos Rovira <ca...@apache.org>.
I know Greg will be glad to hear about that since he was the man behind the
ArrayListView! ;-)

El lun., 31 ago. 2020 a las 17:30, Hugo Ferreira (<hf...@gmail.com>)
escribió:

> I have a EntityList that extends from ArrayCollection.
> Now extends from ArrayListView without any change !
>
> I use it on my framework to hide deleted item (change the state of object
> to DELETE before remove and the list is automatically filter to hide this
> itens).
> When I save, the server delete the itens from the database, update the
> opens that changed and insert the others.
> It works perfectly.
>
> Carlos Rovira <ca...@apache.org> escreveu no dia segunda,
> 31/08/2020
> à(s) 16:25:
>
> > Yeah,
> > we used it in all our Flex migrations ;)
> >
> > El lun., 31 ago. 2020 a las 17:23, Hugo Ferreira (<
> hferreira.80@gmail.com
> > >)
> > escribió:
> >
> > > Thank you.
> > > This new ArraListView + ArraList, seems to 100% replace my previous use
> > of
> > > ArrayCollection.
> > > Now only on real scenarios that I can full test it but at list at
> compile
> > > time and a simple use case, it works.
> > >
> > > Carlos Rovira <ca...@apache.org> escreveu no dia segunda,
> > > 31/08/2020
> > > à(s) 16:16:
> > >
> > > > Hi Hugo,
> > > >
> > > > also check TDJ for a page (at the end of the drawer menu) with some
> > > > ArrayListView examples for filtering and sorting.
> > > >
> > > > El lun., 31 ago. 2020 a las 16:33, Hugo Ferreira (<
> > > hferreira.80@gmail.com
> > > > >)
> > > > escribió:
> > > >
> > > > > Fanstastic.
> > > > > One more issue solved.
> > > > > Thank you.
> > > > >
> > > > > Harbs <ha...@gmail.com> escreveu no dia segunda, 31/08/2020
> > à(s)
> > > > > 15:01:
> > > > >
> > > > > > Try ArrayListView instead of ArrayList.
> > > > > >
> > > > > > > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <
> > hferreira.80@gmail.com
> > > >
> > > > > > wrote:
> > > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > There is already a bead or a way to add filterFunction to
> Royale
> > > > > > ArrayList
> > > > > > > as we have with ArrayCollection in Flex ?
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Carlos Rovira
> > > > http://about.me/carlosrovira
> > > >
> > >
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: ArrayList filterFunction

Posted by Hugo Ferreira <hf...@gmail.com>.
I have a EntityList that extends from ArrayCollection.
Now extends from ArrayListView without any change !

I use it on my framework to hide deleted item (change the state of object
to DELETE before remove and the list is automatically filter to hide this
itens).
When I save, the server delete the itens from the database, update the
opens that changed and insert the others.
It works perfectly.

Carlos Rovira <ca...@apache.org> escreveu no dia segunda, 31/08/2020
à(s) 16:25:

> Yeah,
> we used it in all our Flex migrations ;)
>
> El lun., 31 ago. 2020 a las 17:23, Hugo Ferreira (<hferreira.80@gmail.com
> >)
> escribió:
>
> > Thank you.
> > This new ArraListView + ArraList, seems to 100% replace my previous use
> of
> > ArrayCollection.
> > Now only on real scenarios that I can full test it but at list at compile
> > time and a simple use case, it works.
> >
> > Carlos Rovira <ca...@apache.org> escreveu no dia segunda,
> > 31/08/2020
> > à(s) 16:16:
> >
> > > Hi Hugo,
> > >
> > > also check TDJ for a page (at the end of the drawer menu) with some
> > > ArrayListView examples for filtering and sorting.
> > >
> > > El lun., 31 ago. 2020 a las 16:33, Hugo Ferreira (<
> > hferreira.80@gmail.com
> > > >)
> > > escribió:
> > >
> > > > Fanstastic.
> > > > One more issue solved.
> > > > Thank you.
> > > >
> > > > Harbs <ha...@gmail.com> escreveu no dia segunda, 31/08/2020
> à(s)
> > > > 15:01:
> > > >
> > > > > Try ArrayListView instead of ArrayList.
> > > > >
> > > > > > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <
> hferreira.80@gmail.com
> > >
> > > > > wrote:
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > There is already a bead or a way to add filterFunction to Royale
> > > > > ArrayList
> > > > > > as we have with ArrayCollection in Flex ?
> > > > >
> > > > >
> > > >
> > >
> > >
> > > --
> > > Carlos Rovira
> > > http://about.me/carlosrovira
> > >
> >
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>

Re: ArrayList filterFunction

Posted by Carlos Rovira <ca...@apache.org>.
Yeah,
we used it in all our Flex migrations ;)

El lun., 31 ago. 2020 a las 17:23, Hugo Ferreira (<hf...@gmail.com>)
escribió:

> Thank you.
> This new ArraListView + ArraList, seems to 100% replace my previous use of
> ArrayCollection.
> Now only on real scenarios that I can full test it but at list at compile
> time and a simple use case, it works.
>
> Carlos Rovira <ca...@apache.org> escreveu no dia segunda,
> 31/08/2020
> à(s) 16:16:
>
> > Hi Hugo,
> >
> > also check TDJ for a page (at the end of the drawer menu) with some
> > ArrayListView examples for filtering and sorting.
> >
> > El lun., 31 ago. 2020 a las 16:33, Hugo Ferreira (<
> hferreira.80@gmail.com
> > >)
> > escribió:
> >
> > > Fanstastic.
> > > One more issue solved.
> > > Thank you.
> > >
> > > Harbs <ha...@gmail.com> escreveu no dia segunda, 31/08/2020 à(s)
> > > 15:01:
> > >
> > > > Try ArrayListView instead of ArrayList.
> > > >
> > > > > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <hferreira.80@gmail.com
> >
> > > > wrote:
> > > > >
> > > > > Hello,
> > > > >
> > > > > There is already a bead or a way to add filterFunction to Royale
> > > > ArrayList
> > > > > as we have with ArrayCollection in Flex ?
> > > >
> > > >
> > >
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: ArrayList filterFunction

Posted by Hugo Ferreira <hf...@gmail.com>.
Thank you.
This new ArraListView + ArraList, seems to 100% replace my previous use of
ArrayCollection.
Now only on real scenarios that I can full test it but at list at compile
time and a simple use case, it works.

Carlos Rovira <ca...@apache.org> escreveu no dia segunda, 31/08/2020
à(s) 16:16:

> Hi Hugo,
>
> also check TDJ for a page (at the end of the drawer menu) with some
> ArrayListView examples for filtering and sorting.
>
> El lun., 31 ago. 2020 a las 16:33, Hugo Ferreira (<hferreira.80@gmail.com
> >)
> escribió:
>
> > Fanstastic.
> > One more issue solved.
> > Thank you.
> >
> > Harbs <ha...@gmail.com> escreveu no dia segunda, 31/08/2020 à(s)
> > 15:01:
> >
> > > Try ArrayListView instead of ArrayList.
> > >
> > > > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <hf...@gmail.com>
> > > wrote:
> > > >
> > > > Hello,
> > > >
> > > > There is already a bead or a way to add filterFunction to Royale
> > > ArrayList
> > > > as we have with ArrayCollection in Flex ?
> > >
> > >
> >
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>

Re: ArrayList filterFunction

Posted by Carlos Rovira <ca...@apache.org>.
Hi Hugo,

also check TDJ for a page (at the end of the drawer menu) with some
ArrayListView examples for filtering and sorting.

El lun., 31 ago. 2020 a las 16:33, Hugo Ferreira (<hf...@gmail.com>)
escribió:

> Fanstastic.
> One more issue solved.
> Thank you.
>
> Harbs <ha...@gmail.com> escreveu no dia segunda, 31/08/2020 à(s)
> 15:01:
>
> > Try ArrayListView instead of ArrayList.
> >
> > > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <hf...@gmail.com>
> > wrote:
> > >
> > > Hello,
> > >
> > > There is already a bead or a way to add filterFunction to Royale
> > ArrayList
> > > as we have with ArrayCollection in Flex ?
> >
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: ArrayList filterFunction

Posted by Hugo Ferreira <hf...@gmail.com>.
Fanstastic.
One more issue solved.
Thank you.

Harbs <ha...@gmail.com> escreveu no dia segunda, 31/08/2020 à(s)
15:01:

> Try ArrayListView instead of ArrayList.
>
> > On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <hf...@gmail.com>
> wrote:
> >
> > Hello,
> >
> > There is already a bead or a way to add filterFunction to Royale
> ArrayList
> > as we have with ArrayCollection in Flex ?
>
>

Re: ArrayList filterFunction

Posted by Harbs <ha...@gmail.com>.
Try ArrayListView instead of ArrayList.

> On Aug 31, 2020, at 3:54 PM, Hugo Ferreira <hf...@gmail.com> wrote:
> 
> Hello,
> 
> There is already a bead or a way to add filterFunction to Royale ArrayList
> as we have with ArrayCollection in Flex ?