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.ui.section.taxon;
|
11
|
|
12
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
13
|
import org.eclipse.swt.SWT;
|
14
|
import org.eclipse.swt.widgets.Control;
|
15
|
import org.eclipse.ui.forms.widgets.TableWrapData;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
18
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.name.INonViralName;
|
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.section.AbstractCdmDetailElement;
|
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
|
*/
|
34
|
public class ParsingMessagesSection
|
35
|
extends AbstractCdmDetailSection<INonViralName>
|
36
|
implements ITaxonBaseDetailSection {
|
37
|
|
38
|
/** Constant <code>HEADING_SUCCESS=""</code> */
|
39
|
public static final String HEADING_SUCCESS = "";
|
40
|
/** Constant <code>HEADING_PROBLEM="The name has problems."</code> */
|
41
|
public static final String HEADING_PROBLEM = "The name has problems.";
|
42
|
private TaxonBase taxonBase;
|
43
|
|
44
|
/**
|
45
|
* <p>Constructor for ParsingMessagesSection.</p>
|
46
|
*
|
47
|
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
48
|
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
|
49
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
|
50
|
* @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
|
51
|
* @param style a int.
|
52
|
*/
|
53
|
public ParsingMessagesSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement,
|
54
|
ISelectionProvider selectionProvider, int style) {
|
55
|
super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
|
56
|
}
|
57
|
|
58
|
/** {@inheritDoc} */
|
59
|
@Override
|
60
|
protected void createControls(AbstractCdmDetailSection formElement, int style) {
|
61
|
// we do it differently here
|
62
|
}
|
63
|
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public void setTaxonBase(TaxonBase entity) {
|
67
|
this.taxonBase = entity;
|
68
|
setEntity(HibernateProxyHelper.deproxy(entity.getName()));
|
69
|
destroyParsingProblemComposites();
|
70
|
if(getEntity().hasProblem()){
|
71
|
displayParsingProblems();
|
72
|
}
|
73
|
}
|
74
|
|
75
|
private void destroyParsingProblemComposites() {
|
76
|
setText(HEADING_SUCCESS);
|
77
|
for(Control control : getLayoutComposite().getChildren()){
|
78
|
control.dispose();
|
79
|
control = null;
|
80
|
}
|
81
|
TableWrapData layoutData = (TableWrapData) getLayoutData();
|
82
|
layoutData.heightHint = 0;
|
83
|
setLayoutData(layoutData);
|
84
|
this.layout();
|
85
|
}
|
86
|
|
87
|
private void displayParsingProblems() {
|
88
|
TableWrapData layoutData = (TableWrapData) getLayoutData();
|
89
|
layoutData.heightHint = -1;
|
90
|
setLayoutData(layoutData);
|
91
|
setText(HEADING_PROBLEM);
|
92
|
for(Object parserProblem : getEntity().getParsingProblems()){
|
93
|
formFactory.createParsingMessageElement(this, (ParserProblem) parserProblem, SWT.NULL);
|
94
|
}
|
95
|
this.layout();
|
96
|
}
|
97
|
|
98
|
/** {@inheritDoc} */
|
99
|
@Override
|
100
|
public String getHeading() {
|
101
|
return HEADING_SUCCESS;
|
102
|
}
|
103
|
|
104
|
@Override
|
105
|
public TaxonBase getTaxonBase() {
|
106
|
return taxonBase;
|
107
|
}
|
108
|
|
109
|
@Override
|
110
|
protected AbstractCdmDetailElement<INonViralName> createCdmDetailElement(
|
111
|
AbstractCdmDetailSection<INonViralName> parentElement, int style) {
|
112
|
//no detail element
|
113
|
return null;
|
114
|
}
|
115
|
}
|