private boolean checkContribution(IEclipseContext lclContext) { if (!(model instanceof MContribution)) { return false; } MContribution contrib = (MContribution) model; if (contrib.getObject() == null) { contrib.setObject(contribFactory.create( contrib.getContributionURI(), lclContext)); } return contrib.getObject() != null; }
@Override protected void executeItem(Event trigger) { final IEclipseContext lclContext = getContext(getModel()); if (!checkContribution(lclContext)) { return; } MContribution contrib = (MContribution) getModel(); IEclipseContext staticContext = getStaticContext(trigger); Object result = ContextInjectionFactory.invoke(contrib.getObject(), Execute.class, getExecutionContext(lclContext), staticContext, missingExecute); if (result == missingExecute && logger != null) { logger.error("Contribution is missing @Execute: " + contrib.getContributionURI()); //$NON-NLS-1$ } }
private boolean canExecuteItem(Event trigger) { final IEclipseContext lclContext = getContext(model); if (!checkContribution(lclContext)) { return false; } MContribution contrib = (MContribution) model; IEclipseContext staticContext = getStaticContext(trigger); Boolean result = ((Boolean) ContextInjectionFactory.invoke( contrib.getObject(), CanExecute.class, getExecutionContext(lclContext), staticContext, Boolean.TRUE)); return result.booleanValue(); }
Object client = contribution.getObject(); IEclipseContext parentContext = renderer.getModelContext(element); if (parentContext != null && client != null) { Object client = contribution.getObject(); IEclipseContext parentContext = renderer.getModelContext(element); if (parentContext != null && client != null) { contribution.setObject(null);
&& ((MContribution) me).getContributionURI() != null) { final MToolItem item = (MToolItem) me; final MContribution contrib = (MContribution) me;
private boolean checkContribution(IEclipseContext lclContext) { if (!(getModel() instanceof MContribution)) { return false; } MContribution contrib = (MContribution) getModel(); if (contrib.getObject() == null) { contrib.setObject(contribFactory.create( contrib.getContributionURI(), lclContext)); } return contrib.getObject() != null; }
private void executeItem(Event trigger) { final IEclipseContext lclContext = getContext(model); if (!checkContribution(lclContext)) { return; } MContribution contrib = (MContribution) model; IEclipseContext staticContext = getStaticContext(trigger); ContextInjectionFactory.invoke(contrib.getObject(), Execute.class, getExecutionContext(lclContext), staticContext, null); }
private Object getContributionObject(IEclipseContext context, MContribution contribution) { Object rv = contribution.getObject(); if (rv == null) { if (contribution.getContributionURI() == null) { getLogger().error("No contribution uri defined for " + contribution); //$NON-NLS-1$ return null; } IContributionFactory cf = (IContributionFactory) context.get(IContributionFactory.class.getName()); rv = cf.create(contribution.getContributionURI(), context); contribution.setObject(rv); } return rv; }
@Override protected boolean canExecuteItem(Event trigger) { final IEclipseContext lclContext = getContext(getModel()); if (!checkContribution(lclContext)) { return false; } MContribution contrib = (MContribution) getModel(); IEclipseContext staticContext = getStaticContext(trigger); Boolean result = ((Boolean) ContextInjectionFactory.invoke( contrib.getObject(), CanExecute.class, getExecutionContext(lclContext), staticContext, Boolean.TRUE)); return result.booleanValue(); }
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); lclContext.remove(MItem.class.getName()); }
@Override public void focusGui(MUIElement element) { @SuppressWarnings("unchecked") ElementRenderer<MUIElement, Object> renderer = (ElementRenderer<MUIElement, Object>) element.getRenderer(); if (renderer == null || element.getWidget() == null) return; Object implementation = element instanceof MContribution ? ((MContribution) element).getObject() : null; // If there is no class to call @Focus on then revert to the default if (implementation == null) { renderer.focus(element); return; } try { IEclipseContext context = getContext(element); Object defaultValue = new Object(); Object returnValue = ContextInjectionFactory.invoke(implementation, Focus.class, context, defaultValue); if (returnValue == defaultValue) { // No @Focus method, force the focus renderer.focus(element); } } catch (InjectionException e) { this.logger.errorf("Failed to grant focus to element (%s)", e, element.getElementId()); //$NON-NLS-1$ } catch (RuntimeException e) { this.logger.errorf("Failed to grant focus via DI to element (%s)", e, element.getElementId()); //$NON-NLS-1$ } } }