3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
19 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
21 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 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * <p>NameEditorInput class.</p>
34 public class NameEditorInput
extends AbstractBulkEditorInput
<TaxonNameBase
> {
39 private static final long serialVersionUID
= -3085029575759626823L;
40 private static NameEditorInput instance
;
42 /** Constant <code>ID="bulkeditor.input.name"</code> */
43 public static final String ID
= "bulkeditor.input.name";
46 * <p>Getter for the field <code>instance</code>.</p>
48 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
50 public static AbstractBulkEditorInput
getInstance() {
51 if (instance
== null) {
52 instance
= new NameEditorInput();
58 * @see org.eclipse.ui.IEditorInput#getName()
63 * @return a {@link java.lang.String} object.
65 public String
getName() {
66 return BulkEditorInputType
.NAME
.label
;
70 * @see org.eclipse.ui.IEditorInput#getToolTipText()
73 * <p>getToolTipText</p>
75 * @return a {@link java.lang.String} object.
77 public String
getToolTipText() {
84 * @return a {@link java.lang.Object} object.
86 public static Object
getID() {
91 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
95 public boolean isMergingEnabled() {
101 public List
listEntities(IIdentifiableEntityServiceConfigurator configurator
) {
102 return CdmStore
.getSearchManager().findNames(configurator
);
107 public TaxonNameBase
loadEntity(UUID uuid
) {
108 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{});
109 return CdmStore
.getService(INameService
.class).load(uuid
, propertyPaths
);
113 * @throws ReferencedObjectUndeletableException */
114 public boolean delete(TaxonNameBase entity
) throws ReferencedObjectUndeletableException
{
115 return CdmStore
.getService(INameService
.class).delete(entity
) != null;
119 public boolean save(TaxonNameBase entity
) {
120 return CdmStore
.getService(INameService
.class).saveOrUpdate(entity
) != null;
124 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
127 protected IEntityCreator
<TaxonNameBase
> createEntityCreator() {
128 return new NameCreator();
132 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
135 public List
<IBulkEditorSortProvider
<TaxonNameBase
>> getSortProviders() {
136 List
<IBulkEditorSortProvider
<TaxonNameBase
>> sortProviders
= super.getSortProviders();
138 sortProviders
.add(0, new IdentifiableEntitySortProvider
<TaxonNameBase
>());
140 return sortProviders
;
144 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
147 public String
getTypeText(Object entity
) {
148 if((entity
instanceof TaxonNameBase
) && (((TaxonNameBase
) entity
).getNomenclaturalCode() != null)){
149 return ((TaxonNameBase
) entity
).getNomenclaturalCode().getTitleCache();
151 return super.getTypeText(entity
);
155 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
158 public String
getText(TaxonNameBase entity
) {
159 return (entity
).getFullTitleCache();