Revision cedc4ff1
Added by Katja Luther about 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveFactualDataHandlerE4.java | ||
---|---|---|
26 | 26 |
import org.eclipse.swt.widgets.Display; |
27 | 27 |
import org.eclipse.swt.widgets.Shell; |
28 | 28 |
|
29 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
|
29 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
|
30 | 30 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
31 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
31 | 32 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
32 | 33 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
33 | 34 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels; |
34 | 35 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveFactualDataOperation; |
35 | 36 |
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4; |
37 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
36 | 38 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
37 | 39 |
|
38 | 40 |
/** |
... | ... | |
42 | 44 |
*/ |
43 | 45 |
public class RemotingMoveFactualDataHandlerE4 extends RemotingCdmHandlerE4 { |
44 | 46 |
|
45 |
private TaxonNode sourceTaxonNode; |
|
47 |
private TaxonNodeDto sourceTaxonNode;
|
|
46 | 48 |
private TaxonNode targetTaxonNode; |
47 | 49 |
|
48 | 50 |
public RemotingMoveFactualDataHandlerE4() { |
... | ... | |
70 | 72 |
|
71 | 73 |
// check that selected object is a taxon node |
72 | 74 |
Object obj = selection.iterator().next(); |
73 |
if(obj instanceof ITaxonTreeNode) {
|
|
74 |
sourceTaxonNode = (TaxonNode)obj; |
|
75 |
if(obj instanceof TaxonNodeDto) {
|
|
76 |
sourceTaxonNode = (TaxonNodeDto)obj;
|
|
75 | 77 |
} else { |
76 | 78 |
return new Status(IStatus.ERROR, |
77 | 79 |
"unknown", //$NON-NLS-1$ |
... | ... | |
85 | 87 |
} |
86 | 88 |
|
87 | 89 |
List<UUID> excludeTaxa = new ArrayList<UUID>(); |
88 |
excludeTaxa.add(sourceTaxonNode.getTaxon().getUuid());
|
|
90 |
excludeTaxa.add(sourceTaxonNode.getTaxonUuid()); |
|
89 | 91 |
|
90 | 92 |
targetTaxonNode = TaxonNodeSelectionDialog.select(shell, |
91 | 93 |
// new ConversationHolderMock(), |
92 | 94 |
Messages.RemotingMoveFactualDataHandler_CHOOSE_TAXA, |
93 | 95 |
excludeTaxa, |
94 |
sourceTaxonNode,
|
|
95 |
sourceTaxonNode.getClassification()); |
|
96 |
CdmStore.getService(ITaxonNodeService.class).find(sourceTaxonNode.getUuid()),
|
|
97 |
sourceTaxonNode.getClassificationUUID());
|
|
96 | 98 |
|
97 | 99 |
if(targetTaxonNode == null) { |
98 | 100 |
return new Status(IStatus.CANCEL, |
... | ... | |
114 | 116 |
MHandledMenuItem menuItem) { |
115 | 117 |
return new RemotingMoveFactualDataOperation(getTrigger(), |
116 | 118 |
false, |
117 |
sourceTaxonNode.getTaxon().getUuid(),
|
|
119 |
sourceTaxonNode.getTaxonUuid(), |
|
118 | 120 |
targetTaxonNode.getTaxon().getUuid()); |
119 | 121 |
} |
120 | 122 |
|
121 | 123 |
@CanExecute |
122 | 124 |
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){ |
123 | 125 |
boolean canExecute = false; |
124 |
canExecute = selection.getFirstElement() instanceof TaxonNode |
|
125 |
&& ((TaxonNode) selection.getFirstElement()).getTaxon()!=null; |
|
126 |
canExecute = selection.getFirstElement() instanceof TaxonNodeDto; |
|
126 | 127 |
menuItem.setVisible(canExecute); |
127 | 128 |
return canExecute; |
128 | 129 |
} |
Also available in: Unified diff
ref #2380: implement usage of Dto for taxon navigator