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
|
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler;
|
10
|
|
11
|
import javax.inject.Named;
|
12
|
|
13
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
14
|
import org.eclipse.e4.core.di.annotations.Execute;
|
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
|
|
19
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
20
|
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
|
21
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
22
|
|
23
|
/**
|
24
|
*
|
25
|
* @author pplitzner
|
26
|
* @date 12.09.2017
|
27
|
*
|
28
|
*/
|
29
|
public class SetMergeCandidateHandlerE4 {
|
30
|
|
31
|
@Execute
|
32
|
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
|
33
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
|
34
|
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
|
35
|
AbstractBulkEditorInput input = editor.getEditorInput();
|
36
|
if(input.getMergeTarget()!=null
|
37
|
&& input.getMergeTarget().equals(selection)){
|
38
|
input.setMergeTarget(null);
|
39
|
}
|
40
|
input.addMergeCandidate(selection);
|
41
|
editor.refresh();
|
42
|
}
|
43
|
|
44
|
@CanExecute
|
45
|
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection,
|
46
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
47
|
MHandledMenuItem menuItem) {
|
48
|
boolean canExecute = false;
|
49
|
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
|
50
|
canExecute = selection!=null
|
51
|
&& editor.getEditorInput().isMergingEnabled()
|
52
|
&& !editor.getEditorInput().getMergeCandidates().contains(selection);
|
53
|
menuItem.setVisible(canExecute);
|
54
|
return canExecute;
|
55
|
}
|
56
|
}
|