Search in sources :

Example 6 with IEclipseContext

use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.

the class ContentAssistVisibleWhen method isVisible.

@Override
public boolean isVisible(IBindingManager bm) {
    if (!HandlersBehavior.isValidFocusEntityPart(bm))
        return false;
    IEclipseContext context = (IEclipseContext) bm.wGetValue("eclipse#eclipseContext");
    ContentAssistRunnable runnable = new ContentAssistRunnable(context, bm);
    IEntity result = runnable.syncExec(3000).getResult();
    IEntity[] values = (IEntity[]) result.wGetValue();
    if (values == null)
        return false;
    else if (values.length == 1 && !EntityUtils.isData(values[0])) {
        IEntity value = Matcher.find(new IsConcreteAction(Action), values[0], false);
        return value != null;
    } else
        return values.length > 0;
}
Also used : IEntity(org.whole.lang.model.IEntity) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) ContentAssistRunnable(org.whole.lang.e4.ui.jobs.ContentAssistRunnable)

Example 7 with IEclipseContext

use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.

the class EntityLocationHyperlink method linkActivated.

public void linkActivated() {
    try {
        IEclipseContext context = (IEclipseContext) PlatformUI.getWorkbench().getService(IEclipseContext.class);
        EPartService partService = context.get(EPartService.class);
        Collection<MPart> parts = partService.getParts();
        for (MPart part : parts) {
            IEclipseContext partContext = part.getContext();
            if (partContext == null)
                continue;
            IModelInput modelInput = partContext.get(IModelInput.class);
            if (modelInput != null && ((IFilePersistenceProvider) modelInput.getPersistenceProvider()).getStore().equals(file)) {
                partService.activate(part, true);
                IEntityPartViewer viewer = partContext.get(IEntityPartViewer.class);
                IEntity entityContents = viewer.getEntityContents();
                final IEntity entity = EntityUtils.getEntity(entityContents, location);
                viewer.selectAndReveal(entity);
            }
        }
    } catch (Exception e) {
        E4CompatibilityPlugin.log(e);
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IModelInput(org.whole.lang.ui.input.IModelInput) IEntity(org.whole.lang.model.IEntity) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 8 with IEclipseContext

use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.

the class AssignmentsDialogFactory method createDialog.

public Dialog createDialog(Shell shell, String title, String message, Assignments assignments, IBindingManager bindings) {
    IEclipseContext params = EclipseContextFactory.create();
    params.set("dialogTitle", title);
    params.set("dialogMessage", message);
    params.set("dialogAssignments", assignments);
    IEclipseContext context = (IEclipseContext) bindings.wGetValue("eclipse#eclipseContext");
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(DisabledImportAsModelDialogFactory.class, context);
    params.set(IImportAsModelDialogFactory.class, factory);
    return ContextInjectionFactory.make(AssignmentsDialog.class, context, params);
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)

Example 9 with IEclipseContext

use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.

the class ChooseModelsDialogFactory method createDialog.

public Dialog createDialog(Shell shell, String title, String message, Assignments assignments, IBindingManager bindings) {
    IEclipseContext params = EclipseContextFactory.create();
    params.set("dialogTitle", title);
    params.set("dialogMessage", message);
    params.set("dialogAssignments", assignments);
    IEclipseContext context = (IEclipseContext) bindings.wGetValue("eclipse#eclipseContext");
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(DisabledImportAsModelDialogFactory.class, context);
    params.set(IImportAsModelDialogFactory.class, factory);
    return ContextInjectionFactory.make(ChooseModelsDialog.class, context, params);
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)

Example 10 with IEclipseContext

use of org.eclipse.e4.core.contexts.IEclipseContext in project whole by wholeplatform.

the class TestsUIInterpreterVisitor method reportError.

@Override
protected void reportError(String name, RuntimeException e) {
    super.reportError(name, e);
    IBindingManager debugEnv = getBindings();
    IEclipseContext context = (IEclipseContext) debugEnv.wGetValue("eclipse#eclipseContext");
    if ((debugEnv.wIsSet("debug#reportModeEnabled") && !debugEnv.wBooleanValue("debug#reportModeEnabled")) || (debugEnv.wIsSet("debug#debugModeEnabled") && !debugEnv.wBooleanValue("debug#debugModeEnabled")) || (debugEnv.wIsSet("debug#breakpointsEnabled") && !debugEnv.wBooleanValue("debug#breakpointsEnabled")))
        return;
    else
        E4Utils.suspendOrReportException(context, SuspensionKind.RECOVERABLE_ERROR, "Model test error", "Error while executing " + name + " test", e, debugEnv);
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext)

Aggregations

IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)195 Test (org.junit.Test)142 RunAndTrack (org.eclipse.e4.core.contexts.RunAndTrack)18 ContextFunction (org.eclipse.e4.core.contexts.ContextFunction)17 BundleContext (org.osgi.framework.BundleContext)15 IEntity (org.whole.lang.model.IEntity)11 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)9 Execute (org.eclipse.e4.core.di.annotations.Execute)7 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)6 IImportAsModelDialogFactory (org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)6 Hashtable (java.util.Hashtable)5 PrimaryObjectSupplier (org.eclipse.e4.core.di.suppliers.PrimaryObjectSupplier)4 Named (javax.inject.Named)3 PerformanceTestRunner (org.eclipse.core.tests.harness.PerformanceTestRunner)3 InjectionException (org.eclipse.e4.core.di.InjectionException)3 CanExecute (org.eclipse.e4.core.di.annotations.CanExecute)3 Optional (org.eclipse.e4.core.di.annotations.Optional)3 UISynchronize (org.eclipse.e4.ui.di.UISynchronize)3 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)3 IMenuManager (org.eclipse.jface.action.IMenuManager)3