blob: 85ab46eff3929a717b8b45c373fe7462b644e6ed [file] [log] [blame]
/**
* Copyright (c) 2011, 2014 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.vaaclipse.common.ecview;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.osbp.ecview.core.common.context.IContext;
import org.eclipse.osbp.ecview.core.common.services.IThirdPartyServiceDelegate;
/**
* Creates a service bridge between E4 and ECView. ServiceRequests to ECView are
* being delegated to E4-Context.
*/
public class ECViewToE4ServiceBridge implements IThirdPartyServiceDelegate {
private IEclipseContext context;
@Inject
public ECViewToE4ServiceBridge(IEclipseContext context) {
this.context = context;
}
@Override
public boolean isFor(String selector, IContext viewContext) {
return context.get(selector) != null;
}
@SuppressWarnings("unchecked")
@Override
public <A> A createService(String selector, IContext viewContext) {
return (A) context.get(selector);
}
}