1
|
/**
|
2
|
* Copyright (C) 2018 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
|
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
|
10
|
|
11
|
import javax.inject.Named;
|
12
|
|
13
|
import org.eclipse.core.commands.operations.AbstractOperation;
|
14
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
15
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
16
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
17
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
18
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
19
|
import org.eclipse.jface.viewers.TreeSelection;
|
20
|
import org.eclipse.swt.widgets.Shell;
|
21
|
|
22
|
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
23
|
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetUnplacedExcludedOperation;
|
24
|
|
25
|
/**
|
26
|
* @author k.luther
|
27
|
* @since 11.10.2018
|
28
|
*
|
29
|
*/
|
30
|
public class RemoveExcludedHandler extends UnplacedExcludedHandler {
|
31
|
|
32
|
@Override
|
33
|
public AbstractOperation prepareOperation(IStructuredSelection selection,
|
34
|
Shell shell,
|
35
|
MPart activePart,
|
36
|
MHandledMenuItem menuItem) {
|
37
|
SetUnplacedExcludedOperation operation =
|
38
|
new SetUnplacedExcludedOperation(getTrigger(),
|
39
|
true,
|
40
|
taxonNodes,
|
41
|
null, false);
|
42
|
|
43
|
return operation;
|
44
|
}
|
45
|
|
46
|
@CanExecute
|
47
|
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
|
48
|
boolean canExecute = !selection.isEmpty();
|
49
|
Object[] array = selection.toArray();
|
50
|
for (Object object : array) {
|
51
|
canExecute &= (object instanceof TaxonNodeDto) && (((TaxonNodeDto)object).getUuid() != null) && ((TaxonNodeDto)object).isExcluded();
|
52
|
}
|
53
|
menuItem.setVisible(canExecute);
|
54
|
return canExecute;
|
55
|
}
|
56
|
|
57
|
}
|