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
|
|
14
|
import org.eclipse.swt.SWT;
|
15
|
import org.eclipse.swt.graphics.Color;
|
16
|
import org.eclipse.swt.widgets.Composite;
|
17
|
import org.eclipse.swt.widgets.Label;
|
18
|
|
19
|
import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
|
20
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
21
|
import eu.etaxonomy.taxeditor.store.singlesource.widget.DisplayProxy;
|
22
|
import eu.etaxonomy.taxeditor.ui.forms.AbstractCdmFormElement;
|
23
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
24
|
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
25
|
|
26
|
/**
|
27
|
* <p>ParsingMessageElement class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Mar 3, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class ParsingMessageElement extends AbstractCdmFormElement {
|
34
|
|
35
|
private Label parsingMessage;
|
36
|
|
37
|
private ParserProblem parserProblem;
|
38
|
|
39
|
/**
|
40
|
* <p>Constructor for ParsingMessageElement.</p>
|
41
|
*
|
42
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
|
43
|
* @param parentElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
|
44
|
* @param parserProblem a {@link eu.etaxonomy.cdm.strategy.parser.ParserProblem} object.
|
45
|
* @param style a int.
|
46
|
*/
|
47
|
public ParsingMessageElement(CdmFormFactory formFactory,
|
48
|
ICdmFormElement parentElement, ParserProblem parserProblem, int style) {
|
49
|
super(formFactory, parentElement);
|
50
|
this.parserProblem = parserProblem;
|
51
|
createControl(getLayoutComposite(), SWT.TOP);
|
52
|
}
|
53
|
|
54
|
private void createControl(Composite parent, int style) {
|
55
|
parsingMessage = formFactory.createLabel(parent, parserProblem.getMessage(CdmStore.getDefaultLanguage()));
|
56
|
parsingMessage.setBackground(getColor());
|
57
|
// parsingMessage.setLayoutData(FILL_GRID_HORIZONTALLY());
|
58
|
}
|
59
|
|
60
|
/** {@inheritDoc} */
|
61
|
public void setSelected(boolean selected) {
|
62
|
|
63
|
}
|
64
|
|
65
|
private Color getColor(){
|
66
|
if(parserProblem.isError()){
|
67
|
return DisplayProxy.getDefault().getSystemColor(SWT.COLOR_RED);
|
68
|
}
|
69
|
|
70
|
if(parserProblem.isWarning()){
|
71
|
return DisplayProxy.getDefault().getSystemColor(SWT.COLOR_YELLOW);
|
72
|
}
|
73
|
// we should never get here
|
74
|
return null;
|
75
|
}
|
76
|
}
|