View Javadoc

1   /*
2    * $Id: DumpOntLabelProvider.java,v 1.3 2004/09/08 13:16:47 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8    
9   package com.bbn.swede.library.dumpont;
10  
11  import org.daml.rdf.dumpont.core.Class;
12  import org.daml.rdf.dumpont.core.OntologyReader;
13  import org.daml.rdf.dumpont.core.Property;
14  import org.eclipse.jface.viewers.LabelProvider;
15  import org.eclipse.swt.graphics.Image;
16  
17  import com.bbn.swede.ui.OWLImages;
18  
19  /***
20   * Label provider for the TreeViewer that powers the DumpOnt visualization page.
21   * @author jlerner
22   */
23  public class DumpOntLabelProvider extends LabelProvider
24  {
25     /* (non-Javadoc)
26      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
27      */
28     public Image getImage(Object element)
29     {
30        if (element instanceof Class)
31        {
32           return OWLImages.getSharedImage(OWLImages.IMG_CLASS_OBJ);
33        }
34        if (element instanceof Property)
35        {
36           return OWLImages.getSharedImage(OWLImages.IMG_PROP_OBJ);
37        }
38        return OWLImages.getSharedImage(OWLImages.IMG_ONTOLOGY);
39     }
40     /* (non-Javadoc)
41      * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
42      */
43     public String getText(Object element)
44     {
45        if (element instanceof Class)
46        {
47           Class klass = (Class)element;
48           return OntologyReader.fragment(klass.getNode());
49        }
50        if (element instanceof Property)
51        {
52           Property prop = (Property)element;
53           return OntologyReader.fragment(prop.getNode());
54        }
55        return super.getText(element); //just calls Object.toString()
56     }
57  }