Project

General

Profile

« Previous | Next » 

Revision 3699c749

Added by Katja Luther about 6 years ago

ref #7227: check for empty selection for menu creation

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/ConvertTeam2PersonHandlerE4.java
17 17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18 18
import org.eclipse.e4.ui.services.IServiceConstants;
19 19
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.viewers.StructuredSelection;
20 21

  
21 22
import eu.etaxonomy.cdm.api.service.IAgentService;
22 23
import eu.etaxonomy.cdm.api.service.UpdateResult;
......
73 74
    }
74 75

  
75 76
    @CanExecute
76
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
77
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
77
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
78 78
            MHandledMenuItem menuItem){
79 79
        boolean canExecute = false;
80
        canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection instanceof Team;
80
        StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection();
81
        canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection.getFirstElement() instanceof Team && selection.size() == 1;
81 82
        menuItem.setVisible(canExecute);
82 83
        return canExecute;
83 84
    }

Also available in: Unified diff