1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 org.omwg.ontology.Concept;
28
29 import java.util.Set;
30
31 /***
32 * An extension of <code>WSMOContentProvider</code> which enables the visualization
33 * of attributes as descendants of the representation of their containing concept.
34 *
35 * @author not attributable
36 * @version $Revision: 1.3 $ $Date: 2006/01/09 12:51:14 $
37 */
38
39 public class AttributesContentProvider extends WSMOContentProvider {
40
41 public AttributesContentProvider() {
42 super(CONCEPT_MASK | ONTOLOGY_MASK | ATTRIBUTE_MASK);
43 }
44
45 public Object[] getChildren(Object parentElement) {
46 Object[] result = super.getChildren(parentElement);
47 if (parentElement instanceof Concept) {
48 Set attrs = ((Concept)parentElement).listAttributes();
49 if (attrs.size() > 0) {
50 if (result == null || result.length == 0) {
51 return attrs.toArray();
52 }
53 Object[] newResult = new Object[result.length + attrs.size()];
54 System.arraycopy(result, 0, newResult, 0, result.length);
55 System.arraycopy(attrs.toArray(), 0, newResult, result.length, attrs.size());
56 return newResult;
57 }
58 }
59 return result;
60 }
61
62 public boolean hasChildren(Object element) {
63 if (element instanceof Concept) {
64 if (((Concept)element).listAttributes().size() > 0) {
65 return true;
66 }
67 }
68 return super.hasChildren(element);
69 }
70 }
71
72
73
74
75
76
77
78
79
80
81