1
|
/**
|
2
|
* Copyright (C) 2018 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.Iterator;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.eclipse.core.runtime.IStatus;
|
17
|
import org.eclipse.core.runtime.Status;
|
18
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
19
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
20
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
21
|
import org.eclipse.swt.widgets.Shell;
|
22
|
|
23
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
24
|
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
25
|
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
|
26
|
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
|
27
|
|
28
|
/**
|
29
|
* @author k.luther
|
30
|
* @since 11.10.2018
|
31
|
*
|
32
|
*/
|
33
|
public abstract class UnplacedExcludedHandler extends RemotingCdmHandlerE4{
|
34
|
protected List<UUID> taxonNodes ;
|
35
|
|
36
|
public UnplacedExcludedHandler() {
|
37
|
super(TaxonNavigatorLabels.SET_UNPLACED);
|
38
|
}
|
39
|
|
40
|
@Override
|
41
|
public IStatus allowOperations(IStructuredSelection selection,
|
42
|
Shell shell,
|
43
|
MPart activePart,
|
44
|
MHandledMenuItem menuItem) {
|
45
|
|
46
|
|
47
|
// check for no taxon tree node selected
|
48
|
if(selection.size() == 0) {
|
49
|
return new Status(IStatus.ERROR,
|
50
|
"unknown", //$NON-NLS-1$
|
51
|
TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
|
52
|
}
|
53
|
taxonNodes = new ArrayList<>();
|
54
|
// check that selected object is a taxon node
|
55
|
Iterator<TaxonNodeDto> iterator = selection.iterator();
|
56
|
while(iterator.hasNext()){
|
57
|
Object obj = iterator.next();
|
58
|
if(obj instanceof TaxonNodeDto) {
|
59
|
if(obj instanceof Classification){
|
60
|
taxonNodes.add(((Classification)obj).getRootNode().getUuid());
|
61
|
}else{
|
62
|
taxonNodes.add(((TaxonNodeDto)obj).getUuid());
|
63
|
}
|
64
|
} else{
|
65
|
return new Status(IStatus.ERROR,
|
66
|
"unknown", //$NON-NLS-1$
|
67
|
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
|
68
|
}
|
69
|
}
|
70
|
|
71
|
return Status.OK_STATUS;
|
72
|
}
|
73
|
|
74
|
|
75
|
|
76
|
@Override
|
77
|
public void onComplete() {
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
* {@inheritDoc}
|
82
|
*/
|
83
|
@Override
|
84
|
protected Object getTrigger() {
|
85
|
return this;
|
86
|
}
|
87
|
}
|