Examples of IEclipseContext


Examples of org.eclipse.e4.core.contexts.IEclipseContext

      return serviceContext;
  }

  public static IEclipseContext createDefaultContext() {
    IEclipseContext serviceContext = E4Workbench.getServiceContext();
    final IEclipseContext appContext = serviceContext.createChild("WorkbenchContext");
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    ExceptionHandler exceptionHandler = new ExceptionHandler();
    ReflectionContributionFactory contributionFactory = new ReflectionContributionFactory(registry);
    appContext.set(IContributionFactory.class.getName(), contributionFactory);

    // No default log provider available
    if (appContext.get(ILoggerProvider.class) == null) {
      serviceContext.set(ILoggerProvider.class, ContextInjectionFactory.make(LoggerProviderImpl.class, serviceContext));
    }
   
    appContext.set(Logger.class.getName(), serviceContext.get(ILoggerProvider.class).getClassLogger(E4Workbench.class));

    appContext.set(EModelService.class, new ModelServiceImpl(appContext));
    appContext.set(EPlaceholderResolver.class, new PlaceholderResolver());

    // translation
    String locale = Locale.getDefault().toString();
    appContext.set(TranslationService.LOCALE, locale);
    TranslationService bundleTranslationProvider = TranslationProviderFactory.bundleTranslationService(appContext);
    appContext.set(TranslationService.class, bundleTranslationProvider);

    appContext.set(Adapter.class.getName(), ContextInjectionFactory.make(EclipseAdapter.class, appContext));


    appContext.set(IServiceConstants.ACTIVE_PART, new ActivePartLookupFunction());
    appContext.set(IExceptionHandler.class.getName(), exceptionHandler);
    appContext.set(IExtensionRegistry.class.getName(), registry);

    appContext.set(IServiceConstants.ACTIVE_SHELL, new ActiveChildLookupFunction(IServiceConstants.ACTIVE_SHELL, E4Workbench.LOCAL_ACTIVE_SHELL));

    appContext.set(IExtensionRegistry.class.getName(), registry);
    appContext.set(IContributionFactory.class.getName(), contributionFactory);

    return appContext;
  }
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

    resetState(false);

    final EHandlerService handlerService = getHandlerService();
    final Command command = parameterizedCommand.getCommand();

    final IEclipseContext staticContext = EclipseContextFactory.create("keys-staticContext"); //$NON-NLS-1$
    staticContext.set(Event.class, trigger);

    final boolean commandDefined = command.isDefined();
    // boolean commandEnabled;
    boolean commandHandled;

    try {
      // commandEnabled = handlerService.canExecute(parameterizedCommand, staticContext);
      commandHandled = HandlerServiceImpl.lookUpHandler(context, command.getId()) != null;

      try {
        handlerService.executeHandler(parameterizedCommand, staticContext);
      } catch (final Exception e) {
        commandHandled = false;
        e.printStackTrace();
      }
      /*
       * Now that the command has executed (and had the opportunity to use the remembered
       * state of the dialog), it is safe to delete that information.
       */
//      if (keyAssistDialog != null) {
//        keyAssistDialog.clearRememberedState();
//      }
    } finally {
      staticContext.dispose();
    }
    return (commandDefined && commandHandled);
  }
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

    File file = new File("/Users/tomschindl/git/e-fx-clipse/at.bestsolution.efxclipse.testcases.e4/Application.e4xmi");
    URI uri = URI.createFileURI(file.getAbsolutePath());
    Resource resource = resourceSet.getResource(uri, true);

    IEclipseContext appContext = context.createChild();
    appContext.set("rootElement", resource.getContents().get(0));
   
    BorderPane p = new BorderPane();
    appContext.set(BorderPane.class, p);
   
    ContextInjectionFactory.make(ModelEditor.class, appContext);

    Scene s = new Scene(p);
    primaryStage.setScene(s);
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

  @Override
  public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
    Requestor req = (Requestor) requestor;
    ContextObjectSupplier sub = (ContextObjectSupplier) req
        .getPrimarySupplier();
    final IEclipseContext context = sub.getContext();

    String loggerName = descriptor.getQualifier(Log.class).value();
   
    if( loggerName == null || loggerName.isEmpty() ) {
      loggerName = requestor.getRequestingObjectClass().getName();
    }
   
    return context.get(LoggerFactory.class).createLogger(loggerName);
  }
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

  @Override
  public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
    Requestor req = (Requestor) requestor;
    ContextObjectSupplier sub = (ContextObjectSupplier) req
        .getPrimarySupplier();
    final IEclipseContext context = sub.getContext();
    final Class<?> requestingClass = requestor.getRequestingObject().getClass();
   
    return new FXMLLoaderFactory() {
     
      public <N> FXMLBuilder<N> loadRequestorRelative(String relativePath) {
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

    PackageAdmin packageAdmin = context.getService(ref);
    Bundle[] bundles = packageAdmin.getBundles(bundleName, null);
    if( bundles != null && bundles.length > 0 ) {
      try {
        Class<?> cl = bundles[0].loadClass(applicationClass);
        IEclipseContext eContext = EclipseContextFactory.getServiceContext(context);
        eContext.set(IApplicationContext.class, applicationContext);
        eContext.set(Application.class, jfxApplication);
        eContext.set(Stage.class, primaryStage);
        ContextInjectionFactory.make(cl, eContext);
      } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

 
  @Override
  protected void initWidget(final MToolItem element, final WToolItem<N> widget) {
    super.initWidget(element, widget);
   
    final IEclipseContext modelContext = getModelContext(element);
    widget.setOnActionCallback(new Runnable() {
     
      @Override
      public void run() {
        executeAction(element,modelContext.getActiveLeaf());
      }
    });
  }
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

    sync.asyncExec(new Runnable() {
     
      @Override
      public void run() {
        try {
          IEclipseContext context = getModelContext(toolbarElement);
          if( context != null && (widget.getWidgetState() == WidgetState.CREATED || widget.getWidgetState() == WidgetState.IN_SETUP ) ) {
            widget.setHandled(canExecute(toolbarElement, context))
          }
        } catch(Throwable t) {
          //TODO Log it
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

    if (inContentProcessing(stackToActivate)) {
      return false;
    }
   
    if (application != null) {
      IEclipseContext applicationContext = application.getContext();
      IEclipseContext activeChild = applicationContext
          .getActiveChild();
      if (activeChild == null
          || activeChild.get(MWindow.class) != application
              .getSelectedElement()
          || application.getSelectedElement() != modelService
              .getTopLevelWindowFor(stackToActivate)) {
        return false;
      }
View Full Code Here

Examples of org.eclipse.e4.core.contexts.IEclipseContext

    stack.selectItem(stack.getItems().indexOf(initalItem));
  }

  private WStackItem<I, IC> createStackItem(WStack<N, I, IC> stack, final MStackElement e, AbstractRenderer<MStackElement, ?> renderer) {
    IEclipseContext context = renderer.setupRenderingContext(e);
    WStackItem<I, IC> item = ContextInjectionFactory.make(stack.getStackItemClass(), context);
    item.setDomElement(e);
    item.setInitCallback(new WCallback<WStackItem<I, IC>, IC>() {

      @SuppressWarnings("unchecked")
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.