Revision 432276e4
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TreeNodeDropAdapterE4.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.navigation.navigator.e4; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
12 | 13 |
import java.util.EnumSet; |
13 | 14 |
import java.util.HashSet; |
14 | 15 |
import java.util.Iterator; |
16 |
import java.util.List; |
|
15 | 17 |
import java.util.Set; |
16 | 18 |
import java.util.UUID; |
17 | 19 |
|
... | ... | |
143 | 145 |
|
144 | 146 |
// do not allow to drop onto itself and |
145 | 147 |
// check users permissions with all selected taxon nodes and taxa |
148 |
List<UUID> nodeUuids = new ArrayList<>(); |
|
149 |
boolean isNotSameTaxonNode = true; |
|
150 |
boolean isNotSameParent = true; |
|
146 | 151 |
for(TaxonNodeDto taxonNode : getSelectedTaxa()){ |
147 | 152 |
if (logger.isDebugEnabled()){ |
148 | 153 |
logger.debug("selectedTaxa: " + taxonNode.getTaxonUuid() == null? "-" : taxonNode.getTitleCache()); //$NON-NLS-1$ |
... | ... | |
154 | 159 |
} |
155 | 160 |
return false; |
156 | 161 |
} |
157 |
boolean isSameTaxonNode = taxonNode.equals(target); |
|
158 |
boolean isSameParent = taxonNode.getParentUUID().equals(((TaxonNodeDto) target).getUuid()); |
|
159 |
TaxonNode node = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid()); |
|
160 |
boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(node, UPDATE); |
|
162 |
isNotSameTaxonNode = isNotSameTaxonNode && !taxonNode.equals(target); |
|
163 |
isNotSameParent = isNotSameParent && !taxonNode.getParentUUID().equals(((TaxonNodeDto) target).getUuid()); |
|
164 |
nodeUuids.add(taxonNode.getUuid()); |
|
161 | 165 |
|
162 |
boolean hasTaxonPermission = |
|
163 |
CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE);CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE); |
|
166 |
} |
|
167 |
List<TaxonNode> nodes = CdmStore.getService(ITaxonNodeService.class).load(nodeUuids, null); |
|
168 |
boolean hasPermission = true; |
|
169 |
for (TaxonNode node: nodes){ |
|
170 |
hasPermission = hasPermission && CdmStore.currentAuthentiationHasPermission(node, UPDATE) && CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE); |
|
171 |
} |
|
172 |
// boolean hasTaxonPermission = |
|
173 |
// CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE); |
|
164 | 174 |
if ( |
165 |
isSameTaxonNode
|
|
166 |
|| isSameParent
|
|
167 |
|| !hasTaxonNodePermission
|
|
168 |
|| !hasTaxonPermission |
|
175 |
!isNotSameTaxonNode
|
|
176 |
|| !isNotSameParent
|
|
177 |
|| !hasPermission |
|
178 |
|
|
169 | 179 |
) { |
170 | 180 |
if(logger.isDebugEnabled()){ |
171 |
logger.debug("CANCEL_STATUS for selected " + isSameTaxonNode + Messages.TreeNodeDropAdapter_10 + hasTaxonNodePermission + " " + hasTaxonPermission + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
181 |
logger.debug("CANCEL_STATUS for selected " + isNotSameTaxonNode + Messages.TreeNodeDropAdapter_10 + hasPermission + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
172 | 182 |
} |
173 | 183 |
return false; |
174 | 184 |
} |
175 | 185 |
} |
176 | 186 |
logger.debug("OK_STATUS"); //$NON-NLS-1$ |
177 | 187 |
return true; |
178 |
} |
|
179 |
logger.debug("CANCEL_STATUS"); //$NON-NLS-1$ |
|
180 |
return false; |
|
188 |
// }
|
|
189 |
// logger.debug("CANCEL_STATUS"); //$NON-NLS-1$
|
|
190 |
// return false;
|
|
181 | 191 |
} |
182 | 192 |
|
183 | 193 |
|
... | ... | |
191 | 201 |
} |
192 | 202 |
IUndoContext workspaceUndoContext = taxonNavigator.getUndoContext(); |
193 | 203 |
int movingTypeInt = 0; |
194 |
if (PreferencesUtil.getSortNodesNaturally()){
|
|
204 |
if (PreferencesUtil.isNodesSortedNaturally()){
|
|
195 | 205 |
String[] buttonLables = {TREE_NODE_DROP_ADAPTER_CHILD, TREE_NODE_DROP_ADAPTER_BEHIND,TREE_NODE_DROP_ADAPTER_CANCEL}; |
196 | 206 |
MessageDialog dialog = new MessageDialog(null, TARGET_NODE, null, DO_YOU_WANT_TO_MOVE_THE_TAXONNODE_AS_CHILD_OR_BEHIND_THE_TARGET_NODE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0); |
197 | 207 |
dialog.open(); |
... | ... | |
233 | 243 |
public void run() { |
234 | 244 |
AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ", |
235 | 245 |
uuid, |
236 |
500,
|
|
246 |
1000,
|
|
237 | 247 |
false, |
238 | 248 |
TreeNodeDropAdapterE4.this, |
239 | 249 |
null, |
Also available in: Unified diff
ref #7849: harmonize admin and local preferences for distribution editor and use drop down instead of radio buttons