Revision fa6d38ce
Added by Katja Luther about 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
212 | 212 |
import eu.etaxonomy.taxeditor.ui.section.feature.CharacterNodeDtoDetailSection; |
213 | 213 |
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailElement; |
214 | 214 |
import eu.etaxonomy.taxeditor.ui.section.feature.FeatureDistributionDetailSection; |
215 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailElement; |
|
216 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailSection; |
|
217 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElement; |
|
218 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElementForNode; |
|
219 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSection; |
|
220 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSectionForNode; |
|
221 | 215 |
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfCollectionElement; |
222 | 216 |
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSection; |
223 | 217 |
import eu.etaxonomy.taxeditor.ui.section.feature.InapplicableIfEntityCollectionSectionForNode; |
224 | 218 |
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfCollectionElement; |
225 | 219 |
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSection; |
226 | 220 |
import eu.etaxonomy.taxeditor.ui.section.feature.OnlyApplicableIfEntityCollectionSectionForNode; |
221 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailElement; |
|
222 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermNodeDetailSection; |
|
223 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElement; |
|
224 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailElementForNode; |
|
225 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSection; |
|
226 |
import eu.etaxonomy.taxeditor.ui.section.feature.TermTreeDetailSectionForNode; |
|
227 | 227 |
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityCollectionElement; |
228 | 228 |
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailElement; |
229 | 229 |
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailSection; |
... | ... | |
1370 | 1370 |
return createToggleableTextField(parentElement, labelString, initialText, initialState, CacheRelevance.CACHE1, style); |
1371 | 1371 |
} |
1372 | 1372 |
|
1373 |
/** |
|
1374 |
* like {@link #createToggleableTextField(ICdmFormElement, String, String, boolean, CacheRelevance, int)} |
|
1375 |
* but with predefined cache relevance == 1 |
|
1376 |
*/ |
|
1377 |
public RemovableTextElement createRemovableTextField(ICdmFormElement parentElement, String labelString, |
|
1378 |
String initialText, int style) { |
|
1379 |
RemovableTextElement element = new RemovableTextElement(this, parentElement, labelString, initialText, |
|
1380 |
style | orientation); |
|
1381 |
|
|
1382 |
adapt(element); |
|
1383 |
parentElement.addElement(element); |
|
1384 |
return element; |
|
1385 |
} |
|
1386 |
|
|
1373 | 1387 |
|
1374 | 1388 |
/** |
1375 | 1389 |
* createTimePeriodElement |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/RemovableTextElement.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2021 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 |
package eu.etaxonomy.taxeditor.ui.element; |
|
10 |
|
|
11 |
import org.apache.commons.lang3.StringUtils; |
|
12 |
import org.eclipse.swt.SWT; |
|
13 |
import org.eclipse.swt.events.SelectionEvent; |
|
14 |
import org.eclipse.swt.events.SelectionListener; |
|
15 |
import org.eclipse.swt.widgets.Button; |
|
16 |
import org.eclipse.swt.widgets.Composite; |
|
17 |
import org.eclipse.swt.widgets.Label; |
|
18 |
import org.eclipse.swt.widgets.Text; |
|
19 |
|
|
20 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author k.luther |
|
24 |
* @since Apr 1, 2021 |
|
25 |
*/ |
|
26 |
public class RemovableTextElement extends AbstractCdmFormElement implements SelectionListener { |
|
27 |
|
|
28 |
private final Text text_cache; |
|
29 |
private final Button btnRemoveElement; |
|
30 |
private final Label label; |
|
31 |
private final Composite container; |
|
32 |
private boolean state; |
|
33 |
|
|
34 |
protected RemovableTextElement(CdmFormFactory formFactory, ICdmFormElement parentElement, |
|
35 |
String labelString, String initialText, int style) { |
|
36 |
super(formFactory, parentElement); |
|
37 |
|
|
38 |
label = formFactory.createLabel(getLayoutComposite(), labelString, style); |
|
39 |
addControl(label); |
|
40 |
|
|
41 |
container = formFactory.createComposite(getLayoutComposite(), SWT.WRAP); |
|
42 |
container.setLayout(LayoutConstants.LAYOUT(2, false)); |
|
43 |
container.setLayoutData(LayoutConstants.FILL_HORIZONTALLY()); |
|
44 |
addControl(container); |
|
45 |
|
|
46 |
text_cache = formFactory.createText(container, initialText, SWT.WRAP | SWT.MULTI); |
|
47 |
addControl(text_cache); |
|
48 |
text_cache.setEnabled(false); |
|
49 |
text_cache.setLayoutData(LayoutConstants.FILL()); |
|
50 |
|
|
51 |
btnRemoveElement = formFactory.createButton(container, "Edit", SWT.TOGGLE); |
|
52 |
btnRemoveElement.setText(""); |
|
53 |
btnRemoveElement.setImage(ImageResources.getImage(ImageResources.TRASH_ICON)); |
|
54 |
addControl(btnRemoveElement); |
|
55 |
btnRemoveElement.addSelectionListener(this); |
|
56 |
if (initialText != null){ |
|
57 |
setState(true); |
|
58 |
}else { |
|
59 |
setState(false); |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
@Override |
|
66 |
public void widgetSelected(SelectionEvent e) { |
|
67 |
setText(null); |
|
68 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
73 |
// TODO Auto-generated method stub |
|
74 |
|
|
75 |
} |
|
76 |
|
|
77 |
public void setText(String text){ |
|
78 |
if (text == null){ |
|
79 |
this.text_cache.setText(""); |
|
80 |
} |
|
81 |
if (StringUtils.isBlank(text)){ |
|
82 |
setState(false); |
|
83 |
}else{ |
|
84 |
setState(true); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
public boolean isState() { |
|
90 |
return state; |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
public void setState(boolean state) { |
|
95 |
this.state = state; |
|
96 |
} |
|
97 |
|
|
98 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDetailElement.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
28 | 28 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
29 | 29 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
30 |
import eu.etaxonomy.taxeditor.ui.element.RemovableTextElement; |
|
30 | 31 |
import eu.etaxonomy.taxeditor.ui.element.RepresentationElement; |
31 | 32 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
32 | 33 |
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection; |
... | ... | |
65 | 66 |
private Label labelText_property; |
66 | 67 |
private Text text_property; |
67 | 68 |
|
68 |
private Label labelText_ratioTo; |
|
69 |
private Text text_ratioTo; |
|
69 |
private RemovableTextElement ratioTo; |
|
70 |
// private Label labelText_ratioTo; |
|
71 |
// private Text text_ratioTo; |
|
72 |
// private Button button_remove; |
|
73 |
|
|
74 |
|
|
70 | 75 |
// private TextWithLabelElement text_structure; |
71 | 76 |
// private TextWithLabelElement text_property; |
72 | 77 |
|
... | ... | |
109 | 114 |
|
110 | 115 |
comboStructuralModifier = formFactory.createDefinedTermComboElement(TermType.StructureModifier, formElement, "Structural Modifier", entity.getStructureModifier(), style); |
111 | 116 |
|
112 |
if (labelText_ratioTo != null){ |
|
113 |
labelText_ratioTo.dispose(); |
|
114 |
} |
|
115 |
labelText_ratioTo = new Label(formElement.getLayoutComposite(), SWT.NONE); |
|
116 |
labelText_ratioTo.setText("Ratio to"); |
|
117 |
if (text_ratioTo != null){ |
|
118 |
text_ratioTo.dispose(); |
|
119 |
} |
|
120 |
text_ratioTo = new Text(formElement.getLayoutComposite(), SWT.WRAP); |
|
121 |
text_ratioTo.setEditable(false); |
|
122 |
text_ratioTo.setText( CharacterNodeDetailElement.getRatioToText(entity)); |
|
123 |
text_ratioTo.setLayoutData(LayoutConstants.FILL()); |
|
124 |
text_ratioTo.setForeground(ColorResources.getColor(Resources.BLACK)); |
|
117 |
ratioTo = formFactory.createRemovableTextField(formElement, "Ratio to", CharacterNodeDetailElement.getRatioToText(entity), style); |
|
125 | 118 |
|
126 | 119 |
supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", entity.isSupportsQuantitativeData(), style); |
127 | 120 |
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", entity.isSupportsCategoricalData(), style); |
... | ... | |
150 | 143 |
sectionModifierVocabularies.setEntity(entity); |
151 | 144 |
} |
152 | 145 |
|
146 |
|
|
153 | 147 |
} |
154 | 148 |
// public void createText(ICdmFormElement formElement, String label, String path) { |
155 | 149 |
// labelText = new Label(formElement.getLayoutComposite(), SWT.NONE); |
... | ... | |
172 | 166 |
if(eventSource == comboStructuralModifier){ |
173 | 167 |
getEntity().setStructureModifier(comboStructuralModifier.getSelection()); |
174 | 168 |
} |
169 |
if(eventSource == ratioTo){ |
|
170 |
if (!ratioTo.isState()){ |
|
171 |
getEntity().setRatioToStructure(null); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 | 175 |
// if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){ |
176 | 176 |
// //if any type is selected disable supportsTextData |
177 | 177 |
// getEntity().setSupportsTextData(false); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/feature/CharacterDtoDetailElement.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
34 | 34 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
35 | 35 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
36 |
import eu.etaxonomy.taxeditor.ui.element.RemovableTextElement; |
|
36 | 37 |
import eu.etaxonomy.taxeditor.ui.element.RepresentationElement; |
37 | 38 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
38 | 39 |
import eu.etaxonomy.taxeditor.ui.section.vocabulary.MeasurementUnitCollectionSection; |
... | ... | |
75 | 76 |
private Label labelText_property; |
76 | 77 |
private Text text_property; |
77 | 78 |
|
78 |
private Label labelText_ratioTo;
|
|
79 |
private Text text_ratioTo; |
|
79 |
private RemovableTextElement ratioTo;
|
|
80 |
|
|
80 | 81 |
// private TextWithLabelElement text_structure; |
81 | 82 |
// private TextWithLabelElement text_property; |
82 | 83 |
|
... | ... | |
120 | 121 |
|
121 | 122 |
comboStructuralModifier = formFactory.createDefinedTermComboElementDto(TermType.StructureModifier, formElement, "Structural Modifier", entity.getStructureModifier(), style); |
122 | 123 |
|
123 |
if (labelText_ratioTo != null){ |
|
124 |
labelText_ratioTo.dispose(); |
|
125 |
} |
|
126 |
labelText_ratioTo = new Label(formElement.getLayoutComposite(), SWT.NONE); |
|
127 |
labelText_ratioTo.setText("Ratio to"); |
|
128 |
if (text_ratioTo != null){ |
|
129 |
text_ratioTo.dispose(); |
|
130 |
} |
|
131 |
text_ratioTo = new Text(formElement.getLayoutComposite(), SWT.WRAP); |
|
132 |
text_ratioTo.setEditable(false); |
|
133 |
if (entity.getRatioTo() != null){ |
|
134 |
text_ratioTo.setText(entity.getRatioTo().getPath()); |
|
135 |
} |
|
136 |
text_ratioTo.setLayoutData(LayoutConstants.FILL()); |
|
137 |
text_ratioTo.setForeground(ColorResources.getColor(Resources.BLACK)); |
|
124 |
// if (labelText_ratioTo != null){ |
|
125 |
// labelText_ratioTo.dispose(); |
|
126 |
// } |
|
127 |
// labelText_ratioTo = new Label(formElement.getLayoutComposite(), SWT.NONE); |
|
128 |
// labelText_ratioTo.setText("Ratio to"); |
|
129 |
// if (text_ratioTo != null){ |
|
130 |
// text_ratioTo.dispose(); |
|
131 |
// } |
|
132 |
// text_ratioTo = new Text(formElement.getLayoutComposite(), SWT.WRAP); |
|
133 |
// text_ratioTo.setEditable(false); |
|
134 |
// if (entity.getRatioTo() != null){ |
|
135 |
// text_ratioTo.setText(entity.getRatioTo().getPath()); |
|
136 |
// } |
|
137 |
// text_ratioTo.setLayoutData(LayoutConstants.FILL()); |
|
138 |
// text_ratioTo.setForeground(ColorResources.getColor(Resources.BLACK)); |
|
139 |
|
|
140 |
ratioTo = formFactory.createRemovableTextField(formElement, "Ratio to", entity.getRatioTo() != null? entity.getRatioTo().getPath():null, style); |
|
138 | 141 |
|
139 | 142 |
supportsQuantitativeData = formFactory.createCheckbox(formElement, "Supports Quantitative Data", ((FeatureDto) entity).isSupportsQuantitativeData(), style); |
140 | 143 |
supportsCategoricalData = formFactory.createCheckbox(formElement, "Supports Categorical Data", ((FeatureDto) entity).isSupportsCategoricalData(), style); |
... | ... | |
193 | 196 |
if(eventSource == comboStructuralModifier){ |
194 | 197 |
getEntity().setStructureModifier(TermDto.fromTerm(comboStructuralModifier.getSelection())); |
195 | 198 |
} |
199 |
if(eventSource == ratioTo){ |
|
200 |
if (!ratioTo.isState()){ |
|
201 |
getEntity().setRatioTo(null); |
|
202 |
} |
|
203 |
} |
|
204 |
|
|
196 | 205 |
// if(eventSource == supportsQuantitativeData || eventSource == supportsCategoricalData){ |
197 | 206 |
// //if any type is selected disable supportsTextData |
198 | 207 |
// getEntity().setSupportsCategoricalData(supportsCategoricalData.getSelection()); |
Also available in: Unified diff
ref #9537: add button to ratioTo element