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.
10 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
;
12 import java
.util
.Arrays
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
17 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
18 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
19 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
21 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
22 import eu
.etaxonomy
.taxeditor
.bulkeditor
.IBulkEditorSortProvider
;
23 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
.ReferenceCreator
;
24 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
.IdentifiableEntitySortProvider
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.sortprovider
.ReferenceSortProvider
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * <p>ReferenceEditorInput class.</p>
36 public class ReferenceEditorInput
extends AbstractBulkEditorInput
<Reference
> {
41 private static final long serialVersionUID
= 3806243517765126749L;
43 /** Constant <code>ID="bulkeditor.input.reference"</code> */
44 public static final String ID
= "bulkeditor.input.reference";
46 private static ReferenceEditorInput instance
;
53 public static String
getID() {
58 * @see org.eclipse.ui.IEditorInput#getName()
63 * @return a {@link java.lang.String} object.
65 public String
getName() {
66 return BulkEditorInputType
.REFERENCE
.label
;
70 * @see org.eclipse.ui.IEditorInput#getToolTipText()
73 * <p>getToolTipText</p>
75 * @return a {@link java.lang.String} object.
77 public String
getToolTipText() {
82 * <p>Getter for the field <code>instance</code>.</p>
84 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
86 public static AbstractBulkEditorInput
getInstance() {
87 if (instance
== null) {
88 instance
= new ReferenceEditorInput();
94 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
98 public boolean isMergingEnabled() {
103 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMarkerTypeEditingEnabled(eu.etaxonomy.cdm.model.common.MarkerType)
107 public boolean isMarkerTypeEditingEnabled(MarkerType markerType
) {
108 if (MarkerType
.PUBLISH().equals(markerType
)) {
111 return super.isMarkerTypeEditingEnabled(markerType
);
117 public List
listEntities(IIdentifiableEntityServiceConfigurator configurator
) {
118 return CdmStore
.getSearchManager().findReferences(configurator
);
121 // Entity persistence
125 public Reference
loadEntity(UUID entityUuid
) {
126 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{"*", "inReference.*", "authorTeam.*"});
127 return CdmStore
.getService(IReferenceService
.class).load(entityUuid
, propertyPaths
);
131 * @throws ReferencedObjectUndeletableException */
132 public boolean delete(Reference entity
) throws ReferencedObjectUndeletableException
{
133 return CdmStore
.getService(IReferenceService
.class).delete(entity
) != null;
137 public boolean save(Reference entity
) {
138 return CdmStore
.getService(IReferenceService
.class).saveOrUpdate(entity
) != null;
142 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
145 protected IEntityCreator
<Reference
> createEntityCreator() {
146 return new ReferenceCreator();
150 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
153 public List
<IBulkEditorSortProvider
<Reference
>> getSortProviders() {
154 List
<IBulkEditorSortProvider
<Reference
>> sortProviders
= super.getSortProviders();
156 sortProviders
.add(0, new IdentifiableEntitySortProvider
<Reference
>());
157 sortProviders
.add(1, new ReferenceSortProvider());
159 return sortProviders
;
163 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
166 public String
getTypeText(Object entity
) {
167 if(entity
instanceof Reference
){
168 return ((Reference
) entity
).getType().getMessage(CdmStore
.getDefaultLanguage());
170 return super.getTypeText(entity
);