avoid empty lables in referencing objects view
authorKatja Luther <k.luther@bgbm.org>
Fri, 10 Mar 2017 09:55:01 +0000 (10:55 +0100)
committerKatja Luther <k.luther@bgbm.org>
Fri, 10 Mar 2017 09:55:01 +0000 (10:55 +0100)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/Messages.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages.properties [new file with mode: 0755]
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages_de.properties [new file with mode: 0755]
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsLabelProvider.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/Messages.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/Messages.java
new file mode 100755 (executable)
index 0000000..768046e
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.bulkeditor.l10n;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author k.luther
+ * @date 10.03.2017
+ *
+ */
+public class Messages extends NLS {
+    private static final String BUNDLE_NAME = "src/main/java/eu.etaxonomy.taxeditor.bulkeditor.l10n.messages"; //$NON-NLS-1$
+    public static String ReferencingObjectsLabelProvider_No_description_available;
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages.properties b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages.properties
new file mode 100755 (executable)
index 0000000..5cb5303
--- /dev/null
@@ -0,0 +1 @@
+ReferencingObjectsLabelProvider_No_description_available=No description available
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages_de.properties b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages_de.properties
new file mode 100755 (executable)
index 0000000..bfcb11a
--- /dev/null
@@ -0,0 +1 @@
+ReferencingObjectsLabelProvider_No_description_available=Keine Beschreibung verfügbar
\ No newline at end of file
index 21f7b52a3fa88301c86f76f3a0792afc845b7745..84322e296d9dd5cfe0aadd63b1449cf5b5f77373 100644 (file)
@@ -9,6 +9,7 @@
 
 package eu.etaxonomy.taxeditor.bulkeditor.referencingobjects;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
@@ -16,6 +17,7 @@ import org.eclipse.swt.graphics.Image;
 
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.taxeditor.bulkeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.DescriptionHelper;
 
 /**
@@ -60,11 +62,11 @@ public class ReferencingObjectsLabelProvider extends LabelProvider implements IT
                        }
                }else if (columnIndex == 3) {
                        if(element instanceof CdmBase){
-                               text = ((CdmBase) element).getId() + "";
+                               text = ((CdmBase) element).getId() + ""; //$NON-NLS-1$
                        }
                }
 
-               return text == null ? element.toString() : text;
+               return (StringUtils.isBlank(text)) ? Messages.ReferencingObjectsLabelProvider_No_description_available : text;
 
        }
 }
index 8812ae1629f1c2eff90ccc187110bab5ac14dc96..00bcc23f174f97c644bdde4ed9c6af51817d4111 100644 (file)
@@ -376,15 +376,7 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
                        if (result == 0) {
                                string1 = DescriptionHelper.getObjectDescription(o1);
                                string2 = DescriptionHelper.getObjectDescription(o2);
-                               if (string1 == null && string2 == null){
-                                   return 0;
-                               }
-                               if (string1 == null && string2 != null){
-                                   return -1;
-                               }
-                               if (string2 == null && string1 != null){
-                                   return 1;
-                               }
+
                                result = string1.compareToIgnoreCase(string2);
                                if (result == 0){
                                    return o1.getUuid().compareTo(o2.getUuid());
index aead08f6ce78ffc4c5f76d19d4c1e4c50f11a3b1..b1f806cb4cc81b6e9be7b27dd584ef7db89405b6 100644 (file)
@@ -210,13 +210,14 @@ public class DescriptionHelper {
         * @return a {@link java.lang.String} object.
         */
        public static String getObjectDescription(Object element) {
+           String resultString = null;
                if (element instanceof IdentifiableEntity) {
                        try{
-                               return ((IdentifiableEntity) element).getTitleCache();
+                           resultString = ((IdentifiableEntity) element).getTitleCache();
                        }catch(LazyInitializationException e){
                                String result = "No Session to initialize title cache for IdentifiableEntity";
                                MessagingUtils.error(DescriptionHelper.class, result, e);
-                               return "TODO: " + result;
+                               resultString = "TODO: " + result;
                        }
                }else if (element instanceof OriginalSourceBase) {
                        try{
@@ -232,43 +233,48 @@ public class DescriptionHelper {
 //                                     throw new IllegalStateException("Unknown ISourceable object for given OriginalSourceBase");
 //                             }
 
-                               return CdmUtils.concat("; ", new String[]{originalSource.getIdNamespace(), originalSource.getIdInSource(), sourceObjectTitle});
+                               resultString = CdmUtils.concat("; ", new String[]{originalSource.getIdNamespace(), originalSource.getIdInSource(), sourceObjectTitle});
                        }catch(LazyInitializationException e){
                                String result = "Error initializing title cache for ISourceable of an OriginalSourceBase";
                                MessagingUtils.error(DescriptionHelper.class, result, e);
-                               return "TODO: " + result;
+                               resultString = "TODO: " + result;
                        }
                }else if (element instanceof LanguageStringBase) {
-                       return ((LanguageStringBase) element).getText();
+                   resultString = ((LanguageStringBase) element).getText();
                }else if (element instanceof DescriptionElementBase) {
-                       return getCache((DescriptionElementBase) element);
+                   resultString = getCache((DescriptionElementBase) element);
                }else if (element instanceof RelationshipBase<?, ?, ?>) {
-                       return getCache((RelationshipBase<?, ?, ?>) element);
+                   resultString = getCache((RelationshipBase<?, ?, ?>) element);
                }else if (element instanceof TypeDesignationBase<?>) {
-                       return getCache((TypeDesignationBase<?>) element);
+                   resultString = getCache((TypeDesignationBase<?>) element);
                }else if (element instanceof HomotypicalGroup) {
-                       return getCache((HomotypicalGroup) element);
+                   resultString = getCache((HomotypicalGroup) element);
                }else if (element instanceof TaxonNode) {
-                       return getCache((TaxonNode) element);
+                   resultString = getCache((TaxonNode) element);
                }else if (element instanceof DeterminationEvent) {
-                       return getCache((DeterminationEvent) element);
+                   resultString = getCache((DeterminationEvent) element);
                }else if (element instanceof Marker) {
                        Marker marker = (Marker) element;
                        MarkerType type = marker.getMarkerType();
-                       return (type == null ? "- no marker type -" : marker.getMarkerType().getLabel()) + " (" + marker.getFlag() + ")";
+                       resultString = (type == null ? "- no marker type -" : marker.getMarkerType().getLabel()) + " (" + marker.getFlag() + ")";
                }else if (element instanceof User) {
                        User user = (User) element;
-                       return user.getUsername();
+                       resultString = user.getUsername();
                }else if (element instanceof Group) {
                        Group group = (Group) element;
-                       return group.getName();
+                       resultString = group.getName();
                }else if (element instanceof KeyStatement) {
             KeyStatement keyStatement = (KeyStatement) element;
-            return getCache(keyStatement);
+            resultString = getCache(keyStatement);
         }else{
                        // TODO write return texts for HomotypicalGroup, etc.
-                       return element.toString();
+            resultString = element.toString();
+               }
+
+               if (resultString == null){
+                   resultString = element.toString();
                }
+               return resultString;
        }