Revision 3699c749
Added by Katja Luther about 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeTargetHandlerE4.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; |
... | ... | |
41 | 42 |
} |
42 | 43 |
|
43 | 44 |
@CanExecute |
44 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
45 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
45 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
46 | 46 |
MHandledMenuItem menuItem) { |
47 | 47 |
boolean canExecute = false; |
48 | 48 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
49 |
canExecute = selection!=null |
|
49 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
50 |
canExecute = !selection.isEmpty() |
|
50 | 51 |
&& editor.getEditorInput().isMergingEnabled() |
51 | 52 |
&& (editor.getEditorInput().getMergeTarget()==null |
52 | 53 |
|| !editor.getEditorInput().getMergeTarget().equals(selection)); |
Also available in: Unified diff
ref #7227: check for empty selection for menu creation