use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.
the class E4Utils method suspendOperation.
public static void suspendOperation(SuspensionKind kind, Throwable throwable, IEntity sourceEntity, final IBindingManager bindings, Set<String> includeNames) {
if (bindings.wIsSet("debug#reportModeEnabled") && !bindings.wBooleanValue("debug#reportModeEnabled"))
return;
if (bindings.wIsSet("debug#debugModeEnabled") && !bindings.wBooleanValue("debug#debugModeEnabled")) {
if (kind.isError())
E4Utils.reportError((IEclipseContext) bindings.wGetValue("eclipse#eclipseContext"), "Domain behavior error", "Error while executing domain behavior", throwable);
return;
}
if (kind.isBreak() && bindings.wIsSet("debug#breakpointsEnabled") && !bindings.wBooleanValue("debug#breakpointsEnabled"))
return;
if (bindings.wIsSet("viewer") && ((IEntityPartViewer) bindings.wGetValue("viewer")).getControl().getDisplay().getThread() == Thread.currentThread()) {
E4Utils.reportError((IEclipseContext) bindings.wGetValue("eclipse#eclipseContext"), "Domain behavior error", "Attempted suspension in UI thread", throwable);
return;
}
final IEclipseContext context = (IEclipseContext) bindings.wGetValue("eclipse#eclipseContext");
context.get(UISynchronize.class).syncExec(new Runnable() {
public void run() {
try {
ClassLoader cl = ReflectionFactory.getPlatformClassLoader();
Class<?> uiPluginClass = Class.forName("org.whole.lang.e4.ui.E4CompatibilityPlugin", true, cl);
Method method = uiPluginClass.getMethod("revealPerspective", String.class);
method.invoke(null, "org.whole.lang.ui.perspectives.LanguageWorkbenchDebugPerspectiveFactory");
} catch (Exception e) {
throw new IllegalStateException(e);
}
E4Utils.revealPart(context, IE4UIConstants.DEBUG_PART_ID);
E4Utils.revealPart(context, IE4UIConstants.VARIABLES_PART_ID);
if (bindings.wIsSet("self") && bindings.wIsSet("viewer")) {
IEntity selfEntity = bindings.wGet("self");
((IEntityPartViewer) bindings.wGetValue("viewer")).selectAndReveal(selfEntity);
}
if (throwable instanceof IWholeFrameworkException) {
IEntity messageModel = ((IWholeFrameworkException) throwable).getMessageModel();
E4Utils.revealPart(context, IE4UIConstants.RESULTS_PART_ID);
IEventBroker eventBroker = context.get(IEventBroker.class);
eventBroker.post(IE4UIConstants.TOPIC_UPDATE_RESULTS, messageModel);
}
}
});
IEventBroker eventBroker = context.get(IEventBroker.class);
ExecutionState execution = new ExecutionState(kind, throwable, sourceEntity, bindings, includeNames);
eventBroker.post(IE4UIConstants.TOPIC_UPDATE_DEBUG, execution);
execution.pause();
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.
the class AbstractE4DerivedGraphicalPart method createSelectionLinkable.
protected ILinkableSelectionListener createSelectionLinkable(IEntityPartViewer viewer) {
IEclipseContext params = EclipseContextFactory.create();
// we need to pass the viewer because it has not been set in the active context
params.set(IEntityPartViewer.class, viewer);
return ContextInjectionFactory.make(DerivedLinkableSelectionListener.class, context, configureSelectionLinkable(params));
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.
the class E4PaletteGraphicalPart method createEntityViewer.
protected IEntityPartViewer createEntityViewer(Composite parent) {
IEclipseContext params = EclipseContextFactory.create();
params.set("parent", parent);
IEntityPartViewer viewer = ContextInjectionFactory.make(E4PaletteGraphicalViewer.class, context, params);
setSelectionLinkable(createSelectionLinkable(viewer));
return viewer;
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class InjectionMixedSuppliersTest method testPreferencesQualifier.
@Test
public void testPreferencesQualifier() throws BackingStoreException, InvocationTargetException, InstantiationException {
IEclipseContext context = EclipseContextFactory.create();
setPreference("injectedPrefs", "abc");
context.set("testMixed", "other");
InjectTarget target = ContextInjectionFactory.make(InjectTarget.class, context);
// test
assertEquals("abc", target.pref);
assertEquals("other", target.other);
// change
setPreference("injectedPrefs", "xyz");
context.set("testMixed", "bingo");
// re-test
assertEquals("xyz", target.pref);
assertEquals("bingo", target.other);
}
use of org.eclipse.e4.core.contexts.IEclipseContext in project eclipse.platform.runtime by eclipse.
the class InjectionPreferencesTest method testPreferencesQualifier.
@Test
public void testPreferencesQualifier() throws BackingStoreException {
setPreference(TEST_PREFS_KEY, "abc");
setPreference(TEST_PREFS_KEY, TEST_PREFS_NODE, "123");
IEclipseContext context = EclipseContextFactory.create();
InjectTarget target = ContextInjectionFactory.make(InjectTarget.class, context);
// default node
assertEquals(1, target.counter);
assertEquals("abc", target.pref);
// specific node
assertEquals(1, target.counterNode);
assertEquals("123", target.prefNode);
// optional preference
assertEquals(1, target.counterOptional);
assertNull(target.prefOptional1);
assertEquals("abc", target.prefOptional2);
// change
setPreference(TEST_PREFS_KEY, "xyz");
setPreference(TEST_PREFS_KEY, TEST_PREFS_NODE, "456");
// default node
assertEquals(2, target.counter);
assertEquals("xyz", target.pref);
// specific node
assertEquals(2, target.counterNode);
assertEquals("456", target.prefNode);
// optional preference
assertEquals(2, target.counterOptional);
assertNull(target.prefOptional1);
assertEquals("xyz", target.prefOptional2);
}
Aggregations