Project

General

Profile

Revision 3a5a8583

ID3a5a8583756ead795d138867e1a7dba40f266b10
Parent 898894c8
Child f555d4cc

Added by Katja Luther over 3 years ago

avoid empty lables in referencing objects view

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/Messages.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.bulkeditor.l10n;
10

  
11
import org.eclipse.osgi.util.NLS;
12

  
13
/**
14
 * @author k.luther
15
 * @date 10.03.2017
16
 *
17
 */
18
public class Messages extends NLS {
19
    private static final String BUNDLE_NAME = "src/main/java/eu.etaxonomy.taxeditor.bulkeditor.l10n.messages"; //$NON-NLS-1$
20
    public static String ReferencingObjectsLabelProvider_No_description_available;
21
    static {
22
        // initialize resource bundle
23
        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
24
    }
25

  
26
    private Messages() {
27
    }
28
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages.properties
1
ReferencingObjectsLabelProvider_No_description_available=No description available
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/l10n/messages_de.properties
1
ReferencingObjectsLabelProvider_No_description_available=Keine Beschreibung verf?gbar
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsLabelProvider.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.bulkeditor.referencingobjects;
11 11

  
12
import org.apache.commons.lang.StringUtils;
12 13
import org.apache.log4j.Logger;
13 14
import org.eclipse.jface.viewers.ITableLabelProvider;
14 15
import org.eclipse.jface.viewers.LabelProvider;
......
16 17

  
17 18
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
18 19
import eu.etaxonomy.cdm.model.common.CdmBase;
20
import eu.etaxonomy.taxeditor.bulkeditor.l10n.Messages;
19 21
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
20 22

  
21 23
/**
......
60 62
			}
61 63
		}else if (columnIndex == 3) {
62 64
			if(element instanceof CdmBase){
63
				text = ((CdmBase) element).getId() + "";
65
				text = ((CdmBase) element).getId() + ""; //$NON-NLS-1$
64 66
			}
65 67
		}
66 68

  
67
		return text == null ? element.toString() : text;
69
		return (StringUtils.isBlank(text)) ? Messages.ReferencingObjectsLabelProvider_No_description_available : text;
68 70

  
69 71
	}
70 72
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
376 376
			if (result == 0) {
377 377
				string1 = DescriptionHelper.getObjectDescription(o1);
378 378
				string2 = DescriptionHelper.getObjectDescription(o2);
379
				if (string1 == null && string2 == null){
380
				    return 0;
381
				}
382
				if (string1 == null && string2 != null){
383
				    return -1;
384
				}
385
				if (string2 == null && string1 != null){
386
				    return 1;
387
				}
379

  
388 380
				result = string1.compareToIgnoreCase(string2);
389 381
				if (result == 0){
390 382
				    return o1.getUuid().compareTo(o2.getUuid());
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java
210 210
	 * @return a {@link java.lang.String} object.
211 211
	 */
212 212
	public static String getObjectDescription(Object element) {
213
	    String resultString = null;
213 214
		if (element instanceof IdentifiableEntity) {
214 215
			try{
215
				return ((IdentifiableEntity) element).getTitleCache();
216
			    resultString = ((IdentifiableEntity) element).getTitleCache();
216 217
			}catch(LazyInitializationException e){
217 218
				String result = "No Session to initialize title cache for IdentifiableEntity";
218 219
				MessagingUtils.error(DescriptionHelper.class, result, e);
219
				return "TODO: " + result;
220
				resultString = "TODO: " + result;
220 221
			}
221 222
		}else if (element instanceof OriginalSourceBase) {
222 223
			try{
......
232 233
//					throw new IllegalStateException("Unknown ISourceable object for given OriginalSourceBase");
233 234
//				}
234 235

  
235
				return CdmUtils.concat("; ", new String[]{originalSource.getIdNamespace(), originalSource.getIdInSource(), sourceObjectTitle});
236
				resultString = CdmUtils.concat("; ", new String[]{originalSource.getIdNamespace(), originalSource.getIdInSource(), sourceObjectTitle});
236 237
			}catch(LazyInitializationException e){
237 238
				String result = "Error initializing title cache for ISourceable of an OriginalSourceBase";
238 239
				MessagingUtils.error(DescriptionHelper.class, result, e);
239
				return "TODO: " + result;
240
				resultString = "TODO: " + result;
240 241
			}
241 242
		}else if (element instanceof LanguageStringBase) {
242
			return ((LanguageStringBase) element).getText();
243
		    resultString = ((LanguageStringBase) element).getText();
243 244
		}else if (element instanceof DescriptionElementBase) {
244
			return getCache((DescriptionElementBase) element);
245
		    resultString = getCache((DescriptionElementBase) element);
245 246
		}else if (element instanceof RelationshipBase<?, ?, ?>) {
246
			return getCache((RelationshipBase<?, ?, ?>) element);
247
		    resultString = getCache((RelationshipBase<?, ?, ?>) element);
247 248
		}else if (element instanceof TypeDesignationBase<?>) {
248
			return getCache((TypeDesignationBase<?>) element);
249
		    resultString = getCache((TypeDesignationBase<?>) element);
249 250
		}else if (element instanceof HomotypicalGroup) {
250
			return getCache((HomotypicalGroup) element);
251
		    resultString = getCache((HomotypicalGroup) element);
251 252
		}else if (element instanceof TaxonNode) {
252
			return getCache((TaxonNode) element);
253
		    resultString = getCache((TaxonNode) element);
253 254
		}else if (element instanceof DeterminationEvent) {
254
			return getCache((DeterminationEvent) element);
255
		    resultString = getCache((DeterminationEvent) element);
255 256
		}else if (element instanceof Marker) {
256 257
			Marker marker = (Marker) element;
257 258
			MarkerType type = marker.getMarkerType();
258
			return (type == null ? "- no marker type -" : marker.getMarkerType().getLabel()) + " (" + marker.getFlag() + ")";
259
			resultString = (type == null ? "- no marker type -" : marker.getMarkerType().getLabel()) + " (" + marker.getFlag() + ")";
259 260
		}else if (element instanceof User) {
260 261
			User user = (User) element;
261
			return user.getUsername();
262
			resultString = user.getUsername();
262 263
		}else if (element instanceof Group) {
263 264
			Group group = (Group) element;
264
			return group.getName();
265
			resultString = group.getName();
265 266
		}else if (element instanceof KeyStatement) {
266 267
            KeyStatement keyStatement = (KeyStatement) element;
267
            return getCache(keyStatement);
268
            resultString = getCache(keyStatement);
268 269
        }else{
269 270
			// TODO write return texts for HomotypicalGroup, etc.
270
			return element.toString();
271
            resultString = element.toString();
272
		}
273

  
274
		if (resultString == null){
275
		    resultString = element.toString();
271 276
		}
277
		return resultString;
272 278
	}
273 279

  
274 280

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)