Project

General

Profile

Download (4.39 KB) Statistics
| Branch: | Tag: | Revision:
1 3be6ef3e n.hoffmann
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
11
package eu.etaxonomy.taxeditor.bulkeditor.input;
12
13
import java.util.Arrays;
14
import java.util.List;
15
import java.util.UUID;
16
17 db5e366d n.hoffmann
import eu.etaxonomy.cdm.api.service.INameService;
18 3be6ef3e n.hoffmann
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
19 97e10b7c Katja Luther
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
20 3be6ef3e n.hoffmann
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
21 db5e366d n.hoffmann
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
22
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
23
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.NameCreator;
24
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
25 3be6ef3e n.hoffmann
import eu.etaxonomy.taxeditor.store.CdmStore;
26
27
/**
28
 * <p>NameEditorInput class.</p>
29
 *
30
 * @author p.ciardelli
31
 * @created 20.08.2009
32
 * @version 1.0
33
 */
34
public class NameEditorInput extends AbstractBulkEditorInput<TaxonNameBase> {
35 143e2f91 n.hoffmann
36 3be6ef3e n.hoffmann
	/**
37 db5e366d n.hoffmann
	 * 
38 3be6ef3e n.hoffmann
	 */
39 db5e366d n.hoffmann
	private static final long serialVersionUID = -3085029575759626823L;
40
	private static NameEditorInput instance;
41 3be6ef3e n.hoffmann
42
	/** Constant <code>ID="bulkeditor.input.name"</code> */
43
	public static final String ID = "bulkeditor.input.name";
44
	
45
	/**
46
	 * <p>Getter for the field <code>instance</code>.</p>
47
	 *
48
	 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
49
	 */
50
	public static AbstractBulkEditorInput getInstance() {
51
		if (instance == null) {
52
			instance = new NameEditorInput();
53
		}
54
		return instance;
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.ui.IEditorInput#getName()
59
	 */
60
	/**
61
	 * <p>getName</p>
62
	 *
63
	 * @return a {@link java.lang.String} object.
64
	 */
65
	public String getName() {
66
		return BulkEditorInputType.NAME.label;
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
71
	 */
72
	/**
73
	 * <p>getToolTipText</p>
74
	 *
75
	 * @return a {@link java.lang.String} object.
76
	 */
77
	public String getToolTipText() {
78
		return getName();
79
	}
80
81
	/**
82
	 * <p>getID</p>
83
	 *
84
	 * @return a {@link java.lang.Object} object.
85
	 */
86
	public static Object getID() {
87
		return ID;
88
	}
89
90
	/* (non-Javadoc)
91
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
92
	 */
93
	/** {@inheritDoc} */
94
	@Override
95
	public boolean isMergingEnabled() {
96
		return false;
97
	}
98
99
	/** {@inheritDoc} */
100
	@Override
101
	public List listEntities(IIdentifiableEntityServiceConfigurator configurator) {
102 143e2f91 n.hoffmann
		return CdmStore.getSearchManager().findNames(configurator);
103 3be6ef3e n.hoffmann
	}
104
105 bafb4761 Katja Luther
	/** {@inheritDoc} 
106 3be6ef3e n.hoffmann
	@Override
107
	public TaxonNameBase loadEntity(UUID uuid) {
108
		List<String> propertyPaths = Arrays.asList(new String[]{}); 
109 db5e366d n.hoffmann
		return CdmStore.getService(INameService.class).load(uuid, propertyPaths);
110 3be6ef3e n.hoffmann
	}
111 bafb4761 Katja Luther
*/
112 97e10b7c Katja Luther
	/** {@inheritDoc} 
113 3f8e87ed Katja Luther
	 **/
114
	public boolean delete(TaxonNameBase entity)  {
115 db5e366d n.hoffmann
		return CdmStore.getService(INameService.class).delete(entity) != null;
116 3be6ef3e n.hoffmann
	}
117
118
	/** {@inheritDoc} */
119 db5e366d n.hoffmann
	public boolean save(TaxonNameBase entity) {
120
		return CdmStore.getService(INameService.class).saveOrUpdate(entity) != null;
121
	}
122
123
	/* (non-Javadoc)
124
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
125
	 */
126
	@Override
127
	protected IEntityCreator<TaxonNameBase> createEntityCreator() {
128
		return new NameCreator();
129
	}
130
131
	/* (non-Javadoc)
132
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
133
	 */
134
	@Override
135
	public List<IBulkEditorSortProvider<TaxonNameBase>> getSortProviders() {
136
		List<IBulkEditorSortProvider<TaxonNameBase>> sortProviders = super.getSortProviders();
137
		
138 79630d2f n.hoffmann
		sortProviders.add(0, new IdentifiableEntitySortProvider<TaxonNameBase>());
139 db5e366d n.hoffmann
		
140
		return sortProviders;
141
	}
142
	
143
	/* (non-Javadoc)
144
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
145
	 */
146
	@Override
147
	public String getTypeText(Object entity) {
148 3c4607b1 Cherian Mathew
		if((entity instanceof TaxonNameBase) && (((TaxonNameBase) entity).getNomenclaturalCode() != null)){
149 db5e366d n.hoffmann
			return ((TaxonNameBase) entity).getNomenclaturalCode().getTitleCache();
150
		}
151
		return super.getTypeText(entity);
152 3be6ef3e n.hoffmann
	}
153 a60842d7 n.hoffmann
	
154
	/* (non-Javadoc)
155
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
156
	 */
157
	@Override
158
	public String getText(TaxonNameBase entity) {
159 eea5c6dc n.hoffmann
		return (entity).getFullTitleCache();
160 a60842d7 n.hoffmann
	}
161 3be6ef3e n.hoffmann
162 eea5c6dc n.hoffmann
163 3be6ef3e n.hoffmann
}