Revision 3699c749
Added by Katja Luther about 6 years ago
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 |
} |
Also available in: Unified diff
ref #7227: check for empty selection for menu creation