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
.model
.name
.TaxonNameBase
;
20 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
21 import eu
.etaxonomy
.taxeditor
.bulkeditor
.IBulkEditorSortProvider
;
22 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
.NameCreator
;
23 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
.IdentifiableEntitySortProvider
;
24 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 * <p>NameEditorInput class.</p>
33 public class NameEditorInput
extends AbstractBulkEditorInput
<TaxonNameBase
> {
38 private static final long serialVersionUID
= -3085029575759626823L;
39 private static NameEditorInput instance
;
41 /** Constant <code>ID="bulkeditor.input.name"</code> */
42 public static final String ID
= "bulkeditor.input.name";
45 * <p>Getter for the field <code>instance</code>.</p>
47 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
49 public static AbstractBulkEditorInput
getInstance() {
50 if (instance
== null) {
51 instance
= new NameEditorInput();
57 * @see org.eclipse.ui.IEditorInput#getName()
62 * @return a {@link java.lang.String} object.
64 public String
getName() {
65 return BulkEditorInputType
.NAME
.label
;
69 * @see org.eclipse.ui.IEditorInput#getToolTipText()
72 * <p>getToolTipText</p>
74 * @return a {@link java.lang.String} object.
76 public String
getToolTipText() {
83 * @return a {@link java.lang.Object} object.
85 public static Object
getID() {
90 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
94 public boolean isMergingEnabled() {
100 public List
listEntities(IIdentifiableEntityServiceConfigurator configurator
) {
101 return CdmStore
.getSearchManager().findNames(configurator
);
106 public TaxonNameBase
loadEntity(UUID uuid
) {
107 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{});
108 return CdmStore
.getService(INameService
.class).load(uuid
, propertyPaths
);
112 public boolean delete(TaxonNameBase entity
) {
113 return CdmStore
.getService(INameService
.class).delete(entity
) != null;
117 public boolean save(TaxonNameBase entity
) {
118 return CdmStore
.getService(INameService
.class).saveOrUpdate(entity
) != null;
122 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
125 protected IEntityCreator
<TaxonNameBase
> createEntityCreator() {
126 return new NameCreator();
130 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
133 public List
<IBulkEditorSortProvider
<TaxonNameBase
>> getSortProviders() {
134 List
<IBulkEditorSortProvider
<TaxonNameBase
>> sortProviders
= super.getSortProviders();
136 sortProviders
.add(0, new IdentifiableEntitySortProvider
<TaxonNameBase
>());
138 return sortProviders
;
142 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
145 public String
getTypeText(Object entity
) {
146 if((entity
instanceof TaxonNameBase
) && (((TaxonNameBase
) entity
).getNomenclaturalCode() != null)){
147 return ((TaxonNameBase
) entity
).getNomenclaturalCode().getTitleCache();
149 return super.getTypeText(entity
);
153 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
156 public String
getText(TaxonNameBase entity
) {
157 return (entity
).getFullTitleCache();