Project

General

Profile

Download (1.33 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.model;
2

    
3
import org.eclipse.jface.resource.ImageDescriptor;
4
import org.eclipse.ui.IEditorInput;
5
import org.eclipse.ui.IPersistableElement;
6

    
7
import eu.etaxonomy.cdm.model.taxon.Taxon;
8

    
9
/**
10
 * @author p.ciardelli
11
 *
12
 */
13
public class NameEditorInput implements IEditorInput {
14

    
15
	private Taxon taxon;
16
	
17
	public NameEditorInput (Taxon taxon) {
18
		this.taxon = taxon;
19
	}
20
	
21
	public boolean exists() {
22
		// TODO Auto-generated method stub
23
		return false;
24
	}
25

    
26
	public ImageDescriptor getImageDescriptor() {
27
		// TODO Auto-generated method stub
28
		return null;
29
	}
30

    
31
	public String getName() {
32
		if (taxon.getName().getNameCache() == null)
33
			return "New taxon";
34
		else
35
			return taxon.getName().getNameCache();
36
	}
37

    
38
	public IPersistableElement getPersistable() {
39
		// TODO Auto-generated method stub
40
		return null;
41
	}
42

    
43
	public String getToolTipText() {
44
		return getName();
45
	}
46

    
47
	public Object getAdapter(Class adapter) {
48

    
49
		if (adapter == Taxon.class) {
50
			return this.taxon;
51
		}
52
		
53
		return null;
54
	}
55

    
56
    /**
57
     * Overrides equals to ensure that a taxon can only be edited by
58
     *  one editor at a time.
59
     * 
60
     * @return boolean
61
     */
62
	public boolean equals(Object obj) {		
63
		if (this.taxon.equals(((NameEditorInput) obj).taxon))
64
			return true;
65
		return false;
66
	}
67
}
(1-1/3)