Revision 384b41bd
Added by Katja Luther over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java | ||
---|---|---|
15 | 15 |
import java.util.Arrays; |
16 | 16 |
import java.util.List; |
17 | 17 |
|
18 |
import org.eclipse.jface.wizard.WizardPage; |
|
19 | 18 |
import org.eclipse.swt.SWT; |
20 | 19 |
import org.eclipse.swt.widgets.Display; |
21 |
import org.eclipse.swt.widgets.Label; |
|
22 |
import org.eclipse.swt.graphics.Color; |
|
23 |
import org.eclipse.swt.graphics.FontData; |
|
24 | 20 |
|
25 | 21 |
import eu.etaxonomy.cdm.common.CdmUtils; |
26 | 22 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
... | ... | |
31 | 27 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
32 | 28 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
33 | 29 |
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement; |
34 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage; |
|
35 | 30 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
36 | 31 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
37 | 32 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
... | ... | |
59 | 54 |
implements IErrorIntolerableElement, IExceptionHandler { |
60 | 55 |
|
61 | 56 |
private LabelElement warnForReferencedObjects; |
62 |
|
|
57 |
|
|
63 | 58 |
private ToggleableTextElement toggleableAbbrevCache; |
64 | 59 |
|
65 | 60 |
private TextWithLabelElement text_edition; |
... | ... | |
118 | 113 |
ICdmFormElement o = this.getParentElement(); |
119 | 114 |
Class clazz=o.getClass(); |
120 | 115 |
setWarnForReferencingObjects(formElement); |
121 |
|
|
122 |
|
|
116 |
|
|
117 |
|
|
123 | 118 |
toggleable_cache = formFactory.createToggleableTextField(formElement, |
124 | 119 |
"Reference Cache", entity.getTitleCache(), |
125 | 120 |
entity.isProtectedTitleCache(), style); |
... | ... | |
606 | 601 |
} |
607 | 602 |
setIrrelevant(pushedState, except); |
608 | 603 |
} |
609 |
|
|
604 |
|
|
610 | 605 |
public void setWarnForReferencingObjects(ICdmFormElement formElement){ |
611 |
Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(getEntity()); |
|
612 |
if (referencingObjectsCount > 1){ |
|
613 |
if (warnForReferencedObjects == null){ |
|
614 |
warnForReferencedObjects = formFactory.createLabel(formElement, CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects")); |
|
615 |
warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
616 |
warnForReferencedObjects.setLayout(LayoutConstants.FILL(2, 2)); |
|
617 |
warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor( |
|
618 |
SWT.COLOR_RED)); |
|
619 |
|
|
620 |
}else{ |
|
621 |
warnForReferencedObjects.setText(CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects")); |
|
622 |
} |
|
623 |
warnForReferencedObjects.setVisible(false); |
|
624 |
} |
|
606 |
if (getEntity().getId() != 0){ |
|
607 |
Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(getEntity()); |
|
608 |
|
|
609 |
if (referencingObjectsCount > 1){ |
|
610 |
if (warnForReferencedObjects == null){ |
|
611 |
warnForReferencedObjects = formFactory.createLabel(formElement, CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects")); |
|
612 |
warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
613 |
warnForReferencedObjects.setLayout(LayoutConstants.FILL(2, 2)); |
|
614 |
warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor( |
|
615 |
SWT.COLOR_RED)); |
|
616 |
|
|
617 |
}else{ |
|
618 |
warnForReferencedObjects.setText(CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects")); |
|
619 |
} |
|
620 |
warnForReferencedObjects.setVisible(false); |
|
621 |
} |
|
622 |
} |
|
625 | 623 |
} |
626 |
|
|
624 |
|
|
627 | 625 |
public void setWarnForReferencingObjectsVisible(boolean isVisible){ |
628 | 626 |
if (warnForReferencedObjects != null){ |
629 | 627 |
warnForReferencedObjects.setVisible(isVisible); |
630 | 628 |
} |
631 | 629 |
} |
632 | 630 |
|
633 |
|
|
631 |
|
|
634 | 632 |
} |
Also available in: Unified diff
fix #6176: check if entity is new