View Javadoc
1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2006</p>
22   * <p>Company: OntoText Lab. / SIRMA </p>
23   */
24  
25  package org.wsmostudio.ui.views.navigator;
26  
27  import java.util.*;
28  
29  /***
30   * An extension class of <code>WSMOContentProvider</code> dedicated to the
31   * WSMO Navigator view. It collaborates with the ContentExtensionManager, responsible
32   * for extension point <code>org.wsmostudio.ui.navigator_content</code>.
33   *
34   * @author not attributable
35   * @version $Revision: 1.2 $ $Date: 2006/01/09 12:51:14 $
36   */
37  
38  public class NavigatorContentProvider extends WSMOContentProvider {
39  
40      private ContentExtensionManager extManager;
41      
42      NavigatorContentProvider(ContentExtensionManager extManager) {
43          super(WSMOContentProvider.NO_FILTER);
44          this.extManager = extManager;
45      }
46      
47      public Object[] getChildren(Object parentElement) {
48          Object[] allChildren = extManager.getChildrenFor(parentElement, this);
49          if (allChildren != null) {
50              return applyFilters(allChildren);
51          }
52          return null;
53      }
54      
55      public boolean hasChildren(Object element) {
56          return extManager.hasChildrenFor(element, this);
57      }
58  
59      
60      public Object[] getDefaultChildren(Object parentElement) {
61          return super.getChildren(parentElement);
62      }
63  
64      public boolean hasDefaultChildren(Object parentElement) {
65          return super.hasChildren(parentElement);
66      }
67  
68      private Object[] applyFilters(Object[] all) {
69          List<Object> result = new LinkedList<Object>();
70          for(int i = 0; i < all.length; i++) {
71              if (false == extManager.isFiltered(all[i])) {
72                  result.add(all[i]);
73              }
74          }
75          if (result.size() == 0) {
76              return null;
77          }
78          return result.toArray();
79      }
80  }
81  
82  /*
83   * $Log: NavigatorContentProvider.java,v $
84   * Revision 1.2  2006/01/09 12:51:14  alex_simov
85   * Copyright message in header updated
86   *
87   * Revision 1.1  2005/10/14 13:25:18  alex_simov
88   * WSMO Navigator's extension point creation
89   *
90   */