Revision 5f3e1fcb
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonOfRelationshipElement.java | ||
---|---|---|
3 | 3 |
import java.util.Arrays; |
4 | 4 |
|
5 | 5 |
import org.eclipse.swt.SWT; |
6 |
import org.eclipse.swt.widgets.Display; |
|
6 | 7 |
|
8 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
7 | 9 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
10 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
8 | 11 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
9 | 12 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement; |
10 | 13 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
11 | 14 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
15 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
12 | 16 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
13 | 17 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
14 | 18 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
... | ... | |
76 | 80 |
|
77 | 81 |
@Override |
78 | 82 |
protected void createControls(ICdmFormElement formElement, Taxon entity, int style) { |
83 |
this.setWarnForReferencingObjects(formElement, 2); |
|
79 | 84 |
toggleable_cache = formFactory.createToggleableTextField(this, |
80 | 85 |
"Title Cache", getEntity().getTitleCache(), |
81 | 86 |
getEntity().isProtectedTitleCache(), style); |
... | ... | |
116 | 121 |
public SelectionArbitrator getSelectionArbitrator() { |
117 | 122 |
return selectionArbitrator; |
118 | 123 |
} |
119 |
|
|
124 |
@Override |
|
125 |
public void setWarnForReferencingObjects(ICdmFormElement formElement, int defaultReferencingObjects){ |
|
126 |
if (getEntity() instanceof Taxon){ |
|
127 |
Taxon taxon = getEntity(); |
|
128 |
if (taxon.getId() != 0){ |
|
129 |
long referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(taxon); |
|
130 |
|
|
131 |
if (referencingObjectsCount > defaultReferencingObjects){ |
|
132 |
setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The "+ taxon.getUserFriendlyTypeName()+" is referenced by " + (referencingObjectsCount - defaultReferencingObjects)+ " other object(s), if you change it, it is changed for all these objects"))); |
|
133 |
getWarnForReferencedObjects().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
134 |
getWarnForReferencedObjects().setLayout(LayoutConstants.FILL(2, 3)); |
|
135 |
getWarnForReferencedObjects().setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
136 |
formFactory.createLabel(formElement, ""); |
|
137 |
|
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
} |
|
120 | 142 |
|
121 | 143 |
|
122 | 144 |
} |
Also available in: Unified diff
fix #8444: add warning if taxon used in taxonrelationship is used more than once