Search in sources :

Example 1 with IWholeFrameworkException

use of org.whole.lang.exceptions.IWholeFrameworkException 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();
}
Also used : ExecutionState(org.whole.lang.e4.ui.jobs.ExecutionState) IEntity(org.whole.lang.model.IEntity) Method(java.lang.reflect.Method) WholeRuntimeException(org.whole.lang.exceptions.WholeRuntimeException) IWholeFrameworkException(org.whole.lang.exceptions.IWholeFrameworkException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IWholeFrameworkException(org.whole.lang.exceptions.IWholeFrameworkException) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer) UISynchronize(org.eclipse.e4.ui.di.UISynchronize) IEventBroker(org.eclipse.e4.core.services.events.IEventBroker)

Aggregations

Method (java.lang.reflect.Method)1 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 IEventBroker (org.eclipse.e4.core.services.events.IEventBroker)1 UISynchronize (org.eclipse.e4.ui.di.UISynchronize)1 ExecutionState (org.whole.lang.e4.ui.jobs.ExecutionState)1 IWholeFrameworkException (org.whole.lang.exceptions.IWholeFrameworkException)1 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)1 WholeRuntimeException (org.whole.lang.exceptions.WholeRuntimeException)1 IEntity (org.whole.lang.model.IEntity)1 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)1