1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.taxon;
|
12
|
|
13
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
14
|
import org.eclipse.swt.SWT;
|
15
|
import org.eclipse.swt.widgets.Control;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
18
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
20
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
21
|
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
|
27
|
|
28
|
/**
|
29
|
* <p>ParsingMessagesSection class.</p>
|
30
|
*
|
31
|
* @author n.hoffmann
|
32
|
* @created Mar 3, 2010
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class ParsingMessagesSection extends AbstractCdmDetailSection<NonViralName> implements ITaxonBaseDetailSection {
|
36
|
|
37
|
/** Constant <code>HEADING_SUCCESS=""</code> */
|
38
|
public static final String HEADING_SUCCESS = "";
|
39
|
/** Constant <code>HEADING_PROBLEM="The name has problems."</code> */
|
40
|
public static final String HEADING_PROBLEM = "The name has problems.";
|
41
|
private TaxonBase taxonBase;
|
42
|
|
43
|
/**
|
44
|
* <p>Constructor for ParsingMessagesSection.</p>
|
45
|
*
|
46
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
47
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
48
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
|
49
|
* @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
|
50
|
* @param style a int.
|
51
|
*/
|
52
|
public ParsingMessagesSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement,
|
53
|
ISelectionProvider selectionProvider, int style) {
|
54
|
super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
|
55
|
}
|
56
|
|
57
|
/** {@inheritDoc} */
|
58
|
@Override
|
59
|
protected void createControls(AbstractCdmDetailSection formElement, int style) {
|
60
|
// we do it differently here
|
61
|
}
|
62
|
|
63
|
/** {@inheritDoc} */
|
64
|
public void setTaxonBase(TaxonBase entity) {
|
65
|
this.taxonBase = entity;
|
66
|
setEntity((NonViralName) HibernateProxyHelper.deproxy(entity.getName()));
|
67
|
destroyParsingProblemComposites();
|
68
|
if(getEntity().hasProblem()){
|
69
|
displayParsingProblems();
|
70
|
}
|
71
|
}
|
72
|
|
73
|
private void destroyParsingProblemComposites() {
|
74
|
setText(HEADING_SUCCESS);
|
75
|
for(Control control : getLayoutComposite().getChildren()){
|
76
|
control.dispose();
|
77
|
control = null;
|
78
|
}
|
79
|
}
|
80
|
|
81
|
private void displayParsingProblems() {
|
82
|
setText(HEADING_PROBLEM);
|
83
|
for(Object parserProblem : getEntity().getParsingProblems()){
|
84
|
formFactory.createParsingMessageElement(this, (ParserProblem) parserProblem, SWT.NULL);
|
85
|
}
|
86
|
this.layout();
|
87
|
}
|
88
|
|
89
|
/** {@inheritDoc} */
|
90
|
@Override
|
91
|
public String getHeading() {
|
92
|
return HEADING_SUCCESS;
|
93
|
}
|
94
|
|
95
|
/** {@inheritDoc} */
|
96
|
@Override
|
97
|
protected DetailType getDetailType() {
|
98
|
return DetailType.PARSINGMESSAGE;
|
99
|
}
|
100
|
|
101
|
/* (non-Javadoc)
|
102
|
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
|
103
|
*/
|
104
|
@Override
|
105
|
public TaxonBase getTaxonBase() {
|
106
|
return taxonBase;
|
107
|
}
|
108
|
}
|