View Javadoc

1   // $Id: SameNameDetailListModelFactory.java 165 2009-05-28 21:46:38Z agony $
2   /*
3    * xsAnalyzer - XML schema analyzing tool. Copyright (C) 2008 Michael Engelhardt
4    * 
5    * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6    * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7    * version.
8    * 
9    * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11   * 
12   * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
13   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14   */
15  /**
16   * 
17   */
18  package de.mindcrimeilab.xsanalyzer.model;
19  
20  import java.util.Map.Entry;
21  
22  import javax.swing.ListModel;
23  import javax.xml.namespace.QName;
24  
25  import org.apache.xerces.xs.XSObjectList;
26  import org.springframework.core.closure.Constraint;
27  import org.springframework.richclient.list.FilteredListModel;
28  
29  import de.mindcrimeilab.xsanalyzer.ui.ListModelFactory;
30  
31  /**
32   * 
33   * @author Michael Engelhardt<me@mindcrime-ilab.de>
34   * @author $Author: agony $
35   * @version $Revision: 165 $
36   * 
37   */
38  public class SameNameDetailListModelFactory implements ListModelFactory<Entry<QName, XSObjectList>> {
39  
40      private final Constraint constraint;
41  
42      public SameNameDetailListModelFactory() {
43          this(null);
44      }
45  
46      public SameNameDetailListModelFactory(Constraint constraint) {
47          super();
48          this.constraint = constraint;
49      }
50  
51      /*
52       * (non-Javadoc)
53       * 
54       * @see de.mindcrimeilab.xsanalyzer.ui.ListModelFactory#createListModel(java.lang.Object)
55       */
56      @Override
57      public ListModel createListModel(Entry<QName, XSObjectList> value) {
58          final ListModel retValue;
59          if (null == constraint) {
60              retValue = new XSObjectListModelAdapter(value.getValue());
61          }
62          else {
63              retValue = new FilteredListModel(new XSObjectListModelAdapter(value.getValue()), constraint);
64          }
65          return retValue;
66      }
67  }