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