Revision 3699c749
Added by Katja Luther about 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/RemoveMergeCandidateHandlerE4.java | ||
---|---|---|
15 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
17 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
18 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
18 | 19 |
|
19 | 20 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 | 21 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
... | ... | |
43 | 44 |
editor.getEditorInput().removeMergeCandidate((CdmBase)selection); |
44 | 45 |
editor.refresh(); |
45 | 46 |
} |
46 |
|
|
47 |
|
|
47 |
|
|
48 |
|
|
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
@CanExecute |
51 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection, |
|
52 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
52 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
53 | 53 |
MHandledMenuItem menuItem) { |
54 | 54 |
boolean canExecute = false; |
55 | 55 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
56 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
56 | 57 |
boolean selectedMergeCandidate = false; |
57 |
if (selection instanceof Object[]){
|
|
58 |
for(Object object: (Object[])selection){
|
|
58 |
if (selection instanceof StructuredSelection){
|
|
59 |
for(Object object: selection.toArray()){
|
|
59 | 60 |
if (object instanceof CdmBase){ |
60 |
editor.getEditorInput().getMergeCandidates().contains((CdmBase)object);
|
|
61 |
editor.getEditorInput().getMergeCandidates().contains(object); |
|
61 | 62 |
selectedMergeCandidate = true; |
62 | 63 |
} |
63 | 64 |
} |
64 | 65 |
} |
65 |
|
|
66 |
|
|
66 | 67 |
canExecute = editor.getEditorInput().isMergingEnabled() && selectedMergeCandidate; |
67 | 68 |
// && editor.getEditorInput().getMergeCandidates().contains(selection); |
68 | 69 |
menuItem.setVisible(canExecute); |
Also available in: Unified diff
ref #7227: check for empty selection for menu creation