Project

General

Profile

« Previous | Next » 

Revision 3be6ef3e

Added by Niels Hoffmann over 13 years ago

performed javacscript:fix and worked on documentation

View differences:

taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/ConceptContainer.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor.name;
11

  
12
import org.eclipse.swt.graphics.Font;
13

  
14
import eu.etaxonomy.cdm.model.taxon.Taxon;
15
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
16
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
17
import eu.etaxonomy.taxeditor.editor.EditorUtil;
18
import eu.etaxonomy.taxeditor.preference.Resources;
19

  
20
/**
21
 * @author p.ciardelli
22
 * @created 26.01.2009
23
 * @version 1.0
24
 */
25
public class ConceptContainer extends AbstractGroupedContainer<Taxon> {
26
	
27
	private TaxonRelationshipType relationshipType;
28
	
29
		
30
	private ConceptContainer(TaxonNameEditor editor, AbstractGroup group,
31
			Taxon relatedTaxon, TaxonRelationshipType relationshipType, 
32
			boolean acceptedTaxonIsFromTaxon) {
33
		super(editor, group, relatedTaxon);
34

  
35
		// FIXME the acceptedTaxonIsFromTaxon is never used and 
36
		// I can't remember what is was used for in the first place
37
		
38
		this.relationshipType = relationshipType;
39
		showRelationshipType();
40
	}
41
	
42
	/* (non-Javadoc)
43
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
44
	 */
45
	@Override
46
	protected void initializeComposite() {
47
		
48
		setIsDraggable(true);
49
		setIcon(CONCEPT_ICON);
50
		setFont(getViewerFont());
51
		setIndent(CONCEPT_INDENT);
52
		
53
		showSec();
54
				
55
		initTextViewer();
56
	}
57
	
58
	private void showRelationshipType() {
59
		setNonEditableInfo(relationshipType.getLabel(), true);
60
	}
61

  
62
	private void showSec() {
63
		if (getTaxonBase() == null) {
64
			return;
65
		}
66
		
67
		if (getTaxonBase().getSec() == null) {
68
			setNonEditableInfo("sec. ???", false);
69
		} else {
70
			setNonEditableInfo("sec. " + getTaxonBase().getSec().getTitleCache(), false);
71
		}
72
	}
73

  
74
	public static ConceptContainer getNewInstance(TaxonNameEditor editor, AbstractGroup group, TaxonRelationship relationship){
75

  
76
		TaxonRelationshipType relationshipType = relationship.getType();
77
		
78
		if (relationship.getToTaxon().equals(editor.getTaxon())) {
79
			return new ConceptContainer (editor, group, 
80
					relationship.getFromTaxon(), relationshipType, false);
81
		} else {
82
			return new ConceptContainer (editor, group, 
83
					relationship.getToTaxon(), relationshipType, true);
84
		} 
85
	}
86

  
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#getViewerFont()
89
	 */
90
	@Override
91
	protected Font getViewerFont() {
92
		return EditorUtil.getFont(Resources.CONCEPT_FONT);
93
	}
94

  
95
	public Taxon getRelatedTaxon() {
96
		return getTaxonBase();
97
	}
98
	
99
	protected void calculateErrors() {
100
		super.calculateErrors();
101
		
102
		nameViewer.setShowSecError(getTaxonBase());
103
	}
104
	
105
	@Override
106
	protected void updateNonEditableInfo() {
107
		showSec();
108
		showRelationshipType();
109
	}
110
}
111

  
112

  
113

  
114

  
115

  
116

  
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.taxeditor.editor.name;
11

  
12
import org.eclipse.swt.graphics.Font;
13

  
14
import eu.etaxonomy.cdm.model.taxon.Taxon;
15
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
16
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
17
import eu.etaxonomy.taxeditor.editor.EditorUtil;
18
import eu.etaxonomy.taxeditor.preference.Resources;
19

  
20
/**
21
 * <p>ConceptContainer class.</p>
22
 *
23
 * @author p.ciardelli
24
 * @created 26.01.2009
25
 * @version 1.0
26
 */
