Java Code Examples for org.eclipse.e4.core.contexts.IEclipseContext#set()

The following examples show how to use org.eclipse.e4.core.contexts.IEclipseContext#set() . 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: LifeCycleHook.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: E4PreferencesHandler.java    From e4Preferences with Eclipse Public License 1.0 6 votes vote down vote up
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Optional PreferenceManager pm, MApplication appli)
{
	// Manage the possible null pm (case of pure E4 application. With E3 it
	// will be initialized by org.eclipse.ui.internal.WorkbenchPlugin
	// see line 1536
	if (pm == null)
	{
		pm = new E4PrefManager();
		E4PreferenceRegistry registry = new E4PreferenceRegistry();
		IEclipseContext appliContext = appli.getContext();
		registry.populatePrefManagerWithE4Extensions(pm, appliContext);
		appliContext.set(PreferenceManager.class, pm);
	}
	
	// Can display the standard dialog.
	PreferenceDialog dialog = new PreferenceDialog(shell, pm);
	dialog.create();
	dialog.getTreeViewer().setComparator(new ViewerComparator());
	dialog.getTreeViewer().expandAll();
	dialog.open();
}
 
Example 3
Source File: GroovyViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: DemoGeometryPageFactoryContextFunction.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object compute(IEclipseContext context, String contextKey) {
	IPageFactory factory = ContextInjectionFactory
			.make(DemoGeometryPageFactory.class, context);
	// add the new object to the application context
	MApplication application = context.get(MApplication.class);
	IEclipseContext ctx = application.getContext();
	ctx.set(IPageFactory.class, factory);
	return factory;
}
 
Example 5
Source File: DemoEntryCompositeContextFunction.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object compute(IEclipseContext context, String contextKey) {
	IEntryCompositeProvider provider = ContextInjectionFactory
			.make(DemoEntryCompositeProvider.class, context);
	// add the new object to the application context
	MApplication application = context.get(MApplication.class);
	IEclipseContext ctx = application.getContext();
	ctx.set(IEntryCompositeProvider.class, provider);
	return provider;
}
 
Example 6
Source File: DefaultPageFactoryContextFunction.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object compute(IEclipseContext context, String contextKey) {
	IPageFactory factory = ContextInjectionFactory
			.make(DefaultPageFactory.class, context);
	// add the new object to the application context
	MApplication application = context.get(MApplication.class);
	IEclipseContext ctx = application.getContext();
	ctx.set(IPageFactory.class, factory);
	return factory;
}
 
Example 7
Source File: OtherWindowScrollHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, IEmacsPlusCommandDefinitionIds.SCROLL_UP);
	super.addToContext(ctx);
}
 
Example 8
Source File: OtherWindowScrollDownHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, IEmacsPlusCommandDefinitionIds.SCROLL_DOWN);
	super.addToContext(ctx);
}
 
Example 9
Source File: OtherWindowRecenterHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, IEmacsPlusCommandDefinitionIds.RECENTER);
	super.addToContext(ctx);
}
 
Example 10
Source File: SwitchToBufferFrameHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, false);		
	ctx.set(E4CmdHandler.PRE_CTX_KEY, PREFIX);
	super.addToContext(ctx);
}
 
Example 11
Source File: WindowSplitHorizHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, WindowSplitCmd.getDirection(true));
	super.addToContext(ctx);
}
 
Example 12
Source File: SwitchToBufferOtherHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, false);		
	ctx.set(E4CmdHandler.PRE_CTX_KEY, PREFIX);
	super.addToContext(ctx);
}
 
Example 13
Source File: WindowJoinHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, Join.ALL);
	super.addToContext(ctx);
}
 
Example 14
Source File: FrameCreateHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, WindowSplitCmd.getDirection(true));
	super.addToContext(ctx);
}
 
Example 15
Source File: WindowEnlargeHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, Col.ENLARGE);
	super.addToContext(ctx);
}
 
Example 16
Source File: E4PreferenceRegistry.java    From e4Preferences with Eclipse Public License 1.0 4 votes vote down vote up
/** Read the e4PreferenceStoreProvider extension point */
private void initialisePreferenceStoreProviders(IEclipseContext context)
{
	if (psProviders == null)
	{
		IContributionFactory factory = context.get(IContributionFactory.class);

		psProviders = new HashMap<String, Object>();
		IExtensionRegistry registry = context.get(IExtensionRegistry.class);

		// Read extensions and fill the map...
		for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREF_STORE_PROVIDER))
		{
			String declaringBundle = elmt.getNamespaceIdentifier();
			String pluginId = elmt.getAttribute(ATTR_PLUGIN_ID);
			if (isEmpty(pluginId))
			{
				logger.warn("missing plugin Id in extension " + PREF_STORE_PROVIDER + " check the plugin " + declaringBundle);
				continue;
			}

			String classname = elmt.getAttribute(ATTR_CLASS);
			String objectId = elmt.getAttribute(ATTR_ID_IN_WBCONTEXT);

			if ((isEmpty(classname) && isEmpty(objectId)) || (((classname != null) && classname.length() > 0) && ((objectId != null) && objectId.length() > 0)))
			{
				logger.warn("In extension " + PREF_STORE_PROVIDER + " only one of the two attributes (pluginId or idInWorkbenchContext) must be set. Check the plugin "
						+ declaringBundle);
				continue;
			}

			// Ok can now work with data...
			Object data = objectId;
			if (classname != null)
			{
				data = factory.create(classname, context);
				if (!(data instanceof IPreferenceStoreProvider))
				{
					logger.warn("In extension " + PREF_STORE_PROVIDER + " the class must implements IPreferenceStoreProvider. Check the plugin " + declaringBundle);
					continue;
				}
			}

			psProviders.put(pluginId, data);

		}
		
		context.set(KEY_PREF_STORE_PROVIDERS, psProviders);
	}
}
 
Example 17
Source File: WindowBalanceHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, Col.BALANCE);
	super.addToContext(ctx);
}
 
Example 18
Source File: FramesJoinHandler.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void addToContext(IEclipseContext ctx) {
	ctx.set(E4CmdHandler.CMD_CTX_KEY, Join.ALL);
	super.addToContext(ctx);
}
 
Example 19
Source File: StatusBar.java    From MergeProcessor with Apache License 2.0 3 votes vote down vote up
/**
 * Creates an instance of {@link IStatusLineManager} and sets it into the
 * context.
 * 
 * @param context   the eclipse context where so set the
 *                  {@link IStatusLineManager}
 * @param composite the parent composite
 */
@PostConstruct
public void createControl(final IEclipseContext context, @Optional final Composite composite) {
	final StatusLineManager statusLine = new StatusLineManager();
	statusLine.createControl(composite);
	context.set(IStatusLineManager.class, statusLine);
}
 
Example 20
Source File: LifeCycleHook.java    From MergeProcessor with Apache License 2.0 2 votes vote down vote up
/**
 * Adds the configuration directly after context creation, because it is
 * required in the {@link ToolbarProcessor}.
 * 
 * @param context the context to enrich
 */
@PostContextCreate
public void postContextCreate(IEclipseContext context) {
	context.set(IConfiguration.class, ContextInjectionFactory.make(Configuration.class, context));
}