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.
66 public String
getName() {
67 return BulkEditorInputType
.REFERENCE
.label
;
71 * @see org.eclipse.ui.IEditorInput#getToolTipText()
74 * <p>getToolTipText</p>
76 * @return a {@link java.lang.String} object.
79 public String
getToolTipText() {
84 * <p>Getter for the field <code>instance</code>.</p>
86 * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
88 public static AbstractBulkEditorInput
getInstance() {
89 if (instance
== null) {
90 instance
= new ReferenceEditorInput();
96 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
100 public boolean isMergingEnabled() {
105 * @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMarkerTypeEditingEnabled(eu.etaxonomy.cdm.model.common.MarkerType)
109 public boolean isMarkerTypeEditingEnabled(MarkerType markerType
) {
110 if (MarkerType
.PUBLISH().equals(markerType
)) {
113 return super.isMarkerTypeEditingEnabled(markerType
);
119 public List
listEntities(IIdentifiableEntityServiceConfigurator configurator
) {
120 return CdmStore
.getSearchManager().findReferences(configurator
);
123 // Entity persistence
127 public Reference
loadEntity(UUID entityUuid
) {
128 List
<String
> propertyPaths
= Arrays
.asList(new String
[]{"*", "inReference.*", "authorTeam.*"});
129 return CdmStore
.getService(IReferenceService
.class).load(entityUuid
, propertyPaths
);
133 * @throws ReferencedObjectUndeletableException */
135 public boolean delete(Reference entity
) throws ReferencedObjectUndeletableException
{
136 return CdmStore
.getService(IReferenceService
.class).delete(entity
) != null;
141 public Reference
save(Reference entity
) {
142 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
143 return CdmStore
.getService(IReferenceService
.class).merge(entity
, true);
145 CdmStore
.getService(IReferenceService
.class).saveOrUpdate(entity
);
151 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
154 protected IEntityCreator
<Reference
> createEntityCreator() {
155 return new ReferenceCreator();
159 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
162 public List
<IBulkEditorSortProvider
<Reference
>> getSortProviders() {
163 List
<IBulkEditorSortProvider
<Reference
>> sortProviders
= super.getSortProviders();
165 sortProviders
.add(0, new IdentifiableEntitySortProvider
<Reference
>());
166 sortProviders
.add(1, new ReferenceSortProvider());
168 return sortProviders
;
172 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
175 public String
getTypeText(Object entity
) {
176 if(entity
instanceof Reference
){
177 return ((Reference
) entity
).getType().getMessage(CdmStore
.getDefaultLanguage());
179 return super.getTypeText(entity
);
183 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
186 public void merge() {