-// $Id$
/**
* Copyright (C) 2007 EDIT
* European Distributed Institute of Taxonomy
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.taxeditor.editor.view.concept;
+import java.util.Map.Entry;
+
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
-import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.Representation;
-import eu.etaxonomy.cdm.model.reference.IReference;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
-import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author n.hoffmann
- * @created Jan 24, 2011
- * @version 1.0
*/
public class ConceptLabelProvider extends LabelProvider implements IStyledLabelProvider {
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
@Override
public Image getImage(Object element) {
- if(element instanceof TaxonRelationship){
- return getTaxonRelationshipImage((TaxonRelationship) element);
+ if(element instanceof Entry){
+ return getTaxonRelationshipImage((TaxonRelationship) ((Entry<TaxonRelationship, Taxon>) element).getKey());
}
return super.getImage(element);
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
- */
@Override
public String getText(Object element) {
- if(element instanceof TaxonRelationship){
- return formatRelationship((TaxonRelationship) element);
+ if(element instanceof Entry){
+ return formatRelationship((Entry<TaxonRelationship, Taxon>) element);
}
- return "";
+ return ""; //$NON-NLS-1$
}
/**
* Creates a string that holds a representation of the {@link TaxonRelationship} in relation to
- * the accepted taxon of the currently active {@link MultiPageTaxonEditor}.
+ * the currently selected and accepted taxon.
*
* @param relationship
* @return a formatted String representation of the relationship
*/
- private String formatRelationship(TaxonRelationship relationship){
- Taxon sourceTaxon = EditorUtil.getActiveMultiPageTaxonEditor().getTaxon();
- TaxonRelationshipTypeInverseContainer container = TaxonRelationshipTypeInverseContainer.CreateFromSource(sourceTaxon, relationship);
- Taxon relatedTaxon = TaxonRelationshipTypeInverseContainer.RelatedTaxon(sourceTaxon, relationship);
- String string = String.format("%s %s", container.getAbbreviatedLabel(), relatedTaxon);
+ private String formatRelationship(Entry<TaxonRelationship, Taxon> entry){
+ Taxon sourceTaxon = entry.getValue();
+ TaxonRelationshipTypeInverseContainer container = TaxonRelationshipTypeInverseContainer.CreateFromSource(sourceTaxon, entry.getKey());
+ Taxon relatedTaxon = TaxonRelationshipTypeInverseContainer.RelatedTaxon(sourceTaxon, entry.getKey());
+ String string = String.format("%s %s", container.getAbbreviatedLabel(), relatedTaxon); //$NON-NLS-1$
return string;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
- */
@Override
public StyledString getStyledText(Object element) {
return new StyledString(getText(element), StyledString.QUALIFIER_STYLER);