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.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      /* (non-Javadoc)
65       * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
66       */
67      public Object getEditableValue() {
68          // TODO Auto-generated method stub
69          return null;
70      }
71  
72      /* (non-Javadoc)
73       * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
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(); // the real object is not reachable
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     /* (non-Javadoc)
101      * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
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     /* (non-Javadoc)
115      * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
116      */
117     public boolean isPropertySet(Object id) {
118         if (id.equals(ID_KEY)) {
119             return false;
120         }
121         return true;
122     }
123 
124     /* (non-Javadoc)
125      * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
126      */
127     public void resetPropertyValue(Object id) {
128         // TODO Auto-generated method stub
129 
130     }
131 
132     /* (non-Javadoc)
133      * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
134      */
135     public void setPropertyValue(Object id, Object value) {
136         // TODO Auto-generated method stub
137 
138     }
139 }
140 
141 /*
142  * $Log: WSMOPropertiesSource.java,v $
143  * Revision 1.5  2006/01/09 12:51:14  alex_simov
144  * Copyright message in header updated
145  *
146  * Revision 1.4  2005/09/16 14:25:11  alex_simov
147  * Identifier.asString() removed, use Object.toString() instead
148  *
149  * Revision 1.3  2005/07/29 15:08:03  alex_simov
150  * added javadoc: class description, footer
151  *
152  *
153  */