1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
|
11
|
|
12
|
import javax.inject.Named;
|
13
|
|
14
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
15
|
import org.eclipse.e4.core.di.annotations.Execute;
|
16
|
import org.eclipse.e4.ui.di.UISynchronize;
|
17
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
18
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
19
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
20
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
21
|
import org.eclipse.swt.widgets.Shell;
|
22
|
|
23
|
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditor;
|
24
|
import eu.etaxonomy.taxeditor.editor.name.e4.container.AbstractGroupedContainerE4;
|
25
|
|
26
|
/**
|
27
|
*
|
28
|
* @author pplitzner
|
29
|
* @since Aug 28, 2017
|
30
|
*
|
31
|
*/
|
32
|
public class DeleteAllEmptyNamesHandler extends DeleteTaxonBaseHandler {
|
33
|
|
34
|
@Override
|
35
|
@Execute
|
36
|
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
37
|
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
|
38
|
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
|
39
|
MHandledMenuItem menuItem,
|
40
|
UISynchronize sync) {
|
41
|
|
42
|
editor = (TaxonNameEditor) activePart.getObject();
|
43
|
|
44
|
for(AbstractGroupedContainerE4 containerWithEmptyName : editor.getEmptyContainers()){
|
45
|
editor.removeGroup(containerWithEmptyName.getGroup());
|
46
|
doExecute(menuItem.getLocalizedLabel(), shell, editor, containerWithEmptyName.getData(), sync);
|
47
|
}
|
48
|
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
@CanExecute
|
53
|
public boolean canExecute(
|
54
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
55
|
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
|
56
|
MHandledMenuItem menuItem){
|
57
|
|
58
|
editor = (TaxonNameEditor) activePart.getObject();
|
59
|
|
60
|
boolean canExecute = false;
|
61
|
canExecute = editor.checkForEmptyNames();
|
62
|
menuItem.setVisible(canExecute);
|
63
|
return canExecute;
|
64
|
}
|
65
|
|
66
|
}
|