Project

General

Profile

Revision 2d7d6704

ID2d7d6704d437d8d698819614b942ee7a4621a0ab
Parent ae5816a7
Child 956da1e4

Added by Patrick Plitzner about 5 years ago

fix #5801 Make concept relations view work with taxon bulk editor

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptContentProvider.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.editor.view.concept;
12 12

  
13
import java.util.HashSet;
14
import java.util.Set;
13
import java.util.HashMap;
14
import java.util.Map;
15 15

  
16 16
import org.eclipse.jface.viewers.IStructuredContentProvider;
17 17
import org.eclipse.jface.viewers.Viewer;
......
28 28
 */
29 29
public class ConceptContentProvider implements IStructuredContentProvider {
30 30

  
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
33
	 */
34 31
	@Override
35 32
	public void dispose() {
36
		// TODO Auto-generated method stub
37 33
		
38 34
	}
39 35

  
40
	/* (non-Javadoc)
41
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
42
	 */
43 36
	@Override
44 37
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
45
		// TODO Auto-generated method stub
46
		
47 38
	}
48 39

  
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
51
	 */
52 40
	@Override
53 41
	public Object[] getElements(Object inputElement) {
42
		Taxon taxon = null;
54 43
		if(inputElement instanceof TaxonEditorInput){
55
			Taxon taxon = ((TaxonEditorInput) inputElement).getTaxon();
56
			
57
			Set<TaxonRelationship> filteredTaxonRelations = new HashSet<TaxonRelationship>();
44
			taxon = ((TaxonEditorInput) inputElement).getTaxon();
45
		}
46
		else if(inputElement instanceof Taxon){
47
			taxon = (Taxon) inputElement;
48
		}
49
		if(taxon!=null){
50
			Map<TaxonRelationship, Taxon> taxonToTaxonRelationsMap = new HashMap<>();
58 51
			
59 52
			for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
60 53
				if (! relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) ||
61 54
						 relationship.getType().equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
62
					filteredTaxonRelations.add(relationship);
55
					taxonToTaxonRelationsMap.put(relationship, taxon);
63 56
				}
64 57
			}
65
			
66
			return filteredTaxonRelations.toArray();
58
			return taxonToTaxonRelationsMap.entrySet().toArray();
67 59
		}
68 60
		return new Object[0];
69 61
	}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptLabelProvider.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.editor.view.concept;
12 12

  
13
import java.util.Map.Entry;
14

  
13 15
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
14 16
import org.eclipse.jface.viewers.LabelProvider;
15 17
import org.eclipse.jface.viewers.StyledString;
16 18
import org.eclipse.swt.graphics.Image;
17 19

  
18
import eu.etaxonomy.cdm.model.common.Language;
19
import eu.etaxonomy.cdm.model.common.Representation;
20
import eu.etaxonomy.cdm.model.reference.IReference;
21 20
import eu.etaxonomy.cdm.model.taxon.Taxon;
22 21
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
23 22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
24
import eu.etaxonomy.taxeditor.editor.EditorUtil;
25
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
26 23
import eu.etaxonomy.taxeditor.model.ImageResources;
27 24
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29 25

  
30 26
/**
31 27
 * @author n.hoffmann
......
34 30
 */
35 31
public class ConceptLabelProvider extends LabelProvider implements IStyledLabelProvider {
36 32

  
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
39
	 */
40 33
	@Override
41 34
	public Image getImage(Object element) {
42
		if(element instanceof TaxonRelationship){
43
			return getTaxonRelationshipImage((TaxonRelationship) element);
35
		if(element instanceof Entry){
36
			return getTaxonRelationshipImage((TaxonRelationship) ((Entry<TaxonRelationship, Taxon>) element).getKey());
44 37
		}
45 38
		return super.getImage(element);
46 39
	}
47 40
	
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
50
	 */
51 41
	@Override
52 42
	public String getText(Object element) {
53
		if(element instanceof TaxonRelationship){
54
			return formatRelationship((TaxonRelationship) element);
43
		if(element instanceof Entry){
44
			return formatRelationship((Entry<TaxonRelationship, Taxon>) element);
55 45
		}
56 46
		
57 47
		return "";
......
59 49
	
60 50
	/**
61 51
	 * Creates a string that holds a representation of the {@link TaxonRelationship} in relation to
62
	 * the accepted taxon of the currently active {@link MultiPageTaxonEditor}.
52
	 * the currently selected and accepted taxon.
63 53
	 * 
64 54
	 * @param relationship
65 55
	 * @return a formatted String representation of the relationship
66 56
	 */
67
	private String formatRelationship(TaxonRelationship relationship){
68
		Taxon sourceTaxon = EditorUtil.getActiveMultiPageTaxonEditor().getTaxon();
69
		TaxonRelationshipTypeInverseContainer container = TaxonRelationshipTypeInverseContainer.CreateFromSource(sourceTaxon, relationship);
70
		Taxon relatedTaxon = TaxonRelationshipTypeInverseContainer.RelatedTaxon(sourceTaxon, relationship);
57
	private String formatRelationship(Entry<TaxonRelationship, Taxon> entry){
58
		Taxon sourceTaxon = entry.getValue();
59
		TaxonRelationshipTypeInverseContainer container = TaxonRelationshipTypeInverseContainer.CreateFromSource(sourceTaxon, entry.getKey());
60
		Taxon relatedTaxon = TaxonRelationshipTypeInverseContainer.RelatedTaxon(sourceTaxon, entry.getKey());
71 61
		String string = String.format("%s %s", container.getAbbreviatedLabel(), relatedTaxon);
72 62
		
73 63
		return string;
74 64
	}
75 65
	
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
78
	 */
79 66
	@Override
80 67
	public StyledString getStyledText(Object element) {
81 68
		return  new StyledString(getText(element), StyledString.QUALIFIER_STYLER);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptViewPart.java
25 25
import org.eclipse.ui.IWorkbenchActionConstants;
26 26
import org.eclipse.ui.IWorkbenchPart;
27 27

  
28
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 29
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
29 30
import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
30 31
import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
31 32
import eu.etaxonomy.taxeditor.model.AbstractUtility;
32 33
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
33 34
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
35
import eu.etaxonomy.taxeditor.model.LineSelection;
34 36
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
35 37

  
36 38
/**
......
51 53
			return;
52 54
		}
53 55

  
54
		if(part instanceof BulkEditor){
55
			showEmptyPage();
56
		if(part instanceof BulkEditor && selection instanceof LineSelection){
57
			if(((LineSelection) selection).getFirstElement() instanceof Taxon){
58
				showViewer(part, (LineSelection) selection);
59
			}
60
			else{
61
				showEmptyPage();
62
			}
56 63
			return;
57 64
		}
58 65

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)