Revision 0fde7fba
Added by Katja Luther almost 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveTaxonNodeHandlerE4.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
11 |
import java.util.HashSet; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.Set; |
|
13 | 14 |
import java.util.UUID; |
14 | 15 |
|
15 | 16 |
import javax.inject.Named; |
... | ... | |
26 | 27 |
import org.eclipse.jface.viewers.TreeSelection; |
27 | 28 |
import org.eclipse.swt.widgets.Shell; |
28 | 29 |
|
29 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
30 | 30 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
31 | 31 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
32 | 32 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
... | ... | |
36 | 36 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveTaxonOperation; |
37 | 37 |
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4; |
38 | 38 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
39 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
40 | 39 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
41 | 40 |
|
42 | 41 |
/** |
... | ... | |
46 | 45 |
*/ |
47 | 46 |
public class RemotingMoveTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 { |
48 | 47 |
|
49 |
private TaxonNodeDto oldTaxonNode;
|
|
48 |
private Set<UUID> oldTaxonNodeUUIDs = new HashSet<>();
|
|
50 | 49 |
|
51 | 50 |
public RemotingMoveTaxonNodeHandlerE4() { |
52 | 51 |
super(TaxonNavigatorLabels.MOVE_TAXON_LABEL); |
... | ... | |
58 | 57 |
MPart activePart, |
59 | 58 |
MHandledMenuItem menuItem) { |
60 | 59 |
// check that only a single taxon tree node has been selected |
61 |
if(selection.size() > 1) { |
|
62 |
return new Status(IStatus.ERROR, |
|
63 |
"unknown", //$NON-NLS-1$ |
|
64 |
TaxonNavigatorLabels.SINGLE_TAXON_SELECTION_MESSAGE); |
|
65 |
} |
|
60 |
// if(selection.size() > 1) {
|
|
61 |
// return new Status(IStatus.ERROR,
|
|
62 |
// "unknown", //$NON-NLS-1$
|
|
63 |
// TaxonNavigatorLabels.SINGLE_TAXON_SELECTION_MESSAGE);
|
|
64 |
// }
|
|
66 | 65 |
|
67 | 66 |
// check for no taxon tree node selected |
68 | 67 |
if(selection.size() == 0) { |
... | ... | |
71 | 70 |
TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE); |
72 | 71 |
} |
73 | 72 |
// check that selected object is a taxon node |
74 |
Object obj = selection.iterator().next(); |
|
75 |
if(obj instanceof TaxonNodeDto) { |
|
76 |
oldTaxonNode = (TaxonNodeDto)obj; |
|
77 |
} else { |
|
78 |
return new Status(IStatus.ERROR, |
|
79 |
"unknown", //$NON-NLS-1$ |
|
80 |
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE); |
|
73 |
Object obj ; |
|
74 |
Iterator iter = selection.iterator(); |
|
75 |
while (iter.hasNext()){ |
|
76 |
obj = iter.next(); |
|
77 |
if(obj instanceof TaxonNodeDto) { |
|
78 |
oldTaxonNodeUUIDs.add(((TaxonNodeDto)obj).getUuid()); |
|
79 |
} else { |
|
80 |
return new Status(IStatus.ERROR, |
|
81 |
"unknown", //$NON-NLS-1$ |
|
82 |
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE); |
|
83 |
} |
|
81 | 84 |
} |
82 | 85 |
return Status.OK_STATUS; |
83 | 86 |
} |
... | ... | |
88 | 91 |
MPart activePart, |
89 | 92 |
MHandledMenuItem menuItem) { |
90 | 93 |
TaxonNode parentTaxonNode; |
91 |
|
|
92 |
List<UUID> excludeTaxa = new ArrayList<UUID>(); |
|
93 |
excludeTaxa.add(oldTaxonNode.getTaxonUuid()); |
|
94 |
|
|
95 | 94 |
MovingType moveToNewParent = MovingType.CHILD; |
96 | 95 |
|
97 | 96 |
if (PreferencesUtil.getSortNodesNaturally()){ |
... | ... | |
100 | 99 |
parentTaxonNode = TaxonNodeSelectionDialog.select(shell, |
101 | 100 |
// new ConversationHolderMock(), |
102 | 101 |
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_TAXON, |
103 |
excludeTaxa,
|
|
102 |
oldTaxonNodeUUIDs,
|
|
104 | 103 |
null, |
105 |
oldTaxonNode.getClassificationUUID(), true);
|
|
104 |
null, true);
|
|
106 | 105 |
String[] buttonLables = {Messages.RemotingMoveTaxonNodeHandler_CHILD, Messages.RemotingMoveTaxonNodeHandler_BEHIND,Messages.RemotingMoveTaxonNodeHandler_CANCEL}; |
107 | 106 |
MessageDialog dialog = new MessageDialog(null, Messages.RemotingMoveTaxonNodeHandler_TARGET_NODE, null, Messages.RemotingMoveTaxonNodeHandler_TARGET_NODE_MESSAGE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0); |
108 | 107 |
dialog.open(); |
... | ... | |
116 | 115 |
parentTaxonNode = TaxonNodeSelectionDialog.select(shell, |
117 | 116 |
// new ConversationHolderMock(), |
118 | 117 |
Messages.RemotingMoveTaxonNodeHandler_CHOOSE_PARENT, |
119 |
excludeTaxa,
|
|
120 |
CdmStore.getService(ITaxonNodeService.class).find(oldTaxonNode.getUuid()),
|
|
121 |
oldTaxonNode.getClassificationUUID(), true);
|
|
118 |
oldTaxonNodeUUIDs,
|
|
119 |
null,
|
|
120 |
null, true);
|
|
122 | 121 |
} |
123 | 122 |
|
124 | 123 |
|
... | ... | |
132 | 131 |
|
133 | 132 |
return new RemotingMoveTaxonOperation(getTrigger(), |
134 | 133 |
false, |
135 |
oldTaxonNode.getUuid(),
|
|
134 |
oldTaxonNodeUUIDs,
|
|
136 | 135 |
parentTaxonNode.getUuid(), |
137 | 136 |
moveToNewParent); |
138 | 137 |
} |
Also available in: Unified diff
allow multiple selection for moving taxonnodes