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