« Return to Thread: TransformedList question
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:> Hope this helps,
>
> 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;
> }
>
>
> 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@...
> For additional commands, e-mail: users-help@...
>
>
>
--
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@...
For additional commands, e-mail: users-help@...
« Return to Thread: TransformedList question
| Free embeddable forum powered by Nabble | Forum Help |