public MenuFactoryGenerator(MApplication application, IEclipseContext appContext, IConfigurationElement configElement, String attribute) { this.application = application; // this.appContext = appContext; assert appContext.equals(this.application.getContext()); this.configElement = configElement; this.location = new MenuLocationURI(attribute); }
private static boolean isFirstE4WorkbenchRun(MApplication app) { return app.getContext().containsKey(E4Workbench.NO_SAVED_MODEL_FOUND); }
private EPartService getActiveWindowService() { IEclipseContext activeWindowContext = application.getContext().getActiveChild(); if (activeWindowContext == null) { throw new IllegalStateException("Application does not have an active window"); //$NON-NLS-1$ } EPartService activeWindowPartService = activeWindowContext.get(EPartService.class); if (activeWindowPartService == null) { throw new IllegalStateException("Active window context is invalid"); //$NON-NLS-1$ } if (activeWindowPartService == this) { throw new IllegalStateException("Application does not have an active window"); //$NON-NLS-1$ } return activeWindowPartService; }
public MenuAdditionCacheEntry(MApplication application, IEclipseContext appContext, IConfigurationElement configElement, String attribute, String namespaceIdentifier) { this.application = application; // this.appContext = appContext; assert appContext.equals(this.application.getContext()); this.configElement = configElement; this.location = new MenuLocationURI(attribute); this.namespaceIdentifier = namespaceIdentifier; IWorkbench workbench = application.getContext().get(IWorkbench.class); activityManager = workbench.getActivitySupport().getActivityManager(); }
private void init(MApplication appElement) { Activator.trace(Policy.DEBUG_WORKBENCH, "init() workbench", null); //$NON-NLS-1$ IEclipseContext context = appElement.getContext(); if (context != null) { context.set(ExpressionContext.ALLOW_ACTIVATION, Boolean.TRUE); } }
@Override public String getLabel() { return LocalizationHelper.getLocalized(descriptor.getLabel(), descriptor, application.getContext()); }
@Override public Object compute(IEclipseContext context, String contextKey) { ILocaleChangeService lcService = ContextInjectionFactory.make( LocaleChangeServiceImpl.class, context); // add the new object to the application context MApplication application = context.get(MApplication.class); IEclipseContext ctx = application.getContext(); ctx.set(ILocaleChangeService.class, lcService); return lcService; } }
@Override public void registerLifecycleURI(MUIElement element, String lifecycleURI) { @SuppressWarnings("unchecked") Map<@NonNull String,@NonNull Object> contributions = (Map<@NonNull String,@NonNull Object>) element.getTransientData().get(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY); if (contributions == null) { contributions = new HashMap<>(); element.getTransientData().put(LifecycleAddon.LIFECYCLE_TRANSIENT_KEY, contributions); } if( ! contributions.containsKey(lifecycleURI) ) { Object object = this.factory.create(lifecycleURI, this.app.getContext()); if (object != null) { contributions.put(lifecycleURI,object); } } }
@Override public void init(IWorkbench workbench) { MApplication application = workbench.getService(MApplication.class); IEclipseContext context = application.getContext(); defaultTheme = (String) context.get(E4Application.THEME_ID); engine = context.get(IThemeEngine.class); }
@Override public ImageDescriptor getImageDescriptor() { if (imageDescriptor == null) { String iconURI = descriptor.getIconURI(); if (iconURI == null) { // If the icon attribute was omitted, use the default one IWorkbench workbench = application.getContext().get(IWorkbench.class); imageDescriptor = workbench.getSharedImages().getImageDescriptor( ISharedImages.IMG_DEF_VIEW); } else { ISWTResourceUtilities utility = (ISWTResourceUtilities) application.getContext() .get(IResourceUtilities.class); imageDescriptor = utility.imageDescriptorFromURI(URI.createURI(iconURI)); } } return imageDescriptor; }
@Override public void changeApplicationLocale(Locale locale) { // the TranslationService.LOCALE context parameter is specified as String // so we put the String representation of the given Locale to the context this.application.getContext().set(TranslationService.LOCALE, locale); // update model updateLocalization(this.application.getChildren()); // fire event broker.post(LOCALE_CHANGE, locale); }
@Override public void stop() { if (this.app != null) { this.app.getContext().set("__efx_engine_shutdown", Boolean.TRUE); //$NON-NLS-1$ for (MWindow w : this.app.getChildren()) { ElementRenderer<MUIElement, Object> r = getRenderer(w); if (r != null) { removeGui(w); } } } }
/** * Updates the selection of the workbench window with that of the active * part's. * * @param activePart * the currently active part */ public void updateSelection(IWorkbenchPart activePart) { if (activePart != null) { ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider(); if (selectionProvider != null) { ISelection selection = selectionProvider.getSelection(); context.set(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); IEclipseContext applicationContext = application.getContext(); if (applicationContext.getActiveChild() == context) { application.getContext().set(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection); } } } }
@CanExecute public boolean canExecute(IEclipseContext context, @Optional IEvaluationContext staticContext, MApplication application) { if (handler instanceof IHandler2) { Object ctx = staticContext; if (ctx == null) { ctx = new ExpressionContext(application.getContext()); } ((IHandler2) handler).setEnabled(ctx); } return handler.isEnabled(); }
private void createIdentifierTracker(MApplicationElement item) { if (item.getElementId() != null && item.getElementId().length() > 0) { String id = namespaceIdentifier + "/" + item.getElementId(); //$NON-NLS-1$ item.getPersistedState().put(MenuManagerRenderer.VISIBILITY_IDENTIFIER, id); final IIdentifier identifier = activityManager.getIdentifier(id); if (identifier != null) { application.getContext().set(identifier.getId(), identifier.isEnabled()); identifier.addIdentifierListener(idUpdater); } } }
@Override public void identifierChanged(IdentifierEvent identifierEvent) { application.getContext().set(identifierEvent.getIdentifier().getId(), identifierEvent.getIdentifier().isEnabled()); } }
@Override public void handlerChanged(HandlerEvent handlerEvent) { IHandler handler = command.getHandler(); if (handler instanceof HandlerServiceHandler) { IEclipseContext appContext = ((Workbench) PlatformUI.getWorkbench()).getApplication() .getContext(); if (HandlerServiceImpl.lookUpHandler(appContext, command.getId()) == this) { ((HandlerServiceHandler) handler).fireHandlerChanged(handlerEvent); } } }
private boolean shouldActivate(@NonNull MPartStack stackToActivate) { if (inContentProcessing(stackToActivate)) { return false; } if (this.application != null) { IEclipseContext applicationContext = this.application.getContext(); IEclipseContext activeChild = applicationContext.getActiveChild(); if (activeChild == null || activeChild.get(MWindow.class) != this.application.getSelectedElement() || this.application.getSelectedElement() != this.modelService.getTopLevelWindowFor(stackToActivate)) { return false; } } return true; }
@Override public void addToModel(ArrayList<MMenuContribution> menuContributions, ArrayList<MToolBarContribution> toolBarContributions, ArrayList<MTrimContribution> trimContributions) { String idContrib = MenuHelper.getId(configElement); visibleWhen = createExpression(configElement); EContextService contextService = application.getContext().get(EContextService.class); Context actionSetContext = contextService.getContext(idContrib); if (!actionSetContext.isDefined()) { actionSetContext.define(MenuHelper.getLabel(configElement), MenuHelper.getDescription(configElement), "org.eclipse.ui.contexts.actionSet"); //$NON-NLS-1$ } String parentId = parent.getAttribute(IWorkbenchRegistryConstants.ATT_TARGET_ID); addContribution(idContrib, menuContributions, configElement, isMenu, parentId); if (!isMenu) { addToolBarContribution(idContrib, toolBarContributions, trimContributions, configElement, parentId); } }
private void setWindow(MWindow window) { MWindow topWindow = getTopLevelModelWindow(window); MApplication application = topWindow.getContext().get(MApplication.class); Workbench workbench = (Workbench) application.getContext().get(IWorkbench.class); workbenchWindow = workbench.createWorkbenchWindow( workbench.getDefaultPageInput(), workbench.getPerspectiveRegistry().findPerspectiveWithId( workbench.getPerspectiveRegistry().getDefaultPerspective()), topWindow, false); }