Revision 3699c749
Added by Katja Luther about 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/ConvertPerson2TeamHandlerE4.java | ||
---|---|---|
17 | 17 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
18 | 18 |
import org.eclipse.e4.ui.services.IServiceConstants; |
19 | 19 |
import org.eclipse.jface.dialogs.MessageDialog; |
20 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
20 | 21 |
|
21 | 22 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
22 | 23 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
... | ... | |
71 | 72 |
} |
72 | 73 |
|
73 | 74 |
@CanExecute |
74 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
75 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
75 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
76 | 76 |
MHandledMenuItem menuItem){ |
77 | 77 |
boolean canExecute = false; |
78 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection instanceof Person; |
|
78 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
79 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection.getFirstElement() instanceof Person && selection.size() == 1; |
|
79 | 80 |
menuItem.setVisible(canExecute); |
80 | 81 |
return canExecute; |
81 | 82 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/ConvertTeam2PersonHandlerE4.java | ||
---|---|---|
17 | 17 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
18 | 18 |
import org.eclipse.e4.ui.services.IServiceConstants; |
19 | 19 |
import org.eclipse.jface.dialogs.MessageDialog; |
20 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
20 | 21 |
|
21 | 22 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
22 | 23 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
... | ... | |
73 | 74 |
} |
74 | 75 |
|
75 | 76 |
@CanExecute |
76 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
77 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
77 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
78 | 78 |
MHandledMenuItem menuItem){ |
79 | 79 |
boolean canExecute = false; |
80 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection instanceof Team; |
|
80 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
81 |
canExecute = ((BulkEditorE4)activePart.getObject()).getEditorInput().isConvertingEnabled() && selection.getFirstElement() instanceof Team && selection.size() == 1; |
|
81 | 82 |
menuItem.setVisible(canExecute); |
82 | 83 |
return canExecute; |
83 | 84 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/DeleteHandlerE4.java | ||
---|---|---|
23 | 23 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
24 | 24 |
import org.eclipse.e4.ui.services.IServiceConstants; |
25 | 25 |
import org.eclipse.jface.dialogs.MessageDialog; |
26 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
26 | 27 |
import org.eclipse.swt.widgets.Shell; |
27 | 28 |
|
28 | 29 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
... | ... | |
253 | 254 |
} |
254 | 255 |
|
255 | 256 |
@CanExecute |
256 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
|
|
257 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
|
257 | 258 |
MHandledMenuItem menuItem){ |
258 | 259 |
boolean canExecute = false; |
259 |
canExecute = selection!=null; |
|
260 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
261 |
canExecute = !selection.isEmpty(); |
|
260 | 262 |
menuItem.setVisible(canExecute); |
261 | 263 |
return canExecute; |
262 | 264 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/OpenBulkEditorHandlerE4.java | ||
---|---|---|
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4.handler; |
10 |
import javax.inject.Named; |
|
11 |
|
|
10 | 12 |
import org.eclipse.core.commands.ParameterizedCommand; |
13 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
11 | 14 |
import org.eclipse.e4.core.di.annotations.Execute; |
12 | 15 |
import org.eclipse.e4.ui.model.application.MApplication; |
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; |
|
13 | 19 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
14 | 20 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
21 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
15 | 22 |
|
16 | 23 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil; |
17 | 24 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants; |
25 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
|
18 | 26 |
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput; |
19 | 27 |
import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType; |
20 | 28 |
|
... | ... | |
33 | 41 |
AbstractBulkEditorInput input = AbstractBulkEditorInput.NewInstance(inputType); |
34 | 42 |
BulkEditorUtil.openBulkEditor(input, modelService, partService, application); |
35 | 43 |
} |
44 |
|
|
45 |
@CanExecute |
|
46 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
47 |
MHandledMenuItem menuItem) { |
|
48 |
boolean canExecute = false; |
|
49 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
|
50 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
51 |
canExecute = !selection.isEmpty(); |
|
52 |
menuItem.setVisible(canExecute); |
|
53 |
return canExecute; |
|
54 |
|
|
55 |
} |
|
36 | 56 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/RemoveMergeCandidateHandlerE4.java | ||
---|---|---|
15 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
17 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
18 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
18 | 19 |
|
19 | 20 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 | 21 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
... | ... | |
43 | 44 |
editor.getEditorInput().removeMergeCandidate((CdmBase)selection); |
44 | 45 |
editor.refresh(); |
45 | 46 |
} |
46 |
|
|
47 |
|
|
47 |
|
|
48 |
|
|
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
@CanExecute |
51 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection, |
|
52 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
52 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
53 | 53 |
MHandledMenuItem menuItem) { |
54 | 54 |
boolean canExecute = false; |
55 | 55 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
56 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
56 | 57 |
boolean selectedMergeCandidate = false; |
57 |
if (selection instanceof Object[]){
|
|
58 |
for(Object object: (Object[])selection){
|
|
58 |
if (selection instanceof StructuredSelection){
|
|
59 |
for(Object object: selection.toArray()){
|
|
59 | 60 |
if (object instanceof CdmBase){ |
60 |
editor.getEditorInput().getMergeCandidates().contains((CdmBase)object);
|
|
61 |
editor.getEditorInput().getMergeCandidates().contains(object); |
|
61 | 62 |
selectedMergeCandidate = true; |
62 | 63 |
} |
63 | 64 |
} |
64 | 65 |
} |
65 |
|
|
66 |
|
|
66 | 67 |
canExecute = editor.getEditorInput().isMergingEnabled() && selectedMergeCandidate; |
67 | 68 |
// && editor.getEditorInput().getMergeCandidates().contains(selection); |
68 | 69 |
menuItem.setVisible(canExecute); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMarkerFlagHandlerE4.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
17 | 17 |
import org.eclipse.e4.core.di.annotations.Execute; |
18 |
import org.eclipse.e4.core.di.annotations.Optional; |
|
19 | 18 |
import org.eclipse.e4.ui.di.UISynchronize; |
20 | 19 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
21 | 20 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
22 | 21 |
import org.eclipse.e4.ui.services.IServiceConstants; |
22 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
23 | 23 |
|
24 | 24 |
import eu.etaxonomy.cdm.model.common.IAnnotatableEntity; |
25 | 25 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
... | ... | |
54 | 54 |
|
55 | 55 |
|
56 | 56 |
@CanExecute |
57 |
public boolean canExecute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
|
|
57 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
|
58 | 58 |
MHandledMenuItem menuItem){ |
59 | 59 |
boolean canExecute = false; |
60 |
canExecute = selection instanceof IAnnotatableEntity; |
|
60 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
61 |
canExecute = !selection.isEmpty() && selection.getFirstElement() instanceof IAnnotatableEntity; |
|
61 | 62 |
menuItem.setVisible(canExecute); |
62 | 63 |
return canExecute; |
63 | 64 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeCandidateHandlerE4.java | ||
---|---|---|
15 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
17 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
18 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
18 | 19 |
|
19 | 20 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 | 21 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
... | ... | |
50 | 51 |
} |
51 | 52 |
|
52 | 53 |
@CanExecute |
53 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection, |
|
54 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
54 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
55 | 55 |
MHandledMenuItem menuItem) { |
56 | 56 |
boolean canExecute = false; |
57 | 57 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
58 |
canExecute = selection!=null |
|
58 |
|
|
59 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
60 |
canExecute = !selection.isEmpty() |
|
59 | 61 |
&& editor.getEditorInput().isMergingEnabled() |
60 |
&& !editor.getEditorInput().getMergeCandidates().contains(selection); |
|
62 |
&& !editor.getEditorInput().getMergeCandidates().contains(selection.getFirstElement());
|
|
61 | 63 |
menuItem.setVisible(canExecute); |
62 | 64 |
return canExecute; |
63 | 65 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/SetMergeTargetHandlerE4.java | ||
---|---|---|
15 | 15 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
16 | 16 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
17 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
18 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
18 | 19 |
|
19 | 20 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 | 21 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4; |
... | ... | |
41 | 42 |
} |
42 | 43 |
|
43 | 44 |
@CanExecute |
44 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)CdmBase selection, |
|
45 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
45 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
46 | 46 |
MHandledMenuItem menuItem) { |
47 | 47 |
boolean canExecute = false; |
48 | 48 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject(); |
49 |
canExecute = selection!=null |
|
49 |
StructuredSelection selection = (StructuredSelection)((BulkEditorE4)activePart.getObject()).getViewer().getSelection(); |
|
50 |
canExecute = !selection.isEmpty() |
|
50 | 51 |
&& editor.getEditorInput().isMergingEnabled() |
51 | 52 |
&& (editor.getEditorInput().getMergeTarget()==null |
52 | 53 |
|| !editor.getEditorInput().getMergeTarget().equals(selection)); |
Also available in: Unified diff
ref #7227: check for empty selection for menu creation