27
public class ConceptContainer extends AbstractGroupedContainer<Taxon> {
28
	
29
	private TaxonRelationshipType relationshipType;
30
	
31
		
32
	private ConceptContainer(TaxonNameEditor editor, AbstractGroup group,
33
			Taxon relatedTaxon, TaxonRelationshipType relationshipType, 
34
			boolean acceptedTaxonIsFromTaxon) {
35
		super(editor, group, relatedTaxon);
36

  
37
		// FIXME the acceptedTaxonIsFromTaxon is never used and 
38
		// I can't remember what is was used for in the first place
39
		
40
		this.relationshipType = relationshipType;
41
		showRelationshipType();
42
	}
43
	
44
	/* (non-Javadoc)
45
	 * @see eu.etaxonomy.taxeditor.editor.name.NameComposite#initializeComposite()
46
	 */
47
	/** {@inheritDoc} */
48
	@Override
49
	protected void initializeComposite() {
50
		
51
		setIsDraggable(true);
52
		setIcon(CONCEPT_ICON);
53
		setFont(getViewerFont());
54
		setIndent(CONCEPT_INDENT);
55
		
56
		showSec();
57
				
58
		initTextViewer();
59
	}
60
	
61
	private void showRelationshipType() {
62
		setNonEditableInfo(relationshipType.getLabel(), true);
63
	}
64

  
65
	private void showSec() {
66
		if (getTaxonBase() == null) {
67
			return;
68
		}
69
		
70
		if (getTaxonBase().getSec() == null) {
71
			setNonEditableInfo("sec. ???", false);
72
		} else {
73
			setNonEditableInfo("sec. " + getTaxonBase().getSec().getTitleCache(), false);
74
		}
75
	}
76

  
77
	/**
78
	 * <p>getNewInstance</p>
79
	 *
80
	 * @param editor a {@link eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor} object.
81
	 * @param group a {@link eu.etaxonomy.taxeditor.editor.name.AbstractGroup} object.
82
	 * @param relationship a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationship} object.
83
	 * @return a {@link eu.etaxonomy.taxeditor.editor.name.ConceptContainer} object.
84
	 */
85
	public static ConceptContainer getNewInstance(TaxonNameEditor editor, AbstractGroup group, TaxonRelationship relationship){
86

  
87
		TaxonRelationshipType relationshipType = relationship.getType();
88
		
89
		if (relationship.getToTaxon().equals(editor.getTaxon())) {
90
			return new ConceptContainer (editor, group, 
91
					relationship.getFromTaxon(), relationshipType, false);
92
		} else {
93
			return new ConceptContainer (editor, group, 
94
					relationship.getToTaxon(), relationshipType, true);
95
		} 
96
	}
97

  
98
	/* (non-Javadoc)
99
	 * @see eu.etaxonomy.taxeditor.editor.GroupedComposite#getViewerFont()
100
	 */
101
	/** {@inheritDoc} */
102
	@Override
103
	protected Font getViewerFont() {
104
		return EditorUtil.getFont(Resources.CONCEPT_FONT);
105
	}
106

  
107
	/**
108
	 * <p>getRelatedTaxon</p>
109
	 *
110
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
111
	 */
112
	public Taxon getRelatedTaxon() {
113
		return getTaxonBase();
114
	}
115
	
116
	/**
117
	 * <p>calculateErrors</p>
118
	 */
119
	protected void calculateErrors() {
120
		super.calculateErrors();
121
		
122
		nameViewer.setShowSecError(getTaxonBase());
123
	}
124
	
125
	/** {@inheritDoc} */
126
	@Override
127
	protected void updateNonEditableInfo() {
128
		showSec();
129
		showRelationshipType();
130
	}
131
}
132

  
133

  
134

  
135

  
136

  
137

  

Also available in: Unified diff