Revision 8b2d3c40
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/MergeGroupHandlerE4.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import javax.inject.Named; |
14 | 14 |
|
15 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
15 | 16 |
import org.eclipse.e4.core.di.annotations.Execute; |
16 | 17 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
18 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
17 | 19 |
import org.eclipse.e4.ui.services.IServiceConstants; |
18 | 20 |
import org.eclipse.jface.dialogs.MessageDialog; |
19 | 21 |
import org.eclipse.swt.widgets.Shell; |
... | ... | |
108 | 110 |
editor.setDirty(); |
109 | 111 |
editor.refresh(); |
110 | 112 |
} |
113 |
|
|
114 |
@CanExecute |
|
115 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
116 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
117 |
MHandledMenuItem menuItem) { |
|
118 |
boolean canExecute = false; |
|
119 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
120 |
canExecute = !editor.getEditorInput().getMergeCandidates().isEmpty() |
|
121 |
&& editor.getEditorInput().getMergeTarget()!=null; |
|
122 |
menuItem.setVisible(canExecute); |
|
123 |
return canExecute; |
|
124 |
} |
|
111 | 125 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/RemoveMergeCandidateHandlerE4.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import javax.inject.Named; |
12 | 12 |
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
13 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
14 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
16 | 18 |
|
17 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
... | ... | |
33 | 35 |
editor.getEditorInput().removeMergeCandidate(selection); |
34 | 36 |
editor.refresh(); |
35 | 37 |
} |
38 |
|
|
39 |
@CanExecute |
|
40 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
41 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
42 |
MHandledMenuItem menuItem) { |
|
43 |
boolean canExecute = false; |
|
44 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
45 |
canExecute = editor.getEditorInput().getMergeCandidates().contains(selection); |
|
46 |
menuItem.setVisible(canExecute); |
|
47 |
return canExecute; |
|
48 |
} |
|
36 | 49 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeCandidateHandlerE4.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import javax.inject.Named; |
12 | 12 |
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
13 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
14 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
16 | 18 |
|
17 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
18 | 20 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
21 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
|
19 | 22 |
|
20 | 23 |
/** |
21 | 24 |
* |
... | ... | |
29 | 32 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
30 | 33 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
31 | 34 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
32 |
editor.getEditorInput().addMergeCandidate(selection); |
|
35 |
AbstractBulkEditorInput input = editor.getEditorInput(); |
|
36 |
if(input.getMergeTarget()!=null |
|
37 |
&& input.getMergeTarget().equals(selection)){ |
|
38 |
input.setMergeTarget(null); |
|
39 |
} |
|
40 |
input.addMergeCandidate(selection); |
|
33 | 41 |
editor.refresh(); |
34 | 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 = !editor.getEditorInput().getMergeCandidates().contains(selection); |
|
51 |
menuItem.setVisible(canExecute); |
|
52 |
return canExecute; |
|
53 |
} |
|
35 | 54 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeTargetHandlerE4.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import javax.inject.Named; |
12 | 12 |
|
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
13 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
14 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
15 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
16 | 18 |
|
17 | 19 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
... | ... | |
31 | 33 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) { |
32 | 34 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
33 | 35 |
AbstractBulkEditorInput input = editor.getEditorInput(); |
36 |
if(input.getMergeCandidates().contains(selection)){ |
|
37 |
input.removeMergeCandidate(selection); |
|
38 |
} |
|
34 | 39 |
input.setMergeTarget(selection); |
35 | 40 |
editor.refresh(); |
36 | 41 |
} |
42 |
|
|
43 |
@CanExecute |
|
44 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
45 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
46 |
MHandledMenuItem menuItem) { |
|
47 |
boolean canExecute = false; |
|
48 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
49 |
canExecute = editor.getEditorInput().getMergeTarget()==null |
|
50 |
|| !editor.getEditorInput().getMergeTarget().equals(selection); |
|
51 |
menuItem.setVisible(canExecute); |
|
52 |
return canExecute; |
|
53 |
} |
|
37 | 54 |
} |
Also available in: Unified diff
ref #6932 Migrate merge handlers