ref #6159: fix that some column show no data
authorKatja Luther <k.luther@bgbm.org>
Mon, 24 Oct 2016 09:17:00 +0000 (11:17 +0200)
committerKatja Luther <k.luther@bgbm.org>
Mon, 24 Oct 2016 11:05:30 +0000 (13:05 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistLabelProvider.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/edit/DistributionEditingSupport.java
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 014ff4fb7f231fcb20ed9b9d86b53527c2735a26..ec005e447dc9c021636d67510c717d1c0d801ffa 100644 (file)
@@ -129,7 +129,7 @@ public class ChecklistLabelProvider extends LabelProvider implements ITableLabel
             }
         }
 
-        if(columnIndex >2 || (!PreferencesUtil.isShowRankInChecklistEditor() && columnIndex > 1)){
+        if(columnIndex >2 || (!PreferencesUtil.isShowRankInChecklistEditor() && columnIndex > 0)){
 
             for (TaxonDescription td : listTaxonDescriptions) {
                 for (DescriptionElementBase deb : td.getElements()) {
index 2274d9b3fe5af0643968c65b2e28ed9d9a7c8fa2..5e8af9a703732dc40a109298f5700a17e240e181 100644 (file)
@@ -153,7 +153,11 @@ public final class DistributionEditingSupport extends EditingSupport {
                 if (!PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
                     sameArea = column.getText().equalsIgnoreCase(term.getTitleCache());
                 } else{
-                    sameArea = column.getText().equalsIgnoreCase(term.getIdInVocabulary());
+                       if (term.getIdInVocabulary() != null){
+                               sameArea = column.getText().equalsIgnoreCase(term.getIdInVocabulary());
+                       } else{
+                               sameArea = column.getText().equalsIgnoreCase(term.getTitleCache());
+                       }
                 }
                 if (sameArea) {
                     NamedArea area = (NamedArea) term;
index 1405ece32e5b942c09559304a4d409ce29416916..799f2ee6c36db91a70bbcd8092160323725d9e3c 100644 (file)
 package eu.etaxonomy.taxeditor.ui.element;
 
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.TableWrapData;
 
 import eu.etaxonomy.cdm.common.CdmUtils;
 
@@ -49,4 +52,12 @@ public class LabelElement extends AbstractCdmFormElement {
        public void setText(String text) {
                label.setText(CdmUtils.Nz(text));
        }
+       
+       public void setLayout(TableWrapData layoutConstants){
+               label.setLayoutData(layoutConstants);
+       }
+       
+       public void setForeground(Color color){
+               label.setForeground(color);
+       }
 }
index abbc234a23ea13300ed7e19f3c1dddfeb783c256..23d6f315a0f3e8ff449ce94e5b2b9c99bd0ae73c 100644 (file)
 
 package eu.etaxonomy.taxeditor.ui.section.reference;
 
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
 
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Institution;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 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.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.IErrorIntolerableElement;
 import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler;
+import eu.etaxonomy.taxeditor.ui.element.LabelElement;
+import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
 import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement;
@@ -47,6 +56,8 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElement<Reference>
                implements IErrorIntolerableElement, IExceptionHandler {
 
+       private LabelElement warnForReferencedObjects;
+       
     private ToggleableTextElement toggleableAbbrevCache;
 
        private TextWithLabelElement text_edition;
@@ -102,6 +113,8 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
        @Override
        protected void createControls(ICdmFormElement formElement,
                        Reference entity, int style) {
+               setWarnForReferencingObjects(formElement);
+               
                toggleable_cache = formFactory.createToggleableTextField(formElement,
                                "Reference Cache", entity.getTitleCache(),
                                entity.isProtectedTitleCache(), style);
@@ -588,4 +601,21 @@ public class ReferenceDetailElement extends AbstractIdentifiableEntityDetailElem
            }
            setIrrelevant(pushedState, except);
        }
+       
+       public void setWarnForReferencingObjects(ICdmFormElement formElement){
+               Integer referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(getEntity());
+               if (referencingObjectsCount > 1){
+                       if (warnForReferencedObjects == null){
+                               warnForReferencedObjects = formFactory.createLabel(formElement, CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"));
+                               warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+                               warnForReferencedObjects.setLayout(LayoutConstants.FILL(2, 2));
+                               warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor(
+                                               SWT.COLOR_RED));
+                               
+                       }else{
+                               warnForReferencedObjects.setText(CdmUtils.Nz("The reference is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"));
+                       }
+               }
+       }
+       
 }
index a8bdfe4d0d4f5bdca50a1dc84334d12dbd361c83..dd2b1fffbdd7a11773e217aad3dae986eb82afed 100644 (file)
@@ -13,7 +13,10 @@ package eu.etaxonomy.taxeditor.ui.section.reference;
 import org.eclipse.swt.SWT;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.CommonServiceImpl;
+import eu.etaxonomy.cdm.api.service.ReferenceServiceImpl;
 import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
@@ -49,9 +52,11 @@ public class ReferenceWizardPage extends AbstractCdmEntityWizardPage<Reference>
        /** {@inheritDoc} */
        @Override
     public AbstractCdmDetailElement<Reference> createElement(ICdmFormElement rootElement){
+               //TODO: looking for referencing objects
                ReferenceDetailElement referenceElement = formFactory.createReferenceDetailElement(rootElement, SWT.NULL);
                referenceElement.addExceptionHandler(this);
                referenceElement.setEntity(entity);
+               
                return referenceElement;
        }