Project

General

Profile

« Previous | Next » 

Revision fa07dfed

Added by Patrick Plitzner almost 5 years ago

ref #7056 Generate titleCache for newly created image galleries

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaLabelProvider.java
1

  
2
package eu.etaxonomy.taxeditor.editor.view.media;
3

  
4
import org.eclipse.jface.viewers.ColumnLabelProvider;
5

  
6
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
7

  
8
/**
9
 * <p>MediaLabelProvider class.</p>
10
 *
11
 * @author n.hoffmann
12
 * @version $Id: $
13
 */
14
public class MediaLabelProvider extends ColumnLabelProvider {
15

  
16
	/** {@inheritDoc} */
17
	@Override
18
    public String getText(Object element) {
19
		if(element instanceof IdentifiableEntity){
20
			return ((IdentifiableEntity) element).getTitleCache();
21
		}
22

  
23
		return element.toString();
24
	}
25

  
26

  
27

  
28
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewLabelProvider.java
36 36
 */
37 37
public class MediaViewLabelProvider extends LabelProvider implements IStyledLabelProvider {
38 38

  
39
    /**
40
     * {@inheritDoc}
41
     */
42
    @Override
43
    public String getText(Object element) {
44
        return getStyledText(element).getString();
45
    }
46

  
39 47
    @Override
40 48
    public StyledString getStyledText(Object element) {
41 49
        if (element instanceof IdentifiableEntity) {
42 50
            IdentifiableEntity identifiableEntity= (IdentifiableEntity) element;
43
            StyledString styledString = new StyledString(identifiableEntity.getTitleCache());
44

  
45
            return styledString;
51
            if(identifiableEntity.getId()==0){
52
                return new StyledString(identifiableEntity.generateTitle());
53
            }
54
            else{
55
                return new StyledString(identifiableEntity.getTitleCache());
56
            }
46 57
        }
47 58
        return null;
48 59
    }

Also available in: Unified diff