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.properties;
26
27 import org.eclipse.ui.views.properties.IPropertyDescriptor;
28 import org.eclipse.ui.views.properties.IPropertySource;
29 import org.eclipse.ui.views.properties.PropertyDescriptor;
30
31 import org.wsmo.common.*;
32 import org.wsmo.common.exception.SynchronisationException;
33
34 import java.util.*;
35
36 /***
37 * An implementation which is capable of supplying properties for display
38 * by the standard property sheet page implementation (<code>PropertySheetPage</code>).
39 *
40 * This implementation is interested only in objects of type (WSMO-API) Entity
41 * and the properties of interest are identifiers and NonFunctionalProperties.
42 *
43 * @author not attributable
44 * @version $Revision: 1.5 $ $Date: 2006/01/09 12:51:14 $
45 */
46
47
48 public class WSMOPropertiesSource implements IPropertySource {
49
50 Entity wsmoObject = null;
51 private static final String ID_KEY = "ID_KEY";
52 String identifier = null;
53
54 public WSMOPropertiesSource(Entity delegate) {
55 wsmoObject = delegate;
56 identifier = delegate.getIdentifier().toString();
57 }
58
59 public void setData(Entity delegate) {
60 identifier = delegate.getIdentifier().toString();
61 wsmoObject = delegate;
62 }
63
64
65
66
67 public Object getEditableValue() {
68
69 return null;
70 }
71
72
73
74
75 public IPropertyDescriptor[] getPropertyDescriptors() {
76 Set keys = null;
77 try {
78 keys = wsmoObject.listNFPValues().keySet();
79 }
80 catch(SynchronisationException synchEx) {
81 keys = new HashSet();
82 }
83 int truePropsSize = (identifier == null) ? keys.size() : keys.size() + 1;
84 IPropertyDescriptor[] result = new IPropertyDescriptor[truePropsSize];
85 int index = 0;
86 if (identifier != null) {
87 PropertyDescriptor idDesc = new PropertyDescriptor(ID_KEY, "Identifier");
88 idDesc.setCategory("Common");
89 result[index++] = idDesc;
90 }
91 for(Iterator it = keys.iterator(); it.hasNext();) {
92 IRI key = (IRI)it.next();
93 PropertyDescriptor propDesc = new PropertyDescriptor(key, key.toString());
94 propDesc.setCategory("NFP");
95 result[index++] = propDesc;
96 }
97 return result;
98 }
99
100
101
102
103 public Object getPropertyValue(Object id) {
104 if (id.equals(ID_KEY)) {
105 return identifier;
106 }
107 if (false == id instanceof IRI) {
108 return null;
109 }
110
111 return wsmoObject.listNFPValues((IRI)id);
112 }
113
114
115
116
117 public boolean isPropertySet(Object id) {
118 if (id.equals(ID_KEY)) {
119 return false;
120 }
121 return true;
122 }
123
124
125
126
127 public void resetPropertyValue(Object id) {
128
129
130 }
131
132
133
134
135 public void setPropertyValue(Object id, Object value) {
136
137
138 }
139 }
140
141
142
143
144
145
146
147
148
149
150
151
152
153