2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.taxon
;
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
;
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
.section
.AbstractCdmDetailElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailSection
;
26 import eu
.etaxonomy
.taxeditor
.ui
.section
.ITaxonBaseDetailSection
;
29 * <p>ParsingMessagesSection class.</p>
32 * @created Mar 3, 2010
35 public class ParsingMessagesSection
extends AbstractCdmDetailSection
<NonViralName
> implements ITaxonBaseDetailSection
{
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
;
44 * <p>Constructor for ParsingMessagesSection.</p>
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.
52 public ParsingMessagesSection(CdmFormFactory cdmFormFactory
, ConversationHolder conversation
, ICdmFormElement parentElement
,
53 ISelectionProvider selectionProvider
, int style
) {
54 super(cdmFormFactory
, conversation
, parentElement
, selectionProvider
, style
);
59 protected void createControls(AbstractCdmDetailSection formElement
, int style
) {
60 // we do it differently here
65 public void setTaxonBase(TaxonBase entity
) {
66 this.taxonBase
= entity
;
67 setEntity((NonViralName
) HibernateProxyHelper
.deproxy(entity
.getName()));
68 destroyParsingProblemComposites();
69 if(getEntity().hasProblem()){
70 displayParsingProblems();
74 private void destroyParsingProblemComposites() {
75 setText(HEADING_SUCCESS
);
76 for(Control control
: getLayoutComposite().getChildren()){
80 TableWrapData layoutData
= (TableWrapData
) getLayoutData();
81 layoutData
.heightHint
= 0;
82 setLayoutData(layoutData
);
86 private void displayParsingProblems() {
87 TableWrapData layoutData
= (TableWrapData
) getLayoutData();
88 layoutData
.heightHint
= -1;
89 setLayoutData(layoutData
);
90 setText(HEADING_PROBLEM
);
91 for(Object parserProblem
: getEntity().getParsingProblems()){
92 formFactory
.createParsingMessageElement(this, (ParserProblem
) parserProblem
, SWT
.NULL
);
99 public String
getHeading() {
100 return HEADING_SUCCESS
;
104 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
107 public TaxonBase
getTaxonBase() {
112 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
115 protected AbstractCdmDetailElement
<NonViralName
> createCdmDetailElement(AbstractCdmDetailSection
<NonViralName
> parentElement
, int style
) {