ref #5972: the wizard warns the user if the reference is used ssomewhere else
authorKatja Luther <k.luther@bgbm.org>
Mon, 24 Oct 2016 12:09:08 +0000 (14:09 +0200)
committerKatja Luther <k.luther@bgbm.org>
Mon, 24 Oct 2016 12:11:55 +0000 (14:11 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/LabelElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceWizardPage.java

index 799f2ee6c36db91a70bbcd8092160323725d9e3c..a6c0c83d44e7f74751dcc86fd80593f2bc37a174 100644 (file)
@@ -60,4 +60,8 @@ public class LabelElement extends AbstractCdmFormElement {
        public void setForeground(Color color){
                label.setForeground(color);
        }
+       
+       public void setVisible(boolean setVisible){
+               label.setVisible(setVisible);
+       }
 }
index 23d6f315a0f3e8ff449ce94e5b2b9c99bd0ae73c..b8599a88d7092f40f8d1260fa19c1f40a12415f4 100644 (file)
@@ -15,6 +15,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
@@ -30,6 +31,7 @@ import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
 import eu.etaxonomy.cdm.model.reference.ReferenceType;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
+import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -113,8 +115,11 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
        @Override
        protected void createControls(ICdmFormElement formElement,
                        Reference entity, int style) {
+               ICdmFormElement o = this.getParentElement();
+               Class clazz=o.getClass();
                setWarnForReferencingObjects(formElement);
                
+               
                toggleable_cache = formFactory.createToggleableTextField(formElement,
                                "Reference Cache", entity.getTitleCache(),
                                entity.isProtectedTitleCache(), style);
@@ -615,7 +620,15 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
                        }else{
                                warnForReferencedObjects.setText(CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"));
                        }
+                       warnForReferencedObjects.setVisible(false);
                }
        }
        
+       public void setWarnForReferencingObjectsVisible(boolean isVisible){
+               if (warnForReferencedObjects != null){
+                       warnForReferencedObjects.setVisible(isVisible);
+               }
+       }
+
+       
 }
index dd2b1fffbdd7a11773e217aad3dae986eb82afed..643c7d9d9f92d97698cf7dad8196100a9db34d0a 100644 (file)
@@ -56,7 +56,7 @@ public class ReferenceWizardPage extends AbstractCdmEntityWizardPage<Reference>
                ReferenceDetailElement referenceElement = formFactory.createReferenceDetailElement(rootElement, SWT.NULL);
                referenceElement.addExceptionHandler(this);
                referenceElement.setEntity(entity);
-               
+               referenceElement.setWarnForReferencingObjectsVisible(true);
                return referenceElement;
        }