2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.handler
;
12 import javax
.inject
.Named
;
14 import org
.eclipse
.e4
.core
.di
.annotations
.CanExecute
;
15 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
16 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
17 import org
.eclipse
.e4
.ui
.model
.application
.ui
.menu
.MHandledMenuItem
;
18 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.swt
.widgets
.Shell
;
22 import eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.TaxonNameEditorE4
;
23 import eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.container
.AbstractGroupedContainerE4
;
31 public class DeleteAllEmptyNamesHandlerE4
extends DeleteTaxonBaseHandlerE4
{
35 public void execute(@Named(IServiceConstants
.ACTIVE_PART
)MPart activePart
,
36 @Named(IServiceConstants
.ACTIVE_SELECTION
)IStructuredSelection selectedElement
,
37 @Named(IServiceConstants
.ACTIVE_SHELL
)Shell shell
,
38 MHandledMenuItem menuItem
) {
40 editor
= (TaxonNameEditorE4
) activePart
.getObject();
42 for(AbstractGroupedContainerE4 containerWithEmptyName
: editor
.getEmptyContainers()){
43 editor
.removeGroup(containerWithEmptyName
.getGroup());
44 doExecute(menuItem
.getLocalizedLabel(), shell
, editor
, containerWithEmptyName
.getData());
51 public boolean canExecute(
52 @Named(IServiceConstants
.ACTIVE_PART
)MPart activePart
,
53 @Named(IServiceConstants
.ACTIVE_SELECTION
)IStructuredSelection selection
,
54 MHandledMenuItem menuItem
){
56 editor
= (TaxonNameEditorE4
) activePart
.getObject();
58 boolean canExecute
= false;
59 Object selectedElement
= selection
.getFirstElement();
60 canExecute
= editor
.checkForEmptyNames();
61 menuItem
.setVisible(canExecute
);