1
|
// $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
|
package eu.etaxonomy.taxeditor.bulkeditor.input;
|
11
|
|
12
|
import java.util.Arrays;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.IReferenceService;
|
17
|
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
|
18
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
19
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
20
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
21
|
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
|
22
|
import eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorInputTypeValues.BulkEditorInputType;
|
23
|
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.ReferenceCreator;
|
24
|
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider;
|
25
|
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
|
26
|
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.ReferenceSortProvider;
|
27
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
28
|
|
29
|
|
30
|
/**
|
31
|
* <p>ReferenceEditorInput class.</p>
|
32
|
*
|
33
|
* @author p.ciardelli
|
34
|
* @created 25.06.2009
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class ReferenceEditorInput extends AbstractBulkEditorInput<Reference> {
|
38
|
|
39
|
/**
|
40
|
*
|
41
|
*/
|
42
|
private static final long serialVersionUID = 3806243517765126749L;
|
43
|
|
44
|
/** Constant <code>ID="bulkeditor.input.reference"</code> */
|
45
|
public static final String ID = "bulkeditor.input.reference";
|
46
|
|
47
|
private static ReferenceEditorInput instance;
|
48
|
|
49
|
/**
|
50
|
* <p>getID</p>
|
51
|
*
|
52
|
* @return the iD
|
53
|
*/
|
54
|
public static String getID() {
|
55
|
return ID;
|
56
|
}
|
57
|
|
58
|
/* (non-Javadoc)
|
59
|
* @see org.eclipse.ui.IEditorInput#getName()
|
60
|
*/
|
61
|
/**
|
62
|
* <p>getName</p>
|
63
|
*
|
64
|
* @return a {@link java.lang.String} object.
|
65
|
*/
|
66
|
public String getName() {
|
67
|
return BulkEditorInputType.REFERENCE.label;
|
68
|
}
|
69
|
|
70
|
/* (non-Javadoc)
|
71
|
* @see org.eclipse.ui.IEditorInput#getToolTipText()
|
72
|
*/
|
73
|
/**
|
74
|
* <p>getToolTipText</p>
|
75
|
*
|
76
|
* @return a {@link java.lang.String} object.
|
77
|
*/
|
78
|
public String getToolTipText() {
|
79
|
return getName();
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* <p>Getter for the field <code>instance</code>.</p>
|
84
|
*
|
85
|
* @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
|
86
|
*/
|
87
|
public static AbstractBulkEditorInput getInstance() {
|
88
|
if (instance == null) {
|
89
|
instance = new ReferenceEditorInput();
|
90
|
}
|
91
|
return instance;
|
92
|
}
|
93
|
|
94
|
/* (non-Javadoc)
|
95
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled()
|
96
|
*/
|
97
|
/** {@inheritDoc} */
|
98
|
@Override
|
99
|
public boolean isMergingEnabled() {
|
100
|
return true;
|
101
|
}
|
102
|
|
103
|
/* (non-Javadoc)
|
104
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMarkerTypeEditingEnabled(eu.etaxonomy.cdm.model.common.MarkerType)
|
105
|
*/
|
106
|
/** {@inheritDoc} */
|
107
|
@Override
|
108
|
public boolean isMarkerTypeEditingEnabled(MarkerType markerType) {
|
109
|
if (MarkerType.PUBLISH().equals(markerType)) {
|
110
|
return true;
|
111
|
}
|
112
|
return super.isMarkerTypeEditingEnabled(markerType);
|
113
|
}
|
114
|
|
115
|
|
116
|
/** {@inheritDoc} */
|
117
|
@Override
|
118
|
public List listEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
119
|
return CdmStore.getSearchManager().findReferences(configurator);
|
120
|
}
|
121
|
|
122
|
// Entity persistence
|
123
|
|
124
|
/** {@inheritDoc} */
|
125
|
@Override
|
126
|
public Reference loadEntity(UUID entityUuid) {
|
127
|
List<String> propertyPaths = Arrays.asList(new String[]{"*", "inReference.*", "authorTeam.*"});
|
128
|
return CdmStore.getService(IReferenceService.class).load(entityUuid, propertyPaths);
|
129
|
}
|
130
|
|
131
|
/** {@inheritDoc} */
|
132
|
public boolean delete(Reference entity) {
|
133
|
return CdmStore.getService(IReferenceService.class).delete(entity) != null;
|
134
|
}
|
135
|
|
136
|
/** {@inheritDoc} */
|
137
|
public boolean save(Reference entity) {
|
138
|
return CdmStore.getService(IReferenceService.class).saveOrUpdate(entity) != null;
|
139
|
}
|
140
|
|
141
|
/* (non-Javadoc)
|
142
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
|
143
|
*/
|
144
|
@Override
|
145
|
protected IEntityCreator<Reference> createEntityCreator() {
|
146
|
return new ReferenceCreator();
|
147
|
}
|
148
|
|
149
|
/* (non-Javadoc)
|
150
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders()
|
151
|
*/
|
152
|
@Override
|
153
|
public List<IBulkEditorSortProvider<Reference>> getSortProviders() {
|
154
|
List<IBulkEditorSortProvider<Reference>> sortProviders = super.getSortProviders();
|
155
|
|
156
|
sortProviders.add(0, new IdentifiableEntitySortProvider<Reference>());
|
157
|
sortProviders.add(1, new ReferenceSortProvider());
|
158
|
|
159
|
return sortProviders;
|
160
|
}
|
161
|
|
162
|
/* (non-Javadoc)
|
163
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getTypeText(java.lang.Object)
|
164
|
*/
|
165
|
@Override
|
166
|
public String getTypeText(Object entity) {
|
167
|
if(entity instanceof Reference){
|
168
|
return ((Reference) entity).getType().getMessage(CdmStore.getDefaultLanguage());
|
169
|
}
|
170
|
return super.getTypeText(entity);
|
171
|
}
|
172
|
|
173
|
}
|