fix #6726 Use correct selection service for dynamic menu
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / descriptive / handler / DynamicFeatureMenu.java
index 66af4c76f332d614d21c87beba0dd7ba6a6447ee..98bbdf48ac78f9f0f6bb68aff1878eba6985a730 100644 (file)
@@ -37,9 +37,6 @@ import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
- * <p>
- * DynamicFeatureMenu class.
- * </p>
  *
  * @author n.hoffmann
  * @created 17.04.2009
@@ -47,15 +44,6 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class DynamicFeatureMenu extends CompoundContributionItem {
 
-       private final ISelectionService selectionService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(ISelectionService.class);
-       private final IHandlerService handlerService = TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class);
-
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
-        */
        /** {@inheritDoc} */
        @Override
        protected IContributionItem[] getContributionItems() {
@@ -63,9 +51,9 @@ public class DynamicFeatureMenu extends CompoundContributionItem {
                return new IContributionItem[] { new ContributionItem() {
                        @Override
             public void fill(Menu menu, int index) {
+                           ISelectionService selectionService = TaxeditorEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getSelectionService();
 
-                               ISelection selection = selectionService
-                                               .getSelection(DescriptiveViewPart.ID);
+                               ISelection selection = selectionService.getSelection(DescriptiveViewPart.ID);
 
                                if (selection instanceof IStructuredSelection) {
                                        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
@@ -121,7 +109,7 @@ public class DynamicFeatureMenu extends CompoundContributionItem {
                                Event event = new Event();
                                event.data = deproxiedFeature;
                                try {
-                                       handlerService.executeCommand(
+                                   TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class).executeCommand(
                                                        CreateDescriptionElementOperation.ID, event);
                                } catch (Exception e) {
                                        MessagingUtils.error(getClass(), e);