« Return to Thread: TransformedList question
James Lemieux wrote:Holger has it exactly right. CollectionList is the de facto list to use when
a single source element produces multiple transformed elements. Using
CollectionList is the first half of the solution.
The second half is the TextFilterator which extracts Strings from the Issues
to be considered when filtering any given Issue. That TextFilterator needs
to return all users as Strings in addition to any other Strings you deem
worthy of consideration when filtering your Issues. Again, Holger has
sketched the code well.
I'd urge you to check out our screencasts here:
http://www.publicobject.com/glazedlistsdeveloper/
as they do a good job of introducing each concept separate and apart from
each other. The screencast of FilterList may be particularly useful to you.
James
On 8/15/06, wsnyder6 <wsnyder6@gmail.com> wrote:
>
>
> Awesome. I will try this.
>
> I also thought that I could use the TransformedList like such:
>
> class ItemsToLabelsList extends TransformedList {
>
> public IssuesToUsersList(EventList source) {
> super(source);
> for (Object elem : source) {
> addAll( ((Issue)elem).getUsers() );
> }
> source.addListEventListener(this);
> }
>
> public void listChanged(ListEvent listChanges) {
> updates.forwardEvent(listChanges);
> }
>
> }
>
>
> Holger Brands-2 wrote:
> >
> > Hi,
> >
> >>
> >> What if each Issue could have more than one User attached to it? How
> then
> >> would I implement the TransformedList with Dynamic filtering?
> >>
> >
> > The tutorial shows filtering of issues by the issue reporter:
> > Issue.getReporter()
> > For the following discussion let's assume you want to filter by
> > all users of the issue as defined by method Issue.getAllUsers().
> >
> > You would have to change
> > a) the IssueToUserList from tutorial chapter 4
> > b) the IssuesForUsersMatcher from tutorial chapter 5.
> >
> > a) Instead of using the IssueToUserList I would use a CollectionList
> like
> > this:
> >
> > CollectionList<Issue, String> usersNonUnique = new CollectionList<Issue,
> > String>(source, new IssueToUsersModel());
> >
> >
> > /**
> > * Determines all users for an issue.
> > */
> > public class IssueToUsersModel implements CollectionList.Model<Issue,
> > String> {
> > public List<String> getChildren(Issue issue) {
> > return issue.getAllUsers();
> > }
> > }
> >
> > The CollectionList is a TransformedList that maps each issue from the
> > source list to the associated users.
> > It's a kind of parent-child relationship.
> >
> >
> > b) IssuesForUsersMatcher should be changed to match all issue users
> using.
> > Issue.getAllUsers():
> >
> > /**
> > * Test whether to include or not include the specified issue based
> > * on whether or not their user is selected.
> > */
> > public boolean matches(Object o) {
> > if(o == null) return false;
> > if(users.isEmpty()) return true;
> >
> > Issue issue = (Issue)o;
> > for (Iterator i = issue.getAllUsers().iterator(); i.hasNext(); )
> {
> > if(users.contains(i.next())) return true;
> > }
> > return false;
> > }
> >
> >
> > Hope this helps,
> > Holger
> >
> >
> __________________________________________________________________________
> > Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach!
> > Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
> > For additional commands, e-mail: users-help@glazedlists.dev.java.net
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/TransformedList-question-tf2110350.html#a5820094
> Sent from the GlazedLists - User forum at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
> For additional commands, e-mail: users-help@glazedlists.dev.java.net
>
>
« Return to Thread: TransformedList question
| Free embeddable forum powered by Nabble | Forum Help |