org.eclipse.e4.core.contexts.IEclipseContext Java Examples
The following examples show how to use
org.eclipse.e4.core.contexts.IEclipseContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BonitaProjectExplorer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void initContextMenu() { TreeViewer commonViewer = getCommonViewer(); Menu previousMenu = commonViewer.getTree().getMenu(); // Remove menu created by default if (previousMenu != null) { previousMenu.dispose(); } MenuManager menuMgr = new MenuManager(getNavigatorContentService().getViewerDescriptor().getPopupMenuId()); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(manager -> fillContextMenu(manager)); Menu menu = menuMgr.createContextMenu(commonViewer.getTree()); commonViewer.getTree().setMenu(menu); IEclipseContext e4Context = ((PartSite) getSite()).getContext(); new CustomPopupMenuExtender(ID, menuMgr, getSite().getSelectionProvider(), getSite().getPart(), e4Context, true); }
Example #2
Source File: EditLocalDocumentUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * If {@link Preferences#P_TEXT_EDIT_LOCAL} is set, the * <code> ch.elexis.core.ui.command.startEditLocalDocument </code> command is called with the * provided {@link IDocumentLetter}, and the provided {@link IViewPart} is hidden. * * @param view * @param document * @return returns true if edit local is started and view is hidden */ public static boolean startEditLocalDocument(IViewPart view, IDocumentLetter document){ if (CoreHub.localCfg.get(Preferences.P_TEXT_EDIT_LOCAL, false) && document != null) { // open for editing ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(document)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, view, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(view.getSite().getShell(), Messages.TextView_errortitle, Messages.TextView_errorlocaleditmessage); } view.getSite().getPage().hideView(view); return true; } return false; }
Example #3
Source File: EditLocalDocumentUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * If {@link Preferences#P_TEXT_EDIT_LOCAL} is set, the * <code> ch.elexis.core.ui.command.startEditLocalDocument </code> command is called with the * provided {@link Brief}, and the provided {@link IViewPart} is hidden. * * @param view * @param brief * @return returns true if edit local is started and view is hidden */ public static boolean startEditLocalDocument(IViewPart view, Brief brief){ if (CoreHub.localCfg.get(Preferences.P_TEXT_EDIT_LOCAL, false) && brief != null) { // open for editing ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(brief)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, view, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(view.getSite().getShell(), Messages.TextView_errortitle, Messages.TextView_errorlocaleditmessage); } view.getSite().getPage().hideView(view); return true; } return false; }
Example #4
Source File: ContributionAction.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public Object executeCommand(){ try { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command cmd = commandService.getCommand(commandId); if (selection != null) { PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(commandId.concat(".selection"), new StructuredSelection(selection)); } ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null); return cmd.executeWithChecks(ee); } catch (Exception e) { LoggerFactory.getLogger(getClass()) .error("cannot execute command with id: " + commandId, e); } return null; }
Example #5
Source File: LocalDocumentsDialog.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void endLocalEdit(StructuredSelection selection){ ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.endLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), selection); try { command .executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null)); tableViewer.setInput(service.getAll()); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(getShell(), Messages.LocalDocumentsDialog_errortitle, Messages.LocalDocumentsDialog_errorendmessage); } }
Example #6
Source File: UpdateManager.java From developer-studio with Apache License 2.0 | 6 votes |
protected void initProvisioningAgent() throws RuntimeException { try { // Inject references BundleContext bundleContext = FrameworkUtil.getBundle(UpdateManager.class).getBundleContext(); IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(bundleContext); ContextInjectionFactory.inject(this, serviceContext); // get p2 agent for current system(Eclipse instance in this // case) // the location for the currently running system is null (see // docs) p2Agent = agentProvider.createAgent(null); session = new ProvisioningSession(p2Agent); artifactRepoManager = (IArtifactRepositoryManager) p2Agent .getService(IArtifactRepositoryManager.class.getName()); metadataRepoManager = (IMetadataRepositoryManager) p2Agent .getService(IMetadataRepositoryManager.class.getName()); } catch (Exception e) { throw new RuntimeException(Messages.UpdateManager_14, e); } }
Example #7
Source File: FindingsUiUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * Execute the UI command found by the commandId, using the {@link ICommandService}. * * @param commandId * @param selection * @return */ public static Object executeCommand(String commandId, IFinding selection){ try { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command cmd = commandService.getCommand(commandId); if(selection != null) { PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(commandId.concat(".selection"), new StructuredSelection(selection)); } ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null); return cmd.executeWithChecks(ee); } catch (Exception e) { LoggerFactory.getLogger(FindingsUiUtil.class) .error("cannot execute command with id: " + commandId, e); } return null; }
Example #8
Source File: LocalDocumentsDialog.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void abortLocalEdit(StructuredSelection selection){ ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.abortLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), selection); try { command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, this, null)); tableViewer.setInput(service.getAll()); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(getShell(), Messages.LocalDocumentsDialog_errortitle, Messages.LocalDocumentsDialog_errorabortmessage); } }
Example #9
Source File: ContractPropertySection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Inject public ContractPropertySection(final ISharedImages sharedImages, final IEclipseContext eclipseContext, final ContractContainerAdaptableSelectionProvider selectionProvider, final PoolAdaptableSelectionProvider poolSelectionProvider, final RepositoryAccessor repositoryAccessor, final FieldToContractInputMappingOperationBuilder fieldToContractInputMappingOperationBuilder, final FieldToContractInputMappingExpressionBuilder fieldToContractInputMappingExpressionBuilder, final ContractConstraintBuilder contractConstraintBuilder, final IProgressService progressService) { this.eclipseContext = eclipseContext; this.repositoryAccessor = repositoryAccessor; this.selectionProvider = selectionProvider; this.poolSelectionProvider = poolSelectionProvider; this.progressService = progressService; this.sharedImages = sharedImages; this.fieldToContractInputMappingOperationBuilder = fieldToContractInputMappingOperationBuilder; this.fieldToContractInputMappingExpressionBuilder = fieldToContractInputMappingExpressionBuilder; this.contractConstraintBuilder = contractConstraintBuilder; }
Example #10
Source File: CustomPopupMenuExtender.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public CustomPopupMenuExtender(final String id, final MenuManager menu, final ISelectionProvider prov, final IWorkbenchPart part, IEclipseContext context, final boolean includeEditorInput) { super(); this.menu = menu; this.selProvider = prov; this.part = part; this.context = context; this.modelPart = part.getSite().getService(MPart.class); if (includeEditorInput) { bitSet |= INCLUDE_EDITOR_INPUT; } menu.addMenuListener(this); if (!menu.getRemoveAllWhenShown()) { menuWrapper = new SubMenuManager(menu); menuWrapper.setVisible(true); } createModelFor(id); addMenuId(id); Platform.getExtensionRegistry().addRegistryChangeListener(this); }
Example #11
Source File: CustomPopupMenuExtender.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void cleanUpContributionCache() { if (!actionContributionCache.isEmpty()) { PluginActionContributionItem[] items = actionContributionCache .toArray(new PluginActionContributionItem[actionContributionCache.size()]); actionContributionCache.clear(); for (PluginActionContributionItem item : items) { item.dispose(); } } if (modelPart == null || menuModel == null) { return; } IEclipseContext modelContext = modelPart.getContext(); if (modelContext != null) { IRendererFactory factory = modelContext.get(IRendererFactory.class); if (factory != null) { AbstractPartRenderer obj = factory.getRenderer(menuModel, null); if (obj instanceof MenuManagerRenderer) { MenuManagerRenderer renderer = (MenuManagerRenderer) obj; renderer.cleanUp(menuModel); } } } }
Example #12
Source File: XrefExtension.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void startLocalEdit(Brief brief){ if (brief != null) { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(brief)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, this, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.BriefAuswahl_errorttile, Messages.BriefAuswahl_erroreditmessage); } } }
Example #13
Source File: ExpressionProviderService.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@PostConstruct protected void init(final IEclipseContext context) { expressionProviderByType = new HashMap<>(); final IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance() .getConfigurationElements(EXPRESSION_PROVIDER_ID); for (final IConfigurationElement element : elements) { try { final IExpressionProvider provider = extensionContextInjectionFactory.make(element, PROVIDER_CLASS_ATTRIBUTE, IExpressionProvider.class, context); expressionProviderByType.put(provider.getExpressionType(), provider); } catch (final Exception e) { BonitaStudioLog.error(e); } } context.set(ExpressionProviderService.class, this); }
Example #14
Source File: LifeCycleHook.java From MergeProcessor with Apache License 2.0 | 6 votes |
/** * Adds additional elements to the application context. * * @param context the context to enrich * @param display the display */ @ProcessAdditions public void addElementsToContext(IEclipseContext context, Display display) { /* * The PreferenceInitializer is not registered via the extension point * org.eclipse.core.runtime.preferences as we cannot access the instance of * IConfiguration because the workbench is not initialized at the time when it * is required. So it is called directly here and the IConfiguration is handed * directly. */ new PreferenceInitializer(context.get(IConfiguration.class)).initializeDefaultPreferences(); context.set(ICredentialProvider.class, ContextInjectionFactory.make(InstantUserAuthentication.class, context)); context.set(ISvnClient.class, ContextInjectionFactory.make(SvnClientJavaHl.class, context)); context.set(IVersionProvider.class, ContextInjectionFactory.make(PomFileVersionProvider.class, context)); context.set(IFileSystemProvider.class, ContextInjectionFactory.make(SftpFileSystemProvider.class, context)); copyH2ToLocalIfRequired(context.get(IConfiguration.class), display); }
Example #15
Source File: CoolbarToolControl.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void registerHandlers(final IEclipseContext context, final IWorkbenchPage page) { EPartService partService = context.get(EPartService.class); ESelectionService selectionService = context.get(ESelectionService.class); if (!isRegistered && partService != null && selectionService != null) { partService.addPartListener(CoolbarToolControl.this); selectionService.addSelectionListener(CoolbarToolControl.this); isRegistered = true; } }
Example #16
Source File: DependencyInjectionHelper.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void inject(Object object, BundleContext context) { IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(context); if (serviceContext != null) { try{ ContextInjectionFactory.inject(object, serviceContext); } catch(InjectionException e) { LogHelper.logError(e); } } }
Example #17
Source File: QuitHandlerAddon.java From offspring with MIT License | 5 votes |
@Override public void handleEvent(final Event inEvent) { if (!UIEvents.isSET(inEvent)) { return; } final Object lElement = inEvent.getProperty(UIEvents.EventTags.ELEMENT); if (!(lElement instanceof MWindow)) { return; } final MWindow lWindow = (MWindow) lElement; if ("com.dgex.offspring.application.mainwindow".equals(lWindow .getElementId())) { logger.trace(UIEvents.Context.TOPIC_CONTEXT); if (lWindow.equals(inEvent.getProperty("ChangedElement")) && lWindow.getContext() != null) { lWindow.getContext().runAndTrack(new RunAndTrack() { @Override public boolean changed(final IEclipseContext inContext) { final Object lHandler = inContext.get(IWindowCloseHandler.class); if (!quitHandler.equals(lHandler)) { inContext.set(IWindowCloseHandler.class, quitHandler); } return true; } }); } } }
Example #18
Source File: ExtensionContextInjectionFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T> T make(final IConfigurationElement element, final String classNameAttribute, final Class<T> extension, final IEclipseContext context) throws ClassNotFoundException { final String className = element.getAttribute(classNameAttribute); final Class<T> loadClass = (Class<T>) getDeclaringBundle(element).loadClass(className); return ContextInjectionFactory.make(loadClass, context); }
Example #19
Source File: EsbEditorEvent.java From developer-studio with Apache License 2.0 | 5 votes |
public static void CreateBroker(String pluginId) { Bundle bundle = Platform.getBundle(pluginId); IEclipseContext eclipseContext = EclipseContextFactory.getServiceContext(bundle.getBundleContext()); eclipseContext.set(org.eclipse.e4.core.services.log.Logger.class, null); iEventBroker = eclipseContext.get(IEventBroker.class); }
Example #20
Source File: E4PreferenceNode.java From e4Preferences with Eclipse Public License 1.0 | 5 votes |
public E4PreferenceNode(String id, String label, String bID, String classname, IEclipseContext ctx) { super(id, label, null, classname); context = ctx; clazzname = classname; // Private in ancestor, must store it locally... bundleID = bID; }
Example #21
Source File: DemoGeometryPageContextFunction.java From ice with Eclipse Public License 1.0 | 5 votes |
@Override public Object compute(IEclipseContext context, String contextKey) { IPageProvider provider = ContextInjectionFactory .make(DemoGeometryPageProvider.class, context); // add the new object to the application context MApplication application = context.get(MApplication.class); IEclipseContext ctx = application.getContext(); ctx.set(IPageProvider.class, provider); return provider; }
Example #22
Source File: GroovySourceViewerFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void configureContext(Shell shell) { final IEclipseContext e4Context = ((Workbench) PlatformUI.getWorkbench()).getContext(); while (!Objects.equals(e4Context.getActiveLeaf(), e4Context)) { e4Context.getActiveLeaf().deactivate(); } final IEclipseContext expressionDialogContext = e4Context.createChild("expressionDialogContext"); expressionDialogContext.activate(); shell.setData("org.eclipse.e4.ui.shellContext", expressionDialogContext); }
Example #23
Source File: GroovySourceViewerFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public GroovyViewer createSourceViewer(final Composite container, final boolean isPageFlowContext) { final IEclipseContext context = (IEclipseContext) container.getShell().getData("org.eclipse.e4.ui.shellContext"); if (context == null) { configureContext(container.getShell()); } return new GroovyViewer(container, isPageFlowContext, true); }
Example #24
Source File: GroovySourceViewerFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public GroovyViewer createSourceViewer(final Composite container, final BonitaGroovyEditor editor) { final IEclipseContext context = (IEclipseContext) container.getShell().getData("org.eclipse.e4.ui.shellContext"); if (context == null) { configureContext(container.getShell()); } return new GroovyViewer(container, null, editor, true); }
Example #25
Source File: GroovySourceViewerFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public GroovyViewer createSourceViewer(final Composite container) { final IEclipseContext context = (IEclipseContext) container.getShell().getData("org.eclipse.e4.ui.shellContext"); if (context == null) { configureContext(container.getShell()); } return new GroovyViewer(container); }
Example #26
Source File: GroovyViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IEclipseContext createGroovyEditorContext() { final IEclipseContext context = ((Workbench) PlatformUI.getWorkbench()).getContext(); final IEclipseContext activeLeaf = context.getActiveLeaf(); IEclipseContext groovyEditorContext = activeLeaf.createChild("groovyEditorContext"); groovyEditorContext.set("localContexts", Lists.newLinkedList(Lists.newArrayList("org.eclipse.ui.contexts.window", "org.eclipse.ui.contexts.dialogAndWindow", "org.eclipse.ui.textEditorScope", "org.eclipse.jdt.ui.javaEditorScope", "org.codehaus.groovy.eclipse.editor.groovyEditorScope"))); return groovyEditorContext; }
Example #27
Source File: WindowJoinCmd.java From e4macs with Eclipse Public License 1.0 | 5 votes |
void closePart(MPart part) { // based on org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.closePart() IEclipseContext context = part.getContext(); if (context != null && part.isCloseable()) { EPartService partService = context.get(EPartService.class); partService.hidePart(part,true); } }
Example #28
Source File: DeployBDMOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void uninstallBDMAccessControl(IProgressMonitor monitor) { EHandlerService handlerService = handlerService(); IEclipseContext e4Context = e4Context(); e4Context.set(APISession.class, session); Optional.ofNullable(ParameterizedCommand.generateCommand( commandService().getCommand(UNINSTALL_BDM_AC_CMD), null)) .filter(handlerService::canExecute) .ifPresent(handlerService::executeHandler); }
Example #29
Source File: E4CmdHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { extractUniversalCount(event); // initialize uArg // Pass the non-e4 handler so it can be injected into the command if necessary IEclipseContext ctx = EclipseContextFactory.create(); addToContext(ctx); return ContextInjectionFactory.invoke(e4cmd, Execute.class, getContext(), ctx, null); }
Example #30
Source File: EditExpressionDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void configureContext() { final IEclipseContext e4Context = ((Workbench) PlatformUI.getWorkbench()).getContext(); while (!Objects.equals(e4Context.getActiveLeaf(), e4Context)) { e4Context.getActiveLeaf().deactivate(); } getShell().setData("org.eclipse.e4.ui.shellContext", e4Context.createChild("expressionDialogContext")); }