ref #6198 removed synonym type combobox
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / taxon / ParsingMessagesSection.java
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 import org.eclipse.ui.forms.widgets.TableWrapData;
17
18 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20 import eu.etaxonomy.cdm.model.name.NonViralName;
21 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
22 import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
23 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
24 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
25 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
26 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
27 import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection;
28
29 /**
30 * <p>ParsingMessagesSection class.</p>
31 *
32 * @author n.hoffmann
33 * @created Mar 3, 2010
34 * @version 1.0
35 */
36 public class ParsingMessagesSection extends AbstractCdmDetailSection<NonViralName> 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((NonViralName) 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 /* (non-Javadoc)
105 * @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#getTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase)
106 */
107 @Override
108 public TaxonBase getTaxonBase() {
109 return taxonBase;
110 }
111
112 /* (non-Javadoc)
113 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
114 */
115 @Override
116 protected AbstractCdmDetailElement<NonViralName> createCdmDetailElement(AbstractCdmDetailSection<NonViralName> parentElement, int style) {
117 //no detail element
118 return null;
119 }
120 }