aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2012-11-06 15:55:35 (EST)
committerPaul Webster2012-11-06 15:55:35 (EST)
commit5d583c4f05137573387494cfa3e92f58abfcd6d2 (patch)
tree0ffdfc32603035df68e247e08004eff442ad7173
parent8ebbfa43bb1795cd3c7eeec6a0491f2c4a6140a7 (diff)
downloadeclipse.platform.ui-5d583c4f05137573387494cfa3e92f58abfcd6d2.zip
eclipse.platform.ui-5d583c4f05137573387494cfa3e92f58abfcd6d2.tar.gz
eclipse.platform.ui-5d583c4f05137573387494cfa3e92f58abfcd6d2.tar.bz2
Bug 377884 - @CanExecute is not executed using DirectItemsv20121106-205535
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectMenuItemRenderer.java7
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java39
2 files changed, 24 insertions, 22 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectMenuItemRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectMenuItemRenderer.java
index 0c84ecf..57e8b64 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectMenuItemRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectMenuItemRenderer.java
@@ -14,7 +14,6 @@ import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Execute;
-import org.eclipse.e4.core.services.contributions.IContributionFactory;
import org.eclipse.e4.core.services.log.Logger;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.menu.ItemType;
@@ -94,12 +93,6 @@ public class DirectMenuItemRenderer extends MenuItemRenderer {
MenuItem mi = (MenuItem) me.getWidget();
mi.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- if (contrib.getObject() == null) {
- IContributionFactory cf = (IContributionFactory) lclContext
- .get(IContributionFactory.class.getName());
- contrib.setObject(cf.create(
- contrib.getContributionURI(), lclContext));
- }
lclContext.set(MItem.class.getName(), item);
ContextInjectionFactory.invoke(contrib.getObject(),
Execute.class, lclContext);
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java
index 6243a85..a186d7f 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/MenuManagerRendererFilter.java
@@ -22,6 +22,7 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.services.contributions.IContributionFactory;
import org.eclipse.e4.core.services.log.Logger;
import org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer;
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
@@ -220,22 +221,30 @@ public class MenuManagerRendererFilter implements Listener {
}
} else if (updateEnablement && element instanceof MDirectMenuItem) {
MDirectMenuItem contrib = (MDirectMenuItem) element;
- if (contrib.getObject() != null) {
- MDirectMenuItem item = (MDirectMenuItem) element;
- IEclipseContext staticContext = EclipseContextFactory
- .create(MMRF_STATIC_CONTEXT);
- ContributionsAnalyzer.populateModelInterfaces(item,
- staticContext, item.getClass().getInterfaces());
- try {
- Object rc = ContextInjectionFactory.invoke(
- contrib.getObject(), CanExecute.class,
- evalContext, staticContext, Boolean.TRUE);
- if (rc instanceof Boolean) {
- contrib.setEnabled((Boolean) rc);
- }
- } finally {
- staticContext.dispose();
+ if (contrib.getObject() == null) {
+ IContributionFactory icf = evalContext
+ .get(IContributionFactory.class);
+
+ contrib.setObject(icf.create(contrib.getContributionURI(),
+ evalContext, EclipseContextFactory.create()));
+ }
+ if (contrib.getObject() == null) {
+ continue;
+ }
+ MDirectMenuItem item = (MDirectMenuItem) element;
+ IEclipseContext staticContext = EclipseContextFactory
+ .create(MMRF_STATIC_CONTEXT);
+ ContributionsAnalyzer.populateModelInterfaces(item,
+ staticContext, item.getClass().getInterfaces());
+ try {
+ Object rc = ContextInjectionFactory.invoke(
+ contrib.getObject(), CanExecute.class, evalContext,
+ staticContext, Boolean.TRUE);
+ if (rc instanceof Boolean) {
+ contrib.setEnabled((Boolean) rc);
}
+ } finally {
+ staticContext.dispose();
}
}
}