3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.navigation
.search
;
13 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
14 import org
.eclipse
.jface
.viewers
.ILabelProvider
;
15 import org
.eclipse
.swt
.graphics
.Color
;
16 import org
.eclipse
.swt
.graphics
.Font
;
17 import org
.eclipse
.swt
.graphics
.Image
;
19 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
20 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
24 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
25 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
26 import eu
.etaxonomy
.taxeditor
.preference
.Resources
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * <p>SearchResultLabelProvider class.</p>
36 public class SearchResultLabelProvider
extends ColumnLabelProvider
implements ILabelProvider
{
39 public String
getText(Object element
) {
40 if(element
instanceof UuidAndTitleCache
){
41 return ((UuidAndTitleCache
) element
).getTitleCache();
43 return element
.toString();
47 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getBackground(java.lang.Object)
51 public Color
getBackground(Object element
) {
52 return super.getBackground(element
);
56 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getFont(java.lang.Object)
60 public Font
getFont(Object element
) {
61 if(element
instanceof Taxon
){
62 return NavigationUtil
.getFont(Resources
.FONT_SEARCH_VIEW_ACCEPTED
);
63 }else if(element
instanceof Synonym
){
64 return NavigationUtil
.getFont(Resources
.FONT_SEARCH_VIEW_SYNONYM
);
66 return NavigationUtil
.getFont(Resources
.FONT_SEARCH_VIEW_OTHER
);
71 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getForeground(java.lang.Object)
75 public Color
getForeground(Object element
) {
76 if(element
instanceof UuidAndTitleCache
){
77 Class type
= ((UuidAndTitleCache
) element
).getType();
78 if(type
== Taxon
.class){
79 return NavigationUtil
.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorAccepted");
80 }else if(type
== Synonym
.class){
81 return NavigationUtil
.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorSynonym");
84 return NavigationUtil
.getColorRegistry().get("eu.etaxonomy.taxeditor.preferences.searchResult.fontColorDefault");
88 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
92 public Image
getImage(Object element
) {
93 if(element
instanceof UuidAndTitleCache
){
94 Class type
= ((UuidAndTitleCache
) element
).getType();
95 // unfortunately we can not distinct misapplication anymore
96 // if(taxon.isMisapplication()){
97 // return ImageResources.getImage(ImageResources.MISAPPLIED_NAME_ICON);
99 if(type
== Taxon
.class){
100 if(((UuidAndTitleCache
) element
).getIsOrphaned()) {
101 return ImageResources
.getImage(ImageResources
.ORPHANED_TAXON
);
103 return ImageResources
.getImage(ImageResources
.BLACK_SQUARE_ICON
);
104 }else if(type
== Synonym
.class){
105 return ImageResources
.getImage(ImageResources
.HETEROTYPIC_SYN_ICON
);
108 return super.getImage(element
);
112 * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
114 * does not seem t work right now
118 public String
getToolTipText(Object element
) {
119 if(element
instanceof TaxonBase
){
120 if(element
instanceof Synonym
){
121 return "Synonym: " + ((TaxonBase
<?
>) element
).getName().getTitleCache();
123 return "Taxon: " + ((TaxonBase
<?
>) element
).getName().getTitleCache();
126 return "Name: " + element
.toString();