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 org.eclipse.jface.viewers.ILabelProvider;
28  import org.eclipse.jface.viewers.ILabelProviderListener;
29  import org.eclipse.swt.graphics.Image;
30  import org.omwg.ontology.WsmlDataType;
31  import org.wsmo.common.Entity;
32  import org.wsmostudio.runtime.WsmoImageRegistry;
33  
34  /***
35   * A label provider implementation which determines the appearance of the 
36   * various WSMO-API objects in the GUI environment.
37   *
38   * @author not attributable
39   * @version $Revision: 1.9 $ $Date: 2006/01/09 12:51:14 $
40   */
41  
42  public class WSMOLabelProvider implements ILabelProvider {
43  
44      /* (non-Javadoc)
45       * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
46       */
47      public Image getImage(Object element) {
48          return WsmoImageRegistry.getImageForObject(element);
49      }
50  
51      public String getText(Object element) {
52          String label = null;
53          if (element instanceof WsmlDataType) {
54              label = ((WsmlDataType)element).getIRI().toString();
55          }
56          else if (element instanceof Entity) {
57              label =  ((Entity)element).getIdentifier().toString();
58          }
59          else {
60              return element.toString();
61          }
62          int index = label.lastIndexOf("#");
63          if (index == -1 
64                  || index == label.length()-1) {
65              return label;
66          }
67          return label.substring(index+1);
68      }
69  
70      public void addListener(ILabelProviderListener listener) {
71      }
72  
73      public void dispose() {
74      }
75  
76      public boolean isLabelProperty(Object element, String property) {
77          return true;
78      }
79  
80      public void removeListener(ILabelProviderListener listener) {
81      }
82  
83  }
84  
85  /*
86   * $Log: WSMOLabelProvider.java,v $
87   * Revision 1.9  2006/01/09 12:51:14  alex_simov
88   * Copyright message in header updated
89   *
90   * Revision 1.8  2005/10/14 13:25:18  alex_simov
91   * WSMO Navigator's extension point creation
92   *
93   * Revision 1.7  2005/09/16 14:25:11  alex_simov
94   * Identifier.asString() removed, use Object.toString() instead
95   *
96   * Revision 1.6  2005/07/29 15:08:03  alex_simov
97   * added javadoc: class description, footer
98   *
99   *
100  